blob: b4207cadf06190d62061f76d7c353c2c7d57bc78 [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'
39
Ales Komarek2813a682017-04-12 10:07:23 +020040Database with initial data
41
42.. code-block:: yaml
43
44 mysql:
45 server:
46 enabled: true
47 database:
48 datatabese_with_init_data:
49 encoding: 'utf8'
50 users:
51 - name: 'username'
52 password: 'password'
53 host: 'localhost'
54 rights: 'all privileges'
55 initial_data:
56 engine: backupninja
57 source: backup.host
58 host: original-host-name
59 database: original-database-name
60
Filip Pytloun5b3c12e2015-10-06 16:28:32 +020061MySQL replication master with SSL
62
63.. code-block:: yaml
64
65 mysql:
66 server:
67 enabled: true
68 version: 5.5
69 replication:
70 role: master
71 ssl:
72 enabled: true
73 authority: Org_CA
74 certificate: name_of_service
75 admin:
76 user: root
77 password: pass
78 bind:
79 address: '127.0.0.1'
80 port: 3306
81
82MySQL replication slave with SSL
83
84.. code-block:: yaml
85
86 mysql:
87 server:
88 enabled: true
89 version: '5.5'
90 replication:
91 role: slave
92 master: master.salt.id
93 ssl:
94 enabled: true
95 authority: Org_CA
96 certificate: name_of_service
97 client_certificate: name_of_client_cert
98 admin:
99 user: root
100 password: pass
101 bind:
102 address: '127.0.0.1'
103 port: 3306
104
105Tuned up MySQL server
106
107.. code-block:: yaml
108
109 mysql:
110 server:
111 enabled: true
112 version: '5.5'
113 admin:
114 user: root
115 password: pass
116 bind:
117 address: '127.0.0.1'
118 port: 3306
119 key_buffer: 250M
120 max_allowed_packet: 32M
121 max_connections: 1000
122 thread_stack: 512K
123 thread_cache_size: 64
124 query_cache_limit: 16M
125 query_cache_size: 96M
126 force_encoding: utf8
Jakub Pavlikda755f22016-09-02 12:06:53 +0200127 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 +0200128 database:
129 name:
130 encoding: 'utf8'
131 users:
132 - name: 'username'
133 password: 'password'
134 host: 'localhost'
135 rights: 'all privileges'
136
Ales Komarek2813a682017-04-12 10:07:23 +0200137
138MySQL Galera cluster
Filip Pytloun5b3c12e2015-10-06 16:28:32 +0200139--------------------
140
Ales Komarek2813a682017-04-12 10:07:23 +0200141MySQL Galera cluster is configured for ring connection between 3 nodes. Each
142node should have just one member.
Filip Pytloun5b3c12e2015-10-06 16:28:32 +0200143
144Galera initial server (master)
145
146.. code-block:: yaml
147
148 mysql:
149 cluster:
150 enabled: true
151 name: openstack
152 role:master
153 bind:
154 address: 192.168.0.1
155 members:
156 - host: 192.168.0.1
157 port: 4567
158 user:
159 name: wsrep_sst
160 password: password
161 server:
162 enabled: true
163 version: 5.5
164 admin:
165 user: root
166 password: pass
167 bind:
168 address: 192.168.0.1
169 database:
170 name:
171 encoding: 'utf8'
172 users:
173 - name: 'username'
174 password: 'password'
175 host: 'localhost'
176 rights: 'all privileges'
177
Ales Komarek2813a682017-04-12 10:07:23 +0200178MySQL client
179------------
Ales Komarek04991c02016-10-05 10:02:59 +0200180
181Database management on remote MySQL server
182
183.. code-block:: yaml
184
185 mysql:
186 client:
187 enabled: true
188 server:
189 server01:
190 admin:
191 host: database.host
192 port: 3306
193 user: root
194 password: password
195 encoding: utf8
196 database:
197 database01:
198 encoding: utf8
199 users:
200 - name: username
201 password: 'password'
202 host: 'localhost'
203 rights: 'all privileges'
204
205User management on remote MySQL server
206
207.. code-block:: yaml
208
209 mysql:
210 client:
211 enabled: true
212 server:
213 server01:
214 admin:
215 host: database.host
216 port: 3306
217 user: root
218 password: password
219 encoding: utf8
220 users:
221 - name: user01
222 host: "*"
223 password: 'sdgdsgdsgd'
224 - name: user02
225 host: "localhost"
226
227
Ales Komarek2813a682017-04-12 10:07:23 +0200228Sample Usage
229============
Filip Pytloun5b3c12e2015-10-06 16:28:32 +0200230
231MySQL Galera check sripts
232
233.. code-block:: bash
234
235 mysql> SHOW STATUS LIKE 'wsrep%';
236
237 mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;"
238
239Galera monitoring command, performed from extra server
240
241.. code-block:: bash
242
243 garbd -a gcomm://ipaddrofone:4567 -g my_wsrep_cluster -l /tmp/1.out -d
244
2451. salt-call state.sls mysql
2462. Comment everything starting wsrep* (wsrep_provider, wsrep_cluster, wsrep_sst)
2473. service mysql start
2484. run on each node mysql_secure_install and filling root password.
249
250.. code-block:: bash
251
252 Enter current password for root (enter for none):
253 OK, successfully used password, moving on...
254
255 Setting the root password ensures that nobody can log into the MySQL
256 root user without the proper authorisation.
257
258 Set root password? [Y/n] y
259 New password:
260 Re-enter new password:
261 Password updated successfully!
262 Reloading privilege tables..
263 ... Success!
264
265 By default, a MySQL installation has an anonymous user, allowing anyone
266 to log into MySQL without having to have a user account created for
267 them. This is intended only for testing, and to make the installation
268 go a bit smoother. You should remove them before moving into a
269 production environment.
270
271 Remove anonymous users? [Y/n] y
272 ... Success!
273
274 Normally, root should only be allowed to connect from 'localhost'. This
275 ensures that someone cannot guess at the root password from the network.
276
277 Disallow root login remotely? [Y/n] n
278 ... skipping.
279
280 By default, MySQL comes with a database named 'test' that anyone can
281 access. This is also intended only for testing, and should be removed
282 before moving into a production environment.
283
284 Remove test database and access to it? [Y/n] y
285 - Dropping test database...
286 ... Success!
287 - Removing privileges on test database...
288 ... Success!
289
290 Reloading the privilege tables will ensure that all changes made so far
291 will take effect immediately.
292
293 Reload privilege tables now? [Y/n] y
294 ... Success!
295
296 Cleaning up...
297
2985. service mysql stop
2996. uncomment all wsrep* lines except first server, where leave only in my.cnf wsrep_cluster_address='gcomm://';
3007. start first node
3018. Start third node which is connected to first one
3029. Start second node which is connected to third one
30310. After starting cluster, it must be change cluster address at first starting node without restart database and change config my.cnf.
304
305.. code-block:: bash
306
307 mysql> SET GLOBAL wsrep_cluster_address='gcomm://10.0.0.2';
308
Ales Komarek2813a682017-04-12 10:07:23 +0200309More Information
310================
Filip Pytloun5b3c12e2015-10-06 16:28:32 +0200311
312* http://dev.mysql.com/doc/
313* http://www.slideshare.net/osscube/mysql-performance-tuning-top-10-tips
314
Filip Pytloun5b3c12e2015-10-06 16:28:32 +0200315* http://sourceforge.net/projects/automysqlbackup/
316* https://labs.riseup.net/code/projects/backupninja/wiki
317* http://wiki.zmanda.com/index.php/Mysql-zrm
Filip Pytlounfc6c3342017-02-02 13:02:03 +0100318
Ales Komarek2813a682017-04-12 10:07:23 +0200319
Filip Pytlounfc6c3342017-02-02 13:02:03 +0100320Documentation and Bugs
321======================
322
323To learn how to install and update salt-formulas, consult the documentation
324available online at:
325
326 http://salt-formulas.readthedocs.io/
327
328In the unfortunate event that bugs are discovered, they should be reported to
329the appropriate issue tracker. Use Github issue tracker for specific salt
330formula:
331
332 https://github.com/salt-formulas/salt-formula-mysql/issues
333
334For feature requests, bug reports or blueprints affecting entire ecosystem,
335use Launchpad salt-formulas project:
336
337 https://launchpad.net/salt-formulas
338
339You can also join salt-formulas-users team and subscribe to mailing list:
340
341 https://launchpad.net/~salt-formulas-users
342
343Developers wishing to work on the salt-formulas projects should always base
344their work on master branch and submit pull request against specific formula.
345
346 https://github.com/salt-formulas/salt-formula-mysql
347
348Any questions or feedback is always welcome so feel free to join our IRC
349channel:
350
351 #salt-formulas @ irc.freenode.net