Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 1 | |
| 2 | ====== |
| 3 | Galera |
| 4 | ====== |
| 5 | |
| 6 | Galera Cluster for MySQL is a true Multimaster Cluster based on synchronous replication. Galera Cluster is an easy-to-use, high-availability solution, which provides high system uptime, no data loss and scalability for future growth. |
| 7 | |
| 8 | Sample pillars |
| 9 | ============== |
| 10 | |
| 11 | Galera cluster master node |
| 12 | |
| 13 | .. code-block:: yaml |
| 14 | |
| 15 | galera: |
| 16 | master: |
| 17 | enabled: true |
| 18 | name: openstack |
| 19 | bind: |
| 20 | address: 192.168.0.1 |
| 21 | port: 3306 |
| 22 | members: |
| 23 | - host: 192.168.0.1 |
| 24 | port: 4567 |
| 25 | - host: 192.168.0.2 |
| 26 | port: 4567 |
| 27 | admin: |
| 28 | user: root |
| 29 | password: pass |
| 30 | database: |
| 31 | name: |
| 32 | encoding: 'utf8' |
| 33 | users: |
| 34 | - name: 'username' |
| 35 | password: 'password' |
| 36 | host: 'localhost' |
| 37 | rights: 'all privileges' |
| 38 | |
| 39 | Galera cluster slave node |
| 40 | |
| 41 | .. code-block:: yaml |
| 42 | |
| 43 | galera: |
| 44 | slave: |
| 45 | enabled: true |
| 46 | name: openstack |
| 47 | bind: |
| 48 | address: 192.168.0.2 |
| 49 | port: 3306 |
| 50 | members: |
| 51 | - host: 192.168.0.1 |
| 52 | port: 4567 |
| 53 | - host: 192.168.0.2 |
| 54 | port: 4567 |
| 55 | admin: |
| 56 | user: root |
| 57 | password: pass |
| 58 | |
Petr Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 59 | |
| 60 | Additional mysql users: |
| 61 | |
| 62 | .. code-block:: yaml |
| 63 | |
| 64 | mysql: |
| 65 | server: |
| 66 | users: |
| 67 | - name: clustercheck |
| 68 | password: clustercheck |
| 69 | database: '*.*' |
| 70 | grants: PROCESS |
Petr Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 71 | - name: inspector |
| 72 | host: 127.0.0.1 |
| 73 | password: password |
| 74 | databases: |
| 75 | mydb: |
| 76 | - database: mydb |
| 77 | - table: mytable |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 78 | - grant_option: True |
Petr Michalec | bca6ffa | 2017-05-22 13:10:20 +0200 | [diff] [blame] | 79 | - grants: |
| 80 | - all privileges |
| 81 | |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 82 | Additional check params: |
Petr Michalec | 518b834 | 2017-08-04 11:23:03 +0200 | [diff] [blame^] | 83 | ======================== |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 84 | |
| 85 | .. code-block:: yaml |
| 86 | |
| 87 | galera: |
| 88 | clustercheck: |
| 89 | - enabled: True |
| 90 | - user: clustercheck |
| 91 | - password: clustercheck |
| 92 | - available_when_donor: 0 |
| 93 | - available_when_readonly: 1 |
| 94 | - port 9200 |
| 95 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 96 | InnoDB parameters |
| 97 | ================= |
| 98 | |
| 99 | - **innodb_buffer_pool_size** - the default value is 35% of the available ram |
| 100 | |
| 101 | Usage: |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 102 | .. code-block:: yaml |
| 103 | |
| 104 | galera: |
| 105 | master: |
| 106 | innodb_buffer_pool_size: 1024M |
| 107 | slave: |
| 108 | innodb_buffer_pool_size: 1024M |
| 109 | |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 110 | |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 111 | Usage |
| 112 | ===== |
| 113 | |
| 114 | MySQL Galera check sripts |
| 115 | |
| 116 | .. code-block:: bash |
Petr Michalec | 89c8c3f | 2017-05-22 17:19:22 +0200 | [diff] [blame] | 117 | |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 118 | mysql> SHOW STATUS LIKE 'wsrep%'; |
| 119 | |
| 120 | mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;" |
| 121 | |
| 122 | Galera monitoring command, performed from extra server |
| 123 | |
| 124 | .. code-block:: bash |
| 125 | |
| 126 | garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d |
| 127 | |
| 128 | 1. salt-call state.sls mysql |
| 129 | 2. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst) |
| 130 | 3. service mysql start |
| 131 | 4. run on each node mysql_secure_install and filling root password. |
| 132 | |
| 133 | .. code-block:: bash |
| 134 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 135 | Enter current password for root (enter for none): |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 136 | OK, successfully used password, moving on... |
| 137 | |
| 138 | Setting the root password ensures that nobody can log into the MySQL |
| 139 | root user without the proper authorisation. |
| 140 | |
| 141 | Set root password? [Y/n] y |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 142 | New password: |
| 143 | Re-enter new password: |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 144 | Password updated successfully! |
| 145 | Reloading privilege tables.. |
| 146 | ... Success! |
| 147 | |
| 148 | By default, a MySQL installation has an anonymous user, allowing anyone |
| 149 | to log into MySQL without having to have a user account created for |
| 150 | them. This is intended only for testing, and to make the installation |
| 151 | go a bit smoother. You should remove them before moving into a |
| 152 | production environment. |
| 153 | |
| 154 | Remove anonymous users? [Y/n] y |
| 155 | ... Success! |
| 156 | |
| 157 | Normally, root should only be allowed to connect from 'localhost'. This |
| 158 | ensures that someone cannot guess at the root password from the network. |
| 159 | |
| 160 | Disallow root login remotely? [Y/n] n |
| 161 | ... skipping. |
| 162 | |
| 163 | By default, MySQL comes with a database named 'test' that anyone can |
| 164 | access. This is also intended only for testing, and should be removed |
| 165 | before moving into a production environment. |
| 166 | |
| 167 | Remove test database and access to it? [Y/n] y |
| 168 | - Dropping test database... |
| 169 | ... Success! |
| 170 | - Removing privileges on test database... |
| 171 | ... Success! |
| 172 | |
| 173 | Reloading the privilege tables will ensure that all changes made so far |
| 174 | will take effect immediately. |
| 175 | |
| 176 | Reload privilege tables now? [Y/n] y |
| 177 | ... Success! |
| 178 | |
| 179 | Cleaning up... |
| 180 | |
| 181 | 5. service mysql stop |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 182 | 6. uncomment all wsrep* lines except first server, where leave only in my.cnf wsrep_cluster_address='gcomm://'; |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 183 | 7. start first node |
| 184 | 8. Start third node which is connected to first one |
| 185 | 9. Start second node which is connected to third one |
| 186 | 10. After starting cluster, it must be change cluster address at first starting node without restart database and change config my.cnf. |
| 187 | |
| 188 | .. code-block:: bash |
| 189 | |
| 190 | mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2'; |
| 191 | |
| 192 | Read more |
| 193 | ========= |
| 194 | |
| 195 | * https://github.com/CaptTofu/ansible-galera |
| 196 | * http://www.sebastien-han.fr/blog/2012/04/15/active-passive-failover-cluster-on-a-mysql-galera-cluster-with-haproxy-lsb-agent/ |
| 197 | * http://opentodo.net/2012/12/mysql-multi-master-replication-with-galera/ |
| 198 | * http://www.codership.com/wiki/doku.php |
| 199 | * Best one: - 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] | 200 | |
| 201 | Documentation and Bugs |
| 202 | ====================== |
| 203 | |
| 204 | To learn how to install and update salt-formulas, consult the documentation |
| 205 | available online at: |
| 206 | |
| 207 | http://salt-formulas.readthedocs.io/ |
| 208 | |
| 209 | In the unfortunate event that bugs are discovered, they should be reported to |
| 210 | the appropriate issue tracker. Use Github issue tracker for specific salt |
| 211 | formula: |
| 212 | |
| 213 | https://github.com/salt-formulas/salt-formula-galera/issues |
| 214 | |
| 215 | For feature requests, bug reports or blueprints affecting entire ecosystem, |
| 216 | use Launchpad salt-formulas project: |
| 217 | |
| 218 | https://launchpad.net/salt-formulas |
| 219 | |
| 220 | You can also join salt-formulas-users team and subscribe to mailing list: |
| 221 | |
| 222 | https://launchpad.net/~salt-formulas-users |
| 223 | |
| 224 | Developers wishing to work on the salt-formulas projects should always base |
| 225 | their work on master branch and submit pull request against specific formula. |
| 226 | |
| 227 | https://github.com/salt-formulas/salt-formula-galera |
| 228 | |
| 229 | Any questions or feedback is always welcome so feel free to join our IRC |
| 230 | channel: |
| 231 | |
| 232 | #salt-formulas @ irc.freenode.net |