blob: 4873cfa87ddd81a798429bbb3c33e5f24ce50527 [file] [log] [blame]
Ales Komarekcba48ac2015-04-30 11:40:44 +02001
2======
3Galera
4======
5
6Galera Cluster for MySQL is a true Multimaster Cluster based on synchronous replication. Galera Cluster is an easy-to-use, high-availability solution, which provides high system uptime, no data loss and scalability for future growth.
7
8Sample pillars
9==============
10
11Galera cluster master node
12
13.. code-block:: yaml
14
15 galera:
Petr Michalec5ff575c2017-11-06 15:37:05 +010016 version:
17 mysql: 5.6
18 galera: 3
Ales Komarekcba48ac2015-04-30 11:40:44 +020019 master:
20 enabled: true
21 name: openstack
22 bind:
23 address: 192.168.0.1
24 port: 3306
25 members:
26 - host: 192.168.0.1
27 port: 4567
28 - host: 192.168.0.2
29 port: 4567
30 admin:
31 user: root
32 password: pass
33 database:
34 name:
35 encoding: 'utf8'
36 users:
37 - name: 'username'
38 password: 'password'
39 host: 'localhost'
40 rights: 'all privileges'
41
42Galera cluster slave node
43
44.. code-block:: yaml
45
46 galera:
47 slave:
48 enabled: true
49 name: openstack
50 bind:
51 address: 192.168.0.2
52 port: 3306
53 members:
54 - host: 192.168.0.1
55 port: 4567
56 - host: 192.168.0.2
57 port: 4567
58 admin:
59 user: root
60 password: pass
61
Kirill Bespalov5f0c1d62017-08-15 15:29:32 +030062Enable TLS support:
63
64.. code-block:: yaml
65
66 galera:
67 slave or master:
68 ssl:
69 enabled: True
70
71 # path
72 cert_file: /etc/mysql/ssl/cert.pem
73 key_file: /etc/mysql/ssl/key.pem
74 ca_file: /etc/mysql/ssl/ca.pem
75
76 # content (not required if files already exists)
77 key: << body of key >>
78 cert: << body of cert >>
79 cacert_chain: << body of ca certs chain >>
80
81
Petr Michalecbca6ffa2017-05-22 13:10:20 +020082Additional mysql users:
83
84.. code-block:: yaml
85
86 mysql:
87 server:
88 users:
89 - name: clustercheck
90 password: clustercheck
91 database: '*.*'
92 grants: PROCESS
Petr Michalecbca6ffa2017-05-22 13:10:20 +020093 - name: inspector
94 host: 127.0.0.1
95 password: password
96 databases:
97 mydb:
98 - database: mydb
99 - table: mytable
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200100 - grant_option: True
Petr Michalecbca6ffa2017-05-22 13:10:20 +0200101 - grants:
102 - all privileges
103
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200104Additional check params:
Petr Michalec518b8342017-08-04 11:23:03 +0200105========================
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200106
107.. code-block:: yaml
108
109 galera:
110 clustercheck:
111 - enabled: True
112 - user: clustercheck
113 - password: clustercheck
114 - available_when_donor: 0
115 - available_when_readonly: 1
116 - port 9200
117
Dmitry Kalashnikd4e5f472017-08-09 14:28:17 +0400118Configurable soft parameters
119============================
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300120
Petr Michalecc5ca6e82017-09-01 10:10:48 +0200121
Dmitry Kalashnikd4e5f472017-08-09 14:28:17 +0400122- **galera_innodb_buffer_pool_size** - the default value is 3138M
123- **galera_max_connections** - the default value is 20000
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300124
125Usage:
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300126.. code-block:: yaml
127
Dmitry Kalashnikd4e5f472017-08-09 14:28:17 +0400128 _param:
129 galera_innodb_buffer_pool_size: 1024M
Kirill Bespalov5f0c1d62017-08-15 15:29:32 +0300130 galera_max_connections: 200
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300131
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200132
Ales Komarekcba48ac2015-04-30 11:40:44 +0200133Usage
134=====
135
136MySQL Galera check sripts
137
138.. code-block:: bash
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200139
Ales Komarekcba48ac2015-04-30 11:40:44 +0200140 mysql> SHOW STATUS LIKE 'wsrep%';
141
142 mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;"
143
144Galera monitoring command, performed from extra server
145
146.. code-block:: bash
147
148 garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d
149
1501. salt-call state.sls mysql
1512. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst)
1523. service mysql start
1534. run on each node mysql_secure_install and filling root password.
154
155.. code-block:: bash
156
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300157 Enter current password for root (enter for none):
Ales Komarekcba48ac2015-04-30 11:40:44 +0200158 OK, successfully used password, moving on...
159
160 Setting the root password ensures that nobody can log into the MySQL
161 root user without the proper authorisation.
162
163 Set root password? [Y/n] y
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300164 New password:
165 Re-enter new password:
Ales Komarekcba48ac2015-04-30 11:40:44 +0200166 Password updated successfully!
167 Reloading privilege tables..
168 ... Success!
169
170 By default, a MySQL installation has an anonymous user, allowing anyone
171 to log into MySQL without having to have a user account created for
172 them. This is intended only for testing, and to make the installation
173 go a bit smoother. You should remove them before moving into a
174 production environment.
175
176 Remove anonymous users? [Y/n] y
177 ... Success!
178
179 Normally, root should only be allowed to connect from 'localhost'. This
180 ensures that someone cannot guess at the root password from the network.
181
182 Disallow root login remotely? [Y/n] n
183 ... skipping.
184
185 By default, MySQL comes with a database named 'test' that anyone can
186 access. This is also intended only for testing, and should be removed
187 before moving into a production environment.
188
189 Remove test database and access to it? [Y/n] y
190 - Dropping test database...
191 ... Success!
192 - Removing privileges on test database...
193 ... Success!
194
195 Reloading the privilege tables will ensure that all changes made so far
196 will take effect immediately.
197
198 Reload privilege tables now? [Y/n] y
199 ... Success!
200
201 Cleaning up...
202
2035. service mysql stop
Kirill Bespalov162a4d42017-06-21 02:26:19 +03002046. uncomment all wsrep* lines except first server, where leave only in my.cnf wsrep_cluster_address='gcomm://';
Ales Komarekcba48ac2015-04-30 11:40:44 +02002057. start first node
2068. Start third node which is connected to first one
2079. Start second node which is connected to third one
20810. After starting cluster, it must be change cluster address at first starting node without restart database and change config my.cnf.
209
210.. code-block:: bash
211
212 mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2';
213
214Read more
215=========
216
217* https://github.com/CaptTofu/ansible-galera
218* http://www.sebastien-han.fr/blog/2012/04/15/active-passive-failover-cluster-on-a-mysql-galera-cluster-with-haproxy-lsb-agent/
219* http://opentodo.net/2012/12/mysql-multi-master-replication-with-galera/
220* http://www.codership.com/wiki/doku.php
221* Best one: - http://www.sebastien-han.fr/blog/2012/04/01/mysql-multi-master-replication-with-galera/
Filip Pytloun5b356a72017-02-02 13:02:03 +0100222
223Documentation and Bugs
224======================
225
226To learn how to install and update salt-formulas, consult the documentation
227available online at:
228
229 http://salt-formulas.readthedocs.io/
230
231In the unfortunate event that bugs are discovered, they should be reported to
232the appropriate issue tracker. Use Github issue tracker for specific salt
233formula:
234
235 https://github.com/salt-formulas/salt-formula-galera/issues
236
237For feature requests, bug reports or blueprints affecting entire ecosystem,
238use Launchpad salt-formulas project:
239
240 https://launchpad.net/salt-formulas
241
242You can also join salt-formulas-users team and subscribe to mailing list:
243
244 https://launchpad.net/~salt-formulas-users
245
246Developers wishing to work on the salt-formulas projects should always base
247their work on master branch and submit pull request against specific formula.
248
249 https://github.com/salt-formulas/salt-formula-galera
250
251Any questions or feedback is always welcome so feel free to join our IRC
252channel:
253
254 #salt-formulas @ irc.freenode.net