1. 在一台可以联网的centos上安装postgresql源
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
  1. 使用yumdownloader下载安装包
yumdownloader --resolve postgresql13-server
  1. 上传rpm包到安装的centos服务器上
-rw-rw-rw- 1 root root 1490812 Sep 27 09:45 postgresql13-13.4-1PGDG.rhel7.x86_64.rpm
-rw-rw-rw- 1 root root  390420 Sep 27 09:45 postgresql13-libs-13.4-1PGDG.rhel7.x86_64.rpm
-rw-rw-rw- 1 root root 5654980 Sep 27 09:45 postgresql13-server-13.4-1PGDG.rhel7.x86_64.rpm
  1. 批量安装rpm包
rpm -ivh postgresql13-13.4-1PGDG.rhel7.x86_64.rpm postgresql13-libs-13.4-1PGDG.rhel7.x86_64.rpm postgresql13-server-13.4-1PGDG.rhel7.x86_64.rpm

报错了,缺少依赖libicu

warning: postgresql13-13.4-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
error: Failed dependencies:
        libicu is needed by postgresql13-13.4-1PGDG.rhel7.x86_64
        libicui18n.so.50()(64bit) is needed by postgresql13-server-13.4-1PGDG.rhel7.x86_64
        libicuuc.so.50()(64bit) is needed by postgresql13-server-13.4-1PGDG.rhel7.x86_64
  1. 使用yumdownloader下载libicu
yumdownloader --resolve libicu
-rw-r--r-- 1 root root 7250656 Mar 25  2020 libicu-50.2-4.el7_7.i686.rpm
-rw-r--r-- 1 root root 7202728 Mar 25  2020 libicu-50.2-4.el7_7.x86_64.rpm
-rw-r--r-- 1 root root 1490812 Aug 12 18:07 postgresql13-13.4-1PGDG.rhel7.x86_64.rpm
-rw-r--r-- 1 root root  390420 Aug 12 18:07 postgresql13-libs-13.4-1PGDG.rhel7.x86_64.rpm
-rw-r--r-- 1 root root 5654980 Aug 12 18:07 postgresql13-server-13.4-1PGDG.rhel7.x86_64.rpm

删除libicu-50.2-4.el7_7.i686.rpm(32位安装包)
6. 重新上传到需要安装的服务器,执行安装命令

rpm -ivh libicu-50.2-4.el7_7.x86_64.rpm postgresql13-13.4-1PGDG.rhel7.x86_64.rpm postgresql13-libs-13.4-1PGDG.rhel7.x86_64.rpm postgresql13-server-13.4-1PGDG.rhel7.x86_64.rpm
  1. 安装成功后初始化数据库
/usr/pgsql-13/bin/postgresql-13-setup initdb
  1. 开机启动postgresql数据库
systemctl enable postgresql-13
  1. 启动postgresql数据库服务
systemctl start postgresql-13
  1. 创建用户和数据库,使用postgres用户登录(PostgresSQL安装后会自动创建postgres用户,无密码)
su postgres
  1. 登录postgresql数据库
psql
  1. 创建用户和数据库并授权
create user ycloans with password 'ycloans';            // 创建用户
create database sonarqube owner ycloans;                 // 创建数据库
grant all privileges on database sonarqube to ycloans;   // 授权

\q 退出命令模式

13. 开启远程访问,修改/var/lib/pgsql/13/data/postgresql.conf文件,取消 listen_addresses 的注释,将参数值改为“*”

[转帖]centos7离线安装postgresql13_sql

  1. 修改/var/lib/pgsql/13/data/pg_hba.conf文件,增加下图红框部分内容
  2. 切换到root用户,重启postgresql服务
systemctl restart postgresql-13




  1. 在一台可以联网的centos上安装postgresql源
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
  1. 使用yumdownloader下载安装包
yumdownloader --resolve postgresql13-server
  1. 上传rpm包到安装的centos服务器上
-rw-rw-rw- 1 root root 1490812 Sep 27 09:45 postgresql13-13.4-1PGDG.rhel7.x86_64.rpm
-rw-rw-rw- 1 root root  390420 Sep 27 09:45 postgresql13-libs-13.4-1PGDG.rhel7.x86_64.rpm
-rw-rw-rw- 1 root root 5654980 Sep 27 09:45 postgresql13-server-13.4-1PGDG.rhel7.x86_64.rpm
  1. 批量安装rpm包
rpm -ivh postgresql13-13.4-1PGDG.rhel7.x86_64.rpm postgresql13-libs-13.4-1PGDG.rhel7.x86_64.rpm postgresql13-server-13.4-1PGDG.rhel7.x86_64.rpm

报错了,缺少依赖libicu

warning: postgresql13-13.4-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
error: Failed dependencies:
        libicu is needed by postgresql13-13.4-1PGDG.rhel7.x86_64
        libicui18n.so.50()(64bit) is needed by postgresql13-server-13.4-1PGDG.rhel7.x86_64
        libicuuc.so.50()(64bit) is needed by postgresql13-server-13.4-1PGDG.rhel7.x86_64
  1. 使用yumdownloader下载libicu
yumdownloader --resolve libicu
-rw-r--r-- 1 root root 7250656 Mar 25  2020 libicu-50.2-4.el7_7.i686.rpm
-rw-r--r-- 1 root root 7202728 Mar 25  2020 libicu-50.2-4.el7_7.x86_64.rpm
-rw-r--r-- 1 root root 1490812 Aug 12 18:07 postgresql13-13.4-1PGDG.rhel7.x86_64.rpm
-rw-r--r-- 1 root root  390420 Aug 12 18:07 postgresql13-libs-13.4-1PGDG.rhel7.x86_64.rpm
-rw-r--r-- 1 root root 5654980 Aug 12 18:07 postgresql13-server-13.4-1PGDG.rhel7.x86_64.rpm

删除libicu-50.2-4.el7_7.i686.rpm(32位安装包)
6. 重新上传到需要安装的服务器,执行安装命令

rpm -ivh libicu-50.2-4.el7_7.x86_64.rpm postgresql13-13.4-1PGDG.rhel7.x86_64.rpm postgresql13-libs-13.4-1PGDG.rhel7.x86_64.rpm postgresql13-server-13.4-1PGDG.rhel7.x86_64.rpm
  1. 安装成功后初始化数据库
/usr/pgsql-13/bin/postgresql-13-setup initdb
  1. 开机启动postgresql数据库
systemctl enable postgresql-13
  1. 启动postgresql数据库服务
systemctl start postgresql-13
  1. 创建用户和数据库,使用postgres用户登录(PostgresSQL安装后会自动创建postgres用户,无密码)
su postgres
  1. 登录postgresql数据库
psql
  1. 创建用户和数据库并授权
create user ycloans with password 'ycloans';            // 创建用户
create database sonarqube owner ycloans;                 // 创建数据库
grant all privileges on database sonarqube to ycloans;   // 授权

\q 退出命令模式

13. 开启远程访问,修改/var/lib/pgsql/13/data/postgresql.conf文件,取消 listen_addresses 的注释,将参数值改为“*”

[转帖]centos7离线安装postgresql13_sql

  1. 修改/var/lib/pgsql/13/data/pg_hba.conf文件,增加下图红框部分内容
  2. 切换到root用户,重启postgresql服务
systemctl restart postgresql-13