gpt4 book ai didi

aws-cloudformation - AWSCloudFormation - cfn-init 无法运行命令

转载 作者:行者123 更新时间:2023-12-03 07:14:55 24 4
gpt4 key购买 nike

我正在使用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/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 进行配置和其他设置。提取 tar 后,我想启动 elasticsearch ,这是通过 AWS::CloudFormation::Init 中的 command 部分执行的,但是,当我 ssh 进入我的实例时完全创建堆栈后,我无法看到我的 elasticsearch 服务正在运行。所有其他事情(例如提取 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 作为 root 用户运行,而不是作为 ubuntu/ec2-user 运行。尝试将 config2 命令 block 中的路径更改为完全限定路径 (/home/ubuntu/elasticsearch)。

关于aws-cloudformation - AWSCloudFormation - cfn-init 无法运行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38433460/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com