我正在使用cloudformation安装elasticsearch。我正在下载并提取tar.gz。以下是我的EC2实例部分:
"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/bashn",
"sudo add-apt-repository-yppa: webupd8team/javan",
"sudo apt-get updaten",
"echo'oracle-java8-installershared/accepted-oracle-license-v1-1selecttrue'|sudo debconf-set-selectionsn",
"sudo apt-getinstall-yoracle-java8-installern",
"apt-get updaten",
"apt-get-y installpython-setuptoolsn",
"easy_installhttps: //s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gzn",
"/usr/local/bin/cfn-init",
"--stack Elasticsearch",
"--resource masterinstance",
"--configsets ascending",
"-vn"
]
]
}
}
}}
我使用AWS::CloudFormation::Init
进行配置和其他设置。提取完tar后,我想开始弹性搜索,这是我通过AWS::CloudFormation::Init
中的command
部分进行的,但是,当我ssh到实例中时,在完全创建了堆栈之后,我无法看到我的弹性搜索服务正在运行。提取tar和创建文件等所有其他操作都正常工作。
我已经浏览了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
,那么它工作得很好。
我在这里做错了什么。
谢谢。
我猜在尝试运行ES时,主目录(~)正在评估给另一个用户(而不是Ubuntu)。我认为CFN Init是作为根用户而不是作为Ubuntu/ec2用户运行的。尝试将config2命令块中的路径更改为完全限定的路径(/home/ubuntu/elasticsearch)。