41
41
maintains replication for you, using standard PostgreSQL streaming
44
- Multiple services linked using 'master'/'slave' relationships. A
45
single service can be the 'master', and multiple services connected
46
to this master in a 'slave' role. Each service can contain multiple
47
units; the 'master' service will contain a single 'master' unit and
48
remaining units all 'hot standby'. The 'slave' services will only
49
contain 'hot standby' units. 'Cascading replication is not
50
supported', so do not attempt to relate an existing 'slave' service
51
as a 'master' to another service.
54
45
To setup a single 'standalone' service::
64
To deploy a new service containing a 'master' and a 'hot standby'::
66
juju deploy -n 2 postgresql pg-b
69
To relate a PostgreSQL service as a 'slave' of another PostgreSQL service.
70
**Caution** - this destroys the existing databases in the pg-b service::
72
juju add-relation pg-a:master pg-b:slave
75
To setup a client using a PostgreSQL database, in this case OpenERP and
76
its web front end. Note that OpenERP requires an administrative level
55
To deploy a new service containing a 'master' and two 'hot standbys'::
57
juju deploy -n 3 postgresql pg-b
59
You can remove units as normal. If the master unit is removed, failover
60
occurs and the most up to date 'hot standby' is promoted to 'master'.
61
The 'db-relation-changed' and 'db-admin-relation-changed' hooks are
62
fired, letting clients adjust::
64
juju remove-unit pg-b/0
67
To setup a client using a PostgreSQL database, in this case a vanilla
68
Django installation listening on port 8080::
79
70
juju deploy postgresql
80
juju deploy postgresql pg-standby
81
juju deploy openerp-web
82
juju deploy openerp-server
84
juju add-relation postgresql:master pg-standby:slave
85
juju add-relation openerp-server:db postgresql:db-admin
86
juju add-relation openerp-web openerp-server
88
juju expose openerp-web
89
juju expose openerp-server
71
juju deploy python-django
73
juju add-relation python-django postgresql:db
74
juju add-relation python-django gunicorn
75
juju expose python-django
94
80
- Do not attempt to relate client charms to a PostgreSQL service
95
81
containing multiple units unless you know the charm supports
96
a replicated service. You can use a 'master'/'slave' relationship
97
to create a redundant copy of your database until the client charms
100
84
- You cannot host multiple units in a single juju container. This is
101
85
problematic as some PostgreSQL features, such as tablespaces, use
104
88
# Interacting with the Postgresql Service
106
Typically, you just need to join a the `db` relation, and a user and database
107
will be created for you. For more advanced uses, you can join the `db-admin`
108
relation, and a super user will be created. Using this account, you can
109
manipulate all other aspects of the database.
90
At a minimum, you just need to join a the `db` relation, and a user and
91
database will be created for you. For more complex environments,
92
you can provide the `database` name allowing multiple services to share
93
the same database. A client may also wish to defer its setup until the
94
unit name is listed in `allowed-units`, to avoid attempting to connect
95
to a database before it has been authorized.
97
The `db-admin` relation may be used similarly to the `db` relation.
98
The automatically generated user for `db-admin` relations is a
101
## During db-relation-joined
103
### the client service provides:
105
- `database`: Optional. The name of the database to use. The postgresql
106
service will create it if necessary.
111
108
## During db-relation-changed