您的位置:首页 > 其它

Skytools安装配置管理(六)

2014-07-04 16:13 363 查看
子节点接管root节点,如下:[postgres@londiste1 londiste3]$ londiste3 db2.ini takeover node12013-09-21 10:22:13,158 25616 INFO old: node12013-09-21 10:22:13,197 25616 INFO [node1] Consumer londiste_db1 tagged as paused2013-09-21 10:22:13,202 25616 INFO Waiting for worker to accept2013-09-21 10:22:22,224 25616 INFO Consumer 'londiste_db1' on node 'node1' paused2013-09-21 10:22:22,227 25616 INFO [node1] Step 1: Writing disabled for: replika2013-09-21 10:22:22,242 25616 INFO [node1] Step 2: Inserted last tick: replika2013-09-21 10:22:23,260 25616 INFO [node2] Consumer londiste_db2 tagged as paused2013-09-21 10:22:23,268 25616 INFO Waiting for worker to accept2013-09-21 10:22:24,273 25616 INFO Consumer 'londiste_db2' on node 'node2' paused2013-09-21 10:22:24,281 25616 INFO [node2] Branch node promoted to root2013-09-21 10:22:24,299 25616 INFO [node2] Subscriber registered: node12013-09-21 10:22:24,315 25616 INFO [node1] Subscriber unregistered: node22013-09-21 10:22:24,327 25616 INFO [node2] Consumer londiste_db2 tagged as resumed2013-09-21 10:22:24,334 25616 INFO Waiting for worker to accept2013-09-21 10:22:25,338 25616 INFO Consumer 'londiste_db2' on node 'node2' resumed2013-09-21 10:22:25,341 25616 INFO [node1] Step 3: Demoted root to branch: replika2013-09-21 10:22:25,351 25616 INFO [node1] Consumer londiste_db1 tagged as resumed2013-09-21 10:22:25,358 25616 INFO Waiting for worker to accept2013-09-21 10:22:26,363 25616 INFO Consumer 'londiste_db1' on node 'node1' resumed[postgres@londiste1 londiste3]$ londiste3 db1.ini statusQueue: 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的子节点}

3.2、walmgr3常用命令

【2.5节中包括的此处不再累赘说明】

3.2.1 MASTER COMMANDS

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 complete2013-12-23 21:44:32,320 22317 INFO Database state is not 'shut down', copying all2013-12-23 21:44:32,320 22317 INFO Syncing /opt/pg93/data/pg_xlog/0000000300000000000000312013-12-23 21:44:32,822 22317 INFO Syncing /opt/pg93/data/pg_xlog/0000000300000000000000322013-12-23 21:44:33,310 22317 INFO Syncing /opt/pg93/data/pg_xlog/0000000300000000000000332013-12-23 21:44:33,850 22317 INFO Syncing /opt/pg93/data/pg_xlog/0000000300000000000000342013-12-23 21:44:34,595 22317 INFO Syncing /opt/pg93/data/pg_xlog/0000000300000000000000352013-12-23 21:44:35,057 22317 INFO Partial copy done 3.启动定时同步命令(syncdaemon):【同步间隔时间为配置文件中loop_delay参数指定】[postgres@db1 pg93]$ walmgr3 wal-master.ini syncdaemon2013-12-23 21:54:12,574 22473 INFO 000000030000000000000033: last complete2013-12-23 21:54:12,581 22473 INFO Database state is not 'shut down', copying all2013-12-23 21:54:12,582 22473 INFO Syncing /opt/pg93/data/pg_xlog/0000000300000000000000342013-12-23 21:54:12,987 22473 INFO Syncing /opt/pg93/data/pg_xlog/0000000300000000000000352013-12-23 21:54:13,148 22473 INFO Syncing /opt/pg93/data/pg_xlog/0000000300000000000000362013-12-23 21:54:13,575 22473 INFO Syncing /opt/pg93/data/pg_xlog/0000000300000000000000372013-12-23 21:54:13,988 22473 INFO Partial copy done2013-12-23 21:54:23,990 22473 INFO 000000030000000000000033: last complete2013-12-23 21:54:23,994 22473 INFO Database state is not 'shut down', copying all2013-12-23 21:54:23,995 22473 INFO Syncing /opt/pg93/data/pg_xlog/0000000300000000000000342013-12-23 21:54:24,155 22473 INFO Syncing /opt/pg93/data/pg_xlog/0000000300000000000000352013-12-23 21:54:24,318 22473 INFO Syncing /opt/pg93/data/pg_xlog/0000000300000000000000362013-12-23 21:54:24,487 22473 INFO Syncing /opt/pg93/data/pg_xlog/0000000300000000000000372013-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 archiving2013-12-23 21:57:25,490 22524 INFO database must be restarted to disable archiving2013-12-23 21:57:25,490 22524 INFO Setting archive_command to /bin/true to avoid WAL pileup2013-12-23 21:57:25,493 22524 INFO Sending SIGHUP to postmaster2013-12-23 21:57:25,494 22524 INFO Done 5.自定义定期任务命令(periodic):[postgres@db1 pg93]$ walmgr3 wal-master.ini periodic该命令仅在配置文件中制定了定期执行命令(periodic_command)时有效。可以指定任何脚本,如同步、配置文件、系统定时任务crontab脚本等。

