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