Saltstack Official Galera Formula
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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