Guest User

Untitled

a guest
May 7th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. listen_addresses = '*'
  2. port = 9999
  3. socket_dir = '/tmp'
  4. pcp_listen_addresses = '*'
  5. pcp_port = 9898
  6. pcp_socket_dir = '/tmp'
  7. listen_backlog_multiplier = 2
  8.  
  9. backend_hostname0 = 'masterip'
  10. backend_port0 = 5432
  11. backend_weight0 = 1
  12.  
  13. backend_data_directory0 = '/var/lib/pgsql/data'
  14. backend_flag0 = 'ALLOW_TO_FAILOVER'
  15. backend_hostname1 = 'slaveip'
  16. backend_port1 = 5432
  17. backend_weight1 = 1
  18. backend_data_directory1 = '/var/lib/pgsql/data'
  19. backend_flag1 = 'ALLOW_TO_FAILOVER'
  20.  
  21. enable_pool_hba = off
  22. pool_passwd = 'pool_passwd'
  23. authentication_timeout = 60
  24.  
  25. ssl = off
  26. num_init_children = 32
  27. max_pool = 4
  28. child_life_time = 300
  29. child_max_connections = 0
  30. connection_life_time = 0
  31. client_idle_limit = 0
  32.  
  33. log_destination = 'syslog'
  34. log_line_prefix = '%t: pid %p: '
  35. log_connections = off
  36. log_hostname = off
  37. log_statement = off
  38. log_per_node_statement = off
  39. log_standby_delay = 'if_over_threshold'
  40.  
  41.  
  42. syslog_facility = 'LOCAL0'
  43. syslog_ident = 'pgpool'
  44. debug_level = 0
  45.  
  46. pid_file_name = '/var/run/pgpool/pgpool.pid'
  47. logdir = '/var/log/pgpool'
  48. connection_cache = on
  49. reset_query_list = 'ABORT; DISCARD ALL'
  50. replication_mode = off
  51. replicate_select = off
  52. insert_lock = off
  53.  
  54. master_slave_mode = on
  55. master_slave_sub_mode = 'stream'
  56. sr_check_period = 10
  57. sr_check_user = 'postgres'
  58. sr_check_password = 'password'
  59. delay_threshold = 10000000
  60.  
  61. follow_master_command = ''
  62. health_check_period = 5
  63. health_check_timeout = 10
  64. health_check_user = 'postgres'
  65. health_check_password = 'password'
  66. health_check_max_retries = 10
  67. health_check_retry_delay = 2
  68. connect_timeout = 10000
  69.  
  70. failover_command = '/etc/pgpool-II/failover.sh %d %P %H %R'
  71. failback_command = ''
  72.  
  73. recovery_user = 'postgres'
  74. recovery_password = 'password'
  75. recovery_1st_stage_command = 'recovery_1st_stage.sh'
  76. recovery_2nd_stage_command = ''
  77. recovery_timeout = 90
  78. client_idle_limit_in_recovery = 0
  79.  
  80. #! /bin/sh -x
  81. # Execute command by failover.
  82. # special values: %d = node id
  83. # %h = host name
  84. # %p = port number
  85. # %D = database cluster path
  86. # %m = new master node id
  87. # %M = old master node id
  88. # %H = new master node host name
  89. # %P = old primary node id
  90. # %R = new master database cluster path
  91. # %r = new master port number
  92. # %% = '%' character
  93.  
  94. falling_node=$1 # %d
  95. old_primary=$2 # %P
  96. new_primary=$3 # %H
  97. pgdata=$4 # %R
  98.  
  99. log=/var/log/pgpool/failover.log
  100.  
  101. date >> $log
  102. echo "failed_node_id=$falling_node new_primary=$new_primary" >> $log
  103.  
  104. if [ $falling_node = $old_primary ]; then
  105. if [ $UID -eq 0 ]
  106. then
  107. su postgres -c "ssh postgres@$new_primary /usr/bin/pg_ctl promote -D $pgdata"
  108. else
  109. ssh postgres@$new_primary /usr/bin/pg_ctl promote -D $pgdata
  110. fi
  111. exit 0;
  112. fi;
  113.  
  114. #!/bin/bash -x
  115. # Recovery script for streaming replication.
  116.  
  117. pgdata=$1
  118. remote_host=$2
  119. remote_pgdata=$3
  120. port=$4
  121.  
  122.  
  123. archivedir=/var/lib/pgsql/incrementalbackup/archivedwals
  124. hostname=$(hostname)
  125.  
  126. ssh -T postgres@$remote_host
  127. rm -rf $remote_pgdata
  128. /usr/bin/pg_basebackup -h $hostname -U repuser -D $remote_pgdata -x -c fast
  129. rm -rf $archivedir/*
  130.  
  131. cd $remote_pgdata
  132. #cp postgresql.conf postgresql.conf.bak
  133. #sed -e 's/#*hot_standby = off/hot_standby = on/' postgresql.conf.bak > postgresql.conf
  134. #rm -f postgresql.conf.bak
  135. cat > recovery.conf << EOT
  136. standby_mode = 'on'
  137. primary_conninfo = 'host="$hostname" port=$port user=repuser'
  138. restore_command = 'scp $hostname:$archivedir/%f %p'
  139. EOT
  140. "
Add Comment
Please, Sign In to add comment