blob: 700fc5dfb2d4ba2e72f3b16a80b0c8230e76aff5 [file] [log] [blame]
Ales Komarekcba48ac2015-04-30 11:40:44 +02001
2======
3Galera
4======
5
6Galera 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
8Sample pillars
9==============
10
11Galera 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
39Galera 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
59Usage
60=====
61
62MySQL Galera check sripts
63
64.. code-block:: bash
65
66 mysql> SHOW STATUS LIKE 'wsrep%';
67
68 mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;"
69
70Galera monitoring command, performed from extra server
71
72.. code-block:: bash
73
74 garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d
75
761. salt-call state.sls mysql
772. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst)
783. service mysql start
794. run on each node mysql_secure_install and filling root password.
80
81.. code-block:: bash
82
83 Enter current password for root (enter for none):
84 OK, successfully used password, moving on...
85
86 Setting the root password ensures that nobody can log into the MySQL
87 root user without the proper authorisation.
88
89 Set root password? [Y/n] y
90 New password:
91 Re-enter new password:
92 Password updated successfully!
93 Reloading privilege tables..
94 ... Success!
95
96 By default, a MySQL installation has an anonymous user, allowing anyone
97 to log into MySQL without having to have a user account created for
98 them. This is intended only for testing, and to make the installation
99 go a bit smoother. You should remove them before moving into a
100 production environment.
101
102 Remove anonymous users? [Y/n] y
103 ... Success!
104
105 Normally, root should only be allowed to connect from 'localhost'. This
106 ensures that someone cannot guess at the root password from the network.
107
108 Disallow root login remotely? [Y/n] n
109 ... skipping.
110
111 By default, MySQL comes with a database named 'test' that anyone can
112 access. This is also intended only for testing, and should be removed
113 before moving into a production environment.
114
115 Remove test database and access to it? [Y/n] y
116 - Dropping test database...
117 ... Success!
118 - Removing privileges on test database...
119 ... Success!
120
121 Reloading the privilege tables will ensure that all changes made so far
122 will take effect immediately.
123
124 Reload privilege tables now? [Y/n] y
125 ... Success!
126
127 Cleaning up...
128
1295. service mysql stop
1306. uncomment all wsrep* lines except first server, where leave only in my.cnf wsrep_cluster_address='gcomm://';
1317. start first node
1328. Start third node which is connected to first one
1339. Start second node which is connected to third one
13410. After starting cluster, it must be change cluster address at first starting node without restart database and change config my.cnf.
135
136.. code-block:: bash
137
138 mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2';
139
140Read more
141=========
142
143* https://github.com/CaptTofu/ansible-galera
144* http://www.sebastien-han.fr/blog/2012/04/15/active-passive-failover-cluster-on-a-mysql-galera-cluster-with-haproxy-lsb-agent/
145* http://opentodo.net/2012/12/mysql-multi-master-replication-with-galera/
146* http://www.codership.com/wiki/doku.php
147* Best one: - http://www.sebastien-han.fr/blog/2012/04/01/mysql-multi-master-replication-with-galera/