• Centos6.5 下安装PostgreSQL9.4数据库


    一、安装PostgreSQL源

      

    CentOS 6.x 32bit

    rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-i386/pgdg-centos94-9.4-1.noarch.rpm

    CentOS 6.x 64bit

    rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm

    CentOS 7 64bit

    rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm

    注意:PostgreSQL9.4 版本有更新  目前变为9.4.2   将rpm 中后面的地址9.4.1 变为9.4.2即可

    二、执行安装命令

     yum install postgresql94-server postgresql94-contrib

    三、验证是否安装成功

    rpm -aq| grep postgres

    执行结果如下:

    postgresql94-libs-9.4.1-1PGDG.rhel7.x86_64
    postgresql94-server-9.4.1-1PGDG.rhel7.x86_64
    postgresql94-9.4.1-1PGDG.rhel7.x86_64
    postgresql94-contrib-9.4.1-1PGDG.rhel7.x86_64

    四、初始化数据库

    CentOS 6.x 系统

    service postgresql-9.4 initdb

    CentOS 7 系统

    /usr/pgsql-9.4/bin/postgresql94-setup initdb

    五、启动服务并设置为开机启动

    CentOS 6.x 系统

    service postgresql-9.4 start
    chkconfig postgresql-9.4 on

    CentOS 7 系统

    systemctl enable postgresql-9.4
    systemctl start postgresql-9.4

    六、开放防火墙端口

         参考《阿里云中Centos下配置防火墙》

    七、访问PostgreSQL

       

    su - postgres

    输出结果如下:

    上一次登录:一 5月 18 15:17:29 CST 2015pts/0 上
    -bash-4.2$

    输入命令psql将看到PostgrSQL的版本信息。

    psql (9.4.1)
    输入 "help" 来获取帮助信息.

    八、设置postgres用户密码

    postgres=# password postgres

      注意:要加

    九、 设置远程访问

          用vi 编辑postgresql.conf  和 pg_hba.conf文件的内容

    /var/lib/pgsql/9.4/data/postgresql.conf

    listen_addresses ='*'

    /var/lib/pgsql/9.4/data/pg_hba.conf

    # IPv4 local connections:
    host    all             all             127.0.0.1/32            trust
    host    all             all             IP地址/24         md5
    # IPv6 local connections:
    host    all             all             ::1/128                 trust

    十、设置客户端心跳连接(防止客户端没有操作时,失去连接)

      

    tcp_keepalives_idle = 60

    tcp_keepalives_interval = 10

    tcp_keepalives_count = 6 #空闲多少秒后,给idle的连接的客户端发送tcp的keepalives包, Linux下面默认是2小时

     

     以上完成Postgresql安装和配置。

  • 相关阅读:
    SpringKafka——消息监听
    RabbitMQ(八)线程池消费
    RabbitMQ(七)延迟队列
    window计划任务 0x1
    获取网页URL地址及参数等的两种方法(js和C#)
    HttpWebRequest的偶尔请求超时问题
    用HTML、CSS、JS制作圆形进度条(无动画效果)
    批量关联update
    仅仅 IE8 有效的 CSS hack 写法
    SqlServer关闭与启用标识(自增长)列
  • 原文地址:https://www.cnblogs.com/yunfeng83/p/4936192.html
Copyright © 2020-2023  润新知