prestogres 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +20 -0
- data/LICENSE +202 -0
- data/NOTICE +22 -0
- data/README.md +217 -0
- data/Rakefile +13 -0
- data/VERSION +1 -0
- data/bin/prestogres +254 -0
- data/config/pcp.conf.sample +28 -0
- data/config/pgpool.conf +678 -0
- data/config/pool_hba.conf +84 -0
- data/config/pool_passwd +0 -0
- data/config/postgresql.conf +2 -0
- data/ext/.gitignore +6 -0
- data/ext/depend +26 -0
- data/ext/extconf.rb +4 -0
- data/ext/prestogres_config.c +12 -0
- data/pgpool2/.gitignore +36 -0
- data/pgpool2/AUTHORS +4 -0
- data/pgpool2/COPYING +12 -0
- data/pgpool2/ChangeLog +1 -0
- data/pgpool2/INSTALL +1 -0
- data/pgpool2/Makefile.am +159 -0
- data/pgpool2/Makefile.in +1187 -0
- data/pgpool2/NEWS +4960 -0
- data/pgpool2/README +1 -0
- data/pgpool2/README.euc_jp +1 -0
- data/pgpool2/README.online-recovery +62 -0
- data/pgpool2/TODO +103 -0
- data/pgpool2/ac_func_accept_argtypes.m4 +85 -0
- data/pgpool2/aclocal.m4 +1088 -0
- data/pgpool2/c-compiler.m4 +134 -0
- data/pgpool2/c-library.m4 +325 -0
- data/pgpool2/child.c +2097 -0
- data/pgpool2/config.guess +1532 -0
- data/pgpool2/config.h.in +332 -0
- data/pgpool2/config.sub +1640 -0
- data/pgpool2/configure +15752 -0
- data/pgpool2/configure.in +392 -0
- data/pgpool2/depcomp +522 -0
- data/pgpool2/doc/basebackup.sh +17 -0
- data/pgpool2/doc/pgpool-de.html +4220 -0
- data/pgpool2/doc/pgpool-en.html +5738 -0
- data/pgpool2/doc/pgpool-fr.html +4118 -0
- data/pgpool2/doc/pgpool-ja.css +198 -0
- data/pgpool2/doc/pgpool-ja.html +11279 -0
- data/pgpool2/doc/pgpool-zh_cn.html +4445 -0
- data/pgpool2/doc/pgpool.css +280 -0
- data/pgpool2/doc/pgpool_remote_start +13 -0
- data/pgpool2/doc/recovery.conf.sample +117 -0
- data/pgpool2/doc/tutorial-en.html +707 -0
- data/pgpool2/doc/tutorial-ja.html +422 -0
- data/pgpool2/doc/tutorial-memqcache-en.html +325 -0
- data/pgpool2/doc/tutorial-memqcache-ja.html +370 -0
- data/pgpool2/doc/tutorial-memqcache-zh_cn.html +322 -0
- data/pgpool2/doc/tutorial-watchdog-en.html +306 -0
- data/pgpool2/doc/tutorial-watchdog-ja.html +343 -0
- data/pgpool2/doc/tutorial-watchdog-zh_cn.html +301 -0
- data/pgpool2/doc/tutorial-zh_cn.html +537 -0
- data/pgpool2/doc/watchdog.png +0 -0
- data/pgpool2/doc/wd-en.html +236 -0
- data/pgpool2/doc/wd-en.jpg +0 -0
- data/pgpool2/doc/wd-ja.html +219 -0
- data/pgpool2/doc/wd-ja.jpg +0 -0
- data/pgpool2/doc/wd-zh_cn.html +201 -0
- data/pgpool2/doc/where_to_send_queries.odg +0 -0
- data/pgpool2/doc/where_to_send_queries.pdf +0 -0
- data/pgpool2/general.m4 +166 -0
- data/pgpool2/getopt_long.c +200 -0
- data/pgpool2/getopt_long.h +44 -0
- data/pgpool2/install-sh +251 -0
- data/pgpool2/ltmain.sh +8406 -0
- data/pgpool2/m4/libtool.m4 +7360 -0
- data/pgpool2/m4/ltoptions.m4 +368 -0
- data/pgpool2/m4/ltsugar.m4 +123 -0
- data/pgpool2/m4/ltversion.m4 +23 -0
- data/pgpool2/m4/lt~obsolete.m4 +92 -0
- data/pgpool2/main.c +2971 -0
- data/pgpool2/md5.c +444 -0
- data/pgpool2/md5.h +28 -0
- data/pgpool2/missing +360 -0
- data/pgpool2/mkinstalldirs +40 -0
- data/pgpool2/parser/Makefile.am +50 -0
- data/pgpool2/parser/Makefile.in +559 -0
- data/pgpool2/parser/copyfuncs.c +3310 -0
- data/pgpool2/parser/gram.c +39100 -0
- data/pgpool2/parser/gram.h +940 -0
- data/pgpool2/parser/gram.y +13408 -0
- data/pgpool2/parser/gramparse.h +74 -0
- data/pgpool2/parser/keywords.c +32 -0
- data/pgpool2/parser/keywords.h +39 -0
- data/pgpool2/parser/kwlist.h +425 -0
- data/pgpool2/parser/kwlookup.c +88 -0
- data/pgpool2/parser/list.c +1156 -0
- data/pgpool2/parser/makefuncs.c +518 -0
- data/pgpool2/parser/makefuncs.h +83 -0
- data/pgpool2/parser/memnodes.h +79 -0
- data/pgpool2/parser/nodes.c +29 -0
- data/pgpool2/parser/nodes.h +609 -0
- data/pgpool2/parser/outfuncs.c +5790 -0
- data/pgpool2/parser/parsenodes.h +2615 -0
- data/pgpool2/parser/parser.c +262 -0
- data/pgpool2/parser/parser.h +46 -0
- data/pgpool2/parser/pg_class.h +158 -0
- data/pgpool2/parser/pg_config_manual.h +273 -0
- data/pgpool2/parser/pg_list.h +352 -0
- data/pgpool2/parser/pg_trigger.h +147 -0
- data/pgpool2/parser/pg_wchar.h +492 -0
- data/pgpool2/parser/pool_memory.c +342 -0
- data/pgpool2/parser/pool_memory.h +77 -0
- data/pgpool2/parser/pool_parser.h +222 -0
- data/pgpool2/parser/pool_string.c +121 -0
- data/pgpool2/parser/pool_string.h +37 -0
- data/pgpool2/parser/primnodes.h +1280 -0
- data/pgpool2/parser/scan.c +4094 -0
- data/pgpool2/parser/scan.l +1451 -0
- data/pgpool2/parser/scanner.h +120 -0
- data/pgpool2/parser/scansup.c +221 -0
- data/pgpool2/parser/scansup.h +28 -0
- data/pgpool2/parser/snprintf.c +1102 -0
- data/pgpool2/parser/stringinfo.c +294 -0
- data/pgpool2/parser/stringinfo.h +178 -0
- data/pgpool2/parser/value.c +78 -0
- data/pgpool2/parser/value.h +62 -0
- data/pgpool2/parser/wchar.c +2048 -0
- data/pgpool2/pcp.conf.sample +28 -0
- data/pgpool2/pcp/Makefile.am +40 -0
- data/pgpool2/pcp/Makefile.in +771 -0
- data/pgpool2/pcp/libpcp_ext.h +250 -0
- data/pgpool2/pcp/md5.c +444 -0
- data/pgpool2/pcp/md5.h +28 -0
- data/pgpool2/pcp/pcp.c +1652 -0
- data/pgpool2/pcp/pcp.h +61 -0
- data/pgpool2/pcp/pcp_attach_node.c +172 -0
- data/pgpool2/pcp/pcp_detach_node.c +185 -0
- data/pgpool2/pcp/pcp_error.c +87 -0
- data/pgpool2/pcp/pcp_node_count.c +160 -0
- data/pgpool2/pcp/pcp_node_info.c +198 -0
- data/pgpool2/pcp/pcp_pool_status.c +166 -0
- data/pgpool2/pcp/pcp_proc_count.c +166 -0
- data/pgpool2/pcp/pcp_proc_info.c +261 -0
- data/pgpool2/pcp/pcp_promote_node.c +185 -0
- data/pgpool2/pcp/pcp_recovery_node.c +172 -0
- data/pgpool2/pcp/pcp_stop_pgpool.c +179 -0
- data/pgpool2/pcp/pcp_stream.c +385 -0
- data/pgpool2/pcp/pcp_stream.h +52 -0
- data/pgpool2/pcp/pcp_systemdb_info.c +194 -0
- data/pgpool2/pcp/pcp_watchdog_info.c +211 -0
- data/pgpool2/pcp_child.c +1493 -0
- data/pgpool2/pg_md5.c +305 -0
- data/pgpool2/pgpool.8.in +121 -0
- data/pgpool2/pgpool.conf +553 -0
- data/pgpool2/pgpool.conf.sample +666 -0
- data/pgpool2/pgpool.conf.sample-master-slave +665 -0
- data/pgpool2/pgpool.conf.sample-replication +664 -0
- data/pgpool2/pgpool.conf.sample-stream +664 -0
- data/pgpool2/pgpool.spec +264 -0
- data/pgpool2/pgpool_adm/TODO +7 -0
- data/pgpool2/pgpool_adm/pgpool_adm--1.0.sql +85 -0
- data/pgpool2/pgpool_adm/pgpool_adm.c +558 -0
- data/pgpool2/pgpool_adm/pgpool_adm.control +5 -0
- data/pgpool2/pgpool_adm/pgpool_adm.h +46 -0
- data/pgpool2/pgpool_adm/pgpool_adm.sql.in +85 -0
- data/pgpool2/pool.h +655 -0
- data/pgpool2/pool_auth.c +1390 -0
- data/pgpool2/pool_config.c +5007 -0
- data/pgpool2/pool_config.h +284 -0
- data/pgpool2/pool_config.l +3281 -0
- data/pgpool2/pool_config_md5.c +29 -0
- data/pgpool2/pool_connection_pool.c +812 -0
- data/pgpool2/pool_error.c +242 -0
- data/pgpool2/pool_globals.c +27 -0
- data/pgpool2/pool_hba.c +1723 -0
- data/pgpool2/pool_hba.conf.sample +67 -0
- data/pgpool2/pool_ip.c +567 -0
- data/pgpool2/pool_ip.h +65 -0
- data/pgpool2/pool_ipc.h +38 -0
- data/pgpool2/pool_lobj.c +242 -0
- data/pgpool2/pool_lobj.h +32 -0
- data/pgpool2/pool_memqcache.c +3818 -0
- data/pgpool2/pool_memqcache.h +268 -0
- data/pgpool2/pool_params.c +163 -0
- data/pgpool2/pool_passwd.c +249 -0
- data/pgpool2/pool_passwd.h +41 -0
- data/pgpool2/pool_path.c +193 -0
- data/pgpool2/pool_path.h +81 -0
- data/pgpool2/pool_process_context.c +247 -0
- data/pgpool2/pool_process_context.h +62 -0
- data/pgpool2/pool_process_query.c +5001 -0
- data/pgpool2/pool_process_reporting.c +1671 -0
- data/pgpool2/pool_process_reporting.h +44 -0
- data/pgpool2/pool_proto2.c +671 -0
- data/pgpool2/pool_proto_modules.c +3524 -0
- data/pgpool2/pool_proto_modules.h +185 -0
- data/pgpool2/pool_query_cache.c +1020 -0
- data/pgpool2/pool_query_context.c +1871 -0
- data/pgpool2/pool_query_context.h +105 -0
- data/pgpool2/pool_relcache.c +284 -0
- data/pgpool2/pool_relcache.h +78 -0
- data/pgpool2/pool_rewrite_outfuncs.c +9060 -0
- data/pgpool2/pool_rewrite_query.c +715 -0
- data/pgpool2/pool_rewrite_query.h +192 -0
- data/pgpool2/pool_select_walker.c +1150 -0
- data/pgpool2/pool_select_walker.h +68 -0
- data/pgpool2/pool_sema.c +161 -0
- data/pgpool2/pool_session_context.c +952 -0
- data/pgpool2/pool_session_context.h +203 -0
- data/pgpool2/pool_shmem.c +185 -0
- data/pgpool2/pool_signal.c +158 -0
- data/pgpool2/pool_signal.h +61 -0
- data/pgpool2/pool_ssl.c +339 -0
- data/pgpool2/pool_stream.c +962 -0
- data/pgpool2/pool_stream.h +61 -0
- data/pgpool2/pool_system.c +659 -0
- data/pgpool2/pool_timestamp.c +1215 -0
- data/pgpool2/pool_timestamp.h +38 -0
- data/pgpool2/pool_type.h +171 -0
- data/pgpool2/pool_worker_child.c +384 -0
- data/pgpool2/ps_status.c +404 -0
- data/pgpool2/recovery.c +435 -0
- data/pgpool2/redhat/pgpool.conf.sample.patch +52 -0
- data/pgpool2/redhat/pgpool.init +201 -0
- data/pgpool2/redhat/pgpool.sysconfig +7 -0
- data/pgpool2/redhat/rpm_installer/basebackup-replication.sh +53 -0
- data/pgpool2/redhat/rpm_installer/basebackup-stream.sh +55 -0
- data/pgpool2/redhat/rpm_installer/config_for_script +17 -0
- data/pgpool2/redhat/rpm_installer/failover.sh +64 -0
- data/pgpool2/redhat/rpm_installer/getsources.sh +141 -0
- data/pgpool2/redhat/rpm_installer/install.sh +1363 -0
- data/pgpool2/redhat/rpm_installer/pgpool_recovery_pitr +47 -0
- data/pgpool2/redhat/rpm_installer/pgpool_remote_start +15 -0
- data/pgpool2/redhat/rpm_installer/recovery.conf +4 -0
- data/pgpool2/redhat/rpm_installer/uninstall.sh +57 -0
- data/pgpool2/sample/dist_def_pgbench.sql +73 -0
- data/pgpool2/sample/pgpool.pam +3 -0
- data/pgpool2/sample/pgpool_recovery +20 -0
- data/pgpool2/sample/pgpool_recovery_pitr +19 -0
- data/pgpool2/sample/pgpool_remote_start +13 -0
- data/pgpool2/sample/replicate_def_pgbench.sql +18 -0
- data/pgpool2/sql/insert_lock.sql +15 -0
- data/pgpool2/sql/pgpool-recovery/pgpool-recovery.c +280 -0
- data/pgpool2/sql/pgpool-recovery/pgpool-recovery.sql.in +19 -0
- data/pgpool2/sql/pgpool-recovery/pgpool_recovery--1.0.sql +24 -0
- data/pgpool2/sql/pgpool-recovery/pgpool_recovery.control +5 -0
- data/pgpool2/sql/pgpool-recovery/uninstall_pgpool-recovery.sql +3 -0
- data/pgpool2/sql/pgpool-regclass/pgpool-regclass.c +206 -0
- data/pgpool2/sql/pgpool-regclass/pgpool-regclass.sql.in +4 -0
- data/pgpool2/sql/pgpool-regclass/pgpool_regclass--1.0.sql +7 -0
- data/pgpool2/sql/pgpool-regclass/pgpool_regclass.control +5 -0
- data/pgpool2/sql/pgpool-regclass/uninstall_pgpool-regclass.sql +1 -0
- data/pgpool2/sql/system_db.sql +38 -0
- data/pgpool2/strlcpy.c +85 -0
- data/pgpool2/test/C/test_extended.c +98 -0
- data/pgpool2/test/jdbc/.cvsignore +2 -0
- data/pgpool2/test/jdbc/AutoCommitTest.java +45 -0
- data/pgpool2/test/jdbc/BatchTest.java +55 -0
- data/pgpool2/test/jdbc/ColumnTest.java +60 -0
- data/pgpool2/test/jdbc/CreateTempTableTest.java +48 -0
- data/pgpool2/test/jdbc/InsertTest.java +34 -0
- data/pgpool2/test/jdbc/LockTest.java +36 -0
- data/pgpool2/test/jdbc/PgpoolTest.java +75 -0
- data/pgpool2/test/jdbc/README.euc_jp +73 -0
- data/pgpool2/test/jdbc/RunTest.java +83 -0
- data/pgpool2/test/jdbc/SelectTest.java +37 -0
- data/pgpool2/test/jdbc/UpdateTest.java +32 -0
- data/pgpool2/test/jdbc/expected/CreateTempTable +1 -0
- data/pgpool2/test/jdbc/expected/autocommit +10 -0
- data/pgpool2/test/jdbc/expected/batch +1 -0
- data/pgpool2/test/jdbc/expected/column +100 -0
- data/pgpool2/test/jdbc/expected/insert +1 -0
- data/pgpool2/test/jdbc/expected/lock +100 -0
- data/pgpool2/test/jdbc/expected/select +2 -0
- data/pgpool2/test/jdbc/expected/update +1 -0
- data/pgpool2/test/jdbc/pgpool.properties +7 -0
- data/pgpool2/test/jdbc/prepare.sql +54 -0
- data/pgpool2/test/jdbc/run.sh +6 -0
- data/pgpool2/test/parser/.cvsignore +6 -0
- data/pgpool2/test/parser/README +32 -0
- data/pgpool2/test/parser/expected/copy.out +17 -0
- data/pgpool2/test/parser/expected/create.out +64 -0
- data/pgpool2/test/parser/expected/cursor.out +37 -0
- data/pgpool2/test/parser/expected/delete.out +10 -0
- data/pgpool2/test/parser/expected/drop.out +12 -0
- data/pgpool2/test/parser/expected/insert.out +13 -0
- data/pgpool2/test/parser/expected/misc.out +28 -0
- data/pgpool2/test/parser/expected/prepare.out +4 -0
- data/pgpool2/test/parser/expected/privileges.out +31 -0
- data/pgpool2/test/parser/expected/scanner.out +30 -0
- data/pgpool2/test/parser/expected/select.out +89 -0
- data/pgpool2/test/parser/expected/transaction.out +38 -0
- data/pgpool2/test/parser/expected/update.out +11 -0
- data/pgpool2/test/parser/expected/v84.out +37 -0
- data/pgpool2/test/parser/expected/v90.out +25 -0
- data/pgpool2/test/parser/expected/var.out +22 -0
- data/pgpool2/test/parser/input/alter.sql +2 -0
- data/pgpool2/test/parser/input/copy.sql +17 -0
- data/pgpool2/test/parser/input/create.sql +64 -0
- data/pgpool2/test/parser/input/cursor.sql +37 -0
- data/pgpool2/test/parser/input/delete.sql +10 -0
- data/pgpool2/test/parser/input/drop.sql +12 -0
- data/pgpool2/test/parser/input/insert.sql +13 -0
- data/pgpool2/test/parser/input/misc.sql +28 -0
- data/pgpool2/test/parser/input/prepare.sql +4 -0
- data/pgpool2/test/parser/input/privileges.sql +31 -0
- data/pgpool2/test/parser/input/scanner.sql +34 -0
- data/pgpool2/test/parser/input/select.sql +89 -0
- data/pgpool2/test/parser/input/transaction.sql +38 -0
- data/pgpool2/test/parser/input/update.sql +11 -0
- data/pgpool2/test/parser/input/v84.sql +37 -0
- data/pgpool2/test/parser/input/v90.sql +38 -0
- data/pgpool2/test/parser/input/var.sql +22 -0
- data/pgpool2/test/parser/main.c +96 -0
- data/pgpool2/test/parser/parse_schedule +16 -0
- data/pgpool2/test/parser/pool.h +13 -0
- data/pgpool2/test/parser/run-test +62 -0
- data/pgpool2/test/pdo-test/README.euc_jp +58 -0
- data/pgpool2/test/pdo-test/SQLlist/test1.sql +3 -0
- data/pgpool2/test/pdo-test/SQLlist/test2.sql +3 -0
- data/pgpool2/test/pdo-test/collections.inc +11 -0
- data/pgpool2/test/pdo-test/def.inc +7 -0
- data/pgpool2/test/pdo-test/log.txt +0 -0
- data/pgpool2/test/pdo-test/mod/database.inc +36 -0
- data/pgpool2/test/pdo-test/mod/def.inc +0 -0
- data/pgpool2/test/pdo-test/mod/errorhandler.inc +27 -0
- data/pgpool2/test/pdo-test/pdotest.php +11 -0
- data/pgpool2/test/pdo-test/regsql.inc +56 -0
- data/pgpool2/test/pgpool_setup +898 -0
- data/pgpool2/test/regression/README +39 -0
- data/pgpool2/test/regression/clean.sh +21 -0
- data/pgpool2/test/regression/libs.sh +16 -0
- data/pgpool2/test/regression/regress.sh +166 -0
- data/pgpool2/test/regression/tests/001.load_balance/test.sh +128 -0
- data/pgpool2/test/regression/tests/002.native_replication/PgTester.java +47 -0
- data/pgpool2/test/regression/tests/002.native_replication/create.sql +6 -0
- data/pgpool2/test/regression/tests/002.native_replication/test.sh +71 -0
- data/pgpool2/test/regression/tests/003.failover/expected.r +6 -0
- data/pgpool2/test/regression/tests/003.failover/expected.s +6 -0
- data/pgpool2/test/regression/tests/003.failover/test.sh +45 -0
- data/pgpool2/test/regression/tests/004.watchdog/master.conf +12 -0
- data/pgpool2/test/regression/tests/004.watchdog/standby.conf +19 -0
- data/pgpool2/test/regression/tests/004.watchdog/test.sh +52 -0
- data/pgpool2/test/regression/tests/050.bug58/test.sh +50 -0
- data/pgpool2/test/regression/tests/051.bug60/bug.sql +12 -0
- data/pgpool2/test/regression/tests/051.bug60/database-clean.sql +6 -0
- data/pgpool2/test/regression/tests/051.bug60/database-setup.sql +28 -0
- data/pgpool2/test/regression/tests/051.bug60/test.sh +79 -0
- data/pgpool2/test/regression/tests/052.do_query/test.sh +44 -0
- data/pgpool2/test/regression/tests/053.insert_lock_hangs/test.sh +81 -0
- data/pgpool2/test/regression/tests/054.postgres_fdw/test.sh +67 -0
- data/pgpool2/test/regression/tests/055.backend_all_down/test.sh +52 -0
- data/pgpool2/test/regression/tests/056.bug63/jdbctest2.java +66 -0
- data/pgpool2/test/regression/tests/056.bug63/test.sh +47 -0
- data/pgpool2/test/regression/tests/057.bug61/test.sh +40 -0
- data/pgpool2/test/regression/tests/058.bug68/jdbctest3.java +45 -0
- data/pgpool2/test/regression/tests/058.bug68/test.sh +47 -0
- data/pgpool2/test/timestamp/expected/insert.out +16 -0
- data/pgpool2/test/timestamp/expected/misc.out +3 -0
- data/pgpool2/test/timestamp/expected/update.out +6 -0
- data/pgpool2/test/timestamp/input/insert.sql +16 -0
- data/pgpool2/test/timestamp/input/misc.sql +3 -0
- data/pgpool2/test/timestamp/input/update.sql +6 -0
- data/pgpool2/test/timestamp/main.c +129 -0
- data/pgpool2/test/timestamp/parse_schedule +3 -0
- data/pgpool2/test/timestamp/run-test +69 -0
- data/pgpool2/version.h +1 -0
- data/pgpool2/watchdog/Makefile.am +17 -0
- data/pgpool2/watchdog/Makefile.in +505 -0
- data/pgpool2/watchdog/test/stab.c +266 -0
- data/pgpool2/watchdog/test/test.c +85 -0
- data/pgpool2/watchdog/test/wd_child_t.c +87 -0
- data/pgpool2/watchdog/test/wd_lifecheck_t.c +87 -0
- data/pgpool2/watchdog/test/wd_packet_t.c +87 -0
- data/pgpool2/watchdog/test/wd_ping_t.c +20 -0
- data/pgpool2/watchdog/watchdog.c +408 -0
- data/pgpool2/watchdog/watchdog.h +209 -0
- data/pgpool2/watchdog/wd_child.c +444 -0
- data/pgpool2/watchdog/wd_ext.h +123 -0
- data/pgpool2/watchdog/wd_heartbeat.c +577 -0
- data/pgpool2/watchdog/wd_if.c +216 -0
- data/pgpool2/watchdog/wd_init.c +126 -0
- data/pgpool2/watchdog/wd_interlock.c +347 -0
- data/pgpool2/watchdog/wd_lifecheck.c +512 -0
- data/pgpool2/watchdog/wd_list.c +429 -0
- data/pgpool2/watchdog/wd_packet.c +1159 -0
- data/pgpool2/watchdog/wd_ping.c +330 -0
- data/pgpool2/ylwrap +223 -0
- data/pgsql/presto_client.py +346 -0
- data/pgsql/prestogres.py +156 -0
- data/pgsql/setup_functions.sql +21 -0
- data/pgsql/setup_language.sql +3 -0
- data/prestogres.gemspec +23 -0
- metadata +496 -0
@@ -0,0 +1,280 @@
|
|
1
|
+
ul#navlist
|
2
|
+
{
|
3
|
+
width: 158px>;
|
4
|
+
\width: 160px;
|
5
|
+
w\idth: 158px;
|
6
|
+
padding: 0px;
|
7
|
+
border: 1px solid #808080;
|
8
|
+
border-top: 0px;
|
9
|
+
margin: 0px;
|
10
|
+
font: bold 12px verdana,helvetica,arial,sans-serif;
|
11
|
+
background: #808080;
|
12
|
+
}
|
13
|
+
|
14
|
+
ul#navlist li
|
15
|
+
{
|
16
|
+
list-style: none;
|
17
|
+
margin: 0px;
|
18
|
+
border: 0px;
|
19
|
+
border-top: 1px solid #808080;
|
20
|
+
font-size:7pt;
|
21
|
+
}
|
22
|
+
|
23
|
+
ul#navlist li a
|
24
|
+
{
|
25
|
+
display: block;
|
26
|
+
width: 122px;
|
27
|
+
\width: 158px;
|
28
|
+
w\idth: 122px;
|
29
|
+
padding: 4px 8px 4px 8px;
|
30
|
+
border: 0px;
|
31
|
+
border-left: 20px solid #aaaabb;
|
32
|
+
background: #ccccdd;
|
33
|
+
text-decoration: none;
|
34
|
+
text-align: right;
|
35
|
+
|
36
|
+
}
|
37
|
+
|
38
|
+
ul#navlist li a:link { color: #666677; }
|
39
|
+
div#navcontainer li a:visited { color: #666677; }
|
40
|
+
|
41
|
+
ul#navlist li a:hover
|
42
|
+
{
|
43
|
+
border-color: #ff9000;
|
44
|
+
color: #ffffff;
|
45
|
+
background: #000d33;
|
46
|
+
}
|
47
|
+
|
48
|
+
ul#navlist li > ul
|
49
|
+
{
|
50
|
+
margin-left: 0px;
|
51
|
+
padding-left: 0px;
|
52
|
+
}
|
53
|
+
ul#navlist li > ul li a {
|
54
|
+
border-left: 20px solid #B9B9CE;
|
55
|
+
background: #DEDEEF;
|
56
|
+
}
|
57
|
+
|
58
|
+
/* --------------------------- */
|
59
|
+
#menu {
|
60
|
+
border-right:1px dotted #cccccc;
|
61
|
+
float: left;
|
62
|
+
padding-top: 20px;
|
63
|
+
}
|
64
|
+
#navcontainer {
|
65
|
+
margin-bottom: 20px;
|
66
|
+
}
|
67
|
+
#manual {
|
68
|
+
border-left:1px dotted #cccccc;
|
69
|
+
width: 800px;
|
70
|
+
float: left;
|
71
|
+
}
|
72
|
+
body {
|
73
|
+
font-family:Verdana, Arial, Helvetica, sans-serif;
|
74
|
+
font-size:9pt;
|
75
|
+
margin: 0px;
|
76
|
+
color: black;
|
77
|
+
border-left: 20px solid #ccc;
|
78
|
+
}
|
79
|
+
pre {
|
80
|
+
background-color:#f0f0f0;
|
81
|
+
color: brown;
|
82
|
+
padding: 5px;
|
83
|
+
margin-left:40px;
|
84
|
+
margin-right:30px;
|
85
|
+
word-wrap: break-word;
|
86
|
+
word-break: break-all;
|
87
|
+
overflow: auto;
|
88
|
+
}
|
89
|
+
h1 {
|
90
|
+
margin-top: 50px;
|
91
|
+
border-bottom: 2px solid #6699CC;
|
92
|
+
padding: 5px;
|
93
|
+
margin-left:10px;
|
94
|
+
background:#6699CC;
|
95
|
+
color: #ffffff;
|
96
|
+
}
|
97
|
+
h2 {
|
98
|
+
margin-top: 30px;
|
99
|
+
padding: 5px;
|
100
|
+
margin-left:30px;
|
101
|
+
background: #8CD8E2;
|
102
|
+
}
|
103
|
+
|
104
|
+
h3 {
|
105
|
+
margin-top: 30px;
|
106
|
+
border: 2px solid #8CD8E2;
|
107
|
+
border-left: 10px solid #8CD8E2;
|
108
|
+
padding: 5px;
|
109
|
+
margin-left:40px;
|
110
|
+
background: #F4F8F1;
|
111
|
+
}
|
112
|
+
|
113
|
+
h4 {
|
114
|
+
border-bottom: 2px solid #8CD8E2;
|
115
|
+
padding: 5px;
|
116
|
+
margin-left:40px;
|
117
|
+
background: #F4F8F1;
|
118
|
+
}
|
119
|
+
|
120
|
+
p {
|
121
|
+
margin: 3px 25px 3px 40px;
|
122
|
+
text-indent: 1em;
|
123
|
+
}
|
124
|
+
|
125
|
+
li p, dd p {
|
126
|
+
text-indent: 0em;
|
127
|
+
color: black;
|
128
|
+
}
|
129
|
+
|
130
|
+
ul, ol,dl {
|
131
|
+
margin-left:40px;
|
132
|
+
padding-right: 30px;
|
133
|
+
}
|
134
|
+
dt {
|
135
|
+
font-weight:bold;
|
136
|
+
}
|
137
|
+
|
138
|
+
ul li {
|
139
|
+
padding-right: 30px;
|
140
|
+
list-style:square;
|
141
|
+
color: #663333;
|
142
|
+
}
|
143
|
+
|
144
|
+
ul li ul li {
|
145
|
+
list-style: circle;
|
146
|
+
}
|
147
|
+
|
148
|
+
ul li ol li {
|
149
|
+
list-style: decimal;
|
150
|
+
}
|
151
|
+
|
152
|
+
|
153
|
+
ol li {
|
154
|
+
padding-right: 30px;
|
155
|
+
color: #663333;
|
156
|
+
}
|
157
|
+
|
158
|
+
|
159
|
+
table {
|
160
|
+
margin-left:40px;
|
161
|
+
border-collapse: collapse;
|
162
|
+
border: #666666 1px solid;
|
163
|
+
margin-bottom: 10px;
|
164
|
+
}
|
165
|
+
th, td {
|
166
|
+
padding: 5px;
|
167
|
+
font-size:10pt;
|
168
|
+
}
|
169
|
+
th {
|
170
|
+
font-weight: normal;
|
171
|
+
background-color: #eeeeee;
|
172
|
+
}
|
173
|
+
th.nodec {
|
174
|
+
text-align: left;
|
175
|
+
white-space: nowrap;
|
176
|
+
}
|
177
|
+
tr.header th {
|
178
|
+
font-weight: bold;
|
179
|
+
background-color: #cccccc;
|
180
|
+
border-bottom: double;
|
181
|
+
}
|
182
|
+
tr.center td {
|
183
|
+
text-align: center;
|
184
|
+
}
|
185
|
+
|
186
|
+
dd {
|
187
|
+
margin-left: 0px;
|
188
|
+
}
|
189
|
+
a:link { color: blue; }
|
190
|
+
a:hover { color: red; }
|
191
|
+
|
192
|
+
p.top_link {
|
193
|
+
text-align: right;
|
194
|
+
}
|
195
|
+
p.top_link a {
|
196
|
+
text-decoration: none;
|
197
|
+
border: #aaaaaa 1px solid;
|
198
|
+
border-radius: 3px;
|
199
|
+
background-color: #eeeeee;
|
200
|
+
padding: 1px 5px;
|
201
|
+
color: #666666;
|
202
|
+
}
|
203
|
+
.header_small {
|
204
|
+
font-size: 0.9em;
|
205
|
+
background-color: #f0f0f0;
|
206
|
+
|
207
|
+
}
|
208
|
+
.header_text {
|
209
|
+
border-bottom: 2px solid #663366;
|
210
|
+
padding: 5px;
|
211
|
+
background-color: #E9F8F8;
|
212
|
+
font-size: 2em;
|
213
|
+
font-weight:bold;
|
214
|
+
padding:25px;
|
215
|
+
}
|
216
|
+
|
217
|
+
.copyright {
|
218
|
+
padding: 5px;
|
219
|
+
padding:25px;
|
220
|
+
text-align:center;
|
221
|
+
}
|
222
|
+
.version {
|
223
|
+
font-size: smaller;
|
224
|
+
font-weight: bold;
|
225
|
+
border: 1px solid #B27F00;
|
226
|
+
background-color: orange;
|
227
|
+
padding: 1px 3px;
|
228
|
+
border-radius: 3px;
|
229
|
+
color: white;
|
230
|
+
}
|
231
|
+
h1 .version {
|
232
|
+
border-radius: 5px;
|
233
|
+
border-color: white;
|
234
|
+
}
|
235
|
+
.version_notice {
|
236
|
+
border-left: 7px solid orange;
|
237
|
+
border-right: 5px solid orange;
|
238
|
+
padding: 5px;
|
239
|
+
}
|
240
|
+
.caution {
|
241
|
+
font-weight: bold;
|
242
|
+
color: red;
|
243
|
+
}
|
244
|
+
dl.flat dt {
|
245
|
+
clear: both;
|
246
|
+
float: left;
|
247
|
+
width: 40px;
|
248
|
+
line-height: 150%;
|
249
|
+
}
|
250
|
+
dl.flat dd {
|
251
|
+
padding-left: 50px;
|
252
|
+
line-height: 150%;
|
253
|
+
}
|
254
|
+
dl.flat dd * {
|
255
|
+
margin-left: 0px;
|
256
|
+
}
|
257
|
+
li dl dt {
|
258
|
+
font-weight: normal;
|
259
|
+
display: list-item;
|
260
|
+
list-style: square outside;
|
261
|
+
}
|
262
|
+
li dl dd {
|
263
|
+
margin-bottom: 10px;
|
264
|
+
}
|
265
|
+
ul.flat_ul {
|
266
|
+
margin: 0px;
|
267
|
+
list-style-type: none;
|
268
|
+
}
|
269
|
+
ul.flat_ul li {
|
270
|
+
display: inline-block;
|
271
|
+
border: 1px solid #666;
|
272
|
+
border-radius: 3px;
|
273
|
+
width: 100px;
|
274
|
+
margin: 3px;
|
275
|
+
padding: 0px;
|
276
|
+
text-align: center;
|
277
|
+
}
|
278
|
+
ul.flat_ul li a {
|
279
|
+
text-decoration: none;
|
280
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
|
3
|
+
if [ $# -ne 2 ]
|
4
|
+
then
|
5
|
+
echo "pgpool_remote_start remote_host remote_datadir"
|
6
|
+
exit 1
|
7
|
+
fi
|
8
|
+
|
9
|
+
DEST=$1
|
10
|
+
DESTDIR=$2
|
11
|
+
PGCTL=/usr/local/pgsql/bin/pg_ctl
|
12
|
+
|
13
|
+
ssh -T $DEST $PGCTL -w -D $DESTDIR start 2>/dev/null 1>/dev/null < /dev/null &
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# -------------------------------
|
2
|
+
# PostgreSQL recovery config file
|
3
|
+
# -------------------------------
|
4
|
+
#
|
5
|
+
# Edit this file to provide the parameters that PostgreSQL needs to
|
6
|
+
# perform an archive recovery of a database, or to act as a log-streaming
|
7
|
+
# replication standby.
|
8
|
+
#
|
9
|
+
# If "recovery.conf" is present in the PostgreSQL data directory, it is
|
10
|
+
# read on postmaster startup. After successful recovery, it is renamed
|
11
|
+
# to "recovery.done" to ensure that we do not accidentally re-enter
|
12
|
+
# archive recovery or standby mode.
|
13
|
+
#
|
14
|
+
# This file consists of lines of the form:
|
15
|
+
#
|
16
|
+
# name = 'value'
|
17
|
+
#
|
18
|
+
# (The quotes around the value are NOT optional, but the "=" is.)
|
19
|
+
#
|
20
|
+
# Comments are introduced with '#'.
|
21
|
+
#
|
22
|
+
# The complete list of option names and allowed values can be found
|
23
|
+
# in the PostgreSQL documentation.
|
24
|
+
#
|
25
|
+
#---------------------------------------------------------------------------
|
26
|
+
# ARCHIVE RECOVERY PARAMETERS
|
27
|
+
#---------------------------------------------------------------------------
|
28
|
+
#
|
29
|
+
# restore_command
|
30
|
+
#
|
31
|
+
# specifies the shell command that is executed to copy log files
|
32
|
+
# back from archival storage. The command string may contain %f,
|
33
|
+
# which is replaced by the name of the desired log file, and %p,
|
34
|
+
# which is replaced by the absolute path to copy the log file to.
|
35
|
+
#
|
36
|
+
# This parameter is *required* for an archive recovery, but optional
|
37
|
+
# for streaming replication.
|
38
|
+
#
|
39
|
+
# It is important that the command return nonzero exit status on failure.
|
40
|
+
# The command *will* be asked for log files that are not present in the
|
41
|
+
# archive; it must return nonzero when so asked.
|
42
|
+
#
|
43
|
+
# NOTE that the basename of %p will be different from %f; do not
|
44
|
+
# expect them to be interchangeable.
|
45
|
+
#
|
46
|
+
#restore_command = '' # e.g. 'cp /mnt/server/archivedir/%f %p'
|
47
|
+
#
|
48
|
+
#
|
49
|
+
# archive_cleanup_command
|
50
|
+
#
|
51
|
+
# specifies an optional shell command to execute at every restartpoint.
|
52
|
+
# This can be useful for cleaning up the archive of a standby server.
|
53
|
+
#
|
54
|
+
#archive_cleanup_command = ''
|
55
|
+
#
|
56
|
+
# recovery_end_command
|
57
|
+
#
|
58
|
+
# specifies an optional shell command to execute at completion of recovery.
|
59
|
+
# This can be useful for cleaning up after the restore_command.
|
60
|
+
#
|
61
|
+
#recovery_end_command = ''
|
62
|
+
#
|
63
|
+
#---------------------------------------------------------------------------
|
64
|
+
# RECOVERY TARGET PARAMETERS
|
65
|
+
#---------------------------------------------------------------------------
|
66
|
+
#
|
67
|
+
# By default, recovery will rollforward to the end of the WAL log.
|
68
|
+
# If you want to stop rollforward at a specific point, you
|
69
|
+
# must set a recovery target.
|
70
|
+
#
|
71
|
+
# You may set a recovery target either by transactionId, or
|
72
|
+
# by timestamp. Recovery may either include or exclude the
|
73
|
+
# transaction(s) with the recovery target value (ie, stop either
|
74
|
+
# just after or just before the given target, respectively).
|
75
|
+
#
|
76
|
+
#recovery_target_time = '' # e.g. '2004-07-14 22:39:00 EST'
|
77
|
+
#
|
78
|
+
#recovery_target_xid = ''
|
79
|
+
#
|
80
|
+
#recovery_target_inclusive = 'true'
|
81
|
+
#
|
82
|
+
#
|
83
|
+
# If you want to recover into a timeline other than the "main line" shown in
|
84
|
+
# pg_control, specify the timeline number here, or write 'latest' to get
|
85
|
+
# the latest branch for which there's a history file.
|
86
|
+
#
|
87
|
+
#recovery_target_timeline = 'latest'
|
88
|
+
#
|
89
|
+
#---------------------------------------------------------------------------
|
90
|
+
# STANDBY SERVER PARAMETERS
|
91
|
+
#---------------------------------------------------------------------------
|
92
|
+
#
|
93
|
+
# When standby_mode is enabled, the PostgreSQL server will work as
|
94
|
+
# a standby. It tries to connect to the primary according to the
|
95
|
+
# connection settings primary_conninfo, and receives XLOG records
|
96
|
+
# continuously.
|
97
|
+
#
|
98
|
+
#standby_mode = 'off'
|
99
|
+
#
|
100
|
+
#primary_conninfo = '' # e.g. 'host=localhost port=5432'
|
101
|
+
#
|
102
|
+
#
|
103
|
+
# By default, a standby server keeps streaming XLOG records from the
|
104
|
+
# primary indefinitely. If you want to stop streaming and finish recovery,
|
105
|
+
# opening up the system in read/write mode, specify path to a trigger file.
|
106
|
+
# Server will poll the trigger file path periodically and stop streaming
|
107
|
+
# when it's found.
|
108
|
+
#
|
109
|
+
#trigger_file = ''
|
110
|
+
#
|
111
|
+
#---------------------------------------------------------------------------
|
112
|
+
# HOT STANDBY PARAMETERS
|
113
|
+
#---------------------------------------------------------------------------
|
114
|
+
#
|
115
|
+
# Hot Standby related parameters are listed in postgresql.conf
|
116
|
+
#
|
117
|
+
#---------------------------------------------------------------------------
|
@@ -0,0 +1,707 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
2
|
+
|
3
|
+
<html>
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<title>pgpool-II Tutorial</title>
|
7
|
+
<meta http-equiv="Content-Type" content="text/html" />
|
8
|
+
<link href="pgpool.css" rel="stylesheet" type="text/css" />
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<body>
|
12
|
+
<h1>pgpool-II Tutorial</h1>
|
13
|
+
<p>Welcome to the Tutorial for pgpool-II. From here, you can learn how
|
14
|
+
to install, setup, and run parallel queries or do replication using
|
15
|
+
pgpool-II. We assume that you already know basic PostreSQL operations,
|
16
|
+
so please refer to the PostgreSQL document if neccesary.</p>
|
17
|
+
|
18
|
+
<dl>
|
19
|
+
<dt><em>Table of Contents</em></dt>
|
20
|
+
<dt>1. <a href="#start">Let's Begin!</a></dt>
|
21
|
+
<dd>1.1. <a href="#install">Installing pgpool-II</a></dd>
|
22
|
+
<dd>1.2. <a href="#config">Configuration Files</a></dd>
|
23
|
+
<dd>1.3. <a href="#pcp-config">Configuring PCP commands</a></dd>
|
24
|
+
<dd>1.4. <a href="#db-node">Preparing Database Nodes</a></dd>
|
25
|
+
<dd>1.5. <a href="#start-shutdown">Starting/Stopping pgpool-II</a></dd>
|
26
|
+
<dt>2. <a href="#replication">Your First Replication</a></dt>
|
27
|
+
<dd>2.1. <a href="#replication-config">Configuring Replication</a></dd>
|
28
|
+
<dd>2.2. <a href="#replication-check">Checking Replication</a></dd>
|
29
|
+
<dt>3. <a href="#parallel">Your First Parallel Query</a></dt>
|
30
|
+
<dd>3.1. <a href="#parallel-config">Configuring Parallel Query</a></dd>
|
31
|
+
<dd>3.2. <a href="#system-db">Configuring the System Database</a></dd>
|
32
|
+
<dd>3.3. <a href="#dist-def">Partitioning Rule Definition</a></dd>
|
33
|
+
<dd>3.4. <a href="#replicate-def">Replication Rule Definition</a></dd>
|
34
|
+
<dd>3.5. <a href="#parallel-check">Checking Parallel Query</a></dd>
|
35
|
+
</dl>
|
36
|
+
|
37
|
+
|
38
|
+
<h2>1. <a name="start">Let's Begin!</a></h2>
|
39
|
+
|
40
|
+
<p>First, we must learn how to install and configure pgpool-II and
|
41
|
+
database nodes before using replication or parallel query.</p>
|
42
|
+
|
43
|
+
<h3>1.1. <a name="install">Installing pgpool-II</a></h3>
|
44
|
+
|
45
|
+
<p>Installing pgpool-II is very easy. In the directory which you have
|
46
|
+
extracted the source tar ball, execute the following commands.</p>
|
47
|
+
|
48
|
+
<pre>
|
49
|
+
$ ./configure
|
50
|
+
$ make
|
51
|
+
$ make install
|
52
|
+
</pre>
|
53
|
+
|
54
|
+
<p><code>configure</code> script collects your system information
|
55
|
+
and use it for the compilation procedure. You can pass command line
|
56
|
+
arguments to <code>configure</code> script to change the default
|
57
|
+
behavior, such as the installation directory. pgpool-II will be
|
58
|
+
installed to <code>/usr/local</code> directory by default.</p>
|
59
|
+
|
60
|
+
<p><code>make</code> command compiles the source code, and <code>make
|
61
|
+
install</code> will install the executables. You must have write
|
62
|
+
permission on the installation directory.</p>
|
63
|
+
|
64
|
+
<p>In this tutorial, we will install pgpool-II in the default
|
65
|
+
<code>/usr/local</code> directory.</p>
|
66
|
+
|
67
|
+
<p><em>Note</em>: pgpool-II requires libpq library in PostgreSQL 7.4
|
68
|
+
or later (version 3 protocol). If the <code>configure</code> script
|
69
|
+
displays the following error message, the libpq library may not be
|
70
|
+
installed, or it is not of version 3.</p>
|
71
|
+
|
72
|
+
<pre>configure: error: libpq is not installed or libpq is old</pre>
|
73
|
+
|
74
|
+
<p>If the library is version 3, but the above message is still displayed,
|
75
|
+
your libpq library is probably not recognized by
|
76
|
+
the <code>configure</code> script.</p>
|
77
|
+
|
78
|
+
<p>The <code>configure</code> script searches for libpq library under
|
79
|
+
<code>/usr/local/pgsql</code>. If you have installed
|
80
|
+
PostgreSQL in a directory other than <code>/usr/local/pgsql</code>,
|
81
|
+
use <code>--with-pgsql</code>, or <code>--with-pgsql-includedir</code>
|
82
|
+
and <code>--with-pgsql-libdir</code> command line options when you
|
83
|
+
execute <code>configure</code>.</p>
|
84
|
+
|
85
|
+
<h3>1.2. <a name="config">Configuration Files</a></h3>
|
86
|
+
|
87
|
+
<p>pgpool-II configuration parameters are saved in
|
88
|
+
the <code>pgpool.conf</code> file. The file is in "<code>parameter =
|
89
|
+
value</code>" per line format. When you install pgpool-II,
|
90
|
+
<code>pgpool.conf.sample</code> is automatically created. We recommend
|
91
|
+
copying and renaming it to <code>pgpool.conf</code>, and edit it as
|
92
|
+
you like.</p>
|
93
|
+
|
94
|
+
<pre>$ cp /usr/local/etc/pgpool.conf.sample /usr/local/etc/pgpool.conf</pre>
|
95
|
+
|
96
|
+
<p>pgpool-II only accepts connections from the local host using port
|
97
|
+
9999. If you wish to receive conenctions from other hosts, set
|
98
|
+
<code>listen_addresses</code> to '*'.</code></p>
|
99
|
+
|
100
|
+
<pre>
|
101
|
+
listen_addresses = 'localhost'
|
102
|
+
port = 9999
|
103
|
+
</pre>
|
104
|
+
|
105
|
+
<p>We will use the default parameters in thie tutorial.</p>
|
106
|
+
|
107
|
+
<h3>1.3. <a name="pcp-config">Configuring PCP Commands</a></h3>
|
108
|
+
|
109
|
+
<p>pgpool-II has an interface for administrative purpose to retrieve
|
110
|
+
information on database nodes, shutdown pgpool-II, etc. via
|
111
|
+
network. To use PCP commands, user authentication is required. This
|
112
|
+
authentication is different from PostgreSQL's user authentication. A
|
113
|
+
user name and password need to be defined in the <code>pcp.conf</code>
|
114
|
+
file. In the file, a user name and password are listed as a pair on
|
115
|
+
each line, and they are separated by a colon (:). Passwords are
|
116
|
+
encrypted in md5 hash format.</p>
|
117
|
+
|
118
|
+
<pre>postgres:e8a48653851e28c69d0506508fb27fc5</pre>
|
119
|
+
<p>
|
120
|
+
When you install pgpool-II, <code>pcp.conf.sample</code> is
|
121
|
+
automatically created. We recommend copying and renaming it to
|
122
|
+
<code>pcp.conf</code>, and edit it.
|
123
|
+
</p>
|
124
|
+
<pre>$ cp /usr/local/etc/pcp.conf.sample /usr/local/etc/pcp.conf</pre>
|
125
|
+
|
126
|
+
<p>To encrypt your password into md5 hash format, use the pg_md5 command,
|
127
|
+
which is installed as one of pgpool-II's
|
128
|
+
executables. <code>pg_md5</code> takes text as a command line
|
129
|
+
argument, and displays its md5-hashed text.</p>
|
130
|
+
|
131
|
+
<p>For example, give "postgres" as the command line argument, and
|
132
|
+
<code>pg_md5</code> displays md5-hashed text on its standard
|
133
|
+
output.</p>
|
134
|
+
|
135
|
+
<pre>
|
136
|
+
$ /usr/bin/pg_md5 postgres
|
137
|
+
e8a48653851e28c69d0506508fb27fc5
|
138
|
+
</pre>
|
139
|
+
|
140
|
+
<p>PCP commands are executed via network, so the port number must be
|
141
|
+
configured with <code>pcp_port</code> parameter in
|
142
|
+
<code>pgpool.conf</code> file.</p>
|
143
|
+
|
144
|
+
<p>We will use the default 9898 for <code>pcp_port</code> in this tutorial.</p>
|
145
|
+
|
146
|
+
<pre>pcp_port = 9898</pre>
|
147
|
+
|
148
|
+
<h3>1.4. <a name="db-node">Preparing Database Nodes</a></h3>
|
149
|
+
|
150
|
+
<p>Now, we need to set up backend PostgreSQL servers for
|
151
|
+
pgpool-II. These servers can be placed within the same host as
|
152
|
+
pgpool-II, or on separate machines. If you decide to place the servers
|
153
|
+
on the same host, different port numbers must be assigned for each
|
154
|
+
server. If the servers are placed on separate machines, they must be
|
155
|
+
configured properly so that they can accept network connections from
|
156
|
+
pgpool-II.</p>
|
157
|
+
|
158
|
+
<p>In this tutorial, we will place three servers within the same host
|
159
|
+
as pgpool-II, and assign 5432, 5433, 5434 port numbers
|
160
|
+
respectively. To configure pgpool-II, edit <code>pgpool.conf</code> as
|
161
|
+
follows.
|
162
|
+
|
163
|
+
<pre>
|
164
|
+
backend_hostname0 = 'localhost'
|
165
|
+
backend_port0 = 5432
|
166
|
+
backend_weight0 = 1
|
167
|
+
backend_hostname1 = 'localhost'
|
168
|
+
backend_port1 = 5433
|
169
|
+
backend_weight1 = 1
|
170
|
+
backend_hostname2 = 'localhost'
|
171
|
+
backend_port2 = 5434
|
172
|
+
backend_weight2 = 1
|
173
|
+
</pre>
|
174
|
+
|
175
|
+
<p>For <code>backend_hostname</code>, <code>backend_port</code>,
|
176
|
+
<code>backend_weight</code>, set the node's hostname, port number, and
|
177
|
+
ratio for load balancing. At the end of each parameter string, node ID
|
178
|
+
must be specified by adding positive integers starting with 0 (i.e. 0,
|
179
|
+
1, 2, …).</p>
|
180
|
+
|
181
|
+
<p><code>backend_weight</code> parameters are all 1, meaning that
|
182
|
+
SELECT queries are equally distributed among three servers.</p>
|
183
|
+
|
184
|
+
<h3>1.5. <a name="start-shutdown">Starting/Stopping pgpool-II</a></h3>
|
185
|
+
|
186
|
+
<p>To fire up pgpool-II, execute the following command on a terminal.</p>
|
187
|
+
|
188
|
+
<pre>$ pgpool</pre>
|
189
|
+
|
190
|
+
<p>The above command, however, prints no log messages because pgpool
|
191
|
+
detaches the terminal. If you want to show pgpool log messages, you
|
192
|
+
pass <code>-n</code> option to pgpool command so pgpool-II is executed
|
193
|
+
as non-daemon process, and the terminal will not be detached.
|
194
|
+
</p>
|
195
|
+
|
196
|
+
<pre>
|
197
|
+
$ pgpool -n &
|
198
|
+
</pre>
|
199
|
+
|
200
|
+
<p>
|
201
|
+
The log messages are printed on the terminal, so the recommended
|
202
|
+
options to use the following.
|
203
|
+
</p>
|
204
|
+
|
205
|
+
<pre>$ pgpool -n -d > /tmp/pgpool.log 2>&1 &</pre>
|
206
|
+
|
207
|
+
<p>The <code>-d</code> option enables debug messages to be generated.</p>
|
208
|
+
|
209
|
+
<p>
|
210
|
+
The above command keeps appending log messages to /tmp/pgpool.log. If
|
211
|
+
you need to rotate log files, pass the logs to a external command
|
212
|
+
which has log rotation function.
|
213
|
+
|
214
|
+
For example, you can use rotatelogs from Apache2:
|
215
|
+
<pre>
|
216
|
+
$ pgpool -n 2>&1 | /usr/local/apache2/bin/rotatelogs \
|
217
|
+
-l -f /var/log/pgpool/pgpool.log.%A 86400 &
|
218
|
+
</pre>
|
219
|
+
This will generate a log file named "pgpool.log.Thursday" then
|
220
|
+
rotate it 00:00 at midnight. Rotatelogs adds logs to a file if it already
|
221
|
+
exists. To delete old log files before rotation, you could use cron:
|
222
|
+
<pre>
|
223
|
+
55 23 * * * /usr/bin/find /var/log/pgpool -type f -mtime +5 -exec /bin/rm -f '{}' \;
|
224
|
+
</pre>
|
225
|
+
Please note that rotatelogs may exist as /usr/sbin/rotatelogs2 in some
|
226
|
+
distributions.
|
227
|
+
-f option generates a log file as soon as rotatelogs starts and is
|
228
|
+
available in apache2 2.2.9 or greater.
|
229
|
+
</p>
|
230
|
+
<p>
|
231
|
+
Also <a
|
232
|
+
href="http://www.cronolog.org"><code>cronolog</code></a> can be used.
|
233
|
+
</p>
|
234
|
+
|
235
|
+
<pre>
|
236
|
+
$ pgpool -n 2>&1 | /usr/sbin/cronolog \
|
237
|
+
--hardlink=/var/log/pgsql/pgpool.log \
|
238
|
+
'/var/log/pgsql/%Y-%m-%d-pgpool.log' &
|
239
|
+
</pre>
|
240
|
+
|
241
|
+
<p>To stop pgpool-II, execute the following command.</p>
|
242
|
+
|
243
|
+
<pre>$ pgpool stop</pre>
|
244
|
+
|
245
|
+
<p>If any client is still connected, pgpool-II waits for it to
|
246
|
+
disconnect, and then terminates itself. Run the following command
|
247
|
+
instead if you want to shutdown pgpool-II forcibly.
|
248
|
+
|
249
|
+
<pre>$ pgpool -m fast stop</pre>
|
250
|
+
|
251
|
+
<h2>2. <a name="replication">Your First Replication</a></h2>
|
252
|
+
|
253
|
+
<p>Replication enables the same data to be copied to multiple database
|
254
|
+
nodes.</p>
|
255
|
+
|
256
|
+
<p>In this section, we'll use three database nodes, which we have
|
257
|
+
already set up in section "1. <a href="#start">Let's Begin!</a>", and
|
258
|
+
takes you step by step to create a database replication system. Sample
|
259
|
+
data to be replicated will be generated by the pgbench benchmark
|
260
|
+
program.</p>
|
261
|
+
|
262
|
+
<h3>2.1. <a name="replication-config">Configuring Replication</a></h3>
|
263
|
+
|
264
|
+
<p>To enable the database replication function, set
|
265
|
+
<code>replication_mode</code> to true in <code>pgpool.conf</code>
|
266
|
+
file.</p>
|
267
|
+
|
268
|
+
<pre>replication_mode = true</pre>
|
269
|
+
|
270
|
+
<p>When <code>replication_mode</code> is set to true, pgpool-II will send a
|
271
|
+
copy of a received query to all the database nodes.</p>
|
272
|
+
|
273
|
+
<p>When <code>load_balance_mode</code> is set to true, pgpool-II will
|
274
|
+
distribute SELECT queries among the database nodes.</p>
|
275
|
+
|
276
|
+
<pre>load_balance_mode = true</pre>
|
277
|
+
|
278
|
+
<p>In this section, we enable both <code>replication_mode</code> and
|
279
|
+
<code>load_balance_mode</code>.</p>
|
280
|
+
|
281
|
+
<h3>2.2. <a name="replication-check">Checking Replication</a></h3>
|
282
|
+
|
283
|
+
<p>To reflect the changes in <code>pgpool.conf</code>, pgpool-II must
|
284
|
+
be restarted. Please refer to section "1.5 <a
|
285
|
+
href="#start-shutdown">Starting/Stopping pgpool-II</a>".</p>
|
286
|
+
|
287
|
+
<p>After configuring <code>pgpool.conf</code> and restarting
|
288
|
+
pgpool-II, let's try the actual replication and see if everything is
|
289
|
+
working.</p>
|
290
|
+
|
291
|
+
<p>First, we need to create a database to be replicated. We will name
|
292
|
+
it "bench_replication". This database needs to be created on all the
|
293
|
+
nodes. Use the <code>createdb</code> commands through pgpool-II, and the
|
294
|
+
database will be created on all the nodes.</p>
|
295
|
+
|
296
|
+
<pre>$ createdb -p 9999 bench_replication</pre>
|
297
|
+
|
298
|
+
<p>Then, we'll execute pgbench with <code>-i</code>
|
299
|
+
option. <code>-i</code> option initializes the database with
|
300
|
+
pre-defined tables and data.</p>
|
301
|
+
|
302
|
+
<pre>$ pgbench -i -p 9999 bench_replication</pre>
|
303
|
+
|
304
|
+
<p>The following table is the summary of tables and data, which will
|
305
|
+
be created by <code>pgbench -i</code>. If, on all the nodes, the
|
306
|
+
listed tables and data are created, replication is working correctly.
|
307
|
+
|
308
|
+
<table border="1" align="center">
|
309
|
+
<tr>
|
310
|
+
<th>Table Name</th>
|
311
|
+
<th>Number of Rows</th>
|
312
|
+
</tr>
|
313
|
+
<tr>
|
314
|
+
<td>branches</td>
|
315
|
+
<td>1</td>
|
316
|
+
</tr>
|
317
|
+
<tr>
|
318
|
+
<td>tellers</td>
|
319
|
+
<td>10</td>
|
320
|
+
</tr>
|
321
|
+
<tr>
|
322
|
+
<td>accounts</td>
|
323
|
+
<td>100000</td>
|
324
|
+
</tr>
|
325
|
+
<tr>
|
326
|
+
<td>history</td>
|
327
|
+
<td>0</td>
|
328
|
+
</tr>
|
329
|
+
</table>
|
330
|
+
|
331
|
+
<p>Let's use a simple shell script to check the above on all the
|
332
|
+
nodes. The following script will display the number of rows in
|
333
|
+
branches, tellers, accounts, and history tables on all the nodes (5432,
|
334
|
+
5433, 5434).</p>
|
335
|
+
|
336
|
+
<pre>$ for port in 5432 5433 5434; do
|
337
|
+
> echo $port
|
338
|
+
> for table_name in branches tellers accounts history; do
|
339
|
+
> echo $table_name
|
340
|
+
> psql -c "SELECT count(*) FROM $table_name" -p $port bench_replication
|
341
|
+
> done
|
342
|
+
> done
|
343
|
+
</pre>
|
344
|
+
|
345
|
+
<h2>3. <a name="parallel">Your First Parallel Query</a></h2>
|
346
|
+
<p>
|
347
|
+
Data within the range is stored in two or more data base nodes in a parallel Query. This is called a partitioning.
|
348
|
+
Moreover you could replicate some of tables among database nodes even
|
349
|
+
in parallel query mode.
|
350
|
+
</p>
|
351
|
+
|
352
|
+
<p>To enable parallel query in pgpool-II, you must set up another
|
353
|
+
database called "System Database" (we will denote it as SystemDB from
|
354
|
+
this point).</p>
|
355
|
+
|
356
|
+
<p>SystemDB holds the user-defined rules to decide what data will be
|
357
|
+
saved in which database node. Another use of SystemDB is to merge
|
358
|
+
results sent back from the database nodes using dblink.</p>
|
359
|
+
|
360
|
+
<p>In this section, we will use three database nodes which we have set
|
361
|
+
up in section "1. <a href="#start">Let's Begin!</a>", and takes you
|
362
|
+
step by step to create a parallel query database system. We will use
|
363
|
+
pgbench again to create sample data.</p>
|
364
|
+
|
365
|
+
<h3>3.1. <a name="parallel-config">Configuring Parallel Query</a></h3>
|
366
|
+
|
367
|
+
<p>To enable the parallel query function, set <code>parallel_mode</code> to true in <code>pgpool.conf</code> file.</p>
|
368
|
+
|
369
|
+
<pre>parallel_mode = true</pre>
|
370
|
+
|
371
|
+
<p>Setting <code>paralle_mode</code> to true does not start parallel
|
372
|
+
query automatically. pgpool-II needs SystemDB and the rules
|
373
|
+
to know how to distribute data to the database nodes.</p>
|
374
|
+
|
375
|
+
<p>Also, dblink used by SystemDB makes connections to
|
376
|
+
pgpool-II. Therefore, <code>listen_addresses</code> needs to be
|
377
|
+
configured so that pgpool-II accepts those connections.</p>
|
378
|
+
|
379
|
+
<pre>listen_addresses = '*'</pre>
|
380
|
+
|
381
|
+
<p>
|
382
|
+
Attention: The replication is not done for the table that does the partitioning
|
383
|
+
though a parallel Query and the replication can be made effective at the same time.
|
384
|
+
|
385
|
+
<p>
|
386
|
+
Attention: You can have both partitioned tables and replicated
|
387
|
+
tables. However a table cannot be a partioned and replicated at
|
388
|
+
the same time. Because the data structure of partioned tables and
|
389
|
+
replicated tables is different, "bench_replication" database created
|
390
|
+
in section "2. <a href="#replication">Your First Replication</a>"
|
391
|
+
cannot be reused in parallel query mode.</p>
|
392
|
+
|
393
|
+
<pre>
|
394
|
+
replication_mode = true
|
395
|
+
load_balance_mode = false
|
396
|
+
</pre>
|
397
|
+
<p>
|
398
|
+
OR
|
399
|
+
</p>
|
400
|
+
<pre>
|
401
|
+
replication_mode = false
|
402
|
+
load_balance_mode = true
|
403
|
+
</pre>
|
404
|
+
|
405
|
+
<p>In this section, we will set <code>parallel_mode and load_balance_mode</code> to true,
|
406
|
+
<code>listen_addresses</code> to '*', <code>replication_mode</code>to false.</p>
|
407
|
+
|
408
|
+
<h3>3.2. <a name="system-db">Configuring SystemDB</a></h3>
|
409
|
+
|
410
|
+
<p> "System database" is just an ordinaly database. The only
|
411
|
+
requirement is that dblink functions and the dist_def table, which
|
412
|
+
describes partioning rule, must be installed in the system
|
413
|
+
database. You could have a system database on a database node, or you
|
414
|
+
could have multiple nodes having system database by using cascade
|
415
|
+
configuration in pgpool-II. </p>
|
416
|
+
|
417
|
+
<p>In this section, we will create SystemDB on the 5432 port
|
418
|
+
node. The following list is the configuration parameters for
|
419
|
+
SystemDB</p>
|
420
|
+
|
421
|
+
<pre>
|
422
|
+
system_db_hostname = 'localhost'
|
423
|
+
system_db_port = 5432
|
424
|
+
system_db_dbname = 'pgpool'
|
425
|
+
system_db_schema = 'pgpool_catalog'
|
426
|
+
system_db_user = 'pgpool'
|
427
|
+
system_db_password = ''
|
428
|
+
</pre>
|
429
|
+
|
430
|
+
<p>Actually, the above are the default settings of
|
431
|
+
<code>pgpool.conf</code>. Now, we must create a user called "pgpool",
|
432
|
+
and a database called "pgpool" owned by user "pgpool".</p>
|
433
|
+
|
434
|
+
<pre>
|
435
|
+
$ createuser -p 5432 pgpool
|
436
|
+
$ createdb -p 5432 -O pgpool pgpool
|
437
|
+
</pre>
|
438
|
+
|
439
|
+
<h4><p>3.2.1. Installing dblink</p></h4>
|
440
|
+
|
441
|
+
<p>Next, we must install dblink into "pgpool" database. dblink is one
|
442
|
+
of the tools included in the <code>contrib</code> directory in the
|
443
|
+
PostgreSQL source code.</p>
|
444
|
+
|
445
|
+
<p>To install dblink to your system, execute the following commands.</p>
|
446
|
+
|
447
|
+
<pre>
|
448
|
+
$ USE_PGXS=1 make -C contrib/dblink
|
449
|
+
$ USE_PGXS=1 make -C contrib/dblink install
|
450
|
+
</pre>
|
451
|
+
|
452
|
+
<p>After dblink has been installed into your system, we will define
|
453
|
+
dblink functions in the "pgpool" database. If PostgreSQL is installed in
|
454
|
+
<code>/usr/local/pgsql</code>, <code>dblink.sql</code> (a file with
|
455
|
+
function definitions) should have been installed in
|
456
|
+
<code>/usr/local/pgsql/share/contrib</code>. Now, execute the
|
457
|
+
following command to define dblink functions.</p>
|
458
|
+
|
459
|
+
<pre>$ psql -f /usr/local/pgsql/share/contrib/dblink.sql -p 5432 pgpool</pre>
|
460
|
+
|
461
|
+
<h4><p>3.2.2. Defining dist_def table</p></h4>
|
462
|
+
<p>
|
463
|
+
Define a table called "dist_def", which has the partitioning rule, in
|
464
|
+
database called "pgpool".
|
465
|
+
After installing pgpool-II, you will have <code>system_db.sql</code>,
|
466
|
+
which is the <code>psql</code> script to generate the system database.
|
467
|
+
</p>
|
468
|
+
<pre>
|
469
|
+
$ psql -f /usr/local/share/system_db.sql -p 5432 -U pgpool pgpool
|
470
|
+
</pre>
|
471
|
+
<p>
|
472
|
+
dist_def table is created in pgpool_catalog schema.
|
473
|
+
If you have configured
|
474
|
+
<code>system_db_schema</code> to use other schema, you need to edit
|
475
|
+
<code>system_db.sql</code> accordingly.</p>
|
476
|
+
|
477
|
+
<p>The definition for "dist_def" is as shown here, and the table name
|
478
|
+
cannot be changed.</p>
|
479
|
+
|
480
|
+
<pre>
|
481
|
+
CREATE TABLE pgpool_catalog.dist_def (
|
482
|
+
dbname text, -- database name
|
483
|
+
schema_name text, -- schema name
|
484
|
+
table_name text, -- table name
|
485
|
+
col_name text NOT NULL CHECK (col_name = ANY (col_list)), -- distribution key-column
|
486
|
+
col_list text[] NOT NULL, -- list of column names
|
487
|
+
type_list text[] NOT NULL, -- list of column types
|
488
|
+
dist_def_func text NOT NULL, -- distribution function name
|
489
|
+
PRIMARY KEY (dbname, schema_name, table_name)
|
490
|
+
);
|
491
|
+
</pre>
|
492
|
+
|
493
|
+
<p>A tuple stored in "dist_def" can be classified into two types.</p>
|
494
|
+
|
495
|
+
<ul>
|
496
|
+
<li>Distribution Rule (col_name, dist_def_func)</li>
|
497
|
+
<li>Table's meta-information (dbname, schema_name, table_name, col_list, type_list)</li>
|
498
|
+
</ul>
|
499
|
+
|
500
|
+
<p>A distribution rule decides how to distribute data to a
|
501
|
+
particular node. Data will be distributed depending on the value of
|
502
|
+
the "col_name" column. "dist_def_func" is a function that takes the value
|
503
|
+
of "col_name" as its argument, and returns an integer which
|
504
|
+
points to the appropriate database node ID where the data should be
|
505
|
+
stored.</p>
|
506
|
+
|
507
|
+
<p>A meta-information is used to rewrite queries. Parallel query
|
508
|
+
must rewrite queries so that the results sent back from the backend
|
509
|
+
nodes can be merged into one result.</p>
|
510
|
+
|
511
|
+
<h4><p>3.2.3. Defining replicate_def table</p></h4>
|
512
|
+
<p>
|
513
|
+
If you want to use replicated tables in SELECT in parallel mode, you
|
514
|
+
need to register information about such tables(replication rule) to a table
|
515
|
+
called replicate_def.
|
516
|
+
The replicate_def table has already been made when making it from the
|
517
|
+
system_db.sql file when dist_def is defined.
|
518
|
+
The replicate_def table is defined as follows.
|
519
|
+
</p>
|
520
|
+
<pre>
|
521
|
+
CREATE TABLE pgpool_catalog.replicate_def (
|
522
|
+
dbname text, -- database name
|
523
|
+
schema_name text, -- schema name
|
524
|
+
table_name text, -- table name
|
525
|
+
col_list text[] NOT NULL, -- list of column names
|
526
|
+
type_list text[] NOT NULL, -- list of column types
|
527
|
+
PRIMARY KEY (dbname, schema_name, table_name)
|
528
|
+
);
|
529
|
+
</pre>
|
530
|
+
<p>
|
531
|
+
replicate_def includes table's meta data information(dbname, schema_name, table_name, col_list, type_list).
|
532
|
+
</p>
|
533
|
+
<p>
|
534
|
+
All the query analysis and query rewriting process are dependent on the
|
535
|
+
information (table, column and type) stored in dist_def and/or
|
536
|
+
replicate_def table. If the information is not correct, analysis and
|
537
|
+
query rewriting process will produce wrong results.
|
538
|
+
</p>
|
539
|
+
|
540
|
+
<h3>3.3. <a name="dist-def">Defining Distribution Rules</a></h3>
|
541
|
+
|
542
|
+
<p>In this tutorial, we will define rules to distribute pgbench's
|
543
|
+
sample data into three database nodes. The sample data will be created
|
544
|
+
by "pgbench -i -s 3" (i.e. scale factor of 3). We will create a new
|
545
|
+
database called "bench_parallel" for this section.</p>
|
546
|
+
|
547
|
+
<p>In pgpool-II's source code, you can find the
|
548
|
+
<code>dist_def_pgbench.sql</code> file in <code>sample</code>
|
549
|
+
directoy. We will use this sample file here to create distribution
|
550
|
+
rules for pgbench. Execute the following command in extracted
|
551
|
+
pgpool-II source code directory.</p>
|
552
|
+
|
553
|
+
<pre>$ psql -f sample/dist_def_pgbench.sql -p 5432 pgpool</pre>
|
554
|
+
|
555
|
+
<p>Here is the explanation of <code>dist_def_pgbench.sql</code>.</p>
|
556
|
+
|
557
|
+
<p>Inside <code>dist_def_pgbench.sql</code>, we are inserting one
|
558
|
+
row into "dist_def" table. There is a distribution
|
559
|
+
function for accounts table.
|
560
|
+
For the key-column, aid is defined for accounts respectively (which is the primary keys)</p>
|
561
|
+
|
562
|
+
<pre>
|
563
|
+
INSERT INTO pgpool_catalog.dist_def VALUES (
|
564
|
+
'bench_parallel',
|
565
|
+
'public',
|
566
|
+
'accounts',
|
567
|
+
'aid',
|
568
|
+
ARRAY['aid', 'bid', 'abalance', 'filler'],
|
569
|
+
ARRAY['integer', 'integer', 'integer', 'character(84)'],
|
570
|
+
'pgpool_catalog.dist_def_accounts'
|
571
|
+
);
|
572
|
+
</pre>
|
573
|
+
|
574
|
+
<p>Now, we must define the distribution function for the accounts table. Note
|
575
|
+
that you can use the same function from different tables. Also, you
|
576
|
+
can define functions using languages other than SQL (e.g. PL/pgSQL,
|
577
|
+
PL/Tcl, etc.).</p>
|
578
|
+
|
579
|
+
<p>
|
580
|
+
The accounts table when data is initialized specifying 3 scale factor,
|
581
|
+
The value of the aid is 1 to 300000.
|
582
|
+
The function is defined so that data is evenly distributed to three data base nodes.
|
583
|
+
</p>
|
584
|
+
<p>
|
585
|
+
An SQL function will be defined as the return of the number of the data base node.
|
586
|
+
</p>
|
587
|
+
|
588
|
+
</p>
|
589
|
+
<pre>CREATE OR REPLACE FUNCTION pgpool_catalog.dist_def_branches(anyelement)
|
590
|
+
RETURNS integer AS $$
|
591
|
+
SELECT CASE WHEN $1 > 0 AND $1 <= 1 THEN 0
|
592
|
+
WHEN $1 > 1 AND $1 <= 2 THEN 1
|
593
|
+
ELSE 2
|
594
|
+
END;
|
595
|
+
$$ LANGUAGE sql;
|
596
|
+
</pre>
|
597
|
+
|
598
|
+
<h3>3.4. <a name="replicate-def">Defining Replication Rules</a></h3>
|
599
|
+
<p>
|
600
|
+
The replication rule is the one that which table decides the replication whether to be done.
|
601
|
+
</p>
|
602
|
+
|
603
|
+
<p>
|
604
|
+
Here, it is made with pgbench With the branches table and tellers table are registered.
|
605
|
+
|
606
|
+
As a result, the accounts table and the inquiry that uses the branches table
|
607
|
+
and the tellers table become possible.
|
608
|
+
</p>
|
609
|
+
<pre>
|
610
|
+
INSERT INTO pgpool_catalog.replicate_def VALUES (
|
611
|
+
'bench_parallel',
|
612
|
+
'public',
|
613
|
+
'branches',
|
614
|
+
ARRAY['bid', 'bbalance', 'filler'],
|
615
|
+
ARRAY['integer', 'integer', 'character(88)']
|
616
|
+
);
|
617
|
+
|
618
|
+
INSERT INTO pgpool_catalog.replicate_def VALUES (
|
619
|
+
'bench_parallel',
|
620
|
+
'public',
|
621
|
+
'tellers',
|
622
|
+
ARRAY['tid', 'bid', 'tbalance', 'filler'],
|
623
|
+
ARRAY['integer', 'integer', 'integer', 'character(84)']
|
624
|
+
);
|
625
|
+
</pre>
|
626
|
+
<p>
|
627
|
+
Replicate_def_pgbench.sql is prepared in sample directory.
|
628
|
+
|
629
|
+
In the directory that progresses the source code to define a replicate rule by using this as follows The psql command is executed.
|
630
|
+
</p>
|
631
|
+
<pre>
|
632
|
+
$ psql -f sample/replicate_def_pgbench.sql -p 5432 pgpool
|
633
|
+
</pre>
|
634
|
+
|
635
|
+
<h3>3.5. <a name="parallel-check">Checking Parallel Query</a></h3>
|
636
|
+
|
637
|
+
<p>To reflect the changes in <code>pgpool.conf</code>, pgpool-II must
|
638
|
+
be restarted. Please refer to section "1.5 <a
|
639
|
+
href="#start-shutdown">Starting/Stopping pgpool-II</a>".</p>
|
640
|
+
|
641
|
+
<p>After configuring <code>pgpool.conf</code> and restarting
|
642
|
+
pgpool-II, let's try and see if parallel query is working.</p>
|
643
|
+
|
644
|
+
<p>First, we need to create a database to be distributed. We will name
|
645
|
+
it "bench_parallel". This database needs to be created on all the
|
646
|
+
nodes. Use the <code>createdb</code> commands through pgpool-II, and the
|
647
|
+
databases will be created on all the nodes.</p>
|
648
|
+
|
649
|
+
<pre>$ createdb -p 9999 bench_parallel</pre>
|
650
|
+
|
651
|
+
<p>Then, we'll execute pgbench with <code>-i -s 3</code>
|
652
|
+
options. <code>-i</code> option initializes the database with
|
653
|
+
pre-defined tables and data. <code>-s</code> option specifies the
|
654
|
+
scale factor for initialization.</p>
|
655
|
+
|
656
|
+
<pre>$ pgbench -i -s 3 -p 9999 bench_parallel</pre>
|
657
|
+
|
658
|
+
<p>The tables and data created are shown in "3.3. <a
|
659
|
+
href="#dist-def">Defining Distribution Rules</a>".</p>
|
660
|
+
|
661
|
+
<p>One way to check if the data have been distributed correctly is to
|
662
|
+
execute a SELECT query via pgpool-II and directly on the backend, and
|
663
|
+
compare two results. If everything is configured right,
|
664
|
+
"bench_parallel" should be distributed as follows.</p>
|
665
|
+
|
666
|
+
<table border="1" align ="center">
|
667
|
+
<tr>
|
668
|
+
<th >Table Name</th>
|
669
|
+
<th >the number of lines</th>
|
670
|
+
</tr>
|
671
|
+
<tr>
|
672
|
+
<td>branches</td>
|
673
|
+
<td>3</td>
|
674
|
+
</tr>
|
675
|
+
<tr>
|
676
|
+
<td>tellers</td>
|
677
|
+
<td>30</td>
|
678
|
+
</tr>
|
679
|
+
<tr>
|
680
|
+
<td>accounts</td>
|
681
|
+
<td>300000</td>
|
682
|
+
</tr>
|
683
|
+
<tr>
|
684
|
+
<td>history</td>
|
685
|
+
<td>0</td>
|
686
|
+
</tr>
|
687
|
+
</table>
|
688
|
+
|
689
|
+
<p>Let's use a simple shell script to check the above on all the nodes
|
690
|
+
and via pgpool-II. The following script will display the minimum and
|
691
|
+
maximum values in accounts table using port 5432, 5433, 5434, and
|
692
|
+
9999.</p>
|
693
|
+
|
694
|
+
<pre>$ for port in 5432 5433 5434 9999; do
|
695
|
+
> echo $port
|
696
|
+
> psql -c "SELECT min(aid), max(aid) FROM accounts" -p $port bench_parallel
|
697
|
+
> done
|
698
|
+
</pre>
|
699
|
+
|
700
|
+
<div class="copyright">
|
701
|
+
<hr>
|
702
|
+
<copyright>
|
703
|
+
Copyright © 2003 – 2011 pgpool Global Development Group
|
704
|
+
</copyright>
|
705
|
+
</div>
|
706
|
+
</body>
|
707
|
+
</html>
|