blob: d7e2dd847e323df4e6aff6fab1c5bd7768d49135 [file] [log] [blame]
Filip Pytloun26ebcc02015-10-06 16:28:32 +02001
2==========
3PostgreSQL
4==========
5
6PostgreSQL, often simply Postgres, is an object-relational database management system available for many platforms including Linux, FreeBSD, Solaris, Microsoft Windows and Mac OS X. It is released under the PostgreSQL License, which is an MIT-style license, and is thus free and open source software. PostgreSQL is developed by the PostgreSQL Global Development Group, consisting of a handful of volunteers employed and supervised by companies such as Red Hat and EnterpriseDB.
7
8Support
9=======
10
11* required by: [redmine](../master/redmine)
12* service versions: 9.1
13* operating systems: Ubuntu 12.04
14
15Sample pillars
16==============
17
18Single database server with empty database
19------------------------------------------
20
21.. code-block:: yaml
22
23 postgresql:
24 server:
25 enabled: true
26 version: 9.1
27 bind:
28 address: 127.0.0.1
29 port: 5432
30 protocol: tcp
31 clients:
32 - 127.0.0.1
33 database:
34 name: 'databasename'
35 encoding: 'UTF8'
36 locale: 'cs_CZ'
37 user:
38 name: 'username'
39 password: 'password'
40 host: 'localhost'
41 rights: 'all privileges'
42
43Single database server with prepopulated database
44-------------------------------------------------
45
46.. code-block:: yaml
47
48 postgresql:
49 server:
50 enabled: true
51 version: 9.1
52 bind:
53 - address: 127.0.0.1
54 port: 5432
55 protocol: tcp
56 clients:
57 - 127.0.0.1
58 database:
59 name: 'databasename'
60 encoding: 'UTF8'
61 locale: 'cs_CZ'
62 initial_data:
63 engine: backupninja
64 source: backup.host
65 host: original-host-name
66 database: original-database-name
67 user:
68 name: 'username'
69 password: 'password'
70 host: 'localhost'
71 rights: 'all privileges'
72
73User with createdb privileges
74-----------------------------
75
76.. code-block:: yaml
77
78 postgresql:
79 server:
80 enabled: true
81 version: 9.1
82 bind:
83 address: 127.0.0.1
84 port: 5432
85 protocol: tcp
86 clients:
87 - 127.0.0.1
88 database:
89 name: 'databasename'
90 encoding: 'UTF8'
91 locale: 'cs_CZ'
92 user:
93 name: 'username'
94 password: 'password'
95 host: 'localhost'
96 createdb: true
97 rights: 'all privileges'
98
99
100PostgreSQL extensions
101---------------------
102
103.. code-block:: yaml
104
105 postgresql:
106 server:
107 enabled: true
108 version: 9.1
109 bind:
110 address: 127.0.0.1
111 port: 5432
112 protocol: tcp
113 clients:
114 - 127.0.0.1
115 database:
116 name: 'databasename'
117 encoding: 'UTF8'
118 locale: 'cs_CZ'
119 user:
120 name: 'username'
121 password: 'password'
122 host: 'localhost'
123 createdb: true
124 rights: 'all privileges'
125 extension:
126 postgis_topology:
Adam Tenglerb5792ca2017-02-13 14:31:23 +0100127 enabled: true
Filip Pytloun26ebcc02015-10-06 16:28:32 +0200128 fuzzystrmatch:
Adam Tenglerb5792ca2017-02-13 14:31:23 +0100129 enabled: true
Filip Pytloun26ebcc02015-10-06 16:28:32 +0200130 postgis_tiger_geocoder:
Adam Tenglerb5792ca2017-02-13 14:31:23 +0100131 enabled: true
Filip Pytloun26ebcc02015-10-06 16:28:32 +0200132 postgis:
Adam Tenglerb5792ca2017-02-13 14:31:23 +0100133 enabled: true
134 pkgs:
135 - postgresql-9.1-postgis-2.1
Filip Pytloun26ebcc02015-10-06 16:28:32 +0200136
Adam Tenglerb5792ca2017-02-13 14:31:23 +0100137Cluster
138=======
139
140Basic streaming replication.
141
142Master node
143-----------
144
145.. code-block:: yaml
146
147 postgresql:
148 server:
149 enabled: true
150 version: 9.6
151 bind:
152 address: 0.0.0.0
153 database:
154 mydb: ...
155 cluster:
156 enabled: true
157 role: master
158 mode: hot_standby
159 members:
160 - host: "172.16.10.101"
161 - host: "172.16.10.102"
162 - host: "172.16.10.103"
163 replication_user:
164 name: repuser
165 password: password
166 keepalived:
167 cluster:
168 enabled: True
169 instance:
170 VIP:
171 notify_action:
172 master:
173 - 'if [ -f /root/postgresql/flags/failover ]; then touch /var/lib/postgresql/${postgresql:server:version}/main/trigger; fi'
174 backup:
175 - 'if [ -f /root/postgresql/flags/failover ]; then service postgresql stop; fi'
176 fault:
177 - 'if [ -f /root/postgresql/flags/failover ]; then service postgresql stop; fi'
178
179Slave node
180----------
181
182.. code-block:: yaml
183
184 postgresql:
185 server:
186 enabled: true
187 version: 9.6
188 bind:
189 address: 0.0.0.0
190 cluster:
191 enabled: true
192 role: slave
193 mode: hot_standby
194 master:
195 host: "172.16.10.100"
196 port: 5432
197 user: repuser
198 password: password
199 keepalived:
200 cluster:
201 enabled: True
202 instance:
203 VIP:
204 notify_action:
205 master:
206 - 'if [ -f /root/postgresql/flags/failover ]; then touch /var/lib/postgresql/${postgresql:server:version}/main/trigger; fi'
207 backup:
208 - 'if [ -f /root/postgresql/flags/failover ]; then service postgresql stop; fi'
209 fault:
210 - 'if [ -f /root/postgresql/flags/failover ]; then service postgresql stop; fi'
211
212Multi-master cluster with 2ndQuadrant bi-directional replication plugin
213
214Master node
215-----------
216
217.. code-block:: yaml
218
219 postgresql:
220 server:
221 enabled: true
222 version: 9.4
223 bind:
224 address: 0.0.0.0
225 database:
226 mydb:
227 extension:
228 bdr:
229 enabled: true
230 btree_gist:
231 enabled: true
232 ...
233 cluster:
234 enabled: true
235 mode: bdr
236 role: master
237 members:
238 - host: "172.16.10.101"
239 - host: "172.16.10.102"
240 - host: "172.16.10.101"
241 local: "172.16.10.101"
242 replication_user:
243 name: repuser
244 password: password
245
246Slave node
247----------
248
249.. code-block:: yaml
250
251 postgresql:
252 server:
253 enabled: true
254 version: 9.4
255 bind:
256 address: 0.0.0.0
257 database:
258 mydb:
259 extension:
260 bdr:
261 enabled: true
262 btree_gist:
263 enabled: true
264 ...
265 cluster:
266 enabled: true
267 mode: bdr
268 role: master
269 members:
270 - host: "172.16.10.101"
271 - host: "172.16.10.102"
272 - host: "172.16.10.101"
273 local: "172.16.10.102"
274 master: "172.16.10.101"
275 replication_user:
276 name: repuser
277 password: password
278
279Sample usage
280============
Filip Pytloun26ebcc02015-10-06 16:28:32 +0200281
282Init database cluster with given locale
283
284 sudo su - postgres -c "/usr/lib/postgresql/9.3/bin/initdb /var/lib/postgresql/9.3/main --locale=C"
285
286Convert PostgreSQL cluster from 9.1 to 9.3
287
288 sudo su - postgres -c '/usr/lib/postgresql/9.3/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.3/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.3/main/ -O "-c config_file=/etc/postgresql/9.3/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"'
289
290Ubuntu on 14.04 on some machines won't create default cluster
291
292 sudo pg_createcluster 9.3 main --start
293
Adam Tenglerb5792ca2017-02-13 14:31:23 +0100294Read more
295=========
Filip Pytloun26ebcc02015-10-06 16:28:32 +0200296
297* http://www.postgresql.org/
298* http://www.postgresql.org/docs/9.1/interactive/index.html
299* http://momjian.us/main/writings/pgsql/hw_performance/
Filip Pytloun4afffd82017-02-02 13:02:03 +0100300* https://gist.github.com/ibussieres/11262268 - upgrade instructions for ubuntu
301Documentation and Bugs
302======================
303
304To learn how to install and update salt-formulas, consult the documentation
305available online at:
306
307 http://salt-formulas.readthedocs.io/
308
309In the unfortunate event that bugs are discovered, they should be reported to
310the appropriate issue tracker. Use Github issue tracker for specific salt
311formula:
312
313 https://github.com/salt-formulas/salt-formula-postgresql/issues
314
315For feature requests, bug reports or blueprints affecting entire ecosystem,
316use Launchpad salt-formulas project:
317
318 https://launchpad.net/salt-formulas
319
320You can also join salt-formulas-users team and subscribe to mailing list:
321
322 https://launchpad.net/~salt-formulas-users
323
324Developers wishing to work on the salt-formulas projects should always base
325their work on master branch and submit pull request against specific formula.
326
327 https://github.com/salt-formulas/salt-formula-postgresql
328
329Any questions or feedback is always welcome so feel free to join our IRC
330channel:
331
332 #salt-formulas @ irc.freenode.net