Ubuntu的12.04LTS在EC2上的用户数据的脚本后关闭脚本、数据、用户、Ubuntu

2023-09-11 09:41:24 作者:帅哥

我有运行Ubuntu 12.04LTS关停执行用户数据的脚本后,我的EC2实例的一个问题。

其背后ELB和健康检查的运行似乎工作。在系统日志中,经过一番的健康检查,有一个检查无人参与的更新:请注意,然后关闭电源关闭

下面是系统日志的一部分。

 用户数据:使用MemoryStore的为会议
用户数据:使用MemoryStore的用于数据存储
用户数据:2.0的OAuth授权服务器上启动3000端口
用户数据:10.0.18.6  -   -  [星期三,2014年2月12号二十时37分22秒格林尼治标准​​时间]GET / HTTP / 1.1200 2789 - ELB-HealthChecker / 1.0
用户数据:10.0.18.6  -   -  [星期三,2014年2月12号20:37:52 GMT]GET / HTTP / 1.1200 2789 - ELB-HealthChecker / 1.0
检查运行无人参与的升级:
工具acpid:退出

周三2月12日20点38分十三秒UTC 2014年:关闭的关机[高达156s。
 *停止景观客户端守护进程[80G
[74G [31mfail [39;49米]
 *要求所有剩余进程终止... [80G失败:在/ var / lib中/云/实例/脚本/一部分-001 [-15]
二零一四年二月一十二日20:38:13,694  -  cc_scripts_user.py [警告]:无法运行,部分在/ var / lib中/云/实例/脚本
回溯(最近通话最后一个):
  文件/usr/lib/python2.7/logging/handlers.py,线路807,在EMIT
    self._connect_unixsocket(self.address)
  文件/usr/lib/python2.7/logging/handlers.py,线路745,在_connect_unixsocket
    self.socket.connect(地址)
  文件/usr/lib/python2.7/socket.py,线路224,在甲基

[74G回报GETATTR(self._sock,名字)(*参数)
错误:[错误111]连接被拒绝
从文件cc_scripts_user.py,行33登录
[ 好 ]
二零一四年二月十二日20:38:13721  -  __init __吡警告]:回溯(最近通话最后一个):
  文件/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py,线路117,在run_cc_modules
    cc.handle(姓名,run_args,频率=频率)
  文件/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py,78行,在手柄
    [名,self.cfg,self.cloud,cloudinit.log,参数])
  文件/usr/lib/python2.7/dist-packages/cloudinit/__init__.py,线路327,在sem_and_run
    FUNC(*参数)
  文件/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_scripts_user.py,第31行,在手柄
    util.runparts(runparts_path)
  文件/usr/lib/python2.7/dist-packages/cloudinit/util.py,线229,在runparts
    提高RuntimeError('runparts:%我失败'%失败)
RuntimeError:runparts:1失败

回溯(最近通话最后一个):
  文件/usr/lib/python2.7/logging/handlers.py,线路807,在EMIT
    self._connect_unixsocket(self.address)
  文件/usr/lib/python2.7/logging/handlers.py,线路745,在_connect_unixsocket
    self.socket.connect(地址)
  文件/usr/lib/python2.7/socket.py,线路224,在甲基
    返回GETATTR(self._sock,名字)(*参数)
错误:[错误111]连接被拒绝
从文件__init__.py,行119记录
二零一四年二月十二日20:38:13722  -  __init __ PY [错误]:脚本用户的配置处理,无,[]失败

回溯(最近通话最后一个):
  文件/usr/lib/python2.7/logging/handlers.py,线路807,在EMIT
    self._connect_unixsocket(self.address)
  文件/usr/lib/python2.7/logging/handlers.py,线路745,在_connect_unixsocket
    self.socket.connect(地址)
  文件/usr/lib/python2.7/socket.py,线路224,在甲基
    返回GETATTR(self._sock,名字)(*参数)
错误:[错误111]连接被拒绝
从文件__init__.py,线121登录
回溯(最近通话最后一个):
  文件/usr/lib/python2.7/logging/handlers.py,线路807,在EMIT
    self._connect_unixsocket(self.address)
  文件/usr/lib/python2.7/logging/handlers.py,线路745,在_connect_unixsocket
    self.socket.connect(地址)
  文件/usr/lib/python2.7/socket.py,线路224,在甲基
    返回GETATTR(self._sock,名字)(*参数)
错误:[错误111]连接被拒绝
从文件__init__.py,行116记录
EC2:
EC2:################################################ #############
EC2:----- BEGIN SSH主机密钥指纹-----
EC2:1024 40:FA:B0:63:19:CB:BA:AB:D3:60:D5:F1:8E:7B:46:E0根@ IP-10-0-19-71(DSA)
EC2:256 5B:F6:A6:28:8E:70:6D:E5:37:53:F2:2C:D3:9F:4E:80根@ IP-10-0-19-71(ECDSA)
EC2:2048 AB:E4:68:84:28:B7:DD:31:9C:61:36:DF:2A:90:0F:35根@ IP-10-0-19-71(RSA)
EC2:----- END SSH主机密钥指纹-----
EC2:################################################ #############
----- BEGIN SSH主机键按键-----
ECDSA-SHA2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFjnRoQzoWPMShoAHXgvoqWVxils40EfyzTzlj3ASR6zaOTt9Aw+JH+LwHe0bpmyhXAIgiG4Yo0aazwt1301kZY=根@ IP-10-0-19-71
SSH-RSA AAAAB3NzaC1yc2EAAAADAQABAAABAQCp7JxhFxkc8RxfmzhEiLKOuH1NOrpaMsF+SENi47Z8ncA20+VZwhCETxnqVqiybqzITIuuV/33FkCu+4N5ii0GCiZIbdHd9zlbi0QTLXcV1CPORTNH3+1HEiyn6yKC3Cyk2qVqCTpKHNdboG1PKBWrLGg5PqyM45A7+4BSqTNk1vnvE0r3k6hKn8K4WSfQfy8LCBNm4/xq5rxuKSkMTSvoBenWMaaeS63t3k213Y+nQ0dilOXhjxa8VP55Vtx/7t2C1PwMZHiQNNpMiUmhduNzVr1yJKu7G57c+7iMIk7IGgAZ/tiNYqigvfKfJwYqEUEIisNrluBgSR3S2FXI/euJ根@ IP-10-0-19-71
----- END SSH主机键按键-----
回溯(最近通话最后一个):
  文件/usr/lib/python2.7/logging/handlers.py,线路807,在EMIT
    self._connect_unixsocket(self.address)
  文件/usr/lib/python2.7/logging/handlers.py,线路745,在_connect_unixsocket
    self.socket.connect(地址)
  文件/usr/lib/python2.7/socket.py,线路224,在甲基
    返回GETATTR(self._sock,名字)(*参数)
错误:[错误111]连接被拒绝
从文件__init__.py,行116记录
回溯(最近通话最后一个):
  文件/usr/lib/python2.7/logging/handlers.py,线路807,在EMIT
    self._connect_unixsocket(self.address)
  文件/usr/lib/python2.7/logging/handlers.py,线路745,在_connect_unixsocket
    self.socket.connect(地址)
  文件/usr/lib/python2.7/socket.py,线路224,在甲基
    返回GETATTR(self._sock,名字)(*参数)
错误:[错误111]连接被拒绝
从文件__init__.py,行116记录
云初始化启动在周三结束,2014年2月12日20时38分13秒+0000。截至156.72秒
二零一四年二月十二日20:38:13913  - 云的init-CFG [错误]:运行cloud_config [决赛]错误:['脚本用户']
回溯(最近通话最后一个):
  文件/usr/lib/python2.7/logging/handlers.py,线路807,在EMIT
    self._connect_unixsocket(self.address)
  文件/usr/lib/python2.7/logging/handlers.py,线路745,在_connect_unixsocket
    self.socket.connect(地址)
  文件/usr/lib/python2.7/socket.py,线路224,在甲基
    返回GETATTR(self._sock,名字)(*参数)
错误:[错误111]连接被拒绝
从文件云的init-CFG,线路106记录
运行cloud_config [决赛]错误:['脚本用户']
 * 2秒内结束所有的流程... [80G
[74G [确定]
 *解除配置网络接口... [80G
[74G [确定]
 *停用掉... [80G
[74G [确定]
 *现在将暂停
[38117.674998]系统暂停。
 

解决方案

自动缩放有一个可配置的宽限期,在此期间实例必须作出反应。如果它没有。自动缩放将杀死实例,并尝试启动一个新的。

这宽限期内必须要增加一点要考虑到你的启动脚本。

Ubuntu 12.04 LTS 桌面环境的区别

I am having a problem with my EC2 instance running Ubuntu 12.04LTS shutting down after the user-data script is executed.

Its running behind an ELB and the health checks seem to be working. In the system log, after some of the health checks, there is a "Checking for unattended-updates:" note then shutting down for power off.

Below is part of the system log.

user-data: Using MemoryStore for the Session
user-data: Using MemoryStore for the data store
user-data: OAuth 2.0 Authorization Server started on port 3000
user-data: 10.0.18.6 - - [Wed, 12 Feb 2014 20:37:22 GMT] "GET / HTTP/1.1" 200 2789 "-" "ELB-HealthChecker/1.0"
user-data: 10.0.18.6 - - [Wed, 12 Feb 2014 20:37:52 GMT] "GET / HTTP/1.1" 200 2789 "-" "ELB-HealthChecker/1.0"
Checking for running unattended-upgrades: 
acpid: exiting

Wed Feb 12 20:38:13 UTC 2014: shutting down for poweroff [up 156s].
 * Stopping landscape-client daemon       [80G 
[74G[[31mfail[39;49m]
 * Asking all remaining processes to terminate...       [80G failed: /var/lib/cloud/instance/scripts/part-001 [-15]
2014-02-12 20:38:13,694 - cc_scripts_user.py[WARNING]: failed to run-parts in /var/lib/cloud/instance/scripts
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/handlers.py", line 807, in emit
    self._connect_unixsocket(self.address)
  File "/usr/lib/python2.7/logging/handlers.py", line 745, in _connect_unixsocket
    self.socket.connect(address)
  File "/usr/lib/python2.7/socket.py", line 224, in meth

[74G    return getattr(self._sock,name)(*args)
error: [Errno 111] Connection refused
Logged from file cc_scripts_user.py, line 33
[ OK ]
2014-02-12 20:38:13,721 - __init__.py[WARNING]: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 117, in run_cc_modules
    cc.handle(name, run_args, freq=freq)
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 78, in handle
    [name, self.cfg, self.cloud, cloudinit.log, args])
  File "/usr/lib/python2.7/dist-packages/cloudinit/__init__.py", line 327, in sem_and_run
    func(*args)
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_scripts_user.py", line 31, in handle
    util.runparts(runparts_path)
  File "/usr/lib/python2.7/dist-packages/cloudinit/util.py", line 229, in runparts
    raise RuntimeError('runparts: %i failures' % failed)
RuntimeError: runparts: 1 failures

Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/handlers.py", line 807, in emit
    self._connect_unixsocket(self.address)
  File "/usr/lib/python2.7/logging/handlers.py", line 745, in _connect_unixsocket
    self.socket.connect(address)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 111] Connection refused
Logged from file __init__.py, line 119
2014-02-12 20:38:13,722 - __init__.py[ERROR]: config handling of scripts-user, None, [] failed

Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/handlers.py", line 807, in emit
    self._connect_unixsocket(self.address)
  File "/usr/lib/python2.7/logging/handlers.py", line 745, in _connect_unixsocket
    self.socket.connect(address)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 111] Connection refused
Logged from file __init__.py, line 121
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/handlers.py", line 807, in emit
    self._connect_unixsocket(self.address)
  File "/usr/lib/python2.7/logging/handlers.py", line 745, in _connect_unixsocket
    self.socket.connect(address)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 111] Connection refused
Logged from file __init__.py, line 116
ec2: 
ec2: #############################################################
ec2: -----BEGIN SSH HOST KEY FINGERPRINTS-----
ec2: 1024 40:fa:b0:63:19:cb:ba:ab:d3:60:d5:f1:8e:7b:46:e0  root@ip-10-0-19-71 (DSA)
ec2: 256 5b:f6:a6:28:8e:70:6d:e5:37:53:f2:2c:d3:9f:4e:80  root@ip-10-0-19-71 (ECDSA)
ec2: 2048 ab:e4:68:84:28:b7:dd:31:9c:61:36:df:2a:90:0f:35  root@ip-10-0-19-71 (RSA)
ec2: -----END SSH HOST KEY FINGERPRINTS-----
ec2: #############################################################
-----BEGIN SSH HOST KEY KEYS-----
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFjnRoQzoWPMShoAHXgvoqWVxils40EfyzTzlj3ASR6zaOTt9Aw+JH+LwHe0bpmyhXAIgiG4Yo0aazwt1301kZY= root@ip-10-0-19-71
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCp7JxhFxkc8RxfmzhEiLKOuH1NOrpaMsF+SENi47Z8ncA20+VZwhCETxnqVqiybqzITIuuV/33FkCu+4N5ii0GCiZIbdHd9zlbi0QTLXcV1CPORTNH3+1HEiyn6yKC3Cyk2qVqCTpKHNdboG1PKBWrLGg5PqyM45A7+4BSqTNk1vnvE0r3k6hKn8K4WSfQfy8LCBNm4/xq5rxuKSkMTSvoBenWMaaeS63t3k213Y+nQ0dilOXhjxa8VP55Vtx/7t2C1PwMZHiQNNpMiUmhduNzVr1yJKu7G57c+7iMIk7IGgAZ/tiNYqigvfKfJwYqEUEIisNrluBgSR3S2FXI/euJ root@ip-10-0-19-71
-----END SSH HOST KEY KEYS-----
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/handlers.py", line 807, in emit
    self._connect_unixsocket(self.address)
  File "/usr/lib/python2.7/logging/handlers.py", line 745, in _connect_unixsocket
    self.socket.connect(address)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 111] Connection refused
Logged from file __init__.py, line 116
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/handlers.py", line 807, in emit
    self._connect_unixsocket(self.address)
  File "/usr/lib/python2.7/logging/handlers.py", line 745, in _connect_unixsocket
    self.socket.connect(address)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 111] Connection refused
Logged from file __init__.py, line 116
cloud-init boot finished at Wed, 12 Feb 2014 20:38:13 +0000. Up 156.72 seconds
2014-02-12 20:38:13,913 - cloud-init-cfg[ERROR]: errors running cloud_config [final]: ['scripts-user']
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/handlers.py", line 807, in emit
    self._connect_unixsocket(self.address)
  File "/usr/lib/python2.7/logging/handlers.py", line 745, in _connect_unixsocket
    self.socket.connect(address)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 111] Connection refused
Logged from file cloud-init-cfg, line 106
errors running cloud_config [final]: ['scripts-user']
 * All processes ended within 2 seconds....       [80G 
[74G[ OK ]
 * Deconfiguring network interfaces...       [80G 
[74G[ OK ]
 * Deactivating swap...       [80G 
[74G[ OK ]
 * Will now halt
[38117.674998] System halted.

解决方案

Autoscaling has a configurable grace period during which the instance must respond. If it does not. Autoscaling will kill the instance and try to start a new one.

That grace period needs to be to be increased by a bit to take into account your bootstrap script.