谷歌云计算引擎冻结

时间:2017-11-24 09:32:19

标签: google-compute-engine

今天我发现我在谷歌云中的虚拟机实例存在问题。

我无法通过gcloud compute ssh连接。唯一的解决方案是关闭虚拟机并重新启动它。

我想我找到了错误发生的正确日志文件。

/var/log/daemon.log

Nov 23 17:39:01 globo-de systemd[1]: Started Clean php session files.
Nov 23 18:09:01 globo-de systemd[1]: Starting Clean php session files...
Nov 23 18:09:03 globo-de systemd[1]: Started Clean php session files.
Nov 23 18:39:01 globo-de systemd[1]: Starting Clean php session files...
Nov 23 18:39:04 globo-de systemd[1]: Started Clean php session files.
Nov 23 18:56:49 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 18:57:43 globo-de google-accounts: ERROR Exception calling the response handler. [Errno 12] Cannot allocate memory.#012Traceback (most recent call last):#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/metadata_watcher.py", line 196, in WatchMetadata#012    handler(response)#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/accounts_daemon.py", line 259, in HandleAccounts#012    self.oslogin.UpdateOsLogin(enable=False)#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 79, in UpdateOsLogin#012    status = self._GetStatus()#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 60, in _GetStatus#012    retcode = self._RunOsLoginControl('status')#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 47, in _RunOsLoginControl#012    return subprocess.call([constants.OSLOGIN_CONTROL_SCRIPT, action])#012  File "/usr/lib/python2.7/subprocess.py", line 168, in call#012    return Popen(*popenargs, **kwargs).wait()#012  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__#012    errread, errwrite)#012  File "/usr/lib/python2.7/subprocess.py", line 916, in _execute_child#012    self.pid = os.fork()#012OSError: [Errno 12] Cannot allocate memory
Nov 23 18:58:02 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 18:59:35 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 18:59:54 globo-de google-accounts: ERROR Exception calling the response handler. [Errno 12] Cannot allocate memory.#012Traceback (most recent call last):#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/metadata_watcher.py", line 196, in WatchMetadata#012    handler(response)#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/accounts_daemon.py", line 259, in HandleAccounts#012    self.oslogin.UpdateOsLogin(enable=False)#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 79, in UpdateOsLogin#012    status = self._GetStatus()#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 60, in _GetStatus#012    retcode = self._RunOsLoginControl('status')#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 47, in _RunOsLoginControl#012    return subprocess.call([constants.OSLOGIN_CONTROL_SCRIPT, action])#012  File "/usr/lib/python2.7/subprocess.py", line 168, in call#012    return Popen(*popenargs, **kwargs).wait()#012  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__#012    errread, errwrite)#012  File "/usr/lib/python2.7/subprocess.py", line 916, in _execute_child#012    self.pid = os.fork()#012OSError: [Errno 12] Cannot allocate memory
Nov 23 19:03:53 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 19:07:52 globo-de google-accounts: ERROR Exception calling the response handler. [Errno 12] Cannot allocate memory.#012Traceback (most recent call last):#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/metadata_watcher.py", line 196, in WatchMetadata#012    handler(response)#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/accounts_daemon.py", line 259, in HandleAccounts#012    self.oslogin.UpdateOsLogin(enable=False)#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 79, in UpdateOsLogin#012    status = self._GetStatus()#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 60, in _GetStatus#012    retcode = self._RunOsLoginControl('status')#012  File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 47, in _RunOsLoginControl#012    return subprocess.call([constants.OSLOGIN_CONTROL_SCRIPT, action])#012  File "/usr/lib/python2.7/subprocess.py", line 168, in call#012    return Popen(*popenargs, **kwargs).wait()#012  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__#012    errread, errwrite)#012  File "/usr/lib/python2.7/subprocess.py", line 916, in _execute_child#012    self.pid = os.fork()#012OSError: [Errno 12] Cannot allocate memory
Nov 23 19:09:37 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 19:11:32 globo-de systemd[1]: phpsessionclean.service: Failed to fork: Cannot allocate memory
Nov 23 19:11:56 globo-de systemd[1]: phpsessionclean.service: Failed to run 'start' task: Cannot allocate memory
Nov 23 19:12:24 globo-de systemd[1]: Failed to start Clean php session files.
Nov 23 19:12:50 globo-de systemd[1]: phpsessionclean.service: Unit entered failed state.
Nov 23 19:13:37 globo-de systemd[1]: phpsessionclean.service: Failed with result 'resources'.
Nov 23 19:14:58 globo-de systemd[1]: apt-daily.service: Failed to fork: Cannot allocate memory
Nov 23 19:16:13 globo-de systemd[1]: apt-daily.service: Failed to run 'start' task: Cannot allocate memory

我可以做些什么来防止再次发生这种情况?

2 个答案:

答案 0 :(得分:4)

我猜问题是google-cloud-compute引擎vm没有交换文件。所以我使用我在google上找到的以下命令创建了一个。

sudo dd if=/dev/zero of=/var/swap bs=2048 count=524288
sudo chmod 600 /var/swap
sudo mkswap /var/swap
sudo swapon /var/swap

然后我将以下行添加到/ etc / fstab以使其永久化。

/var/swap none swap sw 0 0

答案 1 :(得分:0)

另一种解决方案是避免将vm.swappiness设置交换为0。

# sysctl -w vm.swappiness=0

但是,听起来比谷歌云更像是操作系统映像问题。