LoginSignup
1
0

More than 5 years have passed since last update.

Windows10でVagrantの環境を作ったは良いがyumコマンドが実行できなくて困った話し

Last updated at Posted at 2019-04-19

元々Vagrantで作成した開発環境がどうにもこうにもエラーになって立ち上がらないので新しく環境を作成することにしました。
今回は本番環境とおなじ「Red Hat Linux 7.3」で開発環境を作成しようと思います。
(最初にVagrant環境を作成する手順も簡単に記載していますが、不要であれば飛ばしてしまってOKです。)

vagrant のBoxファイルを探す

https://app.vagrantup.com/boxes/search
VagrantCloudに行って今回ほしいBoxがあるか探します。
マイナーバージョンまで指定しているのでHIT数が少ないですね。
Discover Vagrant Boxes - Vagrant Cloud - Google Chrome 2019-04-19 18.23.05.png

apolloclarkさんの環境をダウンロードしようと思いますので、apolloclark/rhel7.3をクリックします。
今回は新規作成なので「new」のタブをクリックして表示を切り替えます。
Vagrantの環境を作成したいディレクトリ以下でこのコマンドを実行するとBoxデータをダウンロードしてVagrant環境を作成してれます。
Vagrant box apolloclark_rhel7.3 - Vagrant Cloud - Google Chrome 2019-04-19 18.31.39.png

Windows環境にVagrant環境を作成

Windows PowerShellで以下コマンドを実行します。
(ターミナルはどれでもOKです。)

vagrant init を実行してVagrantFileを作成します。

C:\Users\hogehoge\Documents\GitHub\vagrant-test> pwd

Path
----
C:\Users\hogehoge\Documents\GitHub\vagrant-test

C:\Users\hogehoge\Documents\GitHub\vagrant-test>
C:\Users\hogehoge\Documents\GitHub\vagrant-test> ls
C:\Users\hogehoge\Documents\GitHub\vagrant-test>
C:\Users\hogehoge\Documents\GitHub\vagrant-test>
C:\Users\hogehoge\Documents\GitHub\vagrant-test>
C:\Users\hogehoge\Documents\GitHub\vagrant-test> vagrant init apolloclark/rhel7.3
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

C:\Users\hogehoge\Documents\GitHub\vagrant-test>

vagrant up を実行してVagrant環境を作成します。
(30分程度かかりましたので気長に待ちましょう)

C:\Users\hogehoge\Documents\GitHub\vagrant-test>
C:\Users\hogehoge\Documents\GitHub\vagrant-test> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'apolloclark/rhel7.3' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0

Vagrantが出来上がったらsshで接続してみましょう。
無事にログイン出来ましたね。

C:\Users\hogehoge\Documents\GitHub\vagrant-test>
C:\Users\hogehoge\Documents\GitHub\vagrant-test> vagrant ssh
[vagrant@localhost ~]$
[vagrant@localhost ~]$
[vagrant@localhost ~]$

で、このままyumでミドルを入れようかと思ってとりあえずyum updateを実行したのですが

[root@localhost ~]#
[root@localhost ~]# sudo yum update -y
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
There are no enabled repos.
 Run "yum repolist all" to see the repos you have.
 To enable Red Hat Subscription Management repositories:
     subscription-manager repos --enable <repo>
 To enable custom repositories:
     yum-config-manager --enable <repo>
[root@localhost ~]#

あれ?
updateが走らない…
リポジトリが入っているか確認したところ

[root@localhost ~]#
[root@localhost ~]# yum repolist all
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repolist: 0
[root@localhost ~]#
[root@localhost ~]#

おぉ
何も入ってないじゃないか

yumコマンドを使えるようにしました

ここからが対応内容になります。(遅くなってすみません)
対応自体は簡単で

を実行するだけでした。
rpmを入れた後にyum updateを実行したらちゃんとupdateされました。

[root@localhost ~]#
[root@localhost ~]# rpm -Uvh http://download3.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving http://download3.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.3mOvtL: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:epel-release-6-8                 ################################# [100%]
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Retrieving http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
warning: /var/tmp/rpm-tmp.JmQglY: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:remi-release-6.10-1.el6.remi     ################################# [100%]
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# date
Fri Apr 19 09:02:36 UTC 2019
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# yum update
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
epel/x86_64/metalink 

最後まで読んでいただきありがとうございました。

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