3.2.2 SLAVE COMMANDS

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 pause2013-12-23 22:14:47,210 4139 INFO Pausing recovery mode 3.继续wal重放命令(continue):[postgres@db2 pg93]$ walmgr3 wal-slave.ini continue2013-12-23 22:15:21,740 4149 INFO Continuing with recovery 4. 停止恢复模式命令(boot):【slave将变为可读写模式】[postgres@db2 pg93]$ walmgr3 wal-slave.ini boot2013-12-23 22:17:27,412 4164 INFO Stopping recovery mode 5.创建一个slave节点(createslave):【该命令使子节点的创建过程更加简单】[postgres@db2 pg93]$ walmgr3 wal-slave.ini createslave2013-12-23 22:21:20,216 4306 INFO Backup lock obtained.2013-12-23 22:21:20,221 4306 INFO Starting pg_receivexlog2013-12-23 22:21:20,224 4306 INFO Starting pg_basebackup2013-12-23 22:21:22,772 4306 INFO pg_basebackup finished successfully2013-12-23 22:21:22,773 4306 WARNING backup_datadir is disabled, deleting old data dir2013-12-23 22:21:22,826 4306 INFO Move /opt/pg93/slave_walmanager/backup/data.master to /opt/pg93/data2013-12-23 22:21:22,834 4306 INFO Write /opt/pg93/data/recovery.conf2013-12-23 22:21:22,835 4306 INFO Starting postmaster: /opt/pg93/bin/pg_ctl -D /opt/pg93/data startserver startingLOG: database system was interrupted; last known up at 2013-12-23 22:21:20 ESTLOG: creating missing WAL directory "pg_xlog/archive_status"LOG: entering standby mode2013-12-23 22:21:23,149 4358 INFO 00000003.history: Found2013-12-23 22:21:23,154 4358 INFO {count: 1}LOG: restored log file "00000003.history" from archive2013-12-23 22:21:23,237 4360 INFO 000000030000000000000036: Found2013-12-23 22:21:23,266 4360 INFO {count: 1}LOG: restored log file "000000030000000000000036" from archiveLOG: redo starts at 0/36000028LOG: consistent recovery state reached at 0/360000F0LOG: database system is ready to accept read only connections2013-12-23 22:21:23,462 4364 INFO 000000030000000000000037: not found (ignored)LOG: started streaming WAL from primary at 0/37000000 on timeline 32013-12-23 22:21:27,845 4306 INFO pg_receivelog stopped2013-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.htmlhttp://wiki.postgresql.org/wiki/Skytools#Documentation_3http://wiki.postgresql.org/wiki/Londiste_Tutorial

五、错误解决

5.1、ImportError

错误现象:[pg90@localhost conf]$ londiste3 part1.ini create-root part1_root dbname=part1Traceback (most recent call last): File "/opt/skytools/bin/londiste3", line 8, in <module> import pkgloaderImportError: 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

5.2、ProgrammingError

错误现象:ProgrammingError: schema "partconf" does not exist解决方法:在root节点上也创建partconf模式:part_root=# CREATE SCHEMA partconf;CREATE SCHEMApart_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 textpart_root(# );CREATE TABLE

5.3、hash_string

part_root=# CREATE FUNCTION partconf.get_hash_rawpart_root-# ( i_input integer)part_root-# RETURNS integerpart_root-# LANGUAGE sqlpart_root-# AS $$part_root$# -- used to wrap hashtext so that we can replace it in 8.4part_root$# -- with older implementation to keep compatibilitypart_root$# select hash_string($1::text, 'lookup2');part_root$# $$;ERROR: function hash_string(text, unknown) does not existLINE 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.

5.4、rst2html

错误现象:[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 foundmake: *** [hashlib.html] Error 127make: *** 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

5.5、undefined symbol: le64toh

错误现象:[postgres@localhost extension]$ psql test < hashlib--1.0.sqlERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64tohERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64tohERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64tohERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64tohERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64tohERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64tohERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64tohERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64tohERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64tohERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64tohERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64tohERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64tohERROR: could not load library "/opt/pgsql/lib/hashlib.so": /opt/pgsql/lib/hashlib.so: undefined symbol: le64toh 解决办法:换64位操作系统

5.6、找不到头文件

错误现象:编译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.cinsert_event.c:19:22: error: postgres.h: No such file or directoryinsert_event.c:20:21: error: funcapi.h: No such file or directoryinsert_event.c:22:29: error: catalog/pg_type.h: No such file or directoryinsert_event.c:23:30: error: commands/trigger.h: No such file or directoryinsert_event.c:24:26: error: executor/spi.h: No such file or directoryinsert_event.c:25:28: error: lib/stringinfo.h: No such file or directoryinsert_event.c:26:28: error: utils/builtins.h: No such file or directoryinsert_event.c:27:28: error: utils/datetime.h: No such file or directoryinsert_event.c:28:27: error: utils/hsearch.h: No such file or directoryinsert_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

本文出自 “O2P” 博客,请务必保留此出处http://lianshunke.blog.51cto.com/2510072/1434533
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: