Skip to content

Instantly share code, notes, and snippets.

@jrafanie
Created July 7, 2017 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrafanie/e5a595ddd24e4291f29cef105aaf8ae8 to your computer and use it in GitHub Desktop.
Save jrafanie/e5a595ddd24e4291f29cef105aaf8ae8 to your computer and use it in GitHub Desktop.
initial setup of pgbouncer with manageiq
yum install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-2.noarch.rpm
yum install pgbouncer
vim /etc/pgbouncer/pgbouncer.ini
[databases]
...
; redirect bardb to bazdb on localhost
;bardb = host=localhost dbname=bazdb
vmdb_production = host=127.0.0.1 port=5432 user=root password=YOUR_PASSWORD
...
;;;
;;; Where to wait for clients
;;;
; ip address or * which means all ip-s
listen_addr = *
listen_port = 6432
...
;;;
;;; Authentication settings
;;;
; any, trust, plain, crypt, md5
auth_type = any
;auth_file = /8.0/main/global/pg_auth
;auth_file = /etc/pgbouncer/userlist.txt
; comma-separated list of users, who are allowed to change settings
admin_users = postgres, root
;admin_users = postgres
; comma-separated list of users who are just allowed to use SHOW command
stats_users = stats, postgres, root
; stats_users = stats, postgres
...
;;;
;;; Pooler personality questions
;;;
; When server connection is released back to pool:
; session - after client disconnects
; transaction - after transaction finishes
; statement - after statement finishes
pool_mode = transaction
Now, edit the config/database.yml to disable prepared_statements and specify the port of 6432
production:
prepared_statements: false
adapter: postgresql
encoding: utf8
username: root
pool: 5
wait_timeout: 5
min_messages: warning
database: vmdb_production
host: localhost
password: YOUR_PASSWORD
port: 6432
systemctl restart pgbouncer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment