blob: 9f17ac0b61e9e4a59a9aa3507cd613ff2451c10a [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``
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300188
Vasyl Saienkoc50ffc72018-11-15 10:58:50 +0000189When the following parameters are set to 0, theirs
190defaults will be calclulated automatically based on number
191of cpu cores:
192
193 - galera_innodb_read_io_threads
194 - galera_innodb_write_io_threads
195 - galera_wsrep_slave_threads
196
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300197Usage:
OlgaGusarenko43e99902018-07-30 17:18:32 +0300198
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300199.. code-block:: yaml
200
Dmitry Kalashnikd4e5f472017-08-09 14:28:17 +0400201 _param:
202 galera_innodb_buffer_pool_size: 1024M
Kirill Bespalov5f0c1d62017-08-15 15:29:32 +0300203 galera_max_connections: 200
Dennis Dmitriev2c572892018-03-05 23:32:34 +0200204 galera_innodb_read_io_threads: 16
205 galera_innodb_write_io_threads: 16
206 galera_wsrep_slave_threads: 8
207 galera_xtrabackup_parallel: 2
208 galera_error_log_enabled: true
Michal Kobus6a33c422018-09-28 14:32:57 +0200209 galera_error_log_path: /var/log/mysql/error.log
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300210
Ales Komarekcba48ac2015-04-30 11:40:44 +0200211Usage
212=====
213
214MySQL Galera check sripts
215
216.. code-block:: bash
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200217
Ales Komarekcba48ac2015-04-30 11:40:44 +0200218 mysql> SHOW STATUS LIKE 'wsrep%';
219
220 mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;"
221
222Galera monitoring command, performed from extra server
223
224.. code-block:: bash
225
226 garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d
227
OlgaGusarenko43e99902018-07-30 17:18:32 +0300228#. salt-call state.sls mysql
229#. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst)
230#. service mysql start
231#. run on each node mysql_secure_install and filling root password.
Ales Komarekcba48ac2015-04-30 11:40:44 +0200232
OlgaGusarenko43e99902018-07-30 17:18:32 +0300233 .. code-block:: bash
Ales Komarekcba48ac2015-04-30 11:40:44 +0200234
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300235 Enter current password for root (enter for none):
Ales Komarekcba48ac2015-04-30 11:40:44 +0200236 OK, successfully used password, moving on...
237
238 Setting the root password ensures that nobody can log into the MySQL
239 root user without the proper authorisation.
240
241 Set root password? [Y/n] y
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300242 New password:
243 Re-enter new password:
Ales Komarekcba48ac2015-04-30 11:40:44 +0200244 Password updated successfully!
245 Reloading privilege tables..
246 ... Success!
247
248 By default, a MySQL installation has an anonymous user, allowing anyone
249 to log into MySQL without having to have a user account created for
250 them. This is intended only for testing, and to make the installation
251 go a bit smoother. You should remove them before moving into a
252 production environment.
253
254 Remove anonymous users? [Y/n] y
255 ... Success!
256
257 Normally, root should only be allowed to connect from 'localhost'. This
258 ensures that someone cannot guess at the root password from the network.
259
260 Disallow root login remotely? [Y/n] n
261 ... skipping.
262
263 By default, MySQL comes with a database named 'test' that anyone can
264 access. This is also intended only for testing, and should be removed
265 before moving into a production environment.
266
267 Remove test database and access to it? [Y/n] y
268 - Dropping test database...
269 ... Success!
270 - Removing privileges on test database...
271 ... Success!
272
273 Reloading the privilege tables will ensure that all changes made so far
274 will take effect immediately.
275
276 Reload privilege tables now? [Y/n] y
277 ... Success!
278
279 Cleaning up...
280
OlgaGusarenko43e99902018-07-30 17:18:32 +0300281#. service mysql stop
282#. uncomment all wsrep* lines except first server, where leave only in
283 my.cnf wsrep_cluster_address='gcomm://';
284#. start first node
285#. Start third node which is connected to first one
286#. Start second node which is connected to third one
287#. After starting cluster, it must be change cluster address at first starting node
288 without restart database and change config my.cnf.
Ales Komarekcba48ac2015-04-30 11:40:44 +0200289
OlgaGusarenko43e99902018-07-30 17:18:32 +0300290 .. code-block:: bash
Ales Komarekcba48ac2015-04-30 11:40:44 +0200291
OlgaGusarenko43e99902018-07-30 17:18:32 +0300292 mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2';
Ales Komarekcba48ac2015-04-30 11:40:44 +0200293
294Read more
295=========
296
297* https://github.com/CaptTofu/ansible-galera
298* http://www.sebastien-han.fr/blog/2012/04/15/active-passive-failover-cluster-on-a-mysql-galera-cluster-with-haproxy-lsb-agent/
299* http://opentodo.net/2012/12/mysql-multi-master-replication-with-galera/
300* http://www.codership.com/wiki/doku.php
OlgaGusarenko43e99902018-07-30 17:18:32 +0300301* http://www.sebastien-han.fr/blog/2012/04/01/mysql-multi-master-replication-with-galera/