https://access.redhat.com/solutions/1412753
SOLUTION UNVERIFIED - 已更新 2016年六月23日12:21 -
环境
- Red Hat Enterprise Linux 6
- postgresql92
- Red Hat Enterprise Linux 7
- postgresql-9.2
问题
Is there a hot backup function in postgresql so that the data can be backup concurrently?
决议
There is no hot backup function in postgresql before version 9.0, but this function is added in postgresql-9.2 shipped with RHEL7, and postgresql92 in RHEL6 which is provided in optional channel. About method to use packages in optional channel, please refer to the How to subscribe a RHEL system to the Tools, Optional, or Supplementary channels?.
Hot Standby:
This feature allows users to create a 'Standby' database, that is, a second database instance (normally on a separate
server) replaying the primary's binary log, while making that standby server available for read-only queries.
Streaming Replication:
This time, the goal is improving the archiving mechanism to make it as continuous as possible and to not rely on log file
shipping. Standby servers can now connect to the master/primary and get sent, whenever they want, what they are missing from the Write Ahead Log, not in terms of complete files ('wal segments'), but in terms of records in the WAL (you can think of them as fragments of these files).
About setup, please refer to the example in Diagnostic Steps.
根源
N/A
诊断步骤
Following is an example about setup.
Environment:
- Primary server: 192.168.122.10
- Standby server: 192.168.122.20
- iptables in both servers are in stop status.
-
Install postgresql92 or postgresql-9.2 by RHN, RHSM or local iso and init db in both servers. posgresql-9.2 is used in this example.
-
In primary server:
-
Start postgresql.
# su - postgres $ pg_ctl -D data start -
create a database and super user;
$ createdb testdb01 $ createuser -s -N testdbadmin01 -
Modify the following parameters in postgresql.conf.
wal_level = hot_standby max_wal_senders = 2 wal_keep_segments = 32 -
Add the following setup in pg_hba.conf so that standby serve can pull data from primary server with user testdbadmin01.
host replication testdbadmin01 192.168.122.0/24 trust -
Enter into backup mode.
$ psql -d testdb01 -U testdbAdmin01 testdb01=#select pg_start_backup('/'); -
Copy data/* to standby server
$ scp -r data/* 192.168.122.20:/var/lib/pgsql/data/ -
Stop backup
testdb01=#select pg_stop_backup(); -
Restart postgresql.
$ pg_ctl -D data restart
-
-
In standby server.
Make a test:
-
In primary server:
$ psql -d testdb01 -U testdbadmin01 testdb01=# CREATE TABLE testinfo (idnum serial, person varchar(20), age float4); testdb01=# insert into testinfo (person, age) values ('test1', 38); testdb01=# insert into testinfo (person, age) values ('test2', 30); -
In standby server:
$ psql -d testdb01 -U testdbadmin01 testdb01=# select * from testinfo where idnum=1; testdb01=# select * from testinfo where idnum=2;
Note: the standby server is read-only.
本文详细介绍了在Red Hat Enterprise Linux 6和7中使用PostgreSQL 9.2进行热备份和流复制的方法。通过设置,用户可以在主数据库运行的同时创建只读的备用数据库实例,实现数据的连续归档和高效复制。
1万+

被折叠的 条评论
为什么被折叠?



