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 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 59 | InnoDB parameters |
| 60 | ================= |
| 61 | |
| 62 | - **innodb_buffer_pool_size** - the default value is 35% of the available ram |
| 63 | |
| 64 | Usage: |
| 65 | |
| 66 | .. code-block:: yaml |
| 67 | |
| 68 | galera: |
| 69 | master: |
| 70 | innodb_buffer_pool_size: 1024M |
| 71 | slave: |
| 72 | innodb_buffer_pool_size: 1024M |
| 73 | |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 74 | Usage |
| 75 | ===== |
| 76 | |
| 77 | MySQL Galera check sripts |
| 78 | |
| 79 | .. code-block:: bash |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 80 | |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 81 | mysql> SHOW STATUS LIKE 'wsrep%'; |
| 82 | |
| 83 | mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;" |
| 84 | |
| 85 | Galera monitoring command, performed from extra server |
| 86 | |
| 87 | .. code-block:: bash |
| 88 | |
| 89 | garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d |
| 90 | |
| 91 | 1. salt-call state.sls mysql |
| 92 | 2. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst) |
| 93 | 3. service mysql start |
| 94 | 4. run on each node mysql_secure_install and filling root password. |
| 95 | |
| 96 | .. code-block:: bash |
| 97 | |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 98 | Enter current password for root (enter for none): |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 99 | OK, successfully used password, moving on... |
| 100 | |
| 101 | Setting the root password ensures that nobody can log into the MySQL |
| 102 | root user without the proper authorisation. |
| 103 | |
| 104 | Set root password? [Y/n] y |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 105 | New password: |
| 106 | Re-enter new password: |
Ales Komarek | cba48ac | 2015-04-30 11:40:44 +0200 | [diff] [blame] | 107 | Password updated successfully! |
| 108 | Reloading privilege tables.. |
| 109 | ... Success! |
| 110 | |
| 111 | By default, a MySQL installation has an anonymous user, allowing anyone |
| 112 | to log into MySQL without having to have a user account created for |
| 113 | them. This is intended only for testing, and to make the installation |
| 114 | go a bit smoother. You should remove them before moving into a |
| 115 | production environment. |
| 116 | |
| 117 | Remove anonymous users? [Y/n] y |
| 118 | ... Success! |
| 119 | |
| 120 | Normally, root should only be allowed to connect from 'localhost'. This |
| 121 | ensures that someone cannot guess at the root password from the network. |
| 122 | |
| 123 | Disallow root login remotely? [Y/n] n |
| 124 | ... skipping. |
| 125 | |
| 126 | By default, MySQL comes with a database named 'test' that anyone can |
| 127 | access. This is also intended only for testing, and should be removed |
| 128 | before moving into a production environment. |
| 129 | |
| 130 | Remove test database and access to it? [Y/n] y |
| 131 | - Dropping test database... |
| 132 | ... Success! |
| 133 | - Removing privileges on test database... |
| 134 | ... Success! |
| 135 | |
| 136 | Reloading the privilege tables will ensure that all changes made so far |
| 137 | will take effect immediately. |
| 138 | |
| 139 | Reload privilege tables now? [Y/n] y |
| 140 | ... Success! |
| 141 | |
| 142 | Cleaning up... |
| 143 | |
| 144 | 5. service mysql stop |
Kirill Bespalov | 162a4d4 | 2017-06-21 02:26:19 +0300 | [diff] [blame] | 145 | 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] | 146 | 7. start first node |
| 147 | 8. Start third node which is connected to first one |
| 148 | 9. Start second node which is connected to third one |
| 149 | 10. After starting cluster, it must be change cluster address at first starting node without restart database and change config my.cnf. |
| 150 | |
| 151 | .. code-block:: bash |
| 152 | |
| 153 | mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2'; |
| 154 | |
| 155 | Read more |
| 156 | ========= |
| 157 | |
| 158 | * https://github.com/CaptTofu/ansible-galera |
| 159 | * http://www.sebastien-han.fr/blog/2012/04/15/active-passive-failover-cluster-on-a-mysql-galera-cluster-with-haproxy-lsb-agent/ |
| 160 | * http://opentodo.net/2012/12/mysql-multi-master-replication-with-galera/ |
| 161 | * http://www.codership.com/wiki/doku.php |
| 162 | * 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] | 163 | |
| 164 | Documentation and Bugs |
| 165 | ====================== |
| 166 | |
| 167 | To learn how to install and update salt-formulas, consult the documentation |
| 168 | available online at: |
| 169 | |
| 170 | http://salt-formulas.readthedocs.io/ |
| 171 | |
| 172 | In the unfortunate event that bugs are discovered, they should be reported to |
| 173 | the appropriate issue tracker. Use Github issue tracker for specific salt |
| 174 | formula: |
| 175 | |
| 176 | https://github.com/salt-formulas/salt-formula-galera/issues |
| 177 | |
| 178 | For feature requests, bug reports or blueprints affecting entire ecosystem, |
| 179 | use Launchpad salt-formulas project: |
| 180 | |
| 181 | https://launchpad.net/salt-formulas |
| 182 | |
| 183 | You can also join salt-formulas-users team and subscribe to mailing list: |
| 184 | |
| 185 | https://launchpad.net/~salt-formulas-users |
| 186 | |
| 187 | Developers wishing to work on the salt-formulas projects should always base |
| 188 | their work on master branch and submit pull request against specific formula. |
| 189 | |
| 190 | https://github.com/salt-formulas/salt-formula-galera |
| 191 | |
| 192 | Any questions or feedback is always welcome so feel free to join our IRC |
| 193 | channel: |
| 194 | |
| 195 | #salt-formulas @ irc.freenode.net |