设为首页 加入收藏

TOP

PostgrelSql9.4hotstandby配置(一)
2015-11-21 02:03:35 来源: 作者: 【 】 浏览:3
Tags:PostgrelSql9.4hotstandby 配置
----配置同步流复制

****************************************************
1.在主库增加同步的用户名与密码
****************************************************

$ psql -h 192.168.50.110  -d postgres -U postgres 
Password for user postgres: 
psql (9.4.4)
Type "help" for help.

postgres=# \l
                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   
-----------+----------+----------+------------+------------+-----------------------
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
(3 rows)

postgres=# \c postgres
You are now connected to database "postgres" as user "postgres".

 
postgres=# SELECT rolname from pg_roles ;
 rolname  
----------
 postgres
 repluser
(2 rows)

postgres=# SELECT usename from pg_user; 
 usename  
----------
 postgres
 repluser
(2 rows)


postgres=# CREATE ROLE repluser REPLICATION LOGIN PASSWORD '123';
CREATE ROLE

postgres=#

****************************************************
2.新建测试数据库
****************************************************

postgres=# \l
                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   
-----------+----------+----------+------------+------------+-----------------------
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
(3 rows)

postgres=# create database wind;
CREATE DATABASE
postgres=# \l
                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   
-----------+----------+----------+------------+------------+-----------------------
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 wind      | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
(4 rows)

postgres=# \c wind;
You are now connected to database "wind" as user "postgres".
wind=# \d
No relations found.
wind=# create table t1(sid int not null primary key,sname varchar(10));
CREATE TABLE
wind=# insert into t1 values(101,'ocpyang');
INSERT 0 1
wind=# insert into t1 values(102,'yzw');
INSERT 0 1
wind=# select * from t1;
 sid |  sname  
-----+---------
 101 | ocpyang
 102 | yzw
(2 rows)



****************************************************
3.在主库pg01上进行配置
****************************************************

--3.1
$ vi /data/pg/data/pg_hba.conf
增加以下:
host    replication     repluser        192.168.50.0/24           md5


--3.2 在主库pg01的/data/pg/data/postgresql.conf中设置如下三个参数
$ vi /data/pg/data/postgresql.conf
 
59  listen_addresses = '*'
175 wal_level = hot_standby
224 max_wal_senders = 5 
226 wal_keep_segments = 64  




--3.3 在主数据上指定同步复制的Standby名称,在主库pg01的/data/pg/data/postgresql.conf中设置:
vi /data/pg/data/postgresql.conf
 
236 synchronous_standby_names = 'pg02'


--3.4 修改上述参数后需要重启数据库.

pg_ctl -m "immediate" restart


***
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇化繁为简――分解复杂的SQL语句 下一篇【SQL】――触发器

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: