【问题标题】:Ubuntu 12.04LTS on EC2 shuts down after user-data scriptEC2 上的 Ubuntu 12.04LTS 在用户数据脚本后关闭
【发布时间】:2014-02-12 20:53:58
【问题描述】:

我遇到了运行 Ubuntu 12.04LTS 的 EC2 实例在执行用户数据脚本后关闭的问题。

它在 ELB 后面运行,并且运行状况检查似乎正在运行。在系统日志中,经过一些健康检查后,有一个“Checking for unattended-updates:”注释,然后关闭电源。

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

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.

【问题讨论】:

  • 您是否在 ELB 中使用自动缩放功能?
  • 是的,当它使用自动缩放启动时会出现问题。通过控制台使用相同的用户数据脚本启动它,并且很好。

标签: amazon-web-services amazon-ec2 ubuntu-12.04


【解决方案1】:

自动缩放具有可配置的宽限期,在此期间实例必须响应。如果没有。自动缩放将终止实例并尝试启动一个新实例。

该宽限期需要增加一点以考虑您的引导脚本。

【讨论】:

  • 我想就是这样。我将宽限期更改为 300 并且它起作用了。将需要缩小一点。这并不让我感到惊讶,因为脚本运行 npm install ,它在某些模块上进行自定义构建。我想我读错了日志,因为我在脚本执行后安装更新。谢谢!
猜你喜欢
  • 2020-02-01
  • 2012-11-12
  • 1970-01-01
  • 1970-01-01
  • 2013-07-21
  • 1970-01-01
  • 1970-01-01
  • 2013-12-24
  • 1970-01-01
相关资源
最近更新 更多