blob: 3e44619db63228ab57d33f4d17a0282408279c66 [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
Stanislav Riazanov7205cbf2018-12-18 14:38:29 +040036 sst:
37 user: sstuser
38 password: sstpassword
Ales Komarekcba48ac2015-04-30 11:40:44 +020039 database:
40 name:
41 encoding: 'utf8'
42 users:
43 - name: 'username'
44 password: 'password'
45 host: 'localhost'
46 rights: 'all privileges'
Dzmitry Stremkouski9aa71082018-10-29 13:36:13 +010047 database: '*.*'
Ales Komarekcba48ac2015-04-30 11:40:44 +020048
49Galera cluster slave node
50
51.. code-block:: yaml
52
53 galera:
54 slave:
55 enabled: true
56 name: openstack
57 bind:
58 address: 192.168.0.2
59 port: 3306
60 members:
61 - host: 192.168.0.1
62 port: 4567
63 - host: 192.168.0.2
64 port: 4567
65 admin:
66 user: root
67 password: pass
Stanislav Riazanov7205cbf2018-12-18 14:38:29 +040068 sst:
69 user: sstuser
70 password: sstpassword
71
Ales Komarekcba48ac2015-04-30 11:40:44 +020072
Kirill Bespalov5f0c1d62017-08-15 15:29:32 +030073Enable TLS support:
74
75.. code-block:: yaml
76
77 galera:
78 slave or master:
79 ssl:
80 enabled: True
Dzmitry Stremkouskif8433bf2018-10-23 11:29:03 +020081 ciphers:
82 DHE-RSA-AES128-SHA:
83 enabled: True
84 DHE-RSA-AES256-SHA:
85 enabled: True
86 EDH-RSA-DES-CBC3-SHA:
87 name: EDH-RSA-DES-CBC3-SHA
88 enabled: True
89 AES128-SHA:AES256-SHA:
90 name: AES128-SHA:AES256-SHA
91 enabled: True
92 DES-CBC3-SHA:
93 enabled: True
Kirill Bespalov5f0c1d62017-08-15 15:29:32 +030094 # path
95 cert_file: /etc/mysql/ssl/cert.pem
96 key_file: /etc/mysql/ssl/key.pem
97 ca_file: /etc/mysql/ssl/ca.pem
98
99 # content (not required if files already exists)
100 key: << body of key >>
101 cert: << body of cert >>
102 cacert_chain: << body of ca certs chain >>
103
104
Petr Michalecbca6ffa2017-05-22 13:10:20 +0200105Additional mysql users:
106
107.. code-block:: yaml
108
109 mysql:
110 server:
111 users:
112 - name: clustercheck
113 password: clustercheck
114 database: '*.*'
115 grants: PROCESS
Petr Michalecbca6ffa2017-05-22 13:10:20 +0200116 - name: inspector
117 host: 127.0.0.1
118 password: password
119 databases:
120 mydb:
121 - database: mydb
122 - table: mytable
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200123 - grant_option: True
Petr Michalecbca6ffa2017-05-22 13:10:20 +0200124 - grants:
125 - all privileges
126
Vasyl Saienko79f69062018-01-29 11:04:58 +0200127Additional mysql SSL grants:
128
129.. code-block:: yaml
130
131 mysql:
132 server:
133 users:
134 - name: clustercheck
135 password: clustercheck
136 database: '*.*'
137 grants: PROCESS
138 ssl_option:
139 - SSL: True
140 - X509: True
141 - SUBJECT: <subject>
142 - ISSUER: <issuer>
143 - CIPHER: <cipher>
144
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200145Additional check params:
Petr Michalec518b8342017-08-04 11:23:03 +0200146========================
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200147
148.. code-block:: yaml
149
150 galera:
151 clustercheck:
152 - enabled: True
153 - user: clustercheck
154 - password: clustercheck
155 - available_when_donor: 0
156 - available_when_readonly: 1
157 - port 9200
158
Dmitry Kalashnikd4e5f472017-08-09 14:28:17 +0400159Configurable soft parameters
160============================
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300161
OlgaGusarenko43e99902018-07-30 17:18:32 +0300162- ``galera_innodb_buffer_pool_size``
163 Default is ``3138M``
164- ``galera_max_connections``
165 Default is ``20000``
166- ``galera_innodb_read_io_threads``
167 Default is ``8``
168- ``galera_innodb_write_io_threads``
169 Default is ``8``
170- ``galera_wsrep_slave_threads``
171 Default is ``8``
172- ``galera_xtrabackup_parallel``
173 Default is 4
174- ``galera_error_log_enabled``
Michal Kobus6a33c422018-09-28 14:32:57 +0200175 Default is ``true``
176- ``galera_error_log_path``
177 Default is ``/var/log/mysql/error.log``
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300178
Vasyl Saienkoc50ffc72018-11-15 10:58:50 +0000179When the following parameters are set to 0, theirs
180defaults will be calclulated automatically based on number
181of cpu cores:
182
183 - galera_innodb_read_io_threads
184 - galera_innodb_write_io_threads
185 - galera_wsrep_slave_threads
186
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300187Usage:
OlgaGusarenko43e99902018-07-30 17:18:32 +0300188
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300189.. code-block:: yaml
190
Dmitry Kalashnikd4e5f472017-08-09 14:28:17 +0400191 _param:
192 galera_innodb_buffer_pool_size: 1024M
Kirill Bespalov5f0c1d62017-08-15 15:29:32 +0300193 galera_max_connections: 200
Dennis Dmitriev2c572892018-03-05 23:32:34 +0200194 galera_innodb_read_io_threads: 16
195 galera_innodb_write_io_threads: 16
196 galera_wsrep_slave_threads: 8
197 galera_xtrabackup_parallel: 2
198 galera_error_log_enabled: true
Michal Kobus6a33c422018-09-28 14:32:57 +0200199 galera_error_log_path: /var/log/mysql/error.log
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300200
Ales Komarekcba48ac2015-04-30 11:40:44 +0200201Usage
202=====
203
204MySQL Galera check sripts
205
206.. code-block:: bash
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200207
Ales Komarekcba48ac2015-04-30 11:40:44 +0200208 mysql> SHOW STATUS LIKE 'wsrep%';
209
210 mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;"
211
212Galera monitoring command, performed from extra server
213
214.. code-block:: bash
215
216 garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d
217
OlgaGusarenko43e99902018-07-30 17:18:32 +0300218#. salt-call state.sls mysql
219#. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst)
220#. service mysql start
221#. run on each node mysql_secure_install and filling root password.
Ales Komarekcba48ac2015-04-30 11:40:44 +0200222
OlgaGusarenko43e99902018-07-30 17:18:32 +0300223 .. code-block:: bash
Ales Komarekcba48ac2015-04-30 11:40:44 +0200224
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300225 Enter current password for root (enter for none):
Ales Komarekcba48ac2015-04-30 11:40:44 +0200226 OK, successfully used password, moving on...
227
228 Setting the root password ensures that nobody can log into the MySQL
229 root user without the proper authorisation.
230
231 Set root password? [Y/n] y
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300232 New password:
233 Re-enter new password:
Ales Komarekcba48ac2015-04-30 11:40:44 +0200234 Password updated successfully!
235 Reloading privilege tables..
236 ... Success!
237
238 By default, a MySQL installation has an anonymous user, allowing anyone
239 to log into MySQL without having to have a user account created for
240 them. This is intended only for testing, and to make the installation
241 go a bit smoother. You should remove them before moving into a
242 production environment.
243
244 Remove anonymous users? [Y/n] y
245 ... Success!
246
247 Normally, root should only be allowed to connect from 'localhost'. This
248 ensures that someone cannot guess at the root password from the network.
249
250 Disallow root login remotely? [Y/n] n
251 ... skipping.
252
253 By default, MySQL comes with a database named 'test' that anyone can
254 access. This is also intended only for testing, and should be removed
255 before moving into a production environment.
256
257 Remove test database and access to it? [Y/n] y
258 - Dropping test database...
259 ... Success!
260 - Removing privileges on test database...
261 ... Success!
262
263 Reloading the privilege tables will ensure that all changes made so far
264 will take effect immediately.
265
266 Reload privilege tables now? [Y/n] y
267 ... Success!
268
269 Cleaning up...
270
OlgaGusarenko43e99902018-07-30 17:18:32 +0300271#. service mysql stop
272#. uncomment all wsrep* lines except first server, where leave only in
273 my.cnf wsrep_cluster_address='gcomm://';
274#. start first node
275#. Start third node which is connected to first one
276#. Start second node which is connected to third one
277#. After starting cluster, it must be change cluster address at first starting node
278 without restart database and change config my.cnf.
Ales Komarekcba48ac2015-04-30 11:40:44 +0200279
OlgaGusarenko43e99902018-07-30 17:18:32 +0300280 .. code-block:: bash
Ales Komarekcba48ac2015-04-30 11:40:44 +0200281
OlgaGusarenko43e99902018-07-30 17:18:32 +0300282 mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2';
Ales Komarekcba48ac2015-04-30 11:40:44 +0200283
284Read more
285=========
286
287* https://github.com/CaptTofu/ansible-galera
288* http://www.sebastien-han.fr/blog/2012/04/15/active-passive-failover-cluster-on-a-mysql-galera-cluster-with-haproxy-lsb-agent/
289* http://opentodo.net/2012/12/mysql-multi-master-replication-with-galera/
290* http://www.codership.com/wiki/doku.php
OlgaGusarenko43e99902018-07-30 17:18:32 +0300291* http://www.sebastien-han.fr/blog/2012/04/01/mysql-multi-master-replication-with-galera/