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