zoukankan      html  css  js  c++  java
  • centos服务器安装配置Postgre9.6

    安装:

    STEP1:下载对应rpm

    yum install  https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-centos96-9.6-3.noarch.rpm

    STEP2:安装下好的rpm

    yum install postgresql96-server postgresql96-contrib

    step3 初始化数据库

    service postgresql-9.6 initdb

    step4设置开机自启动

    chkconfig postgresql-9.6 on

    step5启动服务

    service postgresql-9.6 start

    配置:

    step1 修改用户密码

    • su - postgres 切换用户,执行后提示符会变为 '-bash-4.2$'
    • psql - U postgres 登录数据库,执行后提示符变为 'postgres=#'
    • ALTER USER postgres WITH PASSWORD 'postgres' 设A置postgres用户密码
    • q 退出数据库 (pgcluster012)

    step2 开启远程访问

    • vi /var/lib/pgsql/9.6/data/postgresql.conf
    • 修改#listen_addresses = 'localhost' 为 listen_addresses='*'
    • 当然,此处‘*’也可以改为任何你想开放的服务器IP
      或者使用scp命令将之前配置好的文件拷贝过来覆盖即可scp /var/lib/pgsql/9.6/data/postgresql_backup.conf root@192.168.10.33:/var/lib/pgsql/9.6/data/

    step3 信任远程连接

    • vi /var/lib/pgsql/9.6/data/pg_hba.conf
      修改如下内容,信任指定服务器连接
        # IPv4 local connections:
        host    all            all      127.0.0.1/32      trust
        host    all            all           10.211.55.6/32(需要连接的服务器IP  trust
        
     同上

    step4 打开防火墙

    CentOS 防火墙中内置了PostgreSQL服务,配置文件位置在/usr/lib/firewalld/services/postgresql.xml,我们只需以服务方式将PostgreSQL服务开放即可。

    Centos7:

      firewall-cmd --add-service=postgresql --permanent 开放postgresql服务

      firewall-cmd --reload 重载防火墙

    centos6.8:

      查询防火墙状态:
      [root@localhost ~]# service   iptables status
      停止防火墙:
      [root@localhost ~]# service   iptables stop
      启动防火墙:
      [root@localhost ~]# service   iptables start
      重启防火墙:
      [root@localhost ~]# service   iptables restart
      永久关闭防火墙:
      [root@localhost ~]# chkconfig   iptables off
      永久关闭后启用:
      [root@localhost ~]# chkconfig   iptables on

    重启PostgreSQL数据服务

      systemctl restart postgresql-9.6.service(centos 7)

      service postgresql-9.6 restart(centos 6.8)

    在其他服务器上切换到postgres下测试连接

         psql -h 172.11.20.45 -p 5432 -U postgres,如果可以进入就算配置完成。

    总结

    至此pg96安装并简单配置完成。

  • 相关阅读:
    POJ3280Cheapest palindrome 经典dp
    hdu1257 最少拦截系统 LIS的应用
    代码着色 test
    Delphi 线程中的 Synchronize 和 临界区TCriticalSection 区别
    Delphi float浮点值转换整型int 方法
    Win.ini 介绍和配置结构
    Delphi Win API 打印函数 WriteProfileString
    Delphi ADOQuery 的Open和ExecSQL有什么区别
    SQL Server 中的 @、@@、#、## 、N 代表什么,以及SQL系统常用全局变量
    SQL 返回新增行的自增ID值方法
  • 原文地址:https://www.cnblogs.com/guoxueyuan/p/6907132.html
Copyright © 2011-2022 走看看