LoginSignup
18
20

More than 5 years have passed since last update.

Windows10にVagrant入れて、CentOS7.1入れた話

Last updated at Posted at 2015-09-04

ある程度わかってる人向けメモだけど、一応基本的な部分も書き留めておきます。
あと、はっきりいってほとんどmacとかも工程一緒ですね。Cmderの恩恵がでかい

この記事の後にやったこと書きました。
CentOS7.1にNginx+NodeJS(nvm)環境の導入(Vagrant環境下)

要件

  • Windows 10 Pro
  • コンソールにCmder←これ重要。Cmder使ってない場合はgitBashとかで代用
  • Vagrant 1.7.4
  • VirtualBox 5.0.2
  • CentOS 7.1

Vagrant入れる

vagrantはいつものサイトから
https://www.vagrantup.com/
DLしてインストール。2015/09/05時点ではver.1.7.4が最新。

終わったら面倒だけど再起動。

CentOS7.1のbox入れる

下記のbox共有サイト見た。

今回は、それほど問題が無く信頼のopscodeのものを使います。

$ vagrant box add opscode_centos-7.1 http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.1_chef-provisionerless.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'opscode_centos-7.1' (v0) for provider:
    box: Downloading: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.1_chef-provisionerless.box
    box: Progress: 100% (Rate: 5258k/s, Estimated time remaining: --:--:--)
==> box: Successfully added box 'opscode_centos-7.1' (v0) for 'vmware_desktop'!

追加完了ー。

注意!
実際のサイトのURLではvirtualboxではなく、vmwareのboxがURLとして指定されてました!
しかもこいつだけ・・・、カテゴリVirtualBoxだし。
vagrant upまでやって気づいた。。。

Vagrantfile作ろう

その前にフォルダ準備してからね。

$ mkdir centos71
$ cd centos71

ファイル作成ー

vagrant init opscode_centos-7.1

Vagrant.configure(2) do |config|のブロックの中に

config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.1_chef-provisionerless.box"

を追加する。

起動する

$ vagrant up

エラー

No usable default provider could be found for your system.

Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.

The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.

If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.

そうだ。VirtualBox入れてない。

どうやら、VirtualBoxはまだ正式にwindows10をサポートしてない。でも入れる。
https://www.virtualbox.org/wiki/Downloads
いつもどおり、ネットワークのインタフェースは信頼するを選択するよ。
5.0.2が入ったよ、起動したよ。

じゃあもう一度upコマンド打つよ。どうやらコンソールは一度落とさなきゃいけないみたい。

$ vagrant up

。。。同じエラー。調べてみたら環境変数の指定がWindowsだと別の値になるからみたい。
ユーザー環境変数に以下を追加する。

変数:VBOX_INSTALL_PATH
値:%VBOX_MSI_INSTALL_PATH%

これでまたコンソール再起動してupする
upは動いたけど、何故かdownloadもう一度やっちゃってる。。。うーんなんでだろう。

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'opscode_centos-7.1' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'opscode_centos-7.1' (v0) for provider: virtualbox
    default: Downloading: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.1_chef-provisionerless.box
    default: Progress: 100% (Rate: 6372k/s, Estimated time remaining: --:--:--)
==> default: Successfully added box 'opscode_centos-7.1' (v0) for 'virtualbox'!
...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/username/vagrant/centos71

入ったー。

入ってみる

sshで入ってみる。Cmderだからssh何事もなく使える。

$ vagrant ssh
[vagrant@localhost ~]$

入れたー。
ネットワークが動いているかの確認と、アップデートのためにyumでupdateする
(なんか別のQiitaでネットワークがおかしいみたいな話あったので)

$ sudo yum update -y

問題なく動いた。
ネットワーク周りも問題なく動作しているっぽいのでこれで良いですね。

ではではー。

後日。。。(なお投稿日)

なぜか再起動したらmountが失敗するようになった。
どうやら、yum updateでカーネルの更新が走ったから?みたいでvbguestを入れて更新するも、うまく行かなくなってしまった。

vagrant plugin install vagrant-vbguest
$ vagrant ssh
$ sudo yum install kernel-devel-3.10.0-229.11.1.el7.x86_64

ちょっとログを見てみたらgccコマンドねーよって怒られてた。

$ sudo yum install -y gcc

もう一回vbguest動かす。

vagrant vbguest
GuestAdditions seems to be installed (5.0.2) correctly, but not running.
Starting vboxadd (via systemctl):  Job for vboxadd.service failed. See 'systemctl status vboxadd.service' and 'journalctl -xn' for details.
[FAILED]
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module[  OK  ]
Building the shared folder support module[  OK  ]
Building the OpenGL support module[  OK  ]
Doing non-kernel setup of the Guest Additions[  OK  ]
Starting the VirtualBox Guest Additions [  OK  ]

動いたっぽい?reloadするよ

$ vagrant reload

行けた。良かった。

追加の話

今回は、開発環境として利用するので、SELinuxとfirewallを無効化しておきます。

$ getenforce
Permissive

やろうと思ったらSELinux無効化されてた。

$ systemctl status firewalld
firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled)
   Active: inactive (dead)

firewalldも無効化されてました。問題なかった。

補足:epelとremiを入れる

epel

$ sudo yum install -y epel-release
$ sudo vi /etc/yum.repos.d/epel.repo

一応、enabledを0に変更しておく。

remi

$ sudo rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
$ sudo vi /etc/yum.repos.d/remi.repo

こいつもenabledを0に変更しておこう。
確認してみたら全部0になってるっぽい?

追加の話

なぜかhaltしてからwindows再起動したら謎のエラーに遭遇。

==> default: Waiting for machine to boot. This may take a few minutes...
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'poweroff' state. Please verify everything is configured
properly and try again.

If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.

The primary issue for this error is that the provider you're using
is not properly configured. This is very rarely a Vagrant issue.

とりあえず、Virtualboxを起動して、vagrant upしたものの同じ結果になったので、vagrant reloadをしたら問題なく起動したので一応書いておきますね。

18
20
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
18
20