# 01.Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# 02.Install PostgreSQL:
sudo yum install -y postgresql12-server
# 03.Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
sudo systemctl enable postgresql-12
sudo systemctl start postgresql-12
执行第二步时,报错:
Errors during downloading metadata for repository 'pgdg-common':
- Status code: 404 for https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-3-x86_64/repodata/repomd.xml
Error: Failed to download metadata for repo 'pgdg-common': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
解决方式:
# 在以下目录找到 pg 的repo。复制其名称,例如:pgdg-redhat-all.repo
ls -l /etc/yum.repos.d/
# 将刚刚复制的repo 名称追加到以下文件的include字段中。
vim /etc/yum/pluginconf.d/releasever-adapter.conf
# 例如
include=docker-ce.repo, epel.repo, pgdg-redhat-all.repo
如果没有 pluginconf.d 目录,则执行如下命令:
dnf install dnf-plugin-releasever-adapter --repo alinux3-plus