zoukankan      html  css  js  c++  java
  • postgresql 主从配置

    安装postgresql

    主从是否一定需要分两台机器,主从必须要同一个版本,不然启动会报错。

    3. 配置Master数据库

    su – postgres

    /usr/local/pgsql/bin/pg_ctl –D /data/pgsql9.1 start #启动数据库

    #进入数据库创建repl用户

    Psql –p 5432 –U postgres –h 127.0.0.1

    Create user repl superuser password ‘密码’

    q

    #修改postgresql.conf文件

    vi /data/pgsql9.1/postgresql.conf

    listen_addresses = '*' //监听地址

    wal_level = hot_standby // 同步级别, 最小的,档案,hot_standby,或逻辑,(更改后需要重新启动)

    synchronous_commit = on // 是否同步,on表示需要同步到其他服务器

    max_wal_senders = 2 // 同步最大的进程数量

    wal_keep_segments = 32 // 日志文件段大小,默认为16M,0表示禁用

    full_page_writes=on


    synchronous_standby_names = '*' /* 提供同步代理的备用服务器
    * 逗号分隔的列表application_name
    * 从待机状态(S);“*”=所有 */

    #修改pg_hba.conf文件

    vi /data/pgsql9.1/pg_hba.conf

    #允许局域网中md5密码认证连接

    host all all 192.168.100.0/24 md5

    #用户数据同步,必须为replication数据库

    host replication repl 192.168.100.0/24 md5

    #用户在当前数据库服务器无密码连接

    local all all trust

    #重启数据库

    Su – postgres

    /usr/local/pgsql/bin/pg_ctl –D /data/pgsql9.1 restart

  • 相关阅读:
    010-你觉得单元测试可行吗
    跳台阶
    斐波那契数列
    旋转数组的最小数字
    用两个栈实现队列
    重建二叉树
    从尾到头打印链表
    替换空格
    二维数组中的查找
    Best Time to Buy and Sell Stock III
  • 原文地址:https://www.cnblogs.com/mywebnumber/p/5826787.html
Copyright © 2011-2022 走看看