虚拟机上的Apache和MySQL消失了

开发环境

・Windows10
・Vagrant 2.2.7
・Centos6
・VirtualBox 6.1.18

・Windows10
・Vagrant 2.2.7
・Centos6
・VirtualBox 6.1.18

In Chinese:
・Windows 10
・Vagrant 2.2.7
・Centos 6
・VirtualBox 6.1.18

總結起來

由于与Vagrant虚拟机的关联出现问题,我不得不重新创建一个新的虚拟机。

由于存在旧虚拟机的数据,通过重新关联,我们成功进行了数据恢复。

设置要关联的ID

/path/to/.vagrant/machines/default/virtualbox/id

看起来正在查看上述文件中所列的ID。

确认虚拟机的ID

kiyop@PC /c/vagrant/centos6
$ VBoxManage.exe list vms
"centos6_default_1617851931696_13816" {hoge3816-3816-3816-3816-161785193169} # 旧VM
"centos6_default_1623287985945_31617" {hoge1617-1617-1617-1617-162328798594} # 新VM

更正了

kiyop@PC /c/vagrant/centos6 
$ vagrant up  
Bringing machine 'default' up with 'virtualbox' provider...  
==> default: Clearing any previously set forwarded ports...  
==> default: Fixed port collision for 22 => 2222. Now on port 2200.  
==> default: Clearing any previously set network interfaces...  
==> default: Preparing network interfaces based on configuration...  
    default: Adapter 1: nat  
    default: Adapter 2: hostonly  
==> default: Forwarding ports...  
    default: 22 (guest) => 2200 (host) (adapter 1)  
==> default: Booting VM...  
==> default: Waiting for machine to boot. This may take a few minutes...  
    default: SSH address: 127.0.0.1:2200  
    default: SSH username: vagrant  
    default: SSH auth method: private key  
    default: Warning: Authentication failure. Retrying...  
    (省略) 
    default: Warning: Authentication failure. Retrying...  
Timed out while waiting for the machine to boot. This means that  
Vagrant was unable to communicate with the guest machine within  
the configured ("config.vm.boot_timeout" value) time period.  
If you look above, you should be able to see the error(s) that  
Vagrant had when attempting to connect to the machine. These errors  
are usually good hints as to what may be wrong.  
If you're using a custom box, make sure that networking is properly  
working and you're able to connect to the machine. It is a common  
problem that networking isn't setup properly in these boxes.  
Verify that authentication configurations are also setup properly,  
as well.  
If the box appears to be booting properly, you may want to increase  
the timeout ("config.vm.boot_timeout") value.

似乎是因为钥匙不对。

创建并安装公钥。

$vagrant ssh

通过vagrant安装了。

$vi ~/.ssh/authorized_keys

我們將在上述位置設置公鑰。

重新启动

kiyop@PC /c/vagrant/centos6 
$ vagrant reload  
==> default: [vagrant-hostsupdater] Removing hosts  
==> default: Attempting graceful shutdown of VM...  
==> default: Clearing any previously set forwarded ports...  
==> default: Clearing any previously set network interfaces...  
==> default: Preparing network interfaces based on configuration...  
    default: Adapter 1: nat  
    default: Adapter 2: hostonly  
==> default: Forwarding ports...  
    default: 22 (guest) => 2222 (host) (adapter 1)  
==> default: Booting VM...  
==> default: Waiting for machine to boot. This may take a few minutes...  
    default: SSH address: 127.0.0.1:2222  
    default: SSH username: vagrant  
    default: SSH auth method: private key  
    default: Warning: Connection reset. Retrying...  
    default: Warning: Connection aborted. Retrying...  
    default: Warning: Connection reset. Retrying...  
==> default: Machine booted and ready!  
[default] GuestAdditions 6.1.18 running --- OK.  
==> default: Checking for guest additions in VM...  
==> default: [vagrant-hostsupdater] Checking for host entries  
==> default: [vagrant-hostsupdater] Writing the following entries to (C:/WINDOWS/system32/drivers/etc/hosts)  
==> default: [vagrant-hostsupdater] 192.168.33.10  vagrant.centos  # VAGRANT: ac4689efd5b5dca9faa3f9f0da2473af (default) / c26520ed-e020-4c06-8ff7-09554c7b954b  
==> default: [vagrant-hostsupdater] This operation requires administrative access. You may skip it by manually adding equivalent entries to the hosts file.  
==> default: Setting hostname...  
==> default: Configuring and enabling network interfaces...  
==> default: Mounting shared folders...  
    default: /vagrant => C:/vagrant/centos6 
    default: /var/www/html => C:/workspace
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.

确认

kiyop@PC /c/vagrant/centos6 
$ vagrant ssh
Last login: Wed Jun 16 06:38:14 2021 from 10.0.2.2
[vagrant@vagrant ~]$ php -v
PHP 5.3.3 (cli) (built: Nov  1 2019 12:28:08)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
[vagrant@vagrant ~]$ mysql --version
mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1

一切都很順利,可以普及開來。

广告
将在 10 秒后关闭
bannerAds