~charmers/charms/precise/pgbouncer/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Overview

PgBouncer is a lightweight connection pooler for PostgreSQL.

http://wiki.postgresql.org/wiki/PgBouncer

# Usage
## Installation

To deploy you'll need at a minimum: a cloud environment, a working Juju
installation, and a successful bootstrap. Please refer to the
[Juju Getting Started](https://juju.ubuntu.com/docs/getting-started.html)
documentation before continuing.

It is also recommended that you read the documentation for the
postgresql charm so you understand how to set up postgresql in
a master-slave relationship.

## Example

First, if you haven't already done so, bootstrap your environment:

    juju bootstrap

Now deploy a standalone PostgreSQL instance:

    juju deploy postgresql

Let's add another unit:

    juju add-unit postgresql

As per the documentation in the postgresql charm, you now have a master
and a hot standby set up with replication.

Now that you have a functional PostgreSQL setup, deploy the 
PgBouncer charm from the Juju charm store:

    juju deploy pgbouncer

Create the relations between pgbouncer and postgresql:

    juju add-relation pgbouncer:backend-db-admin postgresql:db-admin

Now you have set up pgbouncer in front of your PostgreSQL units.

In a real world scenario, you might have a (web) application that
sends write queries to a master (directly) and read-only queries
to a cluster of slaves, with load balancing using pgbouncer.


## Configuration

    juju set pgbouncer max_client_conn=50

## db-proxy relationship

The charm joining the db-proxy relationship can specify a database that
will be created in addition to the default one based on the service name
and can specify a comma seperated list of roles that will be granted to
the user (these roles will be created if they do not already exist)

## Monitoring

This charm provides relations that support monitoring via Nagios using 
nrpe_external_master as a subordinate charm.