我试图在一台机器上设置两个PostgreSQL服务器并执行流复制。我曾经成功过一次,但当我再次尝试遵循完全相同的步骤时,它就行不通了。以下是步骤:我有$PGDATA = home/postgresql/9.1/data和$STANDBY =home/postgresql/9.1/data 2
initdb -D $PGDATA
initdb -D $STANDBY
主节点中的
host replication repuser 127.0.0.1/0 md5
max_wal_senders = 1
archive_mode = on
archive_command = 'cp %p ~/postgresql/backup/archivedir/%f'
wal_level = archive
wal_keep_segments = 32
psql -d dellstore2 -c "SELECT pg_start_backup('backup for replication', true)"
rsync -av ${PGDATA}/ $STANDBY --exclude postmaster.pid
psql -d dellstore2 -c "select pg_stop_backup()"
pg_stop_backup说一切都很好,所有的WAL文件都被归档了
在备用()节点(data2)中创建recovery.conf:
standby_mode = 'on'
primary_conninfo = 'host=127.0.0.1 port=5432 user=repuser password=haslo'
trigger_file = '/home/michau/postgresql/replication.trigger'
restore_command = 'cp /home/michau/postgresql/backup/archivedir/%f "%p"'
LOG: database system was shut down in recovery at 2012-06-12 19:48:01 CEST
LOG: entering standby mode
cp: cannot stat /home/michau/postgresql/backup/archivedir/000000010000000000000007: No such file or directory
LOG: consistent recovery state reached at 0/7000070
LOG: record with zero length at 0/7000070
cp: cannot stat /home/michau/postgresql/backup/archivedir/000000010000000000000007: No such file or directory
LOG: streaming replication successfully connected to primary
LOG: redo starts at 0/7000070
它就挂在这里。运行ps -ef \将产生以下结果:
michau 2491 1898 0 19:46 pts/0 00:00:00 postgres -D /home/michau/postgresql/9.1/data
michau 2493 2491 0 19:46 ? 00:00:01 postgres: writer process
michau 2494 2491 0 19:46 ? 00:00:00 postgres: wal writer process
michau 2495 2491 0 19:46 ? 00:00:00 postgres: autovacuum launcher process
michau 2496 2491 0 19:46 ? 00:00:00 postgres: archiver process last was 000000010000000000000008
michau 2497 2491 0 19:46 ? 00:00:00 postgres: stats collector process
michau 2571 2214 0 19:49 pts/1 00:00:00 postgres -D /home/michau/postgresql/9.1/data2
michau 2572 2571 0 19:49 ? 00:00:01 postgres: startup process recovering 000000010000000000000009
michau 2575 2571 0 19:49 ? 00:00:01 postgres: writer process
michau 2578 2571 0 19:49 ? 00:00:02 postgres: wal receiver process streaming 0/99782DC
michau 2579 2491 0 19:49 ? 00:00:00 postgres: wal sender process repuser 127.0.0.1(42142) streaming 0/99782DC
michau 2586 2491 0 19:51 ? 00:00:00 postgres: michau postgres ::1(49941) idle
michau 2587 2491 0 19:51 ? 00:00:01 postgres: michau dellstore2 ::1(49942) idle
已经恢复了0000000010000009的人改变了一段时间,但是半个小时以后就不再是了。
我确信我一定是第一次做了什么,而不是写下来什么的,但是我完全不知道它是什么。我很感谢你的帮助。
发布于 2012-10-29 08:14:30
我通过了你上面发布的步骤,我得到了准确的错误,正如你发布的,但我能够解决这个问题。
我试图将您的步骤与此站点http://www.debian-administration.org/article/How_to_setup_Postgresql_9.1_Streaming_Replication_Debian_Squeeze中发布的步骤合并
除了您发布的步骤之外,我还从我提供的站点中添加了另外两个步骤。这两个步骤如下:
发布于 2012-09-08 06:26:02
您的待机正在持续恢复,这正是流复制在PostgreSQL中的工作方式。您是否能够登录到待机状态并运行查询?如果是这样的话,恭喜,这是可行的。如果没有,请张贴发生的事情。
https://stackoverflow.com/questions/11002767
复制相似问题