我正在使用cloudformation安裝elasticsearch。 我正在下載並解壓縮tar.gz. 以下是我的EC2實例部分:AWSCloudFormation - cfn-init無法運行命令
"masterinstance": {
"Type": "AWS: : EC2: : Instance",
"Metadata": {
"AWS: : CloudFormation: : Init": {
"configSets" : {
"ascending" : [ "config1" , "config2" ]
},
"config1": {
"sources": {
"/home/ubuntu/": "https: //s3.amazonaws.com/xxxxxxxx/elasticsearch.tar.gz"
},
"files": {
"/home/ubuntu/elasticsearch/config/elasticsearch.yml": {
"content": {
"Fn: : Join": [
"",
[
xxxxxxxx
]
]
}
}
}
},
"config2" : {
"commands": {
"runservice": {
"command": "~/elasticsearch/bin/elasticsearch",
"cwd" : "~",
"test" : "~/elasticsearch/bin/elasticsearch > test.txt",
"ignoreErrors" : "false"
}
}
}
}
},
"Properties": {
"ImageId": "ami-xxxxxxxxxx",
"InstanceType": {
"Ref": "InstanceTypeParameter"
},
"Tags": [
xxxxxxxx
],
"KeyName": "everybody",
"NetworkInterfaces": [
{
"GroupSet": [
{
"Ref": "newSecurity"
}
],
"AssociatePublicIpAddress": "true",
"DeviceIndex": "0",
"SubnetId": {
"Ref": "oneSubnet"
}
}
],
"UserData": {
"Fn: : Base64": {
"Fn: : Join": [
"",
[
"#!/bin/bash\n",
"sudo add-apt-repository-yppa: webupd8team/java\n",
"sudo apt-get update\n",
"echo'oracle-java8-installershared/accepted-oracle-license-v1-1selecttrue'|sudo debconf-set-selections\n",
"sudo apt-getinstall-yoracle-java8-installer\n",
"apt-get update\n",
"apt-get-y installpython-setuptools\n",
"easy_installhttps: //s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n",
"/usr/local/bin/cfn-init",
"--stack Elasticsearch",
"--resource masterinstance",
"--configsets ascending",
"-v\n"
]
]
}
}
}}
我使用AWS::CloudFormation::Init
配置和其他設置。 提取焦油後,我想開始彈性搜索,我通過AWS::CloudFormation::Init
中的command
部分進行彈性搜索,但在完成堆棧創建之後, 執行彈出搜索時,我無法看到我的elasticsearch服務正在運行。 所有其他的東西,如提取焦油和創建文件工作正常。
我已經通過CFN-init.log走了,它給我的以下信息:
2016-07-19 05:53:15,776 P2745 [INFO] Test for Command runservice
2016-07-19 05:53:15,778 P2745 [INFO] -----------------------Command Output-----------------------
2016-07-19 05:53:15,778 P2745 [INFO] /bin/sh: 1: ~/elasticsearch/bin/elasticsearch: not found
2016-07-19 05:53:15,778 P2745 [INFO] ------------------------------------------------------------
2016-07-19 05:53:15,779 P2745 [ERROR] Exited with error code 127
~
如果我火了上面的命令~/elasticsearch/bin/elasticsearch
直接在我的實例則可以正常使用。
我在做什麼錯在這裏。
謝謝。
日誌中是否有任何信息? – Daniel777
如果以下答案解決了您的問題,請不要忘記[將其標記爲已接受](http://meta.stackexchange.com/a/5235/327137)。 – wjordan