子节点接管root节点,如下:
[postgres@londiste1 londiste3]$ londiste3 db2.ini takeover node1
2013-09-21 10:22:13,158 25616 INFO old: node1
ottom:10px;line-height:23px;font-family:'微软雅黑',197 25616 INFO [node1] Consumer londiste_db1 tagged as paused
ottom:10px;line-height:23px;font-family:'微软雅黑',202 25616 INFO Waiting for worker to accept
2013-09-21 10:22:22,224 25616 INFO Consumer 'londiste_db1' on node 'node1' paused
ottom:10px;line-height:23px;font-family:'微软雅黑',227 25616 INFO [node1] Step 1: Writing disabled for: replika
ottom:10px;line-height:23px;font-family:'微软雅黑',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
ottom:10px;line-height:23px;font-family:'微软雅黑',268 25616 INFO Waiting for worker to accept
2013-09-21 10:22:24,273 25616 INFO Consumer 'londiste_db2' on node 'node2' paused
ottom:10px;line-height:23px;font-family:'微软雅黑',281 25616 INFO [node2] Branch node promoted to root
ottom:10px;line-height:23px;font-family:'微软雅黑',299 25616 INFO [node2] Subscriber registered: node1
ottom:10px;line-height:23px;font-family:'微软雅黑',315 25616 INFO [node1] Subscriber unregistered: node2
ottom:10px;line-height:23px;font-family:'微软雅黑',327 25616 INFO [node2] Consumer londiste_db2 tagged as resumed
ottom:10px;line-height:23px;font-family:'微软雅黑',334 25616 INFO Waiting for worker to accept
2013-09-21 10:22:25,338 25616 INFO Consumer 'londiste_db2' on node 'node2' resumed
ottom:10px;line-height:23px;font-family:'微软雅黑',341 25616 INFO [node1] Step 3: Demoted root to branch: replika
ottom:10px;line-height:23px;font-family:'微软雅黑',351 25616 INFO [node1] Consumer londiste_db1 tagged as resumed
ottom:10px;line-height:23px;font-family:'微软雅黑',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)
+--:node1 (branch)
+--:node3 (branch)
+--:node5 (branch)
Tables:1/0/0
Lag:8s,Simsun;font-size:14px;vertical-align:baseline;">{此时,接管节点成为root节点,远root节点变为node2的子节点,且原来与node2同级的节点也变为node2的子节点}
3.2、walmgr3常用命令
@H_404_92@【2.5节中包括的此处不再累赘说明】3.2.1 MASTER COMMANDS
@H_404_92@1.列举当前备份命令(listbackups):[postgres@db1 pg93]$ walmgr3 wal-master.ini listbackups
@H_404_92@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
ottom:10px;line-height:23px;font-family:'微软雅黑',320 22317 INFO Database state is not 'shut down',copying all
ottom:10px;line-height:23px;font-family:'微软雅黑',320 22317 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000031
ottom:10px;line-height:23px;font-family:'微软雅黑',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
ottom:10px;line-height:23px;font-family:'微软雅黑',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
@H_404_92@3.启动定时同步命令(syncdaemon): @H_404_92@【同步间隔时间为配置文件中loop_delay参数指定】[postgres@db1 pg93]$ walmgr3 wal-master.ini syncdaemon
2013-12-23 21:54:12,574 22473 INFO 000000030000000000000033: last complete
ottom:10px;line-height:23px;font-family:'微软雅黑',581 22473 INFO Database state is not 'shut down',582 22473 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000034
ottom:10px;line-height:23px;font-family:'微软雅黑',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
ottom:10px;line-height:23px;font-family:'微软雅黑',575 22473 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000037
ottom:10px;line-height:23px;font-family:'微软雅黑',988 22473 INFO Partial copy done
2013-12-23 21:54:23,990 22473 INFO 000000030000000000000033: last complete
ottom:10px;line-height:23px;font-family:'微软雅黑',994 22473 INFO Database state is not 'shut down',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
ottom:10px;line-height:23px;font-family:'微软雅黑',318 22473 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000036
ottom:10px;line-height:23px;font-family:'微软雅黑',487 22473 INFO Syncing /opt/pg93/data/pg_xlog/000000030000000000000037
ottom:10px;line-height:23px;font-family:'微软雅黑',658 22473 INFO Partial copy done
@H_404_92@4.取消archive配置命令(stop): @H_404_92@【执行后archive_command参数配置将取消】[postgres@db1 pg93]$ walmgr3 wal-master.ini stop
2013-12-23 21:57:25,488 22524 INFO disabling WAL archiving
ottom:10px;line-height:23px;font-family:'微软雅黑',490 22524 INFO database must be restarted to disable archiving
ottom:10px;line-height:23px;font-family:'微软雅黑',490 22524 INFO Setting archive_command to /bin/true to avoid WAL pileup
ottom:10px;line-height:23px;font-family:'微软雅黑',493 22524 INFO Sending SIGHUP to postmaster
ottom:10px;line-height:23px;font-family:'微软雅黑',494 22524 INFO Done
@H_404_92@5.自定义定期任务命令(periodic):[postgres@db1 pg93]$ walmgr3 wal-master.ini periodic
@H_404_92@该命令仅在配置文件中制定了定期执行命令(periodic_command)时有效。可以指定任何脚本,如同步、配置文件、系统定时任务crontab脚本等。3.2.2 SLAVE COMMANDS
[postgres@db2pg93]$ 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
@H_404_92@2.暂停wal重放命令(pause):[postgres@db2pg93]$ walmgr3 wal-slave.ini pause
2013-12-23 22:14:47,210 4139 INFO Pausing recovery mode
@H_404_92@3.继续wal重放命令(continue):[postgres@db2pg93]$ walmgr3 wal-slave.ini continue
2013-12-23 22:15:21,740 4149 INFO Continuing with recovery
@H_404_92@4. 停止恢复模式命令(boot): @H_404_92@【slave将变为可读写模式】[postgres@db2pg93]$ walmgr3 wal-slave.ini boot
2013-12-23 22:17:27,412 4164 INFO Stopping recovery mode
@H_404_92@5.创建一个slave节点(createslave):【该命令使子节点的创建过程更加简单】
[postgres@db2pg93]$ walmgr3 wal-slave.ini createslave
2013-12-23 22:21:20,2164306 INFO Backup lock obtained.
ottom:10px;line-height:23px;font-family:'微软雅黑',221 4306 INFO Starting pg_receivexlog
ottom:10px;line-height:23px;font-family:'微软雅黑',224 4306 INFO Starting pg_basebackup
2013-12-23 22:21:22,772 4306 INFO pg_basebackup finished successfully
ottom:10px;line-height:23px;font-family:'微软雅黑',773 4306 WARNING backup_datadir is disabled,deleting old data dir
ottom:10px;line-height:23px;font-family:'微软雅黑',826 4306 INFO Move /opt/pg93/slave_walmanager/backup/data.master to /opt/pg93/data
ottom:10px;line-height:23px;font-family:'微软雅黑',834 4306 INFO Write /opt/pg93/data/recovery.conf
ottom:10px;line-height:23px;font-family:'微软雅黑',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
ottom:10px;line-height:23px;font-family:'微软雅黑',154 4358 INFO {count: 1}
LOG: restored log file "00000003.history" from archive
ottom:10px;line-height:23px;font-family:'微软雅黑',237 4360 INFO 000000030000000000000036: Found
ottom:10px;line-height:23px;font-family:'微软雅黑',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
ottom:10px;line-height:23px;font-family:'微软雅黑',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
ottom:10px;line-height:23px;font-family:'微软雅黑',846 4306 INFO Backup lock released.
@H_404_92@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
五、错误解决
5.1、ImportError
错误现象:
[pg90@localhostconf]$ londiste3 part1.ini create-root part1_root dbname=part1
Traceback (most recent call last):
File"/opt/skytools/bin/londiste3",line 8,in <module>
importpkgloader
ImportError: No module named pkgloader
解决办法:
[root@localhostskytools-3.1.5]# python setup_pkgloader.py build
[root@localhostskytools-3.1.5]# python setup_pkgloader.py install
[root@localhostskytools-3.1.5]# python setup_skytools.py build
[root@localhostskytools-3.1.5]# python setup_skytools.py install
5.2、ProgrammingError
ProgrammingError: schema "partconf" does not exist
解决方法:
@H_404_92@在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,Simsun;vertical-align:baseline;">part_root(# db_code bigint,Simsun;vertical-align:baseline;">part_root(# is_primary boolean,Simsun;vertical-align:baseline;">part_root(# max_slot integer,Simsun;vertical-align:baseline;">part_root(# cluster_name text
part_root(# );
CREATE TABLE
5.3、hash_string
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,Simsun;vertical-align:baseline;"> ^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
5.4、rst2html
[postgres@localhostpghashlib-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'
@H_404_92@下载docutils并安装https://pypi.python.org/pypi/docutils[root@localhostdocutils-0.11]# python setup.py install
[root@localhost~]# ln -s /opt/python25/bin/rst2html.py /usr/bin/rst2html
5.5、undefined symbol: le64toh
[postgres@localhostextension]$ psql test < hashlib--1.0.sql
ERROR: Could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh
@H_404_92@换64位操作系统5.6、找不到头文件 @H_404_92@编译skytools报错,找不到相应头文件
[root@localhostskytools-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
错误原因:
@H_404[email protected]中头文件路径发生了变化(/opt/pg93/include/postgresql/server),但skytools还是按照之前版本的路径查找(/opt/pg93/include/server) @H_404_92@将server拷贝至include下 @H_404[email protected]、Python.h./psycopg/psycopg.h:30:20: error: Python.h: No such file or directory
@H_404_92@缺少Python.h头文件[root@db1 psycopg2-2.5.1]# find / -name Python.h
[root@db1 psycopg2-2.5.1]# yum install python-devel
/usr/include/python2.6/Python.h
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。