blob: 7a8eab01af8c9d7e6d31309257e9aa9cdb12c6b2 [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
Vasyl Saienko9c696892020-09-04 09:53:54 +0300104Custom wsrep_provider_options:
105
106.. code-block:: yaml
107
108 galera:
109 slave or master:
110 wsrep_provider_options:
111 evs.inactive_check_period: "PT2.5S"
112 evs.inactive_timeout: "PT30S"
113 gmcast.peer_timeout: "PT9S"
Kirill Bespalov5f0c1d62017-08-15 15:29:32 +0300114
Petr Michalecbca6ffa2017-05-22 13:10:20 +0200115Additional mysql users:
116
117.. code-block:: yaml
118
119 mysql:
120 server:
121 users:
122 - name: clustercheck
123 password: clustercheck
124 database: '*.*'
125 grants: PROCESS
Petr Michalecbca6ffa2017-05-22 13:10:20 +0200126 - name: inspector
127 host: 127.0.0.1
128 password: password
129 databases:
130 mydb:
131 - database: mydb
132 - table: mytable
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200133 - grant_option: True
Petr Michalecbca6ffa2017-05-22 13:10:20 +0200134 - grants:
135 - all privileges
136
Vasyl Saienko79f69062018-01-29 11:04:58 +0200137Additional mysql SSL grants:
138
139.. code-block:: yaml
140
141 mysql:
142 server:
143 users:
144 - name: clustercheck
145 password: clustercheck
146 database: '*.*'
147 grants: PROCESS
148 ssl_option:
149 - SSL: True
150 - X509: True
151 - SUBJECT: <subject>
152 - ISSUER: <issuer>
153 - CIPHER: <cipher>
154
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200155Additional check params:
Petr Michalec518b8342017-08-04 11:23:03 +0200156========================
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200157
158.. code-block:: yaml
159
160 galera:
161 clustercheck:
162 - enabled: True
163 - user: clustercheck
164 - password: clustercheck
165 - available_when_donor: 0
166 - available_when_readonly: 1
167 - port 9200
168
Dmitry Kalashnikd4e5f472017-08-09 14:28:17 +0400169Configurable soft parameters
170============================
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300171
OlgaGusarenko43e99902018-07-30 17:18:32 +0300172- ``galera_innodb_buffer_pool_size``
173 Default is ``3138M``
174- ``galera_max_connections``
175 Default is ``20000``
176- ``galera_innodb_read_io_threads``
177 Default is ``8``
178- ``galera_innodb_write_io_threads``
179 Default is ``8``
180- ``galera_wsrep_slave_threads``
181 Default is ``8``
182- ``galera_xtrabackup_parallel``
183 Default is 4
184- ``galera_error_log_enabled``
Michal Kobus6a33c422018-09-28 14:32:57 +0200185 Default is ``true``
186- ``galera_error_log_path``
187 Default is ``/var/log/mysql/error.log``
Kostiantyn Ovchynnykov18e68282021-01-22 16:22:38 +0200188- ``galera_innodb_io_capacity``
189 Default is ``500``
190- ``galera_innodb_io_capacity_max``
191 Default is ``2000``
192- ``galera_innodb_flush_neighbors``
193 Default is ``1``
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300194
Vasyl Saienkoc50ffc72018-11-15 10:58:50 +0000195When the following parameters are set to 0, theirs
196defaults will be calclulated automatically based on number
197of cpu cores:
198
199 - galera_innodb_read_io_threads
200 - galera_innodb_write_io_threads
201 - galera_wsrep_slave_threads
202
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300203Usage:
OlgaGusarenko43e99902018-07-30 17:18:32 +0300204
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300205.. code-block:: yaml
206
Dmitry Kalashnikd4e5f472017-08-09 14:28:17 +0400207 _param:
208 galera_innodb_buffer_pool_size: 1024M
Kirill Bespalov5f0c1d62017-08-15 15:29:32 +0300209 galera_max_connections: 200
Dennis Dmitriev2c572892018-03-05 23:32:34 +0200210 galera_innodb_read_io_threads: 16
211 galera_innodb_write_io_threads: 16
212 galera_wsrep_slave_threads: 8
213 galera_xtrabackup_parallel: 2
214 galera_error_log_enabled: true
Michal Kobus6a33c422018-09-28 14:32:57 +0200215 galera_error_log_path: /var/log/mysql/error.log
Kostiantyn Ovchynnykov18e68282021-01-22 16:22:38 +0200216 galera_innodb_io_capacity: 500
217 galera_innodb_io_capacity_max: 2000
218 galera_innodb_flush_neighbors: 1
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300219
Ales Komarekcba48ac2015-04-30 11:40:44 +0200220Usage
221=====
222
223MySQL Galera check sripts
224
225.. code-block:: bash
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200226
Ales Komarekcba48ac2015-04-30 11:40:44 +0200227 mysql> SHOW STATUS LIKE 'wsrep%';
228
229 mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;"
230
231Galera monitoring command, performed from extra server
232
233.. code-block:: bash
234
235 garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d
236
OlgaGusarenko43e99902018-07-30 17:18:32 +0300237#. salt-call state.sls mysql
238#. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst)
239#. service mysql start
240#. run on each node mysql_secure_install and filling root password.
Ales Komarekcba48ac2015-04-30 11:40:44 +0200241
OlgaGusarenko43e99902018-07-30 17:18:32 +0300242 .. code-block:: bash
Ales Komarekcba48ac2015-04-30 11:40:44 +0200243
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300244 Enter current password for root (enter for none):
Ales Komarekcba48ac2015-04-30 11:40:44 +0200245 OK, successfully used password, moving on...
246
247 Setting the root password ensures that nobody can log into the MySQL
248 root user without the proper authorisation.
249
250 Set root password? [Y/n] y
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300251 New password:
252 Re-enter new password:
Ales Komarekcba48ac2015-04-30 11:40:44 +0200253 Password updated successfully!
254 Reloading privilege tables..
255 ... Success!
256
257 By default, a MySQL installation has an anonymous user, allowing anyone
258 to log into MySQL without having to have a user account created for
259 them. This is intended only for testing, and to make the installation
260 go a bit smoother. You should remove them before moving into a
261 production environment.
262
263 Remove anonymous users? [Y/n] y
264 ... Success!
265
266 Normally, root should only be allowed to connect from 'localhost'. This
267 ensures that someone cannot guess at the root password from the network.
268
269 Disallow root login remotely? [Y/n] n
270 ... skipping.
271
272 By default, MySQL comes with a database named 'test' that anyone can
273 access. This is also intended only for testing, and should be removed
274 before moving into a production environment.
275
276 Remove test database and access to it? [Y/n] y
277 - Dropping test database...
278 ... Success!
279 - Removing privileges on test database...
280 ... Success!
281
282 Reloading the privilege tables will ensure that all changes made so far
283 will take effect immediately.
284
285 Reload privilege tables now? [Y/n] y
286 ... Success!
287
288 Cleaning up...
289
OlgaGusarenko43e99902018-07-30 17:18:32 +0300290#. service mysql stop
291#. uncomment all wsrep* lines except first server, where leave only in
292 my.cnf wsrep_cluster_address='gcomm://';
293#. start first node
294#. Start third node which is connected to first one
295#. Start second node which is connected to third one
296#. After starting cluster, it must be change cluster address at first starting node
297 without restart database and change config my.cnf.
Ales Komarekcba48ac2015-04-30 11:40:44 +0200298
OlgaGusarenko43e99902018-07-30 17:18:32 +0300299 .. code-block:: bash
Ales Komarekcba48ac2015-04-30 11:40:44 +0200300
OlgaGusarenko43e99902018-07-30 17:18:32 +0300301 mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2';
Ales Komarekcba48ac2015-04-30 11:40:44 +0200302
303Read more
304=========
305
306* https://github.com/CaptTofu/ansible-galera
307* http://www.sebastien-han.fr/blog/2012/04/15/active-passive-failover-cluster-on-a-mysql-galera-cluster-with-haproxy-lsb-agent/
308* http://opentodo.net/2012/12/mysql-multi-master-replication-with-galera/
309* http://www.codership.com/wiki/doku.php
OlgaGusarenko43e99902018-07-30 17:18:32 +0300310* http://www.sebastien-han.fr/blog/2012/04/01/mysql-multi-master-replication-with-galera/