我有一个自定义类型的 gcloud vm 实例(4 个 vCPU,8 GB 内存),带有 ubuntu 16.04,10Gb 磁盘空间。今天在特定时间(早上 7 点 30 分),开始使用 99% 的 cpu。我重新启动机器但继续使用 99% 的 cpu。现在我无法通过 ssh 连接。有什么解决方法可以连接到我的实例并查看问题所在??谢谢!!!
最佳答案
您可以尝试 connect through the serial port :
gcloud compute instances add-metadata INSTANCE --metadata serial-port-enable=1
gcloud compute connect-to-serial-port INSTANCE
可能串口上的 tty 对 CPU 使用率高的敏感度会低很多,你就可以登录了。
现在,这将要求您输入用户名和密码...如果您(正确地)仅对 ssh 使用 RSA key 对身份验证该怎么办?这里有一个快速而肮脏的黑客可以完成这项工作:
1 - 将此设置为 startup script
echo "root:1234" | chpasswd
像这样,例如:gcloud compute instances add-metadata INSTANCE --metadata startup-script='echo "root:1234" | chpasswd'
2 - 重新启动实例,以便应用启动脚本
3 - 通过串口登录
gcloud compute connect-to-serial-port INSTANCE
4 - 使用 root 作为用户名和 1234 作为密码(或者你在脚本中输入的任何内容)
5 - 不要忘记在不再需要时禁用串行端口访问。
关于ubuntu - 我无法使用 ssh 连接到 Gcloud 实例,因为 cpu 是 99.9% 的使用率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53188884/