Database

在 Cent OS 上安裝 postgres

  • May 16, 2016

我很難在 Cent OS 7.2 上重新安裝 postgres。這是我嘗試過的。

  • 了postgres的YUM repo
  • 在我的機器上為 RPM 文件創建了一個臨時文件夾
  • 做過wget https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-2.noarch.rpm
  • 接下來我ran rpm -ivh filename

但我得到的只是package pgdg-centos95-9.5-2.noarch is already installed.

我對錯誤消息很好,但是當我使用以下命令安裝 postgres 組件時。

sudo yum install postgresql95-server.x86_64 postgresql95-contrib.x86_64 postgresql95-devel.x86_64

它列出了來自我下載的不同 rpm 的詳細資訊,即 9.5.1-1PGDG.rhel7

Dependencies Resolved

==============================================================================================================================================================================================
Package                                              Arch                                   Version                                             Repository                              Size
==============================================================================================================================================================================================
Installing:
postgresql95-contrib                                 x86_64                                 9.5.1-1PGDG.rhel7                                   pgdg95                                 526 k
postgresql95-devel                                   x86_64                                 9.5.1-1PGDG.rhel7                                   pgdg95                                 1.7 M
postgresql95-server                                  x86_64                                 9.5.1-1PGDG.rhel7                                   pgdg95                                 4.1 M
Installing for dependencies:
postgresql95                                         x86_64                                 9.5.1-1PGDG.rhel7                                   pgdg95                                 1.3 M
postgresql95-libs                                    x86_64                                 9.5.1-1PGDG.rhel7                                   pgdg95                                 218 k

Transaction Summary
==============================================================================================================================================================================================

當我繼續安裝時,我遇到了所有軟體包的 404 錯誤消息。

No Presto metadata available for pgdg95
postgresql95-9.5.1-1PGDG.rhel7 FAILED                                          
https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/postgresql95-9.5.1-1PGDG.rhel7.x86_64.rpm: [Errno 14] HTTPS Error 404 - Not Found    ]  0.0 B/s |    0 B  --:--:-- ETA 
Trying other mirror.
To address this issue please refer to the below knowledge base article 

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/

postgresql95-devel-9.5.1-1PGDG FAILED                                          
https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/postgresql95-devel-9.5.1-1PGDG.rhel7.x86_64.rpm: [Errno 14] HTTPS Error 404 - Not Found 0.0 B/s |    0 B  --:--:-- ETA 
Trying other mirror.
postgresql95-contrib-9.5.1-1PG FAILED                                          
https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/postgresql95-contrib-9.5.1-1PGDG.rhel7.x86_64.rpm: [Errno 14] curl#6 - "Could not resolve host: download.postgresql.org; Temporary failure in name resolution"
Trying other mirror.
postgresql95-libs-9.5.1-1PGDG. FAILED                                          
https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/postgresql95-libs-9.5.1-1PGDG.rhel7.x86_64.rpm: [Errno 14] HTTPS Error 404 - Not Found  0.0 B/s |    0 B  --:--:-- ETA 
Trying other mirror.
postgresql95-server-9.5.1-1PGD FAILED                                          
https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/postgresql95-server-9.5.1-1PGDG.rhel7.x86_64.rpm: [Errno 14] HTTPS Error 404 - Not Found0.0 B/s |    0 B  --:--:-- ETA 
Trying other mirror.

我在這裡做錯了什麼以及為什麼沒有從我下載的 rpm 安裝 postgres。我假設 rpm 版本不匹配是問題所在。

顯然我所做的修復是相當蠻力的,可能很愚蠢,但它仍然有效。

我做到了sudo find / -iname "pgdg95"

在列出的所有文件夾和文件上執行 rm -rf。

重複上面列出的步驟,它安裝得很好。

這個答案幫助我啟動並執行它。還必須更改 hba.conf。

引用自:https://serverfault.com/questions/777036