blob: 552c50cd45d9364390642f06420ab9c50c42656d [file] [log] [blame]
Filip Pytloun5b3c12e2015-10-06 16:28:32 +02001
Ales Komarek2813a682017-04-12 10:07:23 +02002=============
3MySQL Formula
4=============
Filip Pytloun5b3c12e2015-10-06 16:28:32 +02005
Ales Komarek2813a682017-04-12 10:07:23 +02006MySQL is the world's second most widely used open-source relational database
7management system (RDBMS).
Filip Pytloun5b3c12e2015-10-06 16:28:32 +02008
Filip Pytloun5b3c12e2015-10-06 16:28:32 +02009
Ales Komarek2813a682017-04-12 10:07:23 +020010Sample Metadata
11===============
12
13
14Standalone setups
15-----------------
Filip Pytloun5b3c12e2015-10-06 16:28:32 +020016
17Standalone MySQL server
18
19.. code-block:: yaml
20
21 mysql:
22 server:
23 enabled: true
24 version: '5.5'
25 admin:
26 user: root
27 password: pass
28 bind:
29 address: '127.0.0.1'
30 port: 3306
31 database:
32 name:
33 encoding: 'utf8'
34 users:
35 - name: 'username'
36 password: 'password'
37 host: 'localhost'
38 rights: 'all privileges'
Dzmitry Stremkouski588a0212018-10-04 10:15:22 +020039 target: '*.*'
Filip Pytloun5b3c12e2015-10-06 16:28:32 +020040
Ales Komarek2813a682017-04-12 10:07:23 +020041
Filip Pytloun5b3c12e2015-10-06 16:28:32 +020042MySQL replication master with SSL
43
44.. code-block:: yaml
45
46 mysql:
47 server:
48 enabled: true
49 version: 5.5
50 replication:
51 role: master
52 ssl:
53 enabled: true
54 authority: Org_CA
55 certificate: name_of_service
56 admin:
57 user: root
58 password: pass
59 bind:
60 address: '127.0.0.1'
61 port: 3306
62
63MySQL replication slave with SSL
64
65.. code-block:: yaml
66
67 mysql:
68 server:
69 enabled: true
70 version: '5.5'
71 replication:
72 role: slave
73 master: master.salt.id
74 ssl:
75 enabled: true
76 authority: Org_CA
77 certificate: name_of_service
78 client_certificate: name_of_client_cert
79 admin:
80 user: root
81 password: pass
82 bind:
83 address: '127.0.0.1'
84 port: 3306
85
86Tuned up MySQL server
87
88.. code-block:: yaml
89
90 mysql:
91 server:
92 enabled: true
93 version: '5.5'
94 admin:
95 user: root
96 password: pass
97 bind:
98 address: '127.0.0.1'
99 port: 3306
100 key_buffer: 250M
101 max_allowed_packet: 32M
102 max_connections: 1000
103 thread_stack: 512K
104 thread_cache_size: 64
105 query_cache_limit: 16M
106 query_cache_size: 96M
107 force_encoding: utf8
Jakub Pavlikda755f22016-09-02 12:06:53 +0200108 sql_mode: "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Filip Pytloun5b3c12e2015-10-06 16:28:32 +0200109 database:
110 name:
111 encoding: 'utf8'
112 users:
113 - name: 'username'
114 password: 'password'
115 host: 'localhost'
116 rights: 'all privileges'
117
Ales Komarek2813a682017-04-12 10:07:23 +0200118
119MySQL Galera cluster
Filip Pytloun5b3c12e2015-10-06 16:28:32 +0200120--------------------
121
Ales Komarek2813a682017-04-12 10:07:23 +0200122MySQL Galera cluster is configured for ring connection between 3 nodes. Each
123node should have just one member.
Filip Pytloun5b3c12e2015-10-06 16:28:32 +0200124
125Galera initial server (master)
126
127.. code-block:: yaml
128
129 mysql:
130 cluster:
131 enabled: true
132 name: openstack
133 role:master
134 bind:
135 address: 192.168.0.1
136 members:
137 - host: 192.168.0.1
138 port: 4567
139 user:
140 name: wsrep_sst
141 password: password
142 server:
143 enabled: true
144 version: 5.5
145 admin:
146 user: root
147 password: pass
148 bind:
149 address: 192.168.0.1
150 database:
151 name:
152 encoding: 'utf8'
153 users:
154 - name: 'username'
155 password: 'password'
156 host: 'localhost'
157 rights: 'all privileges'
158
Ales Komarek2813a682017-04-12 10:07:23 +0200159MySQL client
160------------
Ales Komarek04991c02016-10-05 10:02:59 +0200161
Jiri Broulik36754472017-04-27 22:15:29 +0200162Database with initial data (Restore DB)
163
164.. code-block:: yaml
165
166 mysql:
167 client:
168 server:
169 database:
170 admin:
171 host: localhost
172 port: 3306
173 user: ${_param:mysql_admin_user}
174 password: ${_param:mysql_admin_password}
175 encoding: utf8
176 database:
177 neutron_upgrade:
178 encoding: utf8
179 users:
180 - name: neutron
181 password: ${_param:mysql_neutron_password}
182 host: '%'
183 rights: all
184 - name: neutron
185 password: ${_param:mysql_neutron_password}
186 host: ${_param:single_address}
187 rights: all
188 initial_data:
189 engine: backupninja
190 source: ${_param:backupninja_backup_host}
191 host: ${linux:network:fqdn}
192 database: neutron
193
194.. note:: This client role needs to be put directly on dbs node.
195 The provided setup restores db named neutron_upgrade with data from db called neutron.
196
197
Ales Komarek04991c02016-10-05 10:02:59 +0200198Database management on remote MySQL server
199
200.. code-block:: yaml
201
202 mysql:
203 client:
204 enabled: true
205 server:
206 server01:
207 admin:
208 host: database.host
209 port: 3306
210 user: root
211 password: password
212 encoding: utf8
213 database:
214 database01:
215 encoding: utf8
216 users:
217 - name: username
218 password: 'password'
219 host: 'localhost'
220 rights: 'all privileges'
221
Jiri Broulik36754472017-04-27 22:15:29 +0200222
Ales Komarek04991c02016-10-05 10:02:59 +0200223User management on remote MySQL server
224
225.. code-block:: yaml
226
227 mysql:
228 client:
229 enabled: true
230 server:
231 server01:
232 admin:
233 host: database.host
234 port: 3306
235 user: root
236 password: password
237 encoding: utf8
238 users:
239 - name: user01
240 host: "*"
241 password: 'sdgdsgdsgd'
242 - name: user02
243 host: "localhost"
244
245
Ales Komarek2813a682017-04-12 10:07:23 +0200246Sample Usage
247============
Filip Pytloun5b3c12e2015-10-06 16:28:32 +0200248
249MySQL Galera check sripts
250
251.. code-block:: bash
252
253 mysql> SHOW STATUS LIKE 'wsrep%';
254
255 mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;"
256
257Galera monitoring command, performed from extra server
258
259.. code-block:: bash
260
261 garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d
262
2631. salt-call state.sls mysql
2642. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst)
2653. service mysql start
2664. run on each node mysql_secure_install and filling root password.
267
268.. code-block:: bash
269
270 Enter current password for root (enter for none):
271 OK, successfully used password, moving on...
272
273 Setting the root password ensures that nobody can log into the MySQL
274 root user without the proper authorisation.
275
276 Set root password? [Y/n] y
277 New password:
278 Re-enter new password:
279 Password updated successfully!
280 Reloading privilege tables..
281 ... Success!
282
283 By default, a MySQL installation has an anonymous user, allowing anyone
284 to log into MySQL without having to have a user account created for
285 them. This is intended only for testing, and to make the installation
286 go a bit smoother. You should remove them before moving into a
287 production environment.
288
289 Remove anonymous users? [Y/n] y
290 ... Success!
291
292 Normally, root should only be allowed to connect from 'localhost'. This
293 ensures that someone cannot guess at the root password from the network.
294
295 Disallow root login remotely? [Y/n] n
296 ... skipping.
297
298 By default, MySQL comes with a database named 'test' that anyone can
299 access. This is also intended only for testing, and should be removed
300 before moving into a production environment.
301
302 Remove test database and access to it? [Y/n] y
303 - Dropping test database...
304 ... Success!
305 - Removing privileges on test database...
306 ... Success!
307
308 Reloading the privilege tables will ensure that all changes made so far
309 will take effect immediately.
310
311 Reload privilege tables now? [Y/n] y
312 ... Success!
313
314 Cleaning up...
315
3165. service mysql stop
3176. uncomment all wsrep* lines except first server, where leave only in my.cnf wsrep_cluster_address='gcomm://';
3187. start first node
3198. Start third node which is connected to first one
3209. Start second node which is connected to third one
32110. After starting cluster, it must be change cluster address at first starting node without restart database and change config my.cnf.
322
323.. code-block:: bash
324
325 mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2';
326
Ales Komarek2813a682017-04-12 10:07:23 +0200327More Information
328================
Filip Pytloun5b3c12e2015-10-06 16:28:32 +0200329
330* http://dev.mysql.com/doc/
331* http://www.slideshare.net/osscube/mysql-performance-tuning-top-10-tips
332
Filip Pytloun5b3c12e2015-10-06 16:28:32 +0200333* http://sourceforge.net/projects/automysqlbackup/
334* https://labs.riseup.net/code/projects/backupninja/wiki
335* http://wiki.zmanda.com/index.php/Mysql-zrm
Filip Pytlounfc6c3342017-02-02 13:02:03 +0100336
Ales Komarek2813a682017-04-12 10:07:23 +0200337
Filip Pytlounfc6c3342017-02-02 13:02:03 +0100338Documentation and Bugs
339======================
340
341To learn how to install and update salt-formulas, consult the documentation
342available online at:
343
344 http://salt-formulas.readthedocs.io/
345
346In the unfortunate event that bugs are discovered, they should be reported to
347the appropriate issue tracker. Use Github issue tracker for specific salt
348formula:
349
350 https://github.com/salt-formulas/salt-formula-mysql/issues
351
352For feature requests, bug reports or blueprints affecting entire ecosystem,
353use Launchpad salt-formulas project:
354
355 https://launchpad.net/salt-formulas
356
357You can also join salt-formulas-users team and subscribe to mailing list:
358
359 https://launchpad.net/~salt-formulas-users
360
361Developers wishing to work on the salt-formulas projects should always base
362their work on master branch and submit pull request against specific formula.
363
364 https://github.com/salt-formulas/salt-formula-mysql
365
366Any questions or feedback is always welcome so feel free to join our IRC
367channel:
368
369 #salt-formulas @ irc.freenode.net