├── Dockerfile ├── README.md ├── bin └── start-pgpool2 └── conf ├── pcp.conf.template └── pgpool.conf.template /Dockerfile: -------------------------------------------------------------------------------- 1 | # Pgpool2. 2 | 3 | FROM ubuntu:14.04 4 | MAINTAINER Thomas Quintana 5 | 6 | # Install Dependencies. 7 | RUN apt-get update && apt-get install -y libffi-dev libssl-dev pgpool2 python python-dev python-pip 8 | RUN pip install Jinja2 9 | 10 | # Post Install Configuration. 11 | ADD bin/start-pgpool2 /usr/bin/start-pgpool2 12 | RUN chmod +x /usr/bin/start-pgpool2 13 | ADD conf/pcp.conf.template /usr/share/pgpool2/pcp.conf.template 14 | ADD conf/pgpool.conf.template /usr/share/pgpool2/pgpool.conf.template 15 | 16 | # Start the container. 17 | CMD start-pgpool2 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Pgpool2 Dockerfile 2 | ================== 3 | 4 | This project can be used to deploy pgpool2 inside a Docker container for transparent failover between two postgresql hosts without requiring a floating IP address. 5 | 6 | ### Running the Container 7 | 8 | ```sudo docker run --name pgpool2 -e PGPOOL_BACKENDS=1:127.0.0.1:5432,2:127.0.0.1:5433 -p 5432:5432/tcp bettervoice/pgpool2-container:3.3.4``` 9 | 10 | ### Configuration Environment Variables 11 | 12 | **PCP_PORT** - The port used to listen for PCP commands. (default: 9898) 13 | 14 | **PCP_USER** - The user allowed to execute PCP commands. (default: postgres) 15 | 16 | **PCP_USER_PASSWORD** - The pcp user password. (default: bettervoice) 17 | 18 | **PGPOOL_PORT** - The port used by pgpool2 to listen for client connections. (default: 5432) 19 | 20 | **PGPOOL_BACKENDS** - A comma separated list of PostgeSQL server backends. The format for each backend is as follows: INDEX:HOST:PORT (default: 1:localhost:5432) 21 | -------------------------------------------------------------------------------- /bin/start-pgpool2: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | from jinja2 import Environment, FileSystemLoader 4 | from subprocess import check_call 5 | 6 | import hashlib 7 | import os 8 | 9 | def pgpool_get_configuration(): 10 | configuration = { } 11 | # Get the port pcp should listen on. 12 | value = os.getenv('PCP_PORT', 9898) 13 | configuration.update({ 'pcp_port': value }) 14 | # Get the PCP user. 15 | value = os.getenv('PCP_USER', 'postgres') 16 | configuration.update({ 'pcp_user': value }) 17 | # Get the PCP user password. 18 | value = os.getenv('PCP_USER_PASSWORD', 'bettervoice') 19 | hash = hashlib.md5() 20 | hash.update(value) 21 | configuration.update({ 'pcp_user_password': hash.hexdigest() }) 22 | # Get the port pgpool should listen on. 23 | value = os.getenv('PGPOOL_PORT', 5432) 24 | configuration.update({ 'pgpool_port': value }) 25 | # Get the configuration for the backends. 26 | # FORMAT - INDEX:HOST:PORT 27 | value = os.getenv('PGPOOL_BACKENDS', '1:localhost:5432').split(',') 28 | for item in value: 29 | if not len(item.split(':')) == 3: 30 | raise ValueError('Invalid Backend: %s' % item) 31 | configuration.update({ 'pgpool_backends': value }) 32 | return configuration 33 | 34 | def run(app, *args): 35 | check_call([app] + list(args)) 36 | 37 | def write(template, path): 38 | with open(path, "wb") as output: 39 | output.write(template) 40 | 41 | if __name__ == "__main__": 42 | # Initialize Jinja2 43 | loader = FileSystemLoader('/usr/share/pgpool2') 44 | templates = Environment(loader = loader) 45 | # Load the configuration into a dictionary. 46 | configuration = pgpool_get_configuration() 47 | # Write PCP user credentials. 48 | pcp = templates.get_template('pcp.conf.template') \ 49 | .render(configuration) 50 | write(pcp, '/etc/pgpool2/pcp.conf') 51 | pgpool = templates.get_template('pgpool.conf.template') \ 52 | .render(configuration) 53 | write(pgpool, '/etc/pgpool2/pgpool.conf') 54 | # Start the container. 55 | try: 56 | run('pgpool', '-n', '-f', '/etc/pgpool2/pgpool.conf', '-F', '/etc/pgpool2/pcp.conf') 57 | except KeyboardInterrupt: 58 | print 'Exiting...' -------------------------------------------------------------------------------- /conf/pcp.conf.template: -------------------------------------------------------------------------------- 1 | # PCP Client Authentication Configuration File 2 | # ============================================ 3 | # 4 | # This file contains user ID and his password for pgpool 5 | # communication manager authentication. 6 | # 7 | # Note that users defined here do not need to be PostgreSQL 8 | # users. These users are authorized ONLY for pgpool 9 | # communication manager. 10 | # 11 | # File Format 12 | # =========== 13 | # 14 | # List one UserID and password on a single line. They must 15 | # be concatenated together using ':' (colon) between them. 16 | # No spaces or tabs are allowed anywhere in the line. 17 | # 18 | # Example: 19 | # postgres:e8a48653851e28c69d0506508fb27fc5 20 | # 21 | # Be aware that there will be no spaces or tabs at the 22 | # beginning of the line! although the above example looks 23 | # like so. 24 | # 25 | # Lines beginning with '#' (pound) are comments and will 26 | # be ignored. Again, no spaces or tabs allowed before '#'. 27 | 28 | # USERID:MD5PASSWD 29 | {{ pcp_user }}:{{ pcp_user_password }} -------------------------------------------------------------------------------- /conf/pgpool.conf.template: -------------------------------------------------------------------------------- 1 | # ---------------------------- 2 | # pgPool-II configuration file 3 | # ---------------------------- 4 | # 5 | # This file consists of lines of the form: 6 | # 7 | # name = value 8 | # 9 | # Whitespace may be used. Comments are introduced with "#" anywhere on a line. 10 | # The complete list of parameter names and allowed values can be found in the 11 | # pgPool-II documentation. 12 | # 13 | # This file is read on server startup and when the server receives a SIGHUP 14 | # signal. If you edit the file on a running system, you have to SIGHUP the 15 | # server for the changes to take effect, or use "pgpool reload". Some 16 | # parameters, which are marked below, require a server shutdown and restart to 17 | # take effect. 18 | # 19 | 20 | 21 | #------------------------------------------------------------------------------ 22 | # CONNECTIONS 23 | #------------------------------------------------------------------------------ 24 | 25 | # - pgpool Connection Settings - 26 | 27 | listen_addresses = '*' 28 | # Host name or IP address to listen on: 29 | # '*' for all, '' for no TCP/IP connections 30 | # (change requires restart) 31 | port = {{ pgpool_port }} 32 | # Port number 33 | # (change requires restart) 34 | socket_dir = '/var/run/postgresql' 35 | # Unix domain socket path 36 | # The Debian package defaults to 37 | # /var/run/postgresql 38 | # (change requires restart) 39 | 40 | 41 | # - pgpool Communication Manager Connection Settings - 42 | pcp_listen_addresses = '*' 43 | 44 | pcp_port = {{ pcp_port }} 45 | # Port number for pcp 46 | # (change requires restart) 47 | pcp_socket_dir = '/var/run/postgresql' 48 | # Unix domain socket path for pcp 49 | # The Debian package defaults to 50 | # /var/run/postgresql 51 | # (change requires restart) 52 | 53 | # - Backend Connection Settings - 54 | 55 | #backend_hostname0 = 'host1' 56 | # Host name or IP address to connect to for backend 0 57 | #backend_port0 = 5432 58 | # Port number for backend 0 59 | #backend_weight0 = 1 60 | # Weight for backend 0 (only in load balancing mode) 61 | #backend_data_directory0 = '/data' 62 | # Data directory for backend 0 63 | #backend_flag0 = 'ALLOW_TO_FAILOVER' 64 | # Controls various backend behavior 65 | # ALLOW_TO_FAILOVER or DISALLOW_TO_FAILOVER 66 | #backend_hostname1 = 'host2' 67 | #backend_port1 = 5433 68 | #backend_weight1 = 1 69 | #backend_data_directory1 = '/data1' 70 | #backend_flag1 = 'ALLOW_TO_FAILOVER' 71 | {% for backend in pgpool_backends %} 72 | {% set tokens = backend.split(':') %} 73 | backend_hostname{{ tokens[0] }} = '{{ tokens[1] }}' 74 | backend_port{{ tokens[0] }} = {{ tokens[2] }} 75 | backend_weight{{ tokens[0] }} = 1 76 | backend_flag{{ tokens[0] }} = 'ALLOW_TO_FAILOVER' 77 | {% endfor %} 78 | 79 | # - Authentication - 80 | 81 | enable_pool_hba = off 82 | # Use pool_hba.conf for client authentication 83 | pool_passwd = 'pool_passwd' 84 | # File name of pool_passwd for md5 authentication. 85 | # "" disables pool_passwd. 86 | # (change requires restart) 87 | authentication_timeout = 60 88 | # Delay in seconds to complete client authentication 89 | # 0 means no timeout. 90 | 91 | # - SSL Connections - 92 | 93 | ssl = off 94 | # Enable SSL support 95 | # (change requires restart) 96 | #ssl_key = './server.key' 97 | # Path to the SSL private key file 98 | # (change requires restart) 99 | #ssl_cert = './server.cert' 100 | # Path to the SSL public certificate file 101 | # (change requires restart) 102 | #ssl_ca_cert = '' 103 | # Path to a single PEM format file 104 | # containing CA root certificate(s) 105 | # (change requires restart) 106 | #ssl_ca_cert_dir = '' 107 | # Directory containing CA root certificate(s) 108 | # (change requires restart) 109 | 110 | 111 | #------------------------------------------------------------------------------ 112 | # POOLS 113 | #------------------------------------------------------------------------------ 114 | 115 | # - Pool size - 116 | 117 | num_init_children = 32 118 | # Number of pools 119 | # (change requires restart) 120 | max_pool = 4 121 | # Number of connections per pool 122 | # (change requires restart) 123 | 124 | # - Life time - 125 | 126 | child_life_time = 300 127 | # Pool exits after being idle for this many seconds 128 | child_max_connections = 0 129 | # Pool exits after receiving that many connections 130 | # 0 means no exit 131 | connection_life_time = 0 132 | # Connection to backend closes after being idle for this many seconds 133 | # 0 means no close 134 | client_idle_limit = 0 135 | # Client is disconnected after being idle for that many seconds 136 | # (even inside an explicit transactions!) 137 | # 0 means no disconnection 138 | 139 | 140 | #------------------------------------------------------------------------------ 141 | # LOGS 142 | #------------------------------------------------------------------------------ 143 | 144 | # - Where to log - 145 | 146 | log_destination = 'stderr' 147 | # Where to log 148 | # Valid values are combinations of stderr, 149 | # and syslog. Default to stderr. 150 | 151 | # - What to log - 152 | 153 | print_timestamp = on 154 | # Print timestamp on each line 155 | # (change requires restart) 156 | 157 | log_connections = on 158 | # Log connections 159 | log_hostname = on 160 | # Hostname will be shown in ps status 161 | # and in logs if connections are logged 162 | log_statement = off 163 | # Log all statements 164 | log_per_node_statement = off 165 | # Log all statements 166 | # with node and backend informations 167 | log_standby_delay = 'none' 168 | # Log standby delay 169 | # Valid values are combinations of always, 170 | # if_over_threshold, none 171 | 172 | # - Syslog specific - 173 | 174 | syslog_facility = 'LOCAL0' 175 | # Syslog local facility. Default to LOCAL0 176 | syslog_ident = 'pgpool' 177 | # Syslog program identification string 178 | # Default to 'pgpool' 179 | 180 | # - Debug - 181 | 182 | debug_level = 0 183 | # Debug message verbosity level 184 | # 0 means no message, 1 or more mean verbose 185 | 186 | 187 | #------------------------------------------------------------------------------ 188 | # FILE LOCATIONS 189 | #------------------------------------------------------------------------------ 190 | 191 | pid_file_name = '/var/run/postgresql/pgpool.pid' 192 | # PID file name 193 | # (change requires restart) 194 | logdir = '/var/log/postgresql' 195 | # Directory of pgPool status file 196 | # (change requires restart) 197 | 198 | 199 | #------------------------------------------------------------------------------ 200 | # CONNECTION POOLING 201 | #------------------------------------------------------------------------------ 202 | 203 | connection_cache = on 204 | # Activate connection pools 205 | # (change requires restart) 206 | 207 | # Semicolon separated list of queries 208 | # to be issued at the end of a session 209 | # The default is for 8.3 and later 210 | reset_query_list = 'ABORT; DISCARD ALL' 211 | # The following one is for 8.2 and before 212 | #reset_query_list = 'ABORT; RESET ALL; SET SESSION AUTHORIZATION DEFAULT' 213 | 214 | 215 | #------------------------------------------------------------------------------ 216 | # REPLICATION MODE 217 | #------------------------------------------------------------------------------ 218 | 219 | replication_mode = off 220 | # Activate replication mode 221 | # (change requires restart) 222 | replicate_select = off 223 | # Replicate SELECT statements 224 | # when in replication or parallel mode 225 | # replicate_select is higher priority than 226 | # load_balance_mode. 227 | 228 | insert_lock = off 229 | # Automatically locks a dummy row or a table 230 | # with INSERT statements to keep SERIAL data 231 | # consistency 232 | # Without SERIAL, no lock will be issued 233 | lobj_lock_table = '' 234 | # When rewriting lo_creat command in 235 | # replication mode, specify table name to 236 | # lock 237 | 238 | # - Degenerate handling - 239 | 240 | replication_stop_on_mismatch = off 241 | # On disagreement with the packet kind 242 | # sent from backend, degenerate the node 243 | # which is most likely "minority" 244 | # If off, just force to exit this session 245 | 246 | failover_if_affected_tuples_mismatch = off 247 | # On disagreement with the number of affected 248 | # tuples in UPDATE/DELETE queries, then 249 | # degenerate the node which is most likely 250 | # "minority". 251 | # If off, just abort the transaction to 252 | # keep the consistency 253 | 254 | 255 | #------------------------------------------------------------------------------ 256 | # LOAD BALANCING MODE 257 | #------------------------------------------------------------------------------ 258 | 259 | load_balance_mode = off 260 | # Activate load balancing mode 261 | # (change requires restart) 262 | ignore_leading_white_space = on 263 | # Ignore leading white spaces of each query 264 | white_function_list = '' 265 | # Comma separated list of function names 266 | # that don't write to database 267 | # Regexp are accepted 268 | black_function_list = 'nextval,setval' 269 | # Comma separated list of function names 270 | # that write to database 271 | # Regexp are accepted 272 | 273 | 274 | #------------------------------------------------------------------------------ 275 | # MASTER/SLAVE MODE 276 | #------------------------------------------------------------------------------ 277 | 278 | master_slave_mode = off 279 | # Activate master/slave mode 280 | # (change requires restart) 281 | master_slave_sub_mode = 'slony' 282 | # Master/slave sub mode 283 | # Valid values are combinations slony or 284 | # stream. Default is slony. 285 | # (change requires restart) 286 | 287 | # - Streaming - 288 | 289 | sr_check_period = 0 290 | # Streaming replication check period 291 | # Disabled (0) by default 292 | sr_check_user = 'nobody' 293 | # Streaming replication check user 294 | # This is necessary even if you disable 295 | # streaming replication delay check with 296 | # sr_check_period = 0 297 | sr_check_password = '' 298 | # Password for streaming replication check user 299 | delay_threshold = 0 300 | # Threshold before not dispatching query to standby node 301 | # Unit is in bytes 302 | # Disabled (0) by default 303 | 304 | # - Special commands - 305 | 306 | follow_master_command = '' 307 | # Executes this command after master failover 308 | # Special values: 309 | # %d = node id 310 | # %h = host name 311 | # %p = port number 312 | # %D = database cluster path 313 | # %m = new master node id 314 | # %H = hostname of the new master node 315 | # %M = old master node id 316 | # %P = old primary node id 317 | # %r = new master port number 318 | # %R = new master database cluster path 319 | # %% = '%' character 320 | 321 | 322 | #------------------------------------------------------------------------------ 323 | # PARALLEL MODE 324 | #------------------------------------------------------------------------------ 325 | 326 | parallel_mode = off 327 | # Activates parallel query mode 328 | # (change requires restart) 329 | pgpool2_hostname = '' 330 | # Set pgpool2 hostname 331 | # (change requires restart) 332 | 333 | # - System DB info - 334 | 335 | system_db_hostname = 'localhost' 336 | # (change requires restart) 337 | system_db_port = 5432 338 | # (change requires restart) 339 | system_db_dbname = 'pgpool' 340 | # (change requires restart) 341 | system_db_schema = 'pgpool_catalog' 342 | # (change requires restart) 343 | system_db_user = 'pgpool' 344 | # (change requires restart) 345 | system_db_password = '' 346 | # (change requires restart) 347 | 348 | 349 | #------------------------------------------------------------------------------ 350 | # HEALTH CHECK 351 | #------------------------------------------------------------------------------ 352 | 353 | health_check_period = 0 354 | # Health check period 355 | # Disabled (0) by default 356 | health_check_timeout = 20 357 | # Health check timeout 358 | # 0 means no timeout 359 | health_check_user = 'nobody' 360 | # Health check user 361 | health_check_password = '' 362 | # Password for health check user 363 | health_check_max_retries = 0 364 | # Maximum number of times to retry a failed health check before giving up. 365 | health_check_retry_delay = 1 366 | # Amount of time to wait (in seconds) between retries. 367 | 368 | 369 | #------------------------------------------------------------------------------ 370 | # FAILOVER AND FAILBACK 371 | #------------------------------------------------------------------------------ 372 | 373 | failover_command = '' 374 | # Executes this command at failover 375 | # Special values: 376 | # %d = node id 377 | # %h = host name 378 | # %p = port number 379 | # %D = database cluster path 380 | # %m = new master node id 381 | # %H = hostname of the new master node 382 | # %M = old master node id 383 | # %P = old primary node id 384 | # %r = new master port number 385 | # %R = new master database cluster path 386 | # %% = '%' character 387 | failback_command = '' 388 | # Executes this command at failback. 389 | # Special values: 390 | # %d = node id 391 | # %h = host name 392 | # %p = port number 393 | # %D = database cluster path 394 | # %m = new master node id 395 | # %H = hostname of the new master node 396 | # %M = old master node id 397 | # %P = old primary node id 398 | # %r = new master port number 399 | # %R = new master database cluster path 400 | # %% = '%' character 401 | 402 | fail_over_on_backend_error = on 403 | # Initiates failover when reading/writing to the 404 | # backend communication socket fails 405 | # If set to off, pgpool will report an 406 | # error and disconnect the session. 407 | 408 | search_primary_node_timeout = 10 409 | # Timeout in seconds to search for the 410 | # primary node when a failover occurs. 411 | # 0 means no timeout, keep searching 412 | # for a primary node forever. 413 | 414 | #------------------------------------------------------------------------------ 415 | # ONLINE RECOVERY 416 | #------------------------------------------------------------------------------ 417 | 418 | recovery_user = 'nobody' 419 | # Online recovery user 420 | recovery_password = '' 421 | # Online recovery password 422 | recovery_1st_stage_command = '' 423 | # Executes a command in first stage 424 | recovery_2nd_stage_command = '' 425 | # Executes a command in second stage 426 | recovery_timeout = 90 427 | # Timeout in seconds to wait for the 428 | # recovering node's postmaster to start up 429 | # 0 means no wait 430 | client_idle_limit_in_recovery = 0 431 | # Client is disconnected after being idle 432 | # for that many seconds in the second stage 433 | # of online recovery 434 | # 0 means no disconnection 435 | # -1 means immediate disconnection 436 | 437 | 438 | #------------------------------------------------------------------------------ 439 | # WATCHDOG 440 | #------------------------------------------------------------------------------ 441 | 442 | # - Enabling - 443 | 444 | use_watchdog = off 445 | # Activates watchdog 446 | # (change requires restart) 447 | 448 | # -Connection to up stream servers - 449 | 450 | trusted_servers = '' 451 | # trusted server list which are used 452 | # to confirm network connection 453 | # (hostA,hostB,hostC,...) 454 | # (change requires restart) 455 | ping_path = '/bin' 456 | # ping command path 457 | # (change requires restart) 458 | 459 | # - Watchdog communication Settings - 460 | 461 | wd_hostname = '' 462 | # Host name or IP address of this watchdog 463 | # (change requires restart) 464 | wd_port = 9000 465 | # port number for watchdog service 466 | # (change requires restart) 467 | wd_authkey = '' 468 | # Authentication key for watchdog communication 469 | # (change requires restart) 470 | 471 | # - Virtual IP control Setting - 472 | 473 | delegate_IP = '' 474 | # delegate IP address 475 | # If this is empty, virtual IP never bring up. 476 | # (change requires restart) 477 | ifconfig_path = '/sbin' 478 | # ifconfig command path 479 | # (change requires restart) 480 | if_up_cmd = 'ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0' 481 | # startup delegate IP command 482 | # (change requires restart) 483 | if_down_cmd = 'ifconfig eth0:0 down' 484 | # shutdown delegate IP command 485 | # (change requires restart) 486 | 487 | arping_path = '/usr/sbin' # arping command path 488 | # (change requires restart) 489 | 490 | arping_cmd = 'arping -U $_IP_$ -w 1' 491 | # arping command 492 | # (change requires restart) 493 | 494 | # - Behaivor on escalation Setting - 495 | 496 | clear_memqcache_on_escalation = on 497 | # Clear all the query cache on shared memory 498 | # when standby pgpool escalate to active pgpool 499 | # (= virtual IP holder). 500 | # This should be off if client connects to pgpool 501 | # not using virtual IP. 502 | # (change requires restart) 503 | wd_escalation_command = '' 504 | # Executes this command at escalation on new active pgpool. 505 | # (change requires restart) 506 | 507 | # - Lifecheck Setting - 508 | 509 | # -- common -- 510 | 511 | wd_lifecheck_method = 'heartbeat' 512 | # Method of watchdog lifecheck ('heartbeat' or 'query') 513 | # (change requires restart) 514 | wd_interval = 10 515 | # lifecheck interval (sec) > 0 516 | # (change requires restart) 517 | 518 | # -- heartbeat mode -- 519 | 520 | wd_heartbeat_port = 9694 521 | # Port number for receiving heartbeat signal 522 | # (change requires restart) 523 | wd_heartbeat_keepalive = 2 524 | # Interval time of sending heartbeat signal (sec) 525 | # (change requires restart) 526 | wd_heartbeat_deadtime = 30 527 | # Deadtime interval for heartbeat signal (sec) 528 | # (change requires restart) 529 | heartbeat_destination0 = 'host0_ip1' 530 | # Host name or IP address of destination 0 531 | # for sending heartbeat signal. 532 | # (change requires restart) 533 | heartbeat_destination_port0 = 9694 534 | # Port number of destination 0 for sending 535 | # heartbeat signal. Usually this is the 536 | # same as wd_heartbeat_port. 537 | # (change requires restart) 538 | heartbeat_device0 = '' 539 | # Name of NIC device (such like 'eth0') 540 | # used for sending/receiving heartbeat 541 | # signal to/from destination 0. 542 | # This works only when this is not empty 543 | # and pgpool has root privilege. 544 | # (change requires restart) 545 | 546 | #heartbeat_destination1 = 'host0_ip2' 547 | #heartbeat_destination_port1 = 9694 548 | #heartbeat_device1 = '' 549 | 550 | # -- query mode -- 551 | 552 | wd_life_point = 3 553 | # lifecheck retry times 554 | # (change requires restart) 555 | wd_lifecheck_query = 'SELECT 1' 556 | # lifecheck query to pgpool from watchdog 557 | # (change requires restart) 558 | wd_lifecheck_dbname = 'template1' 559 | # Database name connected for lifecheck 560 | # (change requires restart) 561 | wd_lifecheck_user = 'nobody' 562 | # watchdog user monitoring pgpools in lifecheck 563 | # (change requires restart) 564 | wd_lifecheck_password = '' 565 | # Password for watchdog user in lifecheck 566 | # (change requires restart) 567 | 568 | # - Other pgpool Connection Settings - 569 | 570 | #other_pgpool_hostname0 = 'host0' 571 | # Host name or IP address to connect to for other pgpool 0 572 | # (change requires restart) 573 | #other_pgpool_port0 = 5432 574 | # Port number for othet pgpool 0 575 | # (change requires restart) 576 | #other_wd_port0 = 9000 577 | # Port number for othet watchdog 0 578 | # (change requires restart) 579 | #other_pgpool_hostname1 = 'host1' 580 | #other_pgpool_port1 = 5432 581 | #other_wd_port1 = 9000 582 | 583 | 584 | #------------------------------------------------------------------------------ 585 | # OTHERS 586 | #------------------------------------------------------------------------------ 587 | relcache_expire = 0 588 | # Life time of relation cache in seconds. 589 | # 0 means no cache expiration(the default). 590 | # The relation cache is used for cache the 591 | # query result against PostgreSQL system 592 | # catalog to obtain various information 593 | # including table structures or if it's a 594 | # temporary table or not. The cache is 595 | # maintained in a pgpool child local memory 596 | # and being kept as long as it survives. 597 | # If someone modify the table by using 598 | # ALTER TABLE or some such, the relcache is 599 | # not consistent anymore. 600 | # For this purpose, cache_expiration 601 | # controls the life time of the cache. 602 | 603 | relcache_size = 256 604 | # Number of relation cache 605 | # entry. If you see frequently: 606 | # "pool_search_relcache: cache replacement happend" 607 | # in the pgpool log, you might want to increate this number. 608 | 609 | check_temp_table = on 610 | # If on, enable temporary table check in SELECT statements. 611 | # This initiates queries against system catalog of primary/master 612 | # thus increases load of master. 613 | # If you are absolutely sure that your system never uses temporary tables 614 | # and you want to save access to primary/master, you could turn this off. 615 | # Default is on. 616 | 617 | 618 | #------------------------------------------------------------------------------ 619 | # ON MEMORY QUERY MEMORY CACHE 620 | #------------------------------------------------------------------------------ 621 | memory_cache_enabled = off 622 | # If on, use the memory cache functionality, off by default 623 | memqcache_method = 'shmem' 624 | # Cache storage method. either 'shmem'(shared memory) or 625 | # 'memcached'. 'shmem' by default 626 | # (change requires restart) 627 | memqcache_memcached_host = 'localhost' 628 | # Memcached host name or IP address. Mandatory if 629 | # memqcache_method = 'memcached'. 630 | # Defaults to localhost. 631 | # (change requires restart) 632 | memqcache_memcached_port = 11211 633 | # Memcached port number. Mondatory if memqcache_method = 'memcached'. 634 | # Defaults to 11211. 635 | # (change requires restart) 636 | memqcache_total_size = 67108864 637 | # Total memory size in bytes for storing memory cache. 638 | # Mandatory if memqcache_method = 'shmem'. 639 | # Defaults to 64MB. 640 | # (change requires restart) 641 | memqcache_max_num_cache = 1000000 642 | # Total number of cache entries. Mandatory 643 | # if memqcache_method = 'shmem'. 644 | # Each cache entry consumes 48 bytes on shared memory. 645 | # Defaults to 1,000,000(45.8MB). 646 | # (change requires restart) 647 | memqcache_expire = 0 648 | # Memory cache entry life time specified in seconds. 649 | # 0 means infinite life time. 0 by default. 650 | # (change requires restart) 651 | memqcache_auto_cache_invalidation = on 652 | # If on, invalidation of query cache is triggered by corresponding 653 | # DDL/DML/DCL(and memqcache_expire). If off, it is only triggered 654 | # by memqcache_expire. on by default. 655 | # (change requires restart) 656 | memqcache_maxcache = 409600 657 | # Maximum SELECT result size in bytes. 658 | # Must be smaller than memqcache_cache_block_size. Defaults to 400KB. 659 | # (change requires restart) 660 | memqcache_cache_block_size = 1048576 661 | # Cache block size in bytes. Mandatory if memqcache_method = 'shmem'. 662 | # Defaults to 1MB. 663 | # (change requires restart) 664 | memqcache_oiddir = '/var/log/pgpool/oiddir' 665 | # Temporary work directory to record table oids 666 | # (change requires restart) 667 | white_memqcache_table_list = '' 668 | # Comma separated list of table names to memcache 669 | # that don't write to database 670 | # Regexp are accepted 671 | black_memqcache_table_list = '' 672 | # Comma separated list of table names not to memcache 673 | # that don't write to database 674 | # Regexp are accepted 675 | 676 | --------------------------------------------------------------------------------