Google 云实例 SSH 连接问题(存储?)

Google 云实例 SSH 连接问题(存储?)

我花了一整天时间尝试修复它。网站上出现了一个意外的 500 错误,然后我重新启动,再也无法连接 SSH。我将磁盘大小调整为相当大的大小(即 500GB),而我知道实际文件大小只有 5GB 左右。有人能帮忙解决这个问题吗?任何帮助都非常感谢!

下面是我从“串行控制台”捕获的错误消息。有这个错误。


Feb 18 06:41:14 primary-server google-accounts: ERROR Exception calling the response handler. [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/'].#012Traceback (most recent call last):#012  File "/usr/lib/python3/dist-packages/google_compute_engine/metadata_watcher.py", line 200, in WatchMetadata#012    handler(response)#012  File "/usr/lib/python3/dist-packages/google_compute_engine/accounts/accounts_daemon.py", line 285, in HandleAccounts#012    self.utils.SetConfiguredUsers(desired_users.keys())#012  File "/usr/lib/python3/dist-packages/google_compute_engine/accounts/accounts_utils.py", line 318, in SetConfiguredUsers#012    mode='w', prefix=prefix, delete=True) as updated_users:#012  File "/usr/lib/python3.6/tempfile.py", line 681, in NamedTemporaryFile#012    prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)#012  File "/usr/lib/python3.6/tempfile.py", line 269, in _sanitize_params#012    dir = gettempdir()#012  File "/usr/lib/python3.6/tempfile.py", line 437, in gettempdir#012    tempdir = _get_default_tempdir()#012  File "/usr/lib/python3.6/tempfile.py", line 372, in _get_default_tempdir#012    dirlist)#012FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Ubuntu 18.04.2 LTS primary-server ttyS0

primary-server login: Feb 18 06:41:22 primary-server snapd[1512]: stateengine.go:102: state ensure error: Get https://api.snapcraft.io/api/v1/snaps/sections: dial tcp: lookup api.snapcraft.io on [::1]:53: read udp [::1]:58853->[::1]:53: read: connection refused

我将磁盘大小调整为 500 GB。


Feb 18 06:41:34 primary-server snapd[1512]: daemon.go:611: gracefully waiting for running hooks
Feb 18 06:41:34 primary-server snapd[1512]: daemon.go:613: done waiting for running hooks
Feb 18 06:41:34 primary-server snapd[1512]: daemon stop requested to wait for socket activation

Mysql 服务被反复停止并启动,然后


Feb 18 06:42:33 primary-server sshd[3744]: /etc/ssh/sshd_config line 31: Deprecated option RSAAuthentication
Feb 18 06:42:33 primary-server sshd[3744]: /etc/ssh/sshd_config line 38: Deprecated option RhostsRSAAuthentication
Feb 18 06:42:33 primary-server sshd[3755]: /etc/ssh/sshd_config line 16: Deprecated option UsePrivilegeSeparation
Feb 18 06:42:33 primary-server sshd[3755]: /etc/ssh/sshd_config line 19: Deprecated option KeyRegenerationInterval
Feb 18 06:42:33 primary-server sshd[3755]: /etc/ssh/sshd_config line 20: Deprecated option ServerKeyBits
Feb 18 06:42:33 primary-server sshd[3755]: /etc/ssh/sshd_config line 31: Deprecated option RSAAuthentication
Feb 18 06:42:33 primary-server sshd[3755]: /etc/ssh/sshd_config line 38: Deprecated option RhostsRSAAuthentication

错误提示空间不足。我将磁盘大小调整为 500GB,内存也调整为 500GB,但错误仍然相同。

Feb 18 06:42:33 primary-server systemd[1]: Started OpenBSD Secure Shell server.
Feb 18 06:42:33 primary-server google-accounts: INFO Removing user jameswalker11.
Feb 18 06:42:34 primary-server google_accounts_daemon[2207]: userdel: /etc/passwd.3759: No space left on device
Feb 18 06:42:34 primary-server google_accounts_daemon[2207]: userdel: cannot lock /etc/passwd; try again later.
Feb 18 06:42:34 primary-server google-accounts: WARNING Could not remove user jameswalker11. Command '['userdel', '-r', 'jameswalker11']' returned non-zero exit status 1..
Feb 18 06:42:34 primary-server google-accounts: INFO Removing user jameswalker11 from the Google sudoers group.
Feb 18 06:42:34 primary-server google_accounts_daemon[2207]: Removing user jameswalker11 from group google-sudoers
Feb 18 06:42:34 primary-server google_accounts_daemon[2207]: gpasswd: /etc/group.3760: No space left on device
Feb 18 06:42:34 primary-server google_accounts_daemon[2207]: gpasswd: cannot lock /etc/group; try again later.
Feb 18 06:42:34 primary-server google-accounts: WARNING Could not update user jameswalker11. Command '['gpasswd', '-d', 'jameswalker11', 'google-sudoers']' returned non-zero exit status 1..
Feb 18 06:42:34 primary-server google-accounts: INFO Removing user logic.
Feb 18 06:42:34 primary-server google_accounts_daemon[2207]: userdel: /etc/passwd.3761: No space left on device
Feb 18 06:42:34 primary-server google_accounts_daemon[2207]: userdel: cannot lock /etc/passwd; try again later.
Feb 18 06:42:34 primary-server google-accounts: WARNING Could not remove user logic. Command '['userdel', '-r', 'logic']' returned non-zero exit status 1..
Feb 18 06:42:34 primary-server google-accounts: INFO Removing user logic from the Google sudoers group.
Feb 18 06:42:34 primary-server google_accounts_daemon[2207]: Removing user logic from group google-sudoers
Feb 18 06:42:34 primary-server google_accounts_daemon[2207]: gpasswd: /etc/group.3764: No space left on device
Feb 18 06:42:34 primary-server google_accounts_daemon[2207]: gpasswd: cannot lock /etc/group; try again later.
Feb 18 06:42:34 primary-server google-accounts: WARNING Could not update user logic. Command '['gpasswd', '-d', 'logic', 'google-sudoers']' returned non-zero exit status 1..
Feb 18 06:42:34 primary-server google-accounts: ERROR Exception calling the response handler. [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/'].#012Traceback (most recent call last):#012  File "/usr/lib/python3/dist-packages/google_compute_engine/metadata_watcher.py", line 200, in WatchMetadata#012    handler(response)#012  File "/usr/lib/python3/dist-packages/google_compute_engine/accounts/accounts_daemon.py", line 285, in HandleAccounts#012    self.utils.SetConfiguredUsers(desired_users.keys())#012  File "/usr/lib/python3/dist-packages/google_compute_engine/accounts/accounts_utils.py", line 318, in SetConfiguredUsers#012    mode='w', prefix=prefix, delete=True) as updated_users:#012  File "/usr/lib/python3.6/tempfile.py", line 681, in NamedTemporaryFile#012    prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)#012  File "/usr/lib/python3.6/tempfile.py", line 269, in _sanitize_params#012    dir = gettempdir()#012  File "/usr/lib/python3.6/tempfile.py", line 437, in gettempdir#012    tempdir = _get_default_tempdir()#012  File "/usr/lib/python3.6/tempfile.py", line 372, in _get_default_tempdir#012    dirlist)#012FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']

答案1

您的文件系统可能已损坏,并且以只读方式挂载。请尝试fsck按照此处描述的“验证您的磁盘是否具有有效的文件系统”步骤运行文件系统检查https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-instances#troubleshooting_general_issues_with_instances

如果 fsck 发现错误,它会询问您是否应该修复它们 - 回答是。然后重新运行 fsck,直到它完成并且没有发现任何问题。

答案2

您可以尝试拍摄快照,然后使用具有新磁盘大小的快照创建新实例,以下是脚步

答案3

感谢 yolabingo 和 Jorge 的帮助。我按照以下步骤解决了这个问题。

  1. 从虚拟机实例“主服务器”创建快照。

2.1 基于Linux发行版创建一个新的实例。

2.2 创建完成后,停止实例。

2.3 按照本指南添加额外的磁盘[2]。

注意:基本上,您必须编辑实例“主服务器”并添加额外的磁盘,不要忘记从“源类型”列表中选择快照选项,然后单击刚刚创建的快照。

2.4 启动实例。

2.5 按照本指南[3]安装磁盘。

注意:请跳过步骤 4。附加磁盘实际上是启动磁盘,因此已经格式化。因此,不要对其应用格式;只需安装它即可。

2.6 检查文件“/etc/fstab”的权限。

注意:权限应为“-rw-r--r--”,所有者为“root”

2.6.1 删除文件以减少磁盘大小。

2.7 在操作系统级别卸载磁盘。

2.8 停止实例。

2.9 从 GCP 中的新实例中分离额外的磁盘。

注意:请遵循本指南[4],不要单击启动盘旁边的“X”,而是单击附加磁盘旁边的“X”。

2.10 创建一个新实例,请不要使用“启动盘”部分中的映像,而是请使用刚刚恢复的磁盘。

注意:为此,请转到“启动盘”部分并单击“更改”按钮,然后转到“现有”选项卡并选择刚刚恢复的磁盘。

如果您还有其他问题,请告诉我。我很乐意为您提供帮助。

我将等待您的答复。


参考:

[1]https://cloud.google.com/compute/docs/disks/add-persistent-disk#inaccessible_instance [2]https://cloud.google.com/compute/docs/disks/add-persistent-disk#create_disk [3]https://cloud.google.com/compute/docs/disks/add-persistent-disk#formatting [4]https://cloud.google.com/compute/docs/disks/detach-reattach-boot-disk#detach_disk

相关内容