blob: 788e908a8d54e707e0a2168fc55e398783c8a311 [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'
Dzmitry Stremkouski9aa71082018-10-29 13:36:13 +010044 database: '*.*'
Ales Komarekcba48ac2015-04-30 11:40:44 +020045
46Galera cluster slave node
47
48.. code-block:: yaml
49
50 galera:
51 slave:
52 enabled: true
53 name: openstack
54 bind:
55 address: 192.168.0.2
56 port: 3306
57 members:
58 - host: 192.168.0.1
59 port: 4567
60 - host: 192.168.0.2
61 port: 4567
62 admin:
63 user: root
64 password: pass
65
Kirill Bespalov5f0c1d62017-08-15 15:29:32 +030066Enable TLS support:
67
68.. code-block:: yaml
69
70 galera:
71 slave or master:
72 ssl:
73 enabled: True
Dzmitry Stremkouskif8433bf2018-10-23 11:29:03 +020074 ciphers:
75 DHE-RSA-AES128-SHA:
76 enabled: True
77 DHE-RSA-AES256-SHA:
78 enabled: True
79 EDH-RSA-DES-CBC3-SHA:
80 name: EDH-RSA-DES-CBC3-SHA
81 enabled: True
82 AES128-SHA:AES256-SHA:
83 name: AES128-SHA:AES256-SHA
84 enabled: True
85 DES-CBC3-SHA:
86 enabled: True
Kirill Bespalov5f0c1d62017-08-15 15:29:32 +030087 # path
88 cert_file: /etc/mysql/ssl/cert.pem
89 key_file: /etc/mysql/ssl/key.pem
90 ca_file: /etc/mysql/ssl/ca.pem
91
92 # content (not required if files already exists)
93 key: << body of key >>
94 cert: << body of cert >>
95 cacert_chain: << body of ca certs chain >>
96
97
Petr Michalecbca6ffa2017-05-22 13:10:20 +020098Additional mysql users:
99
100.. code-block:: yaml
101
102 mysql:
103 server:
104 users:
105 - name: clustercheck
106 password: clustercheck
107 database: '*.*'
108 grants: PROCESS
Petr Michalecbca6ffa2017-05-22 13:10:20 +0200109 - name: inspector
110 host: 127.0.0.1
111 password: password
112 databases:
113 mydb:
114 - database: mydb
115 - table: mytable
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200116 - grant_option: True
Petr Michalecbca6ffa2017-05-22 13:10:20 +0200117 - grants:
118 - all privileges
119
Vasyl Saienko79f69062018-01-29 11:04:58 +0200120Additional mysql SSL grants:
121
122.. code-block:: yaml
123
124 mysql:
125 server:
126 users:
127 - name: clustercheck
128 password: clustercheck
129 database: '*.*'
130 grants: PROCESS
131 ssl_option:
132 - SSL: True
133 - X509: True
134 - SUBJECT: <subject>
135 - ISSUER: <issuer>
136 - CIPHER: <cipher>
137
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200138Additional check params:
Petr Michalec518b8342017-08-04 11:23:03 +0200139========================
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200140
141.. code-block:: yaml
142
143 galera:
144 clustercheck:
145 - enabled: True
146 - user: clustercheck
147 - password: clustercheck
148 - available_when_donor: 0
149 - available_when_readonly: 1
150 - port 9200
151
Dmitry Kalashnikd4e5f472017-08-09 14:28:17 +0400152Configurable soft parameters
153============================
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300154
OlgaGusarenko43e99902018-07-30 17:18:32 +0300155- ``galera_innodb_buffer_pool_size``
156 Default is ``3138M``
157- ``galera_max_connections``
158 Default is ``20000``
159- ``galera_innodb_read_io_threads``
160 Default is ``8``
161- ``galera_innodb_write_io_threads``
162 Default is ``8``
163- ``galera_wsrep_slave_threads``
164 Default is ``8``
165- ``galera_xtrabackup_parallel``
166 Default is 4
167- ``galera_error_log_enabled``
Michal Kobus6a33c422018-09-28 14:32:57 +0200168 Default is ``true``
169- ``galera_error_log_path``
170 Default is ``/var/log/mysql/error.log``
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300171
Vasyl Saienkoc50ffc72018-11-15 10:58:50 +0000172When the following parameters are set to 0, theirs
173defaults will be calclulated automatically based on number
174of cpu cores:
175
176 - galera_innodb_read_io_threads
177 - galera_innodb_write_io_threads
178 - galera_wsrep_slave_threads
179
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300180Usage:
OlgaGusarenko43e99902018-07-30 17:18:32 +0300181
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300182.. code-block:: yaml
183
Dmitry Kalashnikd4e5f472017-08-09 14:28:17 +0400184 _param:
185 galera_innodb_buffer_pool_size: 1024M
Kirill Bespalov5f0c1d62017-08-15 15:29:32 +0300186 galera_max_connections: 200
Dennis Dmitriev2c572892018-03-05 23:32:34 +0200187 galera_innodb_read_io_threads: 16
188 galera_innodb_write_io_threads: 16
189 galera_wsrep_slave_threads: 8
190 galera_xtrabackup_parallel: 2
191 galera_error_log_enabled: true
Michal Kobus6a33c422018-09-28 14:32:57 +0200192 galera_error_log_path: /var/log/mysql/error.log
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300193
Ales Komarekcba48ac2015-04-30 11:40:44 +0200194Usage
195=====
196
197MySQL Galera check sripts
198
199.. code-block:: bash
Petr Michalec89c8c3f2017-05-22 17:19:22 +0200200
Ales Komarekcba48ac2015-04-30 11:40:44 +0200201 mysql> SHOW STATUS LIKE 'wsrep%';
202
203 mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;"
204
205Galera monitoring command, performed from extra server
206
207.. code-block:: bash
208
209 garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d
210
OlgaGusarenko43e99902018-07-30 17:18:32 +0300211#. salt-call state.sls mysql
212#. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst)
213#. service mysql start
214#. run on each node mysql_secure_install and filling root password.
Ales Komarekcba48ac2015-04-30 11:40:44 +0200215
OlgaGusarenko43e99902018-07-30 17:18:32 +0300216 .. code-block:: bash
Ales Komarekcba48ac2015-04-30 11:40:44 +0200217
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300218 Enter current password for root (enter for none):
Ales Komarekcba48ac2015-04-30 11:40:44 +0200219 OK, successfully used password, moving on...
220
221 Setting the root password ensures that nobody can log into the MySQL
222 root user without the proper authorisation.
223
224 Set root password? [Y/n] y
Kirill Bespalov162a4d42017-06-21 02:26:19 +0300225 New password:
226 Re-enter new password:
Ales Komarekcba48ac2015-04-30 11:40:44 +0200227 Password updated successfully!
228 Reloading privilege tables..
229 ... Success!
230
231 By default, a MySQL installation has an anonymous user, allowing anyone
232 to log into MySQL without having to have a user account created for
233 them. This is intended only for testing, and to make the installation
234 go a bit smoother. You should remove them before moving into a
235 production environment.
236
237 Remove anonymous users? [Y/n] y
238 ... Success!
239
240 Normally, root should only be allowed to connect from 'localhost'. This
241 ensures that someone cannot guess at the root password from the network.
242
243 Disallow root login remotely? [Y/n] n
244 ... skipping.
245
246 By default, MySQL comes with a database named 'test' that anyone can
247 access. This is also intended only for testing, and should be removed
248 before moving into a production environment.
249
250 Remove test database and access to it? [Y/n] y
251 - Dropping test database...
252 ... Success!
253 - Removing privileges on test database...
254 ... Success!
255
256 Reloading the privilege tables will ensure that all changes made so far
257 will take effect immediately.
258
259 Reload privilege tables now? [Y/n] y
260 ... Success!
261
262 Cleaning up...
263
OlgaGusarenko43e99902018-07-30 17:18:32 +0300264#. service mysql stop
265#. uncomment all wsrep* lines except first server, where leave only in
266 my.cnf wsrep_cluster_address='gcomm://';
267#. start first node
268#. Start third node which is connected to first one
269#. Start second node which is connected to third one
270#. After starting cluster, it must be change cluster address at first starting node
271 without restart database and change config my.cnf.
Ales Komarekcba48ac2015-04-30 11:40:44 +0200272
OlgaGusarenko43e99902018-07-30 17:18:32 +0300273 .. code-block:: bash
Ales Komarekcba48ac2015-04-30 11:40:44 +0200274
OlgaGusarenko43e99902018-07-30 17:18:32 +0300275 mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2';
Ales Komarekcba48ac2015-04-30 11:40:44 +0200276
277Read more
278=========
279
280* https://github.com/CaptTofu/ansible-galera
281* http://www.sebastien-han.fr/blog/2012/04/15/active-passive-failover-cluster-on-a-mysql-galera-cluster-with-haproxy-lsb-agent/
282* http://opentodo.net/2012/12/mysql-multi-master-replication-with-galera/
283* http://www.codership.com/wiki/doku.php
OlgaGusarenko43e99902018-07-30 17:18:32 +0300284* http://www.sebastien-han.fr/blog/2012/04/01/mysql-multi-master-replication-with-galera/