我使用beanstall设置了Tomcat 7。我试图在该环境中运行以下命令,方法是将命令放在.config(yaml(文件中,如下所示:
iptables -I INPUT -p icmp --icmp-type echo-request -m recent --set
iptables -I INPUT -p icmp --icmp-type echo-request -m recent --update --seconds 20 --hitcount 5 -j DROP
配置文件命令:
sudodisable:
command: echo Defaults:root !requiretty
ipbasedthrotllingcommand1:
command: sudo iptables -I INPUT -p icmp --icmp-type echo-request -m recent --set
ipbasedthrotllingcommand2:
command: sudo iptables -I INPUT -p icmp --icmp-type echo-request -m recent --update --seconds 20 --hitcount 5 -j DROP
以下是我的推论:
1( 我遵循了此线程中的建议-->https://forums.aws.amazon.com/message.jspa?messageID=395894并将上面显示的内容放在我的.config文件中,并上传了我的.war,结果却得到了以下错误
2013-03-03 20:52:39,165 DEBUG Not setting a reboot trigger as scheduling support is not available
2013-03-03 20:52:39,185 INFO Running configSets: deque()
2013-03-03 20:52:39,187 INFO Running configSet Infra-EmbeddedPreBuild
2013-03-03 20:52:39,187 INFO Running config prebuild_0_My_First_Elastic_Beanstalk_Application_sudofix__ebextensions_testit_config
2013-03-03 20:52:39,187 DEBUG No packages specified
2013-03-03 20:52:39,188 DEBUG No groups specified
2013-03-03 20:52:39,188 DEBUG No users specified
2013-03-03 20:52:39,188 DEBUG No sources specified
2013-03-03 20:52:39,188 DEBUG No files specified
2013-03-03 20:52:39,188 DEBUG Running command ipbasedthrotllingcommand1
2013-03-03 20:52:39,188 DEBUG No test for command ipbasedthrotllingcommand1
2013-03-03 20:52:39,204 ERROR Command ipbasedthrotllingcommand1 (sudo iptables -I INPUT -p icmp --icmp-type echo-request -m recent --set) failed
2013-03-03 20:52:39,205 DEBUG Command ipbasedthrotllingcommand1 output: sudo: sorry, you must have a tty to run sudo
2013-03-03 20:52:39,205 ERROR Error encountered during build of prebuild_0_My_First_Elastic_Beanstalk_Application_sudofix__ebextensions_testit_config: Command ipbasedthrotllingcommand1 failed
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 505, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 241, in build
changes = CommandTool().apply(self._config.commands)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/command_tool.py", line 103, in apply
raise ToolError("Command %s failed" % name)
ToolError: Command ipbasedthrotllingcommand1 failed
2013-03-03 20:52:39,206 ERROR Unhandled exception during build: Command ipbasedthrotllingcommand1 failed
Traceback (most recent call last):
File "/opt/aws/bin/cfn-init", line 135, in <module>
worklog.build(detail.metadata, configSets)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 117, in build
Contractor(metadata).build(configSets, self)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 496, in build
self.run_config(config, worklog)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 505, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 241, in build
changes = CommandTool().apply(self._config.commands)
File "/usr/lib/python2.6/site-packages/cfnbootstrap/command_tool.py", line 103, in apply
raise ToolError("Command %s failed" % name)
ToolError: Command ipbasedthrotllingcommand1 failed
2013-03-03 20:53:26,362 DEBUG CloudFormation client initialized with endpoint https://cloudformation.us-west-1.amazonaws.com
2013-03-03 20:53:26,362 DEBUG Describing resource AWSEBAutoScalingGroup in stack arn:aws:cloudformation:us-west-1:726941363581:stack/awseb-e-jiipcgeknm-stack/3bb8eac0-842f-11e2-b50d-50690881bc86
2013-03-03 20:53:26,577 DEBUG Not setting a reboot trigger as scheduling support is not available
2013-03-03 20:53:26,593 INFO Running configSets: deque()
2013-03-03 20:53:26,595 INFO Running configSet InfoTask-TailLogs
2013-03-03 20:53:26,596 INFO Running config InfoTask-TailLogs
2013-03-03 20:53:26,596 DEBUG No packages specified
2013-03-03 20:53:26,596 DEBUG No groups specified
2013-03-03 20:53:26,596 DEBUG No users specified
2013-03-03 20:53:26,596 DEBUG No sources specified
2013-03-03 20:53:26,596 DEBUG No files specified
2013-03-03 20:53:26,597 DEBUG Running command taillogs
2013-03-03 20:53:26,597 DEBUG No test for command taillogs
2( 如果我在没有sudo的情况下运行iptables命令,我根本看不到它们被执行。基本上,我甚至没有在日志文件中看到对.config文件的引用,这让我怀疑配置文件是否被选中。
如果能为我解决这个问题提供任何帮助,我将不胜感激。
command: echo Defaults:root !requiretty
是错误的。根据您链接到的文档,它应该是:
echo Defaults:root !requiretty >> /etc/sudoers