📜 ⬆️ ⬇️

PostgreSQL 9.3 + Pgpool-II

I decided to share with you the experience of setting up a PostgreSQL 9.3 cluster consisting of two nodes, managed by pgpool-II, without using Stream Replication (WAL). I hope someone will be interested.

Scheme:

image
')
As you understand, these will be two separate servers that will be managed by pgpool-II.

PostgreSQL node configuration:
Both servers are identical in their hardware components.

Disks:


Example,
 Filesystem Size Used Avail Use% Mounted on
 / dev / sda3 48G 7.4G 38G 17% /
 tmpfs 7.8G 0 7.8G 0% / dev / shm
 / dev / sda1 194M 28M 157M 15% / boot
 / dev / sdb1 99G 4.9G 89G 6% /var/lib/pgsql/9.3/data/pg_xlog
 / dev / sdc1 493G 234G 234G 50% /var/lib/pgsql/9.3/my_data


Pgpool-II node configuration:

Disks:


I will not go into details about installing PostgreSQL, since it is standard.

Configure pgpool-II.
For the basis of the pgpool-II setup, I took the instruction from the official site: www.pgpool.net/pgpool-web/contrib_docs/simple_sr_setting2_3.3/index.html

I would like to pay attention only to the most important points:

#------------------------------------------------------------------------------ # CONNECTIONS #------------------------------------------------------------------------------ # - pgpool Connection Settings - listen_addresses = '*' port = 9999 socket_dir = '/tmp' pcp_port = 9898 pcp_socket_dir = '/tmp' # - Authentication - enable_pool_hba = off pool_passwd = '' log_destination = 'syslog' #------------------------------------------------------------------------------ # REPLICATION MODE ( pgpool,          ) #------------------------------------------------------------------------------ replication_mode = on replicate_select = on insert_lock = on lobj_lock_table = '' replication_stop_on_mismatch = off failover_if_affected_tuples_mismatch = off #------------------------------------------------------------------------------ # LOAD BALANCING MODE ( pgpool,    SELECT     ) #------------------------------------------------------------------------------ load_balance_mode = on ignore_leading_white_space = on white_function_list = '' black_function_list = 'nextval,setval' follow_master_command = '/etc/pgpool-II/failover.sh %d "%h" %p %D %m %M "%H" %P' #------------------------------------------------------------------------------ # FAILOVER AND FAILBACK #------------------------------------------------------------------------------ failover_command = '/etc/pgpool-II/failover.sh %d %P %H %R' failback_command = '' fail_over_on_backend_error = on search_primary_node_timeout = 10 #------------------------------------------------------------------------------ # ONLINE RECOVERY (  ,  ,   pgpool,      pgpool.         ,          ) #------------------------------------------------------------------------------ recovery_user = 'postgres' recovery_password = '' recovery_1st_stage_command = 'basebackup.sh' recovery_2nd_stage_command = '' recovery_timeout = 90 client_idle_limit_in_recovery = 0 #------------------------------------------------------------------------------ # WATCHDOG #------------------------------------------------------------------------------ # - Enabling - use_watchdog = off trusted_servers = 'IP--pgpool-' ping_path = '/bin' wd_hostname = 'VRRIP IP.     watchdog' wd_port = 9000 wd_authkey = '' delegate_IP = 'VRRIP' ifconfig_path = '/home/apache/sbin' if_up_cmd = 'ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0' if_down_cmd = 'ifconfig eth0:0 down' arping_path = '/home/apache/sbin' arping_cmd = 'arping -U $_IP_$ -w 1' clear_memqcache_on_escalation = on wd_escalation_command = '' wd_lifecheck_method = 'heartbeat' wd_interval = 10 wd_heartbeat_port = 9694 wd_heartbeat_keepalive = 2 wd_heartbeat_deadtime = 30 wd_life_point = 3 wd_lifecheck_query = 'SELECT 1' wd_lifecheck_dbname = 'template1' wd_lifecheck_user = 'nobody' wd_lifecheck_password = '' ssl_key = '' ssl_cert = '' ssl_ca_cert = '' ssl_ca_cert_dir = '' listen_backlog_multiplier = 2 log_line_prefix = '' log_error_verbosity = 'DEFAULT' client_min_messages = 'notice' log_min_messages = 'warning' database_redirect_preference_list = '' app_name_redirect_preference_list = '' allow_sql_comments = off connect_timeout = 10000 check_unlogged_table = off backend_hostname0 = '  ' backend_port0 = 5432 backend_weight0 = 1 backend_data_directory0 = '/var/lib/pgsql/9.3/data' backend_flag0= 'ALLOW_TO_FAILOVER' backend_hostname1 = '  ' backend_port1 = 5432 backend_weight1 = 1 backend_data_directory1 = '/var/lib/pgsql/9.3/data' backend_flag1= 'ALLOW_TO_FAILOVER' other_pgpool_hostname0 = '' other_pgpool_port0 = other_wd_port0 = heartbeat_destination0 = '' heartbeat_destination_port0 = heartbeat_device0 = '' 

After configuring the configuration file, we start the pgpool service. You can also configure pgpooladmin to monitor the status of the nodes.

I did this according to the instructions from here:
www.pgpool.net/docs/pgpoolAdmin/en/install.html

You can also view the status of nodes with PostgreSQL by running the command on pgpool:
 pcp_node_info 10 " pgpool-" 9898 postgres postgres 0 pcp_node_info 10 " pgpool-" 9898 postgres postgres 1 

Next, we check the operation of our scheme - we create an empty database through pgpool. This can be done in two ways:
1) via pgadmin, connecting to the IP address of pgpool-II;
2) running the command on the node with pgpool: createdb -p 9999 bench_replication

Minuses:

Pros:

Based on the instructions on the link: www.pgpool.net/pgpool-web/contrib_docs/simple_sr_setting2_3.3/index.html

Source: https://habr.com/ru/post/263225/


All Articles