简体   繁体   中英

Can't SSH to Google Cloud VM After Installing MySQL

I'm trying to set up a small blog server on Google Cloud Platform using the free tier f1.micro instance. I'm using Ubuntu 20.04 LTS as the base image (Ubuntu is the only Linux distro that I'm at all familiar with), though I tried 20.10. Everything works normally until I install MySQL. This is the guide that I'm following. After each failure, I deleted the VM and started with a fresh one.

These are the VM settings:

虚拟机设置

In addition to the steps listed in the guide, I also tried adding ssh to ufw, just in case.

sudo ufw allow ssh
sudo ufw enable

I also tried running this prior to installing MySQL, based on this article after failing the first couple of times.

sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade

Once I try installing mysql-server the ssh prompt hangs here:

ssh 挂起

I've tried reconnecting immediately and I've tried waiting overnight, but I always get stuck here when I try to connect again (it stays like this for a very long time before failing):

无法重新连接

I experienced a similar issue with a MySQL Instance in GCP, the first issue was related with the type of the VM instance I used, I had a f1-micro machine type on this VM Instance and suddenly I wasn't able to access the ssh. As this type of VM Instance has only 0.6GB of memory, it became out of memory soon, I changed it to a e2-medium that is value by default and it resolved my problems this time. As the Instance was out of memory the services in the instance started to fail, it was the reason that I can't access my instance.

At another time I started again with similar issues, but this time, the problem was the disk, I only had 10 GB and there was a process filling my disk, when a partition was out of space, the instance started to fail again. I only resized my disk, now my instance disk is 20GB and is working fine.

Having said that, I suggest increasing your resources per your convenience to enhance your performance, because to have the problems you described is a good indicator that your existing machine type is not a good fit for your workloads you run on that instance.

So, I suggest to change the machine type to adjust your memory and you can follow the next steps for these tasks please visit the following link to get further information about it.

Changing a machine type

1.- Go to the VM Instances page .

2.- In the Name column, click your instance.

  1. From the instance details page, complete the following steps:

    a) Click the Stop button to stop the instance, if you have not stopped it yet.

    b) After the instance stops, click the Edit button at the top of the page.

    c) Under the Machine configuration section, select the machine type you want to use, or create a custom machine type to increase only the Memory.

    d) Save your changes and start again your VM Instance.

You can resize your disk following this guide or with the following command:

gcloud compute disks resize DISK_NAME --size DISK_SIZE

Or with the Console:

  1. Go to the Disks page to see a list of zonal persistent disks in your project.
  2. Click the name of the disk that you want to resize.
  3. On the disk details page, click Edit .
  4. In the Size field, enter the new size for your disk.
  5. Click Save to apply your changes to the disk.

After you resize the disk, you must resize the file system so that the operating system can access the additional space.

Note: Do not resize boot disks beyond 2 TB because this is the limit.

As per the installation guide you need a server with at least 1GB of memory and your selected VM instance has 614MB of memory. If I understand correctly, when Mysql service is installed it has been occupied total memory and that might be the reason you got stuck on that point also not able to SSH the instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM