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 | |
| 104 | |
Petr Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 105 | Additional mysql users: |
| 106 | |
| 107 | .. code-block:: yaml |
| 108 | |
| 109 | mysql: |
| 110 | server: |
| 111 | users: |
| 112 | - name: clustercheck |
| 113 | password: clustercheck |
| 114 | database: '*.*' |
| 115 | grants: PROCESS |
Petr Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 116 | - name: inspector |
| 117 | host: 127.0.0.1 |
| 118 | password: password |
| 119 | databases: |
| 120 | mydb: |
| 121 | - database: mydb |
| 122 | - table: mytable |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 123 | - grant_option: True |
Petr Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 124 | - grants: |
| 125 | - all privileges |
| 126 | |
Vasyl Saienko | 79f6906 | 2018-01-29 11:04:58 +0200 | [diff] [blame] | 127 | Additional mysql SSL grants: |
| 128 | |
| 129 | .. code-block:: yaml |
| 130 | |
| 131 | mysql: |
| 132 | server: |
| 133 | users: |
| 134 | - name: clustercheck |
| 135 | password: clustercheck |
| 136 | database: '*.*' |
| 137 | grants: PROCESS |
| 138 | ssl_option: |
| 139 | - SSL: True |
| 140 | - X509: True |
| 141 | - SUBJECT: <subject> |
| 142 | - ISSUER: <issuer> |
| 143 | - CIPHER: <cipher> |
| 144 | |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 145 | Additional check params: |
Petr Michalec | 518b834 | 2017-08-04 11:23:03 +0200 | [diff] [blame] | 146 | ======================== |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 147 | |
| 148 | .. code-block:: yaml |
| 149 | |
| 150 | galera: |
| 151 | clustercheck: |
| 152 | - enabled: True |
| 153 | - user: clustercheck |
| 154 | - password: clustercheck |
| 155 | - available_when_donor: 0 |
| 156 | - available_when_readonly: 1 |
| 157 | - port 9200 |
| 158 | |
Dmitry Kalashnik | d4e5f47 | 2017-08-09 14:28:17 +0400 | [diff] [blame] | 159 | Configurable soft parameters |
| 160 | ============================ |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 161 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 162 | - ``galera_innodb_buffer_pool_size`` |
| 163 | Default is ``3138M`` |
| 164 | - ``galera_max_connections`` |
| 165 | Default is ``20000`` |
| 166 | - ``galera_innodb_read_io_threads`` |
| 167 | Default is ``8`` |
| 168 | - ``galera_innodb_write_io_threads`` |
| 169 | Default is ``8`` |
| 170 | - ``galera_wsrep_slave_threads`` |
| 171 | Default is ``8`` |
| 172 | - ``galera_xtrabackup_parallel`` |
| 173 | Default is 4 |
| 174 | - ``galera_error_log_enabled`` |
Michal Kobus | 6a33c42 | 2018-09-28 14:32:57 +0200 | [diff] [blame] | 175 | Default is ``true`` |
| 176 | - ``galera_error_log_path`` |
| 177 | Default is ``/var/log/mysql/error.log`` |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 178 | |
Vasyl Saienko | c50ffc7 | 2018-11-15 10:58:50 +0000 | [diff] [blame] | 179 | When the following parameters are set to 0, theirs |
| 180 | defaults will be calclulated automatically based on number |
| 181 | of cpu cores: |
| 182 | |
| 183 | - galera_innodb_read_io_threads |
| 184 | - galera_innodb_write_io_threads |
| 185 | - galera_wsrep_slave_threads |
| 186 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 187 | Usage: |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 188 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 189 | .. code-block:: yaml |
| 190 | |
Dmitry Kalashnik | d4e5f47 | 2017-08-09 14:28:17 +0400 | [diff] [blame] | 191 | _param: |
| 192 | galera_innodb_buffer_pool_size: 1024M |
Kirill Bespalov | 5f0c1d6 | 2017-08-15 15:29:32 +0300 | [diff] [blame] | 193 | galera_max_connections: 200 |
Dennis Dmitriev | 2c57289 | 2018-03-05 23:32:34 +0200 | [diff] [blame] | 194 | galera_innodb_read_io_threads: 16 |
| 195 | galera_innodb_write_io_threads: 16 |
| 196 | galera_wsrep_slave_threads: 8 |
| 197 | galera_xtrabackup_parallel: 2 |
| 198 | galera_error_log_enabled: true |
Michal Kobus | 6a33c42 | 2018-09-28 14:32:57 +0200 | [diff] [blame] | 199 | galera_error_log_path: /var/log/mysql/error.log |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 200 | |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 201 | Usage |
| 202 | ===== |
| 203 | |
| 204 | MySQL Galera check sripts |
| 205 | |
| 206 | .. code-block:: bash |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 207 | |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 208 | mysql> SHOW STATUS LIKE 'wsrep%'; |
| 209 | |
| 210 | mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;" |
| 211 | |
| 212 | Galera monitoring command, performed from extra server |
| 213 | |
| 214 | .. code-block:: bash |
| 215 | |
| 216 | garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d |
| 217 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 218 | #. salt-call state.sls mysql |
| 219 | #. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst) |
| 220 | #. service mysql start |
| 221 | #. run on each node mysql_secure_install and filling root password. |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 222 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 223 | .. code-block:: bash |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 224 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 225 | Enter current password for root (enter for none): |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 226 | OK, successfully used password, moving on... |
| 227 | |
| 228 | Setting the root password ensures that nobody can log into the MySQL |
| 229 | root user without the proper authorisation. |
| 230 | |
| 231 | Set root password? [Y/n] y |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 232 | New password: |
| 233 | Re-enter new password: |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 234 | Password updated successfully! |
| 235 | Reloading privilege tables.. |
| 236 | ... Success! |
| 237 | |
| 238 | By default, a MySQL installation has an anonymous user, allowing anyone |
| 239 | to log into MySQL without having to have a user account created for |
| 240 | them. This is intended only for testing, and to make the installation |
| 241 | go a bit smoother. You should remove them before moving into a |
| 242 | production environment. |
| 243 | |
| 244 | Remove anonymous users? [Y/n] y |
| 245 | ... Success! |
| 246 | |
| 247 | Normally, root should only be allowed to connect from 'localhost'. This |
| 248 | ensures that someone cannot guess at the root password from the network. |
| 249 | |
| 250 | Disallow root login remotely? [Y/n] n |
| 251 | ... skipping. |
| 252 | |
| 253 | By default, MySQL comes with a database named 'test' that anyone can |
| 254 | access. This is also intended only for testing, and should be removed |
| 255 | before moving into a production environment. |
| 256 | |
| 257 | Remove test database and access to it? [Y/n] y |
| 258 | - Dropping test database... |
| 259 | ... Success! |
| 260 | - Removing privileges on test database... |
| 261 | ... Success! |
| 262 | |
| 263 | Reloading the privilege tables will ensure that all changes made so far |
| 264 | will take effect immediately. |
| 265 | |
| 266 | Reload privilege tables now? [Y/n] y |
| 267 | ... Success! |
| 268 | |
| 269 | Cleaning up... |
| 270 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 271 | #. service mysql stop |
| 272 | #. uncomment all wsrep* lines except first server, where leave only in |
| 273 | my.cnf wsrep_cluster_address='gcomm://'; |
| 274 | #. start first node |
| 275 | #. Start third node which is connected to first one |
| 276 | #. Start second node which is connected to third one |
| 277 | #. After starting cluster, it must be change cluster address at first starting node |
| 278 | without restart database and change config my.cnf. |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 279 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 280 | .. code-block:: bash |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 281 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 282 | mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2'; |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 283 | |
| 284 | Read more |
| 285 | ========= |
| 286 | |
| 287 | * https://github.com/CaptTofu/ansible-galera |
| 288 | * http://www.sebastien-han.fr/blog/2012/04/15/active-passive-failover-cluster-on-a-mysql-galera-cluster-with-haproxy-lsb-agent/ |
| 289 | * http://opentodo.net/2012/12/mysql-multi-master-replication-with-galera/ |
| 290 | * http://www.codership.com/wiki/doku.php |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 291 | * http://www.sebastien-han.fr/blog/2012/04/01/mysql-multi-master-replication-with-galera/ |