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