blob: 472d0db6cf430512274d6631e5c9803125d5ef15 [file] [log] [blame]
Filip Pytloun5b3c12e2015-10-06 16:28:32 +02001
2=====
3MySQL
4=====
5
6MySQL is the world's second most widely used open-source relational database management system (RDBMS).
7
8Sample pillars
9==============
10
11Standalone servers
12------------------
13
14Standalone MySQL server
15
16.. code-block:: yaml
17
18 mysql:
19 server:
20 enabled: true
21 version: '5.5'
22 admin:
23 user: root
24 password: pass
25 bind:
26 address: '127.0.0.1'
27 port: 3306
28 database:
29 name:
30 encoding: 'utf8'
31 users:
32 - name: 'username'
33 password: 'password'
34 host: 'localhost'
35 rights: 'all privileges'
36
37MySQL replication master with SSL
38
39.. code-block:: yaml
40
41 mysql:
42 server:
43 enabled: true
44 version: 5.5
45 replication:
46 role: master
47 ssl:
48 enabled: true
49 authority: Org_CA
50 certificate: name_of_service
51 admin:
52 user: root
53 password: pass
54 bind:
55 address: '127.0.0.1'
56 port: 3306
57
58MySQL replication slave with SSL
59
60.. code-block:: yaml
61
62 mysql:
63 server:
64 enabled: true
65 version: '5.5'
66 replication:
67 role: slave
68 master: master.salt.id
69 ssl:
70 enabled: true
71 authority: Org_CA
72 certificate: name_of_service
73 client_certificate: name_of_client_cert
74 admin:
75 user: root
76 password: pass
77 bind:
78 address: '127.0.0.1'
79 port: 3306
80
81Tuned up MySQL server
82
83.. code-block:: yaml
84
85 mysql:
86 server:
87 enabled: true
88 version: '5.5'
89 admin:
90 user: root
91 password: pass
92 bind:
93 address: '127.0.0.1'
94 port: 3306
95 key_buffer: 250M
96 max_allowed_packet: 32M
97 max_connections: 1000
98 thread_stack: 512K
99 thread_cache_size: 64
100 query_cache_limit: 16M
101 query_cache_size: 96M
102 force_encoding: utf8
103 database:
104 name:
105 encoding: 'utf8'
106 users:
107 - name: 'username'
108 password: 'password'
109 host: 'localhost'
110 rights: 'all privileges'
111
112MySQL galera cluster
113--------------------
114
115MySQL Galera cluster is configured for ring connection between 3 nodes. Each node should have just one member.
116
117Galera initial server (master)
118
119.. code-block:: yaml
120
121 mysql:
122 cluster:
123 enabled: true
124 name: openstack
125 role:master
126 bind:
127 address: 192.168.0.1
128 members:
129 - host: 192.168.0.1
130 port: 4567
131 user:
132 name: wsrep_sst
133 password: password
134 server:
135 enabled: true
136 version: 5.5
137 admin:
138 user: root
139 password: pass
140 bind:
141 address: 192.168.0.1
142 database:
143 name:
144 encoding: 'utf8'
145 users:
146 - name: 'username'
147 password: 'password'
148 host: 'localhost'
149 rights: 'all privileges'
150
151Usage
152=====
153
154MySQL Galera check sripts
155
156.. code-block:: bash
157
158 mysql> SHOW STATUS LIKE 'wsrep%';
159
160 mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;"
161
162Galera monitoring command, performed from extra server
163
164.. code-block:: bash
165
166 garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d
167
1681. salt-call state.sls mysql
1692. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst)
1703. service mysql start
1714. run on each node mysql_secure_install and filling root password.
172
173.. code-block:: bash
174
175 Enter current password for root (enter for none):
176 OK, successfully used password, moving on...
177
178 Setting the root password ensures that nobody can log into the MySQL
179 root user without the proper authorisation.
180
181 Set root password? [Y/n] y
182 New password:
183 Re-enter new password:
184 Password updated successfully!
185 Reloading privilege tables..
186 ... Success!
187
188 By default, a MySQL installation has an anonymous user, allowing anyone
189 to log into MySQL without having to have a user account created for
190 them. This is intended only for testing, and to make the installation
191 go a bit smoother. You should remove them before moving into a
192 production environment.
193
194 Remove anonymous users? [Y/n] y
195 ... Success!
196
197 Normally, root should only be allowed to connect from 'localhost'. This
198 ensures that someone cannot guess at the root password from the network.
199
200 Disallow root login remotely? [Y/n] n
201 ... skipping.
202
203 By default, MySQL comes with a database named 'test' that anyone can
204 access. This is also intended only for testing, and should be removed
205 before moving into a production environment.
206
207 Remove test database and access to it? [Y/n] y
208 - Dropping test database...
209 ... Success!
210 - Removing privileges on test database...
211 ... Success!
212
213 Reloading the privilege tables will ensure that all changes made so far
214 will take effect immediately.
215
216 Reload privilege tables now? [Y/n] y
217 ... Success!
218
219 Cleaning up...
220
2215. service mysql stop
2226. uncomment all wsrep* lines except first server, where leave only in my.cnf wsrep_cluster_address='gcomm://';
2237. start first node
2248. Start third node which is connected to first one
2259. Start second node which is connected to third one
22610. After starting cluster, it must be change cluster address at first starting node without restart database and change config my.cnf.
227
228.. code-block:: bash
229
230 mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2';
231
232Read more
233=========
234
235* http://dev.mysql.com/doc/
236* http://www.slideshare.net/osscube/mysql-performance-tuning-top-10-tips
237
238Galera replication
239------------------
240
241* https://github.com/CaptTofu/ansible-galera
242* http://www.sebastien-han.fr/blog/2012/04/15/active-passive-failover-cluster-on-a-mysql-galera-cluster-with-haproxy-lsb-agent/
243* http://opentodo.net/2012/12/mysql-multi-master-replication-with-galera/
244* http://www.codership.com/wiki/doku.php
245* Best one: - http://www.sebastien-han.fr/blog/2012/04/01/mysql-multi-master-replication-with-galera/
246
247Mysql Backup
248------------
249
250* http://sourceforge.net/projects/automysqlbackup/
251* https://labs.riseup.net/code/projects/backupninja/wiki
252* http://wiki.zmanda.com/index.php/Mysql-zrm