# 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

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