搜索pgsql包

  1. [root@hadoop-node1 bin]# yum list | grep postgresql
  2. postgresql.aarch64 9.2.24-6.el7_9 @updates
  3. postgresql-contrib.aarch64 9.2.24-6.el7_9 @updates
  4. postgresql-libs.aarch64 9.2.24-6.el7_9 @updates
  5. postgresql-server.aarch64 9.2.24-6.el7_9 @updates
  6. freeradius-postgresql.aarch64 3.0.13-15.el7 base
  7. libreoffice-postgresql.aarch64 1:5.3.6.1-25.el7_9 updates
  8. pcp-pmda-postgresql.aarch64 4.3.2-13.el7_9 updates
  9. postgresql-devel.aarch64 9.2.24-6.el7_9 updates
  10. postgresql-docs.aarch64 9.2.24-6.el7_9 updates
  11. postgresql-jdbc.noarch 9.2.1002-8.el7_8 updates
  12. postgresql-jdbc-javadoc.noarch 9.2.1002-8.el7_8 updates
  13. postgresql-odbc.aarch64 09.03.0100-2.el7 base
  14. postgresql-plperl.aarch64 9.2.24-6.el7_9 updates
  15. postgresql-plpython.aarch64 9.2.24-6.el7_9 updates
  16. postgresql-pltcl.aarch64 9.2.24-6.el7_9 updates
  17. postgresql-static.aarch64 9.2.24-6.el7_9 updates
  18. postgresql-test.aarch64 9.2.24-6.el7_9 updates
  19. postgresql-upgrade.aarch64 9.2.24-6.el7_9 updates
  20. qt-postgresql.aarch64 1:4.8.7-9.el7_9 updates
  21. qt5-qtbase-postgresql.aarch64 5.9.7-5.el7_9 updates

安装

  1. yum install postgresql-server postgresql-contrib -y

初始化数据库

  1. postgresql-setup initdb

启动数据库

  1. systemctl enable postgresql #开启启动
  2. systemctl start postgresql

修改配置文件

配置防火墙

  1. 先安装防火墙

    1. yum install firewalld
  2. 开启相关端口

    1. firewall-cmd --permanent --add-port=5432/tcp
    2. firewall-cmd --permanent --add-port=80/tcp
    3. firewall-cmd --reload

    修改配置文件

  3. 开放地址 ```bash vim /var/lib/pgsql/data/postgresql.conf

listen_addresses = ‘*’

这里localhost修改为*,或者指定ip地址

  1. 2. 信任远程连接
  2. ```bash
  3. vim /var/lib/pgsql/data/pg_hba.conf
  4. # TYPE DATABASE USER ADDRESS METHOD
  5. # "local" is for Unix domain socket connections only
  6. local all all peer
  7. # IPv4 local connections:
  8. host all all 127.0.0.1/32 trust
  9. host all all 0.0.0.0/0 md5
  10. # IPv6 local connections:
  11. host all all ::1/128 trust
  1. 修改密码 ```bash

    postgres用户登录:

    su postgres

连接数据库:

psql -U postgres

修改密码:

Alter user postgres with password ‘postgres’;

退出数据库连接:

\q

  1. 4. 重启服务
  2. ```bash
  3. systemctl restart postgresql