0
2

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 5 years have passed since last update.

仮想マシンにPostgreSQLをインストールしたい。

Last updated at Posted at 2017-04-07

仮想環境 VirtualBox - Vagrant

vagrant init centos64 を経て vagrant up。仮想マシンに接続 vagrant ssh
 ruby, Ruby on rails, git を仮想マシンに正常にインストール。
 次にPostgreSQLのバージョンを確認。

[vagrant@localhost ~]$ psql --version
-bash: psql: command not found

 そこでPostgreSQLインストールを試みた。

[vagrant@localhost ~]$ sudo yum install postgresql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-6-x86_64/repodata/repomd.xml: [Errno 14] problem making ssl connection
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: pgdg95. Please verify its path and try again

 失敗。文中 problem making ssl connection のメッセージから、rhel (redhat) リポジトリへの ssl connection が失敗している様子。
 SSLまわりのライブラリのアップデート(久々にログインしたサーバでyumしたらepel接続でsslエラーが出たので対応)が必要とのご助言を質問サイトでいただけたので試行。

[vagrant@localhost ~]$ sudo yum install -y nss
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-6-x86_64/repodata/repomd.xml: [Errno 14] problem making ssl connection
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: pgdg95. Please verify its path and try again

 エラー内容変わらず。
 そこで、いったん yum の引数に --disablerepo=pgdg95 を追加して、このリポジトリを無視するようにしてやってみて下さいとのこと。

[vagrant@localhost ~]$ sudo yum install -y nss --disablerepo=pgdg95
(中略)
base      | 3.7 kB 00:00 #突破
extras    | 3.4 kB 00:00 
updates   | 3.4 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
(中略)
Dependencies Resolved
(中略)
Updated:
nss.x86_64 0:3.27.1-13.el6 
Dependency Updated:
nspr.x86_64 0:4.13.1-1.el6 nss-softokn.x86_64 0:3.14.3-23.3.el6_8 
nss-softokn-freebl.x86_64 0:3.14.3-23.3.el6_8 nss-sysinit.x86_64 0:3.27.1-13.el6 
nss-tools.x86_64 0:3.27.1-13.el6 nss-util.x86_64 0:3.27.1-3.el6 
Complete! #完了

Incredible! いいぞいいぞ。この調子でいけるかぁ?

[vagrant@localhost ~]$ sudo yum install postgresql-server
(中略)
pgdg95         | 4.1 kB 00:00 #突破
pgdg95/primary_db  | 177 kB 00:01
Setting up Install Process
Resolving Dependencies
--> Running transaction check
(中略)
Dependencies Resolved
(中略)
Installed:
postgresql95-server.x86_64 0:9.5.6-2PGDG.rhel6 
Dependency Installed:
postgresql95.x86_64 0:9.5.6-2PGDG.rhel6 postgresql95-libs.x86_64 0:9.5.6-2PGDG.rhel6
Complete! #完了
[vagrant@localhost ~]$ psql --version
psql (PostgreSQL) 9.5.6 #確認

##### Superb! 一件落着。

sudo yum install -y http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm
sudo rpm -ivh http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
sudo yum install -y postgresql95 postgresql95-server postgresql95-contrib postgresql95-libs postgresql95-devel
sudo rpm -i http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-1.noarch.rpm
sudo yum update
sudo yum -y install postgresql96*
sudo vi /etc/yum.repos.d/CentOS-Base.repo
sudo yum -y localinstall https://yum.postgresql.org/9.6/redhat/rhel-6.7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
sudo apt-get install postgresql
wget https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm

>1)上記の如くいくつか試すも、インストールできず。

>```
[root@localhost network-scripts]# vi ifcfg-eth0  
[root@localhost network-scripts]# vi ifcfg-eth1  
[root@localhost network-scripts]# vi ifcfg-lo

2)〜 これらのファイルも異状なし(noをyesに書き換える場合があるようです)。
3)PostgreSQLのサイトからrpmを探し、

$ yum localinstall https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-centos96-9.6-3.noarch.rpm

>>と直接叩く + rpmをPCでダウンロードし、サーバに設置後  

>`$ yum localinstall pgdg-centos96-9.6-3.noarch.rpm  `
>>とするもエラー内容変わらず。
>
>4)〜 その仮想環境からインターネットに接続できているかの確認。  
>> しかし、以下はこちらと仮想マシンとの通信の確認と思われる。

>```
[vagrant@localhost ~]$ ip a  
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN  
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
inet 127.0.0.1/8 scope host lo  
inet6 ::1/128 scope host  
valid_lft forever preferred_lft forever  
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000  
link/ether 08:00:27:62:52:b8 brd ff:ff:ff:ff:ff:ff  
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0  
inet6 fe80::a00:27ff:fe62:52b8/64 scope link  
valid_lft forever preferred_lft forever  
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000  
link/ether 08:00:27:06:9f:0b brd ff:ff:ff:ff:ff:ff  
inet 192.168.78.90/24 brd 192.168.78.255 scope global eth1  
inet6 fe80::a00:27ff:fe06:9f0b/64 scope link  
valid_lft forever preferred_lft forever  
[vagrant@localhost ~]$ ping -c4 192.168.78.90 PING 192.168.78.90 (192.168.78.90) 56(84) bytes of data.  
64 bytes from 192.168.78.90: icmp_seq=1 ttl=64 time=0.008 ms  
64 bytes from 192.168.78.90: icmp_seq=2 ttl=64 time=0.105 ms  
64 bytes from 192.168.78.90: icmp_seq=3 ttl=64 time=0.056 ms  
64 bytes from 192.168.78.90: icmp_seq=4 ttl=64 time=0.020 ms  
--- 192.168.78.90 ping statistics ---  
4 packets transmitted, 4 received, 0% packet loss, time 3001ms  
rtt min/avg/max/mdev = 0.008/0.047/0.105/0.038 ms
0
2
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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?