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 |
Stanislav Riazanov | 7205cbf | 2018-12-18 14:38:29 +0400 | [diff] [blame] | 36 | sst: |
| 37 | user: sstuser |
| 38 | password: sstpassword |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 39 | database: |
| 40 | name: |
| 41 | encoding: 'utf8' |
| 42 | users: |
| 43 | - name: 'username' |
| 44 | password: 'password' |
| 45 | host: 'localhost' |
| 46 | rights: 'all privileges' |
Dzmitry Stremkouski | 9aa7108 | 2018-10-29 13:36:13 +0100 | [diff] [blame] | 47 | database: '*.*' |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 48 | |
| 49 | Galera 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 Riazanov | 7205cbf | 2018-12-18 14:38:29 +0400 | [diff] [blame] | 68 | sst: |
| 69 | user: sstuser |
| 70 | password: sstpassword |
| 71 | |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 72 | |
Kirill Bespalov | 5f0c1d6 | 2017-08-15 15:29:32 +0300 | [diff] [blame] | 73 | Enable TLS support: |
| 74 | |
| 75 | .. code-block:: yaml |
| 76 | |
| 77 | galera: |
| 78 | slave or master: |
| 79 | ssl: |
| 80 | enabled: True |
Dzmitry Stremkouski | f8433bf | 2018-10-23 11:29:03 +0200 | [diff] [blame] | 81 | 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 Bespalov | 5f0c1d6 | 2017-08-15 15:29:32 +0300 | [diff] [blame] | 94 | # 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 Saienko | 9c69689 | 2020-09-04 09:53:54 +0300 | [diff] [blame] | 104 | Custom 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 Bespalov | 5f0c1d6 | 2017-08-15 15:29:32 +0300 | [diff] [blame] | 114 | |
Petr Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 115 | Additional 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 Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 126 | - name: inspector |
| 127 | host: 127.0.0.1 |
| 128 | password: password |
| 129 | databases: |
| 130 | mydb: |
| 131 | - database: mydb |
| 132 | - table: mytable |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 133 | - grant_option: True |
Petr Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 134 | - grants: |
| 135 | - all privileges |
| 136 | |
Vasyl Saienko | 79f6906 | 2018-01-29 11:04:58 +0200 | [diff] [blame] | 137 | Additional 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 Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 155 | Additional check params: |
Petr Michalec | 518b834 | 2017-08-04 11:23:03 +0200 | [diff] [blame] | 156 | ======================== |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 157 | |
| 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 Kalashnik | d4e5f47 | 2017-08-09 14:28:17 +0400 | [diff] [blame] | 169 | Configurable soft parameters |
| 170 | ============================ |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 171 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 172 | - ``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 Kobus | 6a33c42 | 2018-09-28 14:32:57 +0200 | [diff] [blame] | 185 | Default is ``true`` |
| 186 | - ``galera_error_log_path`` |
| 187 | Default is ``/var/log/mysql/error.log`` |
Kostiantyn Ovchynnykov | 18e6828 | 2021-01-22 16:22:38 +0200 | [diff] [blame] | 188 | - ``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 Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 194 | |
Vasyl Saienko | c50ffc7 | 2018-11-15 10:58:50 +0000 | [diff] [blame] | 195 | When the following parameters are set to 0, theirs |
| 196 | defaults will be calclulated automatically based on number |
| 197 | of cpu cores: |
| 198 | |
| 199 | - galera_innodb_read_io_threads |
| 200 | - galera_innodb_write_io_threads |
| 201 | - galera_wsrep_slave_threads |
| 202 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 203 | Usage: |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 204 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 205 | .. code-block:: yaml |
| 206 | |
Dmitry Kalashnik | d4e5f47 | 2017-08-09 14:28:17 +0400 | [diff] [blame] | 207 | _param: |
| 208 | galera_innodb_buffer_pool_size: 1024M |
Kirill Bespalov | 5f0c1d6 | 2017-08-15 15:29:32 +0300 | [diff] [blame] | 209 | galera_max_connections: 200 |
Dennis Dmitriev | 2c57289 | 2018-03-05 23:32:34 +0200 | [diff] [blame] | 210 | 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 Kobus | 6a33c42 | 2018-09-28 14:32:57 +0200 | [diff] [blame] | 215 | galera_error_log_path: /var/log/mysql/error.log |
Kostiantyn Ovchynnykov | 18e6828 | 2021-01-22 16:22:38 +0200 | [diff] [blame] | 216 | galera_innodb_io_capacity: 500 |
| 217 | galera_innodb_io_capacity_max: 2000 |
| 218 | galera_innodb_flush_neighbors: 1 |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 219 | |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 220 | Usage |
| 221 | ===== |
| 222 | |
| 223 | MySQL Galera check sripts |
| 224 | |
| 225 | .. code-block:: bash |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 226 | |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 227 | mysql> SHOW STATUS LIKE 'wsrep%'; |
| 228 | |
| 229 | mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;" |
| 230 | |
| 231 | Galera 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 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 237 | #. 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 Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 241 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 242 | .. code-block:: bash |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 243 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 244 | Enter current password for root (enter for none): |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 245 | 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 Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 251 | New password: |
| 252 | Re-enter new password: |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 253 | 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 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 290 | #. 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 Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 298 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 299 | .. code-block:: bash |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 300 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 301 | mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2'; |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 302 | |
| 303 | Read 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 |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 310 | * http://www.sebastien-han.fr/blog/2012/04/01/mysql-multi-master-replication-with-galera/ |