Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 1 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 2 | ===== |
| 3 | Usage |
| 4 | ===== |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 5 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 6 | Galera Cluster for MySQL is a true Multimaster Cluster based on synchronous |
| 7 | replication. Galera Cluster is an easy-to-use, high-availability solution, |
| 8 | which provides high system uptime, no data loss and scalability for future |
| 9 | growth. |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 10 | |
| 11 | Sample pillars |
| 12 | ============== |
| 13 | |
| 14 | Galera cluster master node |
| 15 | |
| 16 | .. code-block:: yaml |
| 17 | |
| 18 | galera: |
Petr Michalec | 5ff575c | 2017-11-06 15:37:05 +0100 | [diff] [blame] | 19 | version: |
| 20 | mysql: 5.6 |
| 21 | galera: 3 |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 22 | 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 Stremkouski | 9aa7108 | 2018-10-29 13:36:13 +0100 | [diff] [blame] | 44 | database: '*.*' |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 45 | |
| 46 | Galera 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 Bespalov | 5f0c1d6 | 2017-08-15 15:29:32 +0300 | [diff] [blame] | 66 | Enable TLS support: |
| 67 | |
| 68 | .. code-block:: yaml |
| 69 | |
| 70 | galera: |
| 71 | slave or master: |
| 72 | ssl: |
| 73 | enabled: True |
Dzmitry Stremkouski | f8433bf | 2018-10-23 11:29:03 +0200 | [diff] [blame] | 74 | 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 Bespalov | 5f0c1d6 | 2017-08-15 15:29:32 +0300 | [diff] [blame] | 87 | # 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 Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 98 | Additional 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 Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 109 | - name: inspector |
| 110 | host: 127.0.0.1 |
| 111 | password: password |
| 112 | databases: |
| 113 | mydb: |
| 114 | - database: mydb |
| 115 | - table: mytable |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 116 | - grant_option: True |
Petr Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 117 | - grants: |
| 118 | - all privileges |
| 119 | |
Vasyl Saienko | 79f6906 | 2018-01-29 11:04:58 +0200 | [diff] [blame] | 120 | Additional 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 Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 138 | Additional check params: |
Petr Michalec | 518b834 | 2017-08-04 11:23:03 +0200 | [diff] [blame] | 139 | ======================== |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 140 | |
| 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 Kalashnik | d4e5f47 | 2017-08-09 14:28:17 +0400 | [diff] [blame] | 152 | Configurable soft parameters |
| 153 | ============================ |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 154 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 155 | - ``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 Kobus | 6a33c42 | 2018-09-28 14:32:57 +0200 | [diff] [blame] | 168 | Default is ``true`` |
| 169 | - ``galera_error_log_path`` |
| 170 | Default is ``/var/log/mysql/error.log`` |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 171 | |
Vasyl Saienko | c50ffc7 | 2018-11-15 10:58:50 +0000 | [diff] [blame] | 172 | When the following parameters are set to 0, theirs |
| 173 | defaults will be calclulated automatically based on number |
| 174 | of cpu cores: |
| 175 | |
| 176 | - galera_innodb_read_io_threads |
| 177 | - galera_innodb_write_io_threads |
| 178 | - galera_wsrep_slave_threads |
| 179 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 180 | Usage: |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 181 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 182 | .. code-block:: yaml |
| 183 | |
Dmitry Kalashnik | d4e5f47 | 2017-08-09 14:28:17 +0400 | [diff] [blame] | 184 | _param: |
| 185 | galera_innodb_buffer_pool_size: 1024M |
Kirill Bespalov | 5f0c1d6 | 2017-08-15 15:29:32 +0300 | [diff] [blame] | 186 | galera_max_connections: 200 |
Dennis Dmitriev | 2c57289 | 2018-03-05 23:32:34 +0200 | [diff] [blame] | 187 | 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 Kobus | 6a33c42 | 2018-09-28 14:32:57 +0200 | [diff] [blame] | 192 | galera_error_log_path: /var/log/mysql/error.log |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 193 | |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 194 | Usage |
| 195 | ===== |
| 196 | |
| 197 | MySQL Galera check sripts |
| 198 | |
| 199 | .. code-block:: bash |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 200 | |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 201 | mysql> SHOW STATUS LIKE 'wsrep%'; |
| 202 | |
| 203 | mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;" |
| 204 | |
| 205 | Galera 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 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 211 | #. 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 Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 215 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 216 | .. code-block:: bash |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 217 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 218 | Enter current password for root (enter for none): |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 219 | 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 Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 225 | New password: |
| 226 | Re-enter new password: |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 227 | 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 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 264 | #. 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 Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 272 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 273 | .. code-block:: bash |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 274 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 275 | mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2'; |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 276 | |
| 277 | Read 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 |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 284 | * http://www.sebastien-han.fr/blog/2012/04/01/mysql-multi-master-replication-with-galera/ |