1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

VMからapache、mysqlが消えた

Posted at

#開発環境
・Windows10
・Vagrant 2.2.7
・Centos6
・VirtualBox 6.1.18
#結論
Vagrantの仮想マシンとの紐付けがうまくいかず、
新しい仮想マシンを作り直していました。

旧仮想マシンのデータがあったため、紐づけを戻すことで
復旧することができました。
#紐づけたいIDを設定する

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

↑ここに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.

#鍵があっていないらしいです
https://qiita.com/d2cdot-mmori/items/1c340f175ae510e4456a
公開鍵を作成して設置します。

$vagrant ssh

PASS: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

無事、普及することができました。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?