在尝试使用 AWSuserdata
选项在实例启动时运行脚本时,我注意到有时(并非总是)云初始化部分会卡在中间某处并且无法到达运行用户脚本的部分。
它在文件中的样子如下/var/log/cloud-init-output.log
:
Cloud-init v. 0.7.5 running 'init-local' at Tue, 30 May 2017 06:38:40 +0000. Up 18.56 seconds.
Cloud-init v. 0.7.5 running 'init' at Tue, 30 May 2017 06:38:45 +0000. Up 23.39 seconds.
SOME_NETWORK_AND_SSH_KEYS_INFO_HERE
Cloud-init v. 0.7.5 running 'modules:config' at Tue, 30 May 2017 06:38:51 +0000. Up 28.80 seconds.
Generating locales...
en_US.UTF-8... up-to-date
Generation complete.
Cloud-init v. 0.7.5 running 'modules:final' at Tue, 30 May 2017 06:39:35 +0000. Up 73.20 seconds.
MY_USERDATA_SCRIPT_OUTPUT_HERE
但当它卡住时看起来是这样的:
Cloud-init v. 0.7.5 running 'init-local' at Tue, 30 May 2017 06:36:43 +0000. Up 21.80 seconds.
Cloud-init v. 0.7.5 running 'init' at Tue, 30 May 2017 06:36:51 +0000. Up 30.13 seconds.
SOME_NETWORK_AND_SSH_KEYS_INFO_HERE
Cloud-init v. 0.7.5 running 'modules:config' at Tue, 30 May 2017 06:36:59 +0000. Up 37.66 seconds.
Generating locales...
en_US.UTF-8... up-to-date
Generation complete.
正如您所看到的,它卡在了之后,Generation complete
就是这样。
知道是什么原因造成的以及我该如何缓解它吗?
顺便说一下,操作系统是 Ubuntu 14.04
答案1
因此,问题是另一个也设置为在同一运行级别运行的不相关脚本被卡住了,这导致整个运行级别等待它完成后才能开始下一个级别(其中 module:final 位于其中)。
一旦我们修复了该脚本,问题就消失了。