blob: 112a2dbf8d5231d06a9c0b6b48e996316768e6e9 [file] [log] [blame]
Ales Komarekcba48ac2015-04-30 11:40:44 +02001
OlgaGusarenko43e99902018-07-30 17:18:32 +03002=====
3Usage
4=====
Ales Komarekcba48ac2015-04-30 11:40:44 +02005
OlgaGusarenko43e99902018-07-30 17:18:32 +03006Galera Cluster for MySQL is a true Multimaster Cluster based on synchronous
7replication. Galera Cluster is an easy-to-use, high-availability solution,
8which provides high system uptime, no data loss and scalability for future
9growth.
Ales Komarekcba48ac2015-04-30 11:40:44 +020010
11Sample pillars
12==============
13
14Galera cluster master node
15
16.. code-block:: yaml
17
18 galera:
Petr Michalec5ff575c2017-11-06 15:37:05 +010019 version:
20 mysql: 5.6
21 galera: 3
Ales Komarekcba48ac2015-04-30 11:40:44 +020022 master:
23 enabled: true
24 name: openstack
25 bind:
26 address: 192.168.0.1
27 port: 3306
28 members:
29 - host: 192.168.0.1
30 port: 4567
31 - host: 192.168.0.2
32 port: 4567
33 admin:
34 user: root
35 password: pass
36 database:
37 name:
38 encoding: 'utf8'
39 users:
40 - name: 'username'
41 password: 'password'
42 host: 'localhost'
43 rights: 'all privileges'
44
45Galera cluster slave node
46
47.. code-block:: yaml
48
49 galera:
50 slave:
51 enabled: true
52 name: openstack
53 bind:
54 address: 192.168.0.2
55 port: 3306
56 members:
57 - host: 192.168.0.1
58 port: 4567
59 - host: 192.168.0.2
60 port: 4567
61 admin:
62 user: root
63 password: pass
64
Kirill Bespalov5f0c1d62017-08-15 15:29:32 +030065Enable TLS support:
66
67.. code-block:: yaml
68
69 galera:
70 slave or master:
71 ssl:
72 enabled: True
73
74 # path
75 cert_file: /etc/mysql/ssl/cert.pem
76 key_file: /etc/mysql/ssl/key.pem
77 ca_file: /etc/mysql/ssl/ca.pem
78
79 # content (not required if files already exists)
80 key: << body of key >>
81 cert: << body of cert >>
82 cacert_chain: << body of ca certs chain >>
83
84
Petr Michalecbca6ffa2017-05-22 13:10:20 +020085Additional mysql users:
86
87.. code-block:: yaml
88
89 mysql:
90 server:
91 users:
92 - name: clustercheck
93 password: clustercheck
94 database: '*.*'
95 grants: PROCESS
Petr Michalecbca6ffa2017-05-22 13:10:20 +020096 - name: inspector
97 host: 127.0.0.1
98 password: password
99 databases:
100 mydb:
101 - database: mydb
102 - table: mytable
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200103 - grant_option: True
Petr Michalecbca6ffa2017-05-22 13:10:20 +0200104 - grants:
105 - all privileges
106
Vasyl Saienko79f69062018-01-29 11:04:58 +0200107Additional mysql SSL grants:
108
109.. code-block:: yaml
110
111 mysql:
112 server:
113 users:
114 - name: clustercheck
115 password: clustercheck
116 database: '*.*'
117 grants: PROCESS
118 ssl_option:
119 - SSL: True
120 - X509: True
121 - SUBJECT: <subject>
122 - ISSUER: <issuer>
123 - CIPHER: <cipher>
124
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200125Additional check params:
Petr Michalec518b8342017-08-04 11:23:03 +0200126========================
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200127
128.. code-block:: yaml
129
130 galera:
131 clustercheck:
132 - enabled: True
133 - user: clustercheck
134 - password: clustercheck
135 - available_when_donor: 0
136 - available_when_readonly: 1
137 - port 9200
138
Dmitry Kalashnikd4e5f472017-08-09 14:28:17 +0400139Configurable soft parameters
140============================
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300141
OlgaGusarenko43e99902018-07-30 17:18:32 +0300142- ``galera_innodb_buffer_pool_size``
143 Default is ``3138M``
144- ``galera_max_connections``
145 Default is ``20000``
146- ``galera_innodb_read_io_threads``
147 Default is ``8``
148- ``galera_innodb_write_io_threads``
149 Default is ``8``
150- ``galera_wsrep_slave_threads``
151 Default is ``8``
152- ``galera_xtrabackup_parallel``
153 Default is 4
154- ``galera_error_log_enabled``
155 Default is ``false``
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300156
157Usage:
OlgaGusarenko43e99902018-07-30 17:18:32 +0300158
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300159.. code-block:: yaml
160
Dmitry Kalashnikd4e5f472017-08-09 14:28:17 +0400161 _param:
162 galera_innodb_buffer_pool_size: 1024M
Kirill Bespalov5f0c1d62017-08-15 15:29:32 +0300163 galera_max_connections: 200
Dennis Dmitriev2c572892018-03-05 23:32:34 +0200164 galera_innodb_read_io_threads: 16
165 galera_innodb_write_io_threads: 16
166 galera_wsrep_slave_threads: 8
167 galera_xtrabackup_parallel: 2
168 galera_error_log_enabled: true
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300169
Ales Komarekcba48ac2015-04-30 11:40:44 +0200170Usage
171=====
172
173MySQL Galera check sripts
174
175.. code-block:: bash
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200176
Ales Komarekcba48ac2015-04-30 11:40:44 +0200177 mysql> SHOW STATUS LIKE 'wsrep%';
178
179 mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;"
180
181Galera monitoring command, performed from extra server
182
183.. code-block:: bash
184
185 garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d
186
OlgaGusarenko43e99902018-07-30 17:18:32 +0300187#. salt-call state.sls mysql
188#. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst)
189#. service mysql start
190#. run on each node mysql_secure_install and filling root password.
Ales Komarekcba48ac2015-04-30 11:40:44 +0200191
OlgaGusarenko43e99902018-07-30 17:18:32 +0300192 .. code-block:: bash
Ales Komarekcba48ac2015-04-30 11:40:44 +0200193
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300194 Enter current password for root (enter for none):
Ales Komarekcba48ac2015-04-30 11:40:44 +0200195 OK, successfully used password, moving on...
196
197 Setting the root password ensures that nobody can log into the MySQL
198 root user without the proper authorisation.
199
200 Set root password? [Y/n] y
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300201 New password:
202 Re-enter new password:
Ales Komarekcba48ac2015-04-30 11:40:44 +0200203 Password updated successfully!
204 Reloading privilege tables..
205 ... Success!
206
207 By default, a MySQL installation has an anonymous user, allowing anyone
208 to log into MySQL without having to have a user account created for
209 them. This is intended only for testing, and to make the installation
210 go a bit smoother. You should remove them before moving into a
211 production environment.
212
213 Remove anonymous users? [Y/n] y
214 ... Success!
215
216 Normally, root should only be allowed to connect from 'localhost'. This
217 ensures that someone cannot guess at the root password from the network.
218
219 Disallow root login remotely? [Y/n] n
220 ... skipping.
221
222 By default, MySQL comes with a database named 'test' that anyone can
223 access. This is also intended only for testing, and should be removed
224 before moving into a production environment.
225
226 Remove test database and access to it? [Y/n] y
227 - Dropping test database...
228 ... Success!
229 - Removing privileges on test database...
230 ... Success!
231
232 Reloading the privilege tables will ensure that all changes made so far
233 will take effect immediately.
234
235 Reload privilege tables now? [Y/n] y
236 ... Success!
237
238 Cleaning up...
239
OlgaGusarenko43e99902018-07-30 17:18:32 +0300240#. service mysql stop
241#. uncomment all wsrep* lines except first server, where leave only in
242 my.cnf wsrep_cluster_address='gcomm://';
243#. start first node
244#. Start third node which is connected to first one
245#. Start second node which is connected to third one
246#. After starting cluster, it must be change cluster address at first starting node
247 without restart database and change config my.cnf.
Ales Komarekcba48ac2015-04-30 11:40:44 +0200248
OlgaGusarenko43e99902018-07-30 17:18:32 +0300249 .. code-block:: bash
Ales Komarekcba48ac2015-04-30 11:40:44 +0200250
OlgaGusarenko43e99902018-07-30 17:18:32 +0300251 mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2';
Ales Komarekcba48ac2015-04-30 11:40:44 +0200252
253Read more
254=========
255
256* https://github.com/CaptTofu/ansible-galera
257* http://www.sebastien-han.fr/blog/2012/04/15/active-passive-failover-cluster-on-a-mysql-galera-cluster-with-haproxy-lsb-agent/
258* http://opentodo.net/2012/12/mysql-multi-master-replication-with-galera/
259* http://www.codership.com/wiki/doku.php
OlgaGusarenko43e99902018-07-30 17:18:32 +0300260* http://www.sebastien-han.fr/blog/2012/04/01/mysql-multi-master-replication-with-galera/
Filip Pytloun5b356a72017-02-02 13:02:03 +0100261
OlgaGusarenko43e99902018-07-30 17:18:32 +0300262Documentation and bugs
Filip Pytloun5b356a72017-02-02 13:02:03 +0100263======================
264
OlgaGusarenko43e99902018-07-30 17:18:32 +0300265* http://salt-formulas.readthedocs.io/
266 Learn how to install and update salt-formulas
Filip Pytloun5b356a72017-02-02 13:02:03 +0100267
OlgaGusarenko43e99902018-07-30 17:18:32 +0300268* https://github.com/salt-formulas/salt-formula-galera/issues
269 In the unfortunate event that bugs are discovered, report the issue to the
270 appropriate issue tracker. Use the Github issue tracker for a specific salt
271 formula
Filip Pytloun5b356a72017-02-02 13:02:03 +0100272
OlgaGusarenko43e99902018-07-30 17:18:32 +0300273* https://launchpad.net/salt-formulas
274 For feature requests, bug reports, or blueprints affecting the entire
275 ecosystem, use the Launchpad salt-formulas project
Filip Pytloun5b356a72017-02-02 13:02:03 +0100276
OlgaGusarenko43e99902018-07-30 17:18:32 +0300277* https://launchpad.net/~salt-formulas-users
278 Join the salt-formulas-users team and subscribe to mailing list if required
Filip Pytloun5b356a72017-02-02 13:02:03 +0100279
OlgaGusarenko43e99902018-07-30 17:18:32 +0300280* https://github.com/salt-formulas/salt-formula-galera
281 Develop the salt-formulas projects in the master branch and then submit pull
282 requests against a specific formula
Filip Pytloun5b356a72017-02-02 13:02:03 +0100283
OlgaGusarenko43e99902018-07-30 17:18:32 +0300284* #salt-formulas @ irc.freenode.net
285 Use this IRC channel in case of any questions or feedback which is always
286 welcome
Filip Pytloun5b356a72017-02-02 13:02:03 +0100287