pgcat.toml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #
  2. # PgCat config example.
  3. #
  4. #
  5. # General pooler settings
  6. [general]
  7. # What IP to run on, 0.0.0.0 means accessible from everywhere.
  8. host = "0.0.0.0"
  9. # Port to run on, same as PgBouncer used in this example.
  10. port = 6432
  11. # Whether to enable prometheus exporter or not.
  12. enable_prometheus_exporter = true
  13. # Port at which prometheus exporter listens on.
  14. prometheus_exporter_port = 9930
  15. # How long to wait before aborting a server connection (ms).
  16. connect_timeout = 5000
  17. # How much time to give `SELECT 1` health check query to return with a result (ms).
  18. healthcheck_timeout = 1000
  19. # How long to keep connection available for immediate re-use, without running a healthcheck query on it
  20. healthcheck_delay = 30000
  21. # How much time to give clients during shutdown before forcibly killing client connections (ms).
  22. shutdown_timeout = 60000
  23. # For how long to ban a server if it fails a health check (seconds).
  24. ban_time = 60 # seconds
  25. # If we should log client connections
  26. log_client_connections = false
  27. # If we should log client disconnections
  28. log_client_disconnections = false
  29. # TLS
  30. # tls_certificate = "server.cert"
  31. # tls_private_key = "server.key"
  32. # Credentials to access the virtual administrative database (pgbouncer or pgcat)
  33. # Connecting to that database allows running commands like `SHOW POOLS`, `SHOW DATABASES`, etc..
  34. admin_username = "postgres"
  35. admin_password = "postgres"
  36. # pool
  37. # configs are structured as pool.<pool_name>
  38. # the pool_name is what clients use as database name when connecting
  39. # For the example below a client can connect using "postgres://sharding_user:sharding_user@pgcat_host:pgcat_port/sharded"
  40. [pools.postgres]
  41. # Pool mode (see PgBouncer docs for more).
  42. # session: one server connection per connected client
  43. # transaction: one server connection per client transaction
  44. pool_mode = "transaction"
  45. # If the client doesn't specify, route traffic to
  46. # this role by default.
  47. #
  48. # any: round-robin between primary and replicas,
  49. # replica: round-robin between replicas only without touching the primary,
  50. # primary: all queries go to the primary unless otherwise specified.
  51. default_role = "any"
  52. # Query parser. If enabled, we'll attempt to parse
  53. # every incoming query to determine if it's a read or a write.
  54. # If it's a read query, we'll direct it to a replica. Otherwise, if it's a write,
  55. # we'll direct it to the primary.
  56. query_parser_enabled = true
  57. # If the query parser is enabled and this setting is enabled, the primary will be part of the pool of databases used for
  58. # load balancing of read queries. Otherwise, the primary will only be used for write
  59. # queries. The primary can always be explicitly selected with our custom protocol.
  60. primary_reads_enabled = true
  61. # So what if you wanted to implement a different hashing function,
  62. # or you've already built one and you want this pooler to use it?
  63. #
  64. # Current options:
  65. #
  66. # pg_bigint_hash: PARTITION BY HASH (Postgres hashing function)
  67. # sha1: A hashing function based on SHA1
  68. #
  69. sharding_function = "pg_bigint_hash"
  70. # Credentials for users that may connect to this cluster
  71. [pools.postgres.users.0]
  72. username = "postgres"
  73. password = "postgres"
  74. # Maximum number of server connections that can be established for this user
  75. # The maximum number of connection from a single Pgcat process to any database in the cluster
  76. # is the sum of pool_size across all users.
  77. pool_size = 9
  78. # Maximum query duration. Dangerous, but protects against DBs that died in a non-obvious way.
  79. statement_timeout = 0
  80. # Shard 0
  81. [pools.postgres.shards.0]
  82. # [ host, port, role ]
  83. servers = [
  84. [ "postgres", 5432, "primary" ],
  85. [ "postgres", 5432, "replica" ]
  86. ]
  87. # Database name (e.g. "postgres")
  88. database = "postgres"
  89. [pools.postgres.shards.1]
  90. servers = [
  91. [ "postgres", 5432, "primary" ],
  92. [ "postgres", 5432, "replica" ],
  93. ]
  94. database = "postgres"
  95. [pools.postgres.shards.2]
  96. servers = [
  97. [ "postgres", 5432, "primary" ],
  98. [ "postgres", 5432, "replica" ],
  99. ]
  100. database = "postgres"