Advertisement
Guest User

Untitled

a guest
May 5th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.44 KB | None | 0 0
  1. ;; database name = connect string
  2. ;;
  3. ;; connect string params:
  4. ;; dbname= host= port= user= password=
  5. ;; client_encoding= datestyle= timezone=
  6. ;; pool_size= connect_query=
  7. [databases]
  8.  
  9. {{ $default_pool_mode := "session" }}
  10. {{ $default_pool_size := "90" }}
  11. {{ range $key, $pairs := tree "databases" | byKey }}
  12. {{ $schema := $key | printf "databases/%s/schema" }}
  13. {{ $host := $key | printf "databases/%s/host" }}
  14. {{ $pool_mode := $key | printf "databases/%s/pool_mode" }}
  15. {{ $pool_size := $key | printf "databases/%s/pool_size" }}
  16. {{ with $pairs }}
  17. {{ $key }} = dbname={{ key $schema }} host={{ keyOrDefault $host "postgres.service.consul" }} pool_mode={{ keyOrDefault $pool_mode $default_pool_mode}} pool_size={{ keyOrDefault $pool_size $default_pool_size}}
  18. {{ end }}
  19. {{ end }}
  20.  
  21. ;; Configuration section
  22. [pgbouncer]
  23.  
  24. ;;;
  25. ;;; Administrative settings
  26. ;;;
  27.  
  28. logfile = /var/log/pgbouncer/pgbouncer.log
  29. pidfile = /var/run/pgbouncer/pgbouncer.pid
  30.  
  31. ;;;
  32. ;;; Where to wait for clients
  33. ;;;
  34.  
  35. ; ip address or * which means all ip-s
  36. listen_addr = *
  37. listen_port = 6432
  38.  
  39. ; unix socket is also used for -R.
  40. ; On debian it should be /var/run/postgresql
  41. ;unix_socket_dir = /tmp
  42. ;unix_socket_mode = 0777
  43. ;unix_socket_group =
  44.  
  45. ;;;
  46. ;;; Authentication settings
  47. ;;;
  48.  
  49. ; any, trust, plain, crypt, md5
  50. auth_type = trust
  51. ;auth_file = /8.0/main/global/pg_auth
  52. auth_file = /etc/pgbouncer/userlist.txt
  53.  
  54. ;; Query to use to fetch password from database. Result
  55. ;; must have 2 columns - username and password hash.
  56. ;auth_query = SELECT usename, passwd FROM pg_shadow WHERE usename=$1
  57.  
  58. ;;;
  59. ;;; Users allowed into database 'pgbouncer'
  60. ;;;
  61.  
  62. ; comma-separated list of users, who are allowed to change settings
  63. ;admin_users = user2, someadmin, otheradmin
  64. admin_user = admin
  65.  
  66. ; comma-separated list of users who are just allowed to use SHOW command
  67. stats_users = stats
  68.  
  69. ;;;
  70. ;;; Pooler personality questions
  71. ;;;
  72.  
  73. ; When server connection is released back to pool:
  74. ; session - after client disconnects
  75. ; transaction - after transaction finishes
  76. ; statement - after statement finishes
  77. ; pool_mode = transaction
  78. pool_mode = transaction
  79.  
  80. ;
  81. ; Query for cleaning connection immediately after releasing from client.
  82. ; No need to put ROLLBACK here, pgbouncer does not reuse connections
  83. ; where transaction is left open.
  84. ;
  85. ; Query for 8.3+:
  86. ; DISCARD ALL;
  87. ;
  88. ; Older versions:
  89. ; RESET ALL; SET SESSION AUTHORIZATION DEFAULT
  90. ;
  91. ; Empty if transaction pooling is in use.
  92. ;
  93. server_reset_query = DISCARD ALL
  94.  
  95.  
  96. ; Whether server_reset_query should run in all pooling modes.
  97. ; If it is off, server_reset_query is used only for session-pooling.
  98. ;server_reset_query_always = 0
  99.  
  100. ;
  101. ; Comma-separated list of parameters to ignore when given
  102. ; in startup packet. Newer JDBC versions require the
  103. ; extra_float_digits here.
  104. ;
  105. ignore_startup_parameters = extra_float_digits
  106.  
  107. ;
  108. ; When taking idle server into use, this query is ran first.
  109. ; SELECT 1
  110. ;
  111. ;server_check_query = select 1
  112.  
  113. ; If server was used more recently that this many seconds ago,
  114. ; skip the check query. Value 0 may or may not run in immediately.
  115. ;server_check_delay = 30
  116.  
  117. ;; Use <appname - host> as application_name on server.
  118. ;application_name_add_host = 0
  119.  
  120. ;;;
  121. ;;; Connection limits
  122. ;;;
  123.  
  124. ; total number of clients that can connect
  125. max_client_conn = 100
  126.  
  127. ; default pool size. 20 is good number when transaction pooling
  128. ; is in use, in session pooling it needs to be the number of
  129. ; max clients you want to handle at any moment
  130. default_pool_size = 95
  131.  
  132. ;; Minimum number of server connections to keep in pool.
  133. ;min_pool_size = 0
  134.  
  135. ; how many additional connection to allow in case of trouble
  136. ;reserve_pool_size = 5
  137.  
  138. ; if a clients needs to wait more than this many seconds, use reserve pool
  139. ;reserve_pool_timeout = 3
  140.  
  141. ; how many total connections to a single database to allow from all pools
  142. ;max_db_connections = 50
  143. ;max_user_connections = 50
  144.  
  145. ; If off, then server connections are reused in LIFO manner
  146. ;server_round_robin = 0
  147.  
  148. ;;;
  149. ;;; Logging
  150. ;;;
  151.  
  152. ;; Syslog settings
  153. ;syslog = 0
  154. ;syslog_facility = daemon
  155. ;syslog_ident = pgbouncer
  156.  
  157. ; log if client connects or server connection is made
  158. ;log_connections = 1
  159.  
  160. ; log if and why connection was closed
  161. ;log_disconnections = 1
  162.  
  163. ; log error messages pooler sends to clients
  164. ;log_pooler_errors = 1
  165.  
  166. ;; Period for writing aggregated stats into log.
  167. ;stats_period = 60
  168.  
  169. ;; Logging verbosity. Same as -v switch on command line.
  170. ;verbose=0
  171.  
  172. ;;;
  173. ;;; Timeouts
  174. ;;;
  175.  
  176. ;; Close server connection if its been connected longer.
  177. ;server_lifetime = 1200
  178.  
  179. ;; Close server connection if its not been used in this time.
  180. ;; Allows to clean unnecessary connections from pool after peak.
  181. ;server_idle_timeout = 60
  182.  
  183. ;; Cancel connection attempt if server does not answer takes longer.
  184. ;server_connect_timeout = 15
  185.  
  186. ;; If server login failed (server_connect_timeout or auth failure)
  187. ;; then wait this many second.
  188. ;server_login_retry = 15
  189.  
  190. ;; Dangerous. Server connection is closed if query does not return
  191. ;; in this time. Should be used to survive network problems,
  192. ;; _not_ as statement_timeout. (default: 0)
  193. ;query_timeout = 0
  194.  
  195. ;; Dangerous. Client connection is closed if the query is not assigned
  196. ;; to a server in this time. Should be used to limit the number of queued
  197. ;; queries in case of a database or network failure. (default: 120)
  198. ;query_wait_timeout = 120
  199.  
  200. ;; Dangerous. Client connection is closed if no activity in this time.
  201. ;; Should be used to survive network problems. (default: 0)
  202. ;client_idle_timeout = 0
  203.  
  204. ;; Disconnect clients who have not managed to log in after connecting
  205. ;; in this many seconds.
  206. ;client_login_timeout = 60
  207.  
  208. ;; Clean automatically created database entries (via "*") if they
  209. ;; stay unused in this many seconds.
  210. ; autodb_idle_timeout = 3600
  211.  
  212. ;; How long SUSPEND/-R waits for buffer flush before closing connection.
  213. ;suspend_timeout = 10
  214.  
  215. ;; Close connections which are in "IDLE in transaction" state longer than
  216. ;; this many seconds.
  217. ;idle_transaction_timeout = 0
  218.  
  219. ;;;
  220. ;;; Low-level tuning options
  221. ;;;
  222.  
  223. ;; buffer for streaming packets
  224. ;pkt_buf = 4096
  225.  
  226. ;; man 2 listen
  227. ;listen_backlog = 128
  228.  
  229. ;; Max number pkt_buf to process in one event loop.
  230. ;sbuf_loopcnt = 5
  231.  
  232. ;; Maximum Postgres protocol packet size.
  233. ;max_packet_size = 2147483647
  234.  
  235. ;; networking options, for info: man 7 tcp
  236.  
  237. ;; Linux: notify program about new connection only if there
  238. ;; is also data received. (Seconds to wait.)
  239. ;; On Linux the default is 45, on other OS'es 0.
  240. ;tcp_defer_accept = 0
  241.  
  242. ;; In-kernel buffer size (Linux default: 4096)
  243. ;tcp_socket_buffer = 0
  244.  
  245. ;; whether tcp keepalive should be turned on (0/1)
  246. ;tcp_keepalive = 1
  247.  
  248. ;; following options are Linux-specific.
  249. ;; they also require tcp_keepalive=1
  250.  
  251. ;; count of keepaliva packets
  252. ;tcp_keepcnt = 0
  253.  
  254. ;; how long the connection can be idle,
  255. ;; before sending keepalive packets
  256. ;tcp_keepidle = 0
  257.  
  258. ;; The time between individual keepalive probes.
  259. ;tcp_keepintvl = 0
  260.  
  261. ;; DNS lookup caching time
  262. ;dns_max_ttl = 15
  263.  
  264. ;; DNS zone SOA lookup period
  265. ;dns_zone_check_period = 0
  266.  
  267. ;; DNS negative result caching time
  268. ;dns_nxdomain_ttl = 15
  269.  
  270. ;;;
  271. ;;; Random stuff
  272. ;;;
  273.  
  274. ;; Hackish security feature. Helps against SQL-injection - when PQexec is disabled,
  275. ;; multi-statement cannot be made.
  276. ;disable_pqexec=0
  277.  
  278. ;; Config file to use for next RELOAD/SIGHUP.
  279. ;; By default contains config file from command line.
  280. ;conffile
  281.  
  282. ;; Win32 service name to register as. job_name is alias for service_name,
  283. ;; used by some Skytools scripts.
  284. ;service_name = pgbouncer
  285. ;job_name = pgbouncer
  286.  
  287. ;; Read additional config from the /etc/pgbouncer/pgbouncer-other.ini file
  288. ;%include /etc/pgbouncer/pgbouncer-other.ini
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement