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' |
| 44 | |
| 45 | Galera cluster slave node |
| 46 | |
| 47 | .. code-block:: yaml |
| 48 | |
| 49 | galera: |
| 50 | slave: |
| 51 | enabled: true |
| 52 | name: openstack |
| 53 | bind: |
| 54 | address: 192.168.0.2 |
| 55 | port: 3306 |
| 56 | members: |
| 57 | - host: 192.168.0.1 |
| 58 | port: 4567 |
| 59 | - host: 192.168.0.2 |
| 60 | port: 4567 |
| 61 | admin: |
| 62 | user: root |
| 63 | password: pass |
| 64 | |
Kirill Bespalov | 5f0c1d6 | 2017-08-15 15:29:32 +0300 | [diff] [blame] | 65 | Enable TLS support: |
| 66 | |
| 67 | .. code-block:: yaml |
| 68 | |
| 69 | galera: |
| 70 | slave or master: |
| 71 | ssl: |
| 72 | enabled: True |
Dzmitry Stremkouski | f8433bf | 2018-10-23 11:29:03 +0200 | [diff] [blame] | 73 | ciphers: |
| 74 | DHE-RSA-AES128-SHA: |
| 75 | enabled: True |
| 76 | DHE-RSA-AES256-SHA: |
| 77 | enabled: True |
| 78 | EDH-RSA-DES-CBC3-SHA: |
| 79 | name: EDH-RSA-DES-CBC3-SHA |
| 80 | enabled: True |
| 81 | AES128-SHA:AES256-SHA: |
| 82 | name: AES128-SHA:AES256-SHA |
| 83 | enabled: True |
| 84 | DES-CBC3-SHA: |
| 85 | enabled: True |
Kirill Bespalov | 5f0c1d6 | 2017-08-15 15:29:32 +0300 | [diff] [blame] | 86 | # path |
| 87 | cert_file: /etc/mysql/ssl/cert.pem |
| 88 | key_file: /etc/mysql/ssl/key.pem |
| 89 | ca_file: /etc/mysql/ssl/ca.pem |
| 90 | |
| 91 | # content (not required if files already exists) |
| 92 | key: << body of key >> |
| 93 | cert: << body of cert >> |
| 94 | cacert_chain: << body of ca certs chain >> |
| 95 | |
| 96 | |
Petr Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 97 | Additional mysql users: |
| 98 | |
| 99 | .. code-block:: yaml |
| 100 | |
| 101 | mysql: |
| 102 | server: |
| 103 | users: |
| 104 | - name: clustercheck |
| 105 | password: clustercheck |
| 106 | database: '*.*' |
| 107 | grants: PROCESS |
Petr Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 108 | - name: inspector |
| 109 | host: 127.0.0.1 |
| 110 | password: password |
| 111 | databases: |
| 112 | mydb: |
| 113 | - database: mydb |
| 114 | - table: mytable |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 115 | - grant_option: True |
Petr Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 116 | - grants: |
| 117 | - all privileges |
| 118 | |
Vasyl Saienko | 79f6906 | 2018-01-29 11:04:58 +0200 | [diff] [blame] | 119 | Additional mysql SSL grants: |
| 120 | |
| 121 | .. code-block:: yaml |
| 122 | |
| 123 | mysql: |
| 124 | server: |
| 125 | users: |
| 126 | - name: clustercheck |
| 127 | password: clustercheck |
| 128 | database: '*.*' |
| 129 | grants: PROCESS |
| 130 | ssl_option: |
| 131 | - SSL: True |
| 132 | - X509: True |
| 133 | - SUBJECT: <subject> |
| 134 | - ISSUER: <issuer> |
| 135 | - CIPHER: <cipher> |
| 136 | |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 137 | Additional check params: |
Petr Michalec | 518b834 | 2017-08-04 11:23:03 +0200 | [diff] [blame] | 138 | ======================== |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 139 | |
| 140 | .. code-block:: yaml |
| 141 | |
| 142 | galera: |
| 143 | clustercheck: |
| 144 | - enabled: True |
| 145 | - user: clustercheck |
| 146 | - password: clustercheck |
| 147 | - available_when_donor: 0 |
| 148 | - available_when_readonly: 1 |
| 149 | - port 9200 |
| 150 | |
Dmitry Kalashnik | d4e5f47 | 2017-08-09 14:28:17 +0400 | [diff] [blame] | 151 | Configurable soft parameters |
| 152 | ============================ |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 153 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 154 | - ``galera_innodb_buffer_pool_size`` |
| 155 | Default is ``3138M`` |
| 156 | - ``galera_max_connections`` |
| 157 | Default is ``20000`` |
| 158 | - ``galera_innodb_read_io_threads`` |
| 159 | Default is ``8`` |
| 160 | - ``galera_innodb_write_io_threads`` |
| 161 | Default is ``8`` |
| 162 | - ``galera_wsrep_slave_threads`` |
| 163 | Default is ``8`` |
| 164 | - ``galera_xtrabackup_parallel`` |
| 165 | Default is 4 |
| 166 | - ``galera_error_log_enabled`` |
Michal Kobus | 6a33c42 | 2018-09-28 14:32:57 +0200 | [diff] [blame] | 167 | Default is ``true`` |
| 168 | - ``galera_error_log_path`` |
| 169 | Default is ``/var/log/mysql/error.log`` |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 170 | |
| 171 | Usage: |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 172 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 173 | .. code-block:: yaml |
| 174 | |
Dmitry Kalashnik | d4e5f47 | 2017-08-09 14:28:17 +0400 | [diff] [blame] | 175 | _param: |
| 176 | galera_innodb_buffer_pool_size: 1024M |
Kirill Bespalov | 5f0c1d6 | 2017-08-15 15:29:32 +0300 | [diff] [blame] | 177 | galera_max_connections: 200 |
Dennis Dmitriev | 2c57289 | 2018-03-05 23:32:34 +0200 | [diff] [blame] | 178 | galera_innodb_read_io_threads: 16 |
| 179 | galera_innodb_write_io_threads: 16 |
| 180 | galera_wsrep_slave_threads: 8 |
| 181 | galera_xtrabackup_parallel: 2 |
| 182 | galera_error_log_enabled: true |
Michal Kobus | 6a33c42 | 2018-09-28 14:32:57 +0200 | [diff] [blame] | 183 | galera_error_log_path: /var/log/mysql/error.log |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 184 | |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 185 | Usage |
| 186 | ===== |
| 187 | |
| 188 | MySQL Galera check sripts |
| 189 | |
| 190 | .. code-block:: bash |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 191 | |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 192 | mysql> SHOW STATUS LIKE 'wsrep%'; |
| 193 | |
| 194 | mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;" |
| 195 | |
| 196 | Galera monitoring command, performed from extra server |
| 197 | |
| 198 | .. code-block:: bash |
| 199 | |
| 200 | garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d |
| 201 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 202 | #. salt-call state.sls mysql |
| 203 | #. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst) |
| 204 | #. service mysql start |
| 205 | #. run on each node mysql_secure_install and filling root password. |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 206 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 207 | .. code-block:: bash |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 208 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 209 | Enter current password for root (enter for none): |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 210 | OK, successfully used password, moving on... |
| 211 | |
| 212 | Setting the root password ensures that nobody can log into the MySQL |
| 213 | root user without the proper authorisation. |
| 214 | |
| 215 | Set root password? [Y/n] y |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 216 | New password: |
| 217 | Re-enter new password: |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 218 | Password updated successfully! |
| 219 | Reloading privilege tables.. |
| 220 | ... Success! |
| 221 | |
| 222 | By default, a MySQL installation has an anonymous user, allowing anyone |
| 223 | to log into MySQL without having to have a user account created for |
| 224 | them. This is intended only for testing, and to make the installation |
| 225 | go a bit smoother. You should remove them before moving into a |
| 226 | production environment. |
| 227 | |
| 228 | Remove anonymous users? [Y/n] y |
| 229 | ... Success! |
| 230 | |
| 231 | Normally, root should only be allowed to connect from 'localhost'. This |
| 232 | ensures that someone cannot guess at the root password from the network. |
| 233 | |
| 234 | Disallow root login remotely? [Y/n] n |
| 235 | ... skipping. |
| 236 | |
| 237 | By default, MySQL comes with a database named 'test' that anyone can |
| 238 | access. This is also intended only for testing, and should be removed |
| 239 | before moving into a production environment. |
| 240 | |
| 241 | Remove test database and access to it? [Y/n] y |
| 242 | - Dropping test database... |
| 243 | ... Success! |
| 244 | - Removing privileges on test database... |
| 245 | ... Success! |
| 246 | |
| 247 | Reloading the privilege tables will ensure that all changes made so far |
| 248 | will take effect immediately. |
| 249 | |
| 250 | Reload privilege tables now? [Y/n] y |
| 251 | ... Success! |
| 252 | |
| 253 | Cleaning up... |
| 254 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 255 | #. service mysql stop |
| 256 | #. uncomment all wsrep* lines except first server, where leave only in |
| 257 | my.cnf wsrep_cluster_address='gcomm://'; |
| 258 | #. start first node |
| 259 | #. Start third node which is connected to first one |
| 260 | #. Start second node which is connected to third one |
| 261 | #. After starting cluster, it must be change cluster address at first starting node |
| 262 | without restart database and change config my.cnf. |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 263 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 264 | .. code-block:: bash |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 265 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 266 | mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2'; |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 267 | |
| 268 | Read more |
| 269 | ========= |
| 270 | |
| 271 | * https://github.com/CaptTofu/ansible-galera |
| 272 | * http://www.sebastien-han.fr/blog/2012/04/15/active-passive-failover-cluster-on-a-mysql-galera-cluster-with-haproxy-lsb-agent/ |
| 273 | * http://opentodo.net/2012/12/mysql-multi-master-replication-with-galera/ |
| 274 | * http://www.codership.com/wiki/doku.php |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 275 | * http://www.sebastien-han.fr/blog/2012/04/01/mysql-multi-master-replication-with-galera/ |
Filip Pytloun | 5b356a7 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 276 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 277 | Documentation and bugs |
Filip Pytloun | 5b356a7 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 278 | ====================== |
| 279 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 280 | * http://salt-formulas.readthedocs.io/ |
| 281 | Learn how to install and update salt-formulas |
Filip Pytloun | 5b356a7 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 282 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 283 | * https://github.com/salt-formulas/salt-formula-galera/issues |
| 284 | In the unfortunate event that bugs are discovered, report the issue to the |
| 285 | appropriate issue tracker. Use the Github issue tracker for a specific salt |
| 286 | formula |
Filip Pytloun | 5b356a7 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 287 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 288 | * https://launchpad.net/salt-formulas |
| 289 | For feature requests, bug reports, or blueprints affecting the entire |
| 290 | ecosystem, use the Launchpad salt-formulas project |
Filip Pytloun | 5b356a7 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 291 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 292 | * https://launchpad.net/~salt-formulas-users |
| 293 | Join the salt-formulas-users team and subscribe to mailing list if required |
Filip Pytloun | 5b356a7 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 294 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 295 | * https://github.com/salt-formulas/salt-formula-galera |
| 296 | Develop the salt-formulas projects in the master branch and then submit pull |
| 297 | requests against a specific formula |
Filip Pytloun | 5b356a7 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 298 | |
OlgaGusarenko | 43e9990 | 2018-07-30 17:18:32 +0300 | [diff] [blame] | 299 | * #salt-formulas @ irc.freenode.net |
| 300 | Use this IRC channel in case of any questions or feedback which is always |
| 301 | welcome |
Filip Pytloun | 5b356a7 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 302 | |