子节点接管root节点,如下:
[postgres@londiste1 londiste3]$ londiste3 db2.ini takeover node1
2013-09-21 10:22:13,158 25616 INFO old: node1
2013-09-21 10:22:13,197 25616 INFO [node1] Consumer londiste_db1 tagged as paused
2013-09-21 10:22:13,202 25616 INFO Waiting for worker to accept
2013-09-21 10:22:22,224 25616 INFO Consumer 'londiste_db1' on node 'node1' paused
2013-09-21 10:22:22,227 25616 INFO [node1] Step 1: Writing disabled for: replika
2013-09-21 10:22:22,242 25616 INFO [node1] Step 2: Inserted last tick: replika
2013-09-21 10:22:23,260 25616 INFO [node2] Consumer londiste_db2 tagged as paused
2013-09-21 10:22:23,268 25616 INFO Waiting for worker to accept
2013-09-21 10:22:24,273 25616 INFO Consumer 'londiste_db2' on node 'node2' paused
2013-09-21 10:22:24,281 25616 INFO [node2] Branch node promoted to root
2013-09-21 10:22:24,299 25616 INFO [node2] Subscriber registered: node1
2013-09-21 10:22:24,315 25616 INFO [node1] Subscriber unregistered: node2
2013-09-21 10:22:24,327 25616 INFO [node2] Consumer londiste_db2 tagged as resumed
2013-09-21 10:22:24,334 25616 INFO Waiting for worker to accept
2013-09-21 10:22:25,338 25616 INFO Consumer 'londiste_db2' on node 'node2' resumed
2013-09-21 10:22:25,341 25616 INFO [node1] Step 3: Demoted root to branch: replika
2013-09-21 10:22:25,351 25616 INFO [node1] Consumer londiste_db1 tagged as resumed
2013-09-21 10:22:25,358 25616 INFO Waiting for worker to accept
2013-09-21 10:22:26,363 25616 INFO Consumer 'londiste_db1' on node 'node1' resumed
[postgres@londiste1 londiste3]$ londiste3 db1.ini status
Queue: replika Local node: node1
node2 (root)
| Tables: 1/0/0
| Lag: 8s, Tick: 463
+--: node4 (branch)
| Tables: 1/0/0
| Lag: 8s, Tick: 463
+--: node1 (branch)
| Tables: 1/0/0
| Lag: 8s, Tick: 463
+--: node3 (branch)
| Tables: 1/0/0
| Lag: 8s, Tick: 463
+--: node5 (branch)
Tables: 1/0/0
Lag: 8s, Tick: 463
{此时,接管节点成为root节点,远root节点变为node2的子节点,且原来与node2同级的节点也变为node2的子节点}
【2.5节中包括的此处不再累赘说明】
1.列举当前备份命令(listbackups):
[postgres@db1 pg93]$ walmgr3 wal-master.ini listbackups
2.对wal进行一次手动同步命令(sync):
[postgres@db1 pg93]$ walmgr3 wal-master.ini sync
2013-12-23 21:44:32,280 22317 INFO 000000030000000000000030.00000028.backup: last complete
2013-12-23 21:44:32,320 22317 INFO Database state is not 'shut down', copying all
2013-12-23 21:44:32,320 22317 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000031
2013-12-23 21:44:32,822 22317 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000032
2013-12-23 21:44:33,310 22317 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000033
2013-12-23 21:44:33,850 22317 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000034
2013-12-23 21:44:34,595 22317 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000035
2013-12-23 21:44:35,057 22317 INFO Partial copy done
3.启动定时同步命令(syncdaemon):
【同步间隔时间为配置文件中loop_delay参数指定】
[postgres@db1 pg93]$ walmgr3 wal-master.ini syncdaemon
2013-12-23 21:54:12,574 22473 INFO 000000030000000000000033: last complete
2013-12-23 21:54:12,581 22473 INFO Database state is not 'shut down', copying all
2013-12-23 21:54:12,582 22473 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000034
2013-12-23 21:54:12,987 22473 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000035
2013-12-23 21:54:13,148 22473 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000036
2013-12-23 21:54:13,575 22473 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000037
2013-12-23 21:54:13,988 22473 INFO Partial copy done
2013-12-23 21:54:23,990 22473 INFO 000000030000000000000033: last complete
2013-12-23 21:54:23,994 22473 INFO Database state is not 'shut down', copying all
2013-12-23 21:54:23,995 22473 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000034
2013-12-23 21:54:24,155 22473 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000035
2013-12-23 21:54:24,318 22473 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000036
2013-12-23 21:54:24,487 22473 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000037
2013-12-23 21:54:24,658 22473 INFO Partial copy done
4.取消archive配置命令(stop):
【执行后archive_command参数配置将取消】
[postgres@db1 pg93]$ walmgr3 wal-master.ini stop
2013-12-23 21:57:25,488 22524 INFO Disabling WAL archiving
2013-12-23 21:57:25,490 22524 INFO database must be restarted to disable archiving
2013-12-23 21:57:25,490 22524 INFO Setting archive_command to /bin/true to avoid WAL pileup
2013-12-23 21:57:25,493 22524 INFO Sending SIGHUP to postmaster
2013-12-23 21:57:25,494 22524 INFO Done
5.自定义定期任务命令(periodic):
[postgres@db1 pg93]$ walmgr3 wal-master.ini periodic
该命令仅在配置文件中制定了定期执行命令(periodic_command)时有效。可以指定任何脚本,如同步、配置文件、系统定时任务crontab脚本等。
1.列举当前备份命令(listbackups):
[postgres@db2 pg93]$ walmgr3 wal-slave.ini listbackups
List of backups:
Backup set Timestamp Label First WAL
--------------- ------------------------ ----------- ------------------------
data.master 2013-12-23 21:45:30 EST FullBackup 000000030000000000000032
2.暂停wal重放命令(pause):
[postgres@db2 pg93]$ walmgr3 wal-slave.ini pause
2013-12-23 22:14:47,210 4139 INFO Pausing recovery mode
3.继续wal重放命令(continue):
[postgres@db2 pg93]$ walmgr3 wal-slave.ini continue
2013-12-23 22:15:21,740 4149 INFO Continuing with recovery
4. 停止恢复模式命令(boot):
【slave将变为可读写模式】
[postgres@db2 pg93]$ walmgr3 wal-slave.ini boot
2013-12-23 22:17:27,412 4164 INFO Stopping recovery mode
5.创建一个slave节点(createslave):
【该命令使子节点的创建过程更加简单】
[postgres@db2 pg93]$ walmgr3 wal-slave.ini createslave
2013-12-23 22:21:20,216 4306 INFO Backup lock obtained.
2013-12-23 22:21:20,221 4306 INFO Starting pg_receivexlog
2013-12-23 22:21:20,224 4306 INFO Starting pg_basebackup
2013-12-23 22:21:22,772 4306 INFO pg_basebackup finished successfully
2013-12-23 22:21:22,773 4306 WARNING backup_datadir is disabled, deleting old data dir
2013-12-23 22:21:22,826 4306 INFO Move /opt/pg93/slave_walmanager/backup/data.master to /opt/pg93/data
2013-12-23 22:21:22,834 4306 INFO Write /opt/pg93/data/recovery.conf
2013-12-23 22:21:22,835 4306 INFO Starting postmaster: /opt/pg93/bin/pg_ctl -D /opt/pg93/data start
server starting
LOG: database system was interrupted; last known up at 2013-12-23 22:21:20 EST
LOG: creating missing WAL directory "pg_xlog/archive_status"
LOG: entering standby mode
2013-12-23 22:21:23,149 4358 INFO 00000003.history: Found
2013-12-23 22:21:23,154 4358 INFO {count: 1}
LOG: restored log file "00000003.history" from archive
2013-12-23 22:21:23,237 4360 INFO 000000030000000000000036: Found
2013-12-23 22:21:23,266 4360 INFO {count: 1}
LOG: restored log file "000000030000000000000036" from archive
LOG: redo starts at 0/36000028
LOG: consistent recovery state reached at 0/360000F0
LOG: database system is ready to accept read only connections
2013-12-23 22:21:23,462 4364 INFO 000000030000000000000037: not found (ignored)
LOG: started streaming WAL from primary at 0/37000000 on timeline 3
2013-12-23 22:21:27,845 4306 INFO pg_receivelog stopped
2013-12-23 22:21:27,846 4306 INFO Backup lock released.
2013-12-23 22:21:27,846 4306 INFO Streaming replication standby created successfully
http://pgfoundry.org/projects/skytools/
http://skytools.projects.pgfoundry.org/skytools-3.0/
http://skytools.projects.pgfoundry.org/skytools-3.0/doc/skytools3.html
http://wiki.postgresql.org/wiki/Skytools#Documentation_3
http://wiki.postgresql.org/wiki/Londiste_Tutorial
错误现象:
[pg90@localhost conf]$ londiste3 part1.ini create-root part1_root dbname=part1
Traceback (most recent call last):
File "/opt/skytools/bin/londiste3", line 8, in <module>
import pkgloader
ImportError: No module named pkgloader
解决办法:
[root@localhost skytools-3.1.5]# python setup_pkgloader.py build
[root@localhost skytools-3.1.5]# python setup_pkgloader.py install
[root@localhost skytools-3.1.5]# python setup_skytools.py build
[root@localhost skytools-3.1.5]# python setup_skytools.py install
错误现象:
ProgrammingError: schema "partconf" does not exist
解决方法:
在root节点上也创建partconf模式:
part_root=# CREATE SCHEMA partconf;
CREATE SCHEMA
part_root=# CREATE TABLE partconf.conf (
part_root(# part_nr integer,
part_root(# max_part integer,
part_root(# db_code bigint,
part_root(# is_primary boolean,
part_root(# max_slot integer,
part_root(# cluster_name text
part_root(# );
CREATE TABLE
part_root=# CREATE FUNCTION partconf.get_hash_raw
part_root-# ( i_input integer)
part_root-# RETURNS integer
part_root-# LANGUAGE sql
part_root-# AS $$
part_root$# -- used to wrap hashtext so that we can replace it in 8.4
part_root$# -- with older implementation to keep compatibility
part_root$# select hash_string($1::text, 'lookup2');
part_root$# $$;
ERROR: function hash_string(text, unknown) does not exist
LINE 8: select hash_string($1::text, 'lookup2');
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
错误现象:
[postgres@localhost pghashlib-master]$ make install
/bin/mkdir -p '/opt/pgsql/lib'
/bin/mkdir -p '/opt/pgsql/share/contrib'
/bin/mkdir -p '/opt/pgsql/share/doc/contrib'
/bin/sh /opt/pgsql/lib/pgxs/src/makefiles/../../config/install-sh -c -m 755 hashlib.so '/opt/pgsql/lib/hashlib.so'
rst2html README.rst > hashlib.html
/bin/sh: rst2html: command not found
make: *** [hashlib.html] Error 127
make: *** Deleting file `hashlib.html'
解决办法:
下载docutils并安装https://pypi.python.org/pypi/docutils
[root@localhost docutils-0.11]# python setup.py install
[root@localhost ~]# ln -s /opt/python25/bin/rst2html.py /usr/bin/rst2html
错误现象:
[postgres@localhost extension]$ psql test < hashlib--1.0.sql
ERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
ERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
ERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
ERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
ERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
ERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
ERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
ERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
ERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
ERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
ERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
ERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
ERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
解决办法:
换64位操作系统
错误现象:
编译skytools报错,找不到相应头文件
[root@localhost skytools-3.1.5]# make
……
make[3]: Entering directory `/root/skytools-3.1.5/sql/pgq/lowlevel'
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fpic -DHAVE_CONFIG_H -I. -I. -I/opt/pg93/include/server -I/opt/pg93/include/internal -D_GNU_SOURCE -c -o insert_event.o insert_event.c
insert_event.c:19:22: error: postgres.h: No such file or directory
insert_event.c:20:21: error: funcapi.h: No such file or directory
insert_event.c:22:29: error: catalog/pg_type.h: No such file or directory
insert_event.c:23:30: error: commands/trigger.h: No such file or directory
insert_event.c:24:26: error: executor/spi.h: No such file or directory
insert_event.c:25:28: error: lib/stringinfo.h: No such file or directory
insert_event.c:26:28: error: utils/builtins.h: No such file or directory
insert_event.c:27:28: error: utils/datetime.h: No such file or directory
insert_event.c:28:27: error: utils/hsearch.h: No such file or directory
insert_event.c:29:25: error: access/xact.h: No such file or directory
……
错误原因:
9.3中头文件路径发生了变化(/opt/pg93/include/postgresql/server),但skytools还是按照之前版本的路径查找(/opt/pg93/include/server)
解决方法:
将server拷贝至include下
5.7、Python.h
错误现象:
./psycopg/psycopg.h:30:20: error: Python.h: No such file or directory
……
错误原因:
缺少Python.h头文件
[root@db1 psycopg2-2.5.1]# find / -name Python.h
解决办法:
[root@db1 psycopg2-2.5.1]# yum install python-devel
[root@db1 psycopg2-2.5.1]# find / -name Python.h
/usr/include/python2.6/Python.h