s to do so.
You may want to copy the file manually, or create your own,
it will then be used by default by the server when you start it.
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
?
?
?
?
5,启动多实例数据库
mkdir -p /home/mysql/data/log
?
[mysql@data02 data]$ mysqld_multi--defaults-extra-file=/etc/my.cnf start 1,2,3
[mysql@data02 data]$
后台日志信息:
Starting MySQL servers
?
150514 09:36:14 mysqld_safe Logging to'/home/data/mysql3309/data/data02.err'.
150514 09:36:15 mysqld_safe Logging to '/home/data/mysql3308/data/data02.err'.
150514 09:36:15 mysqld_safe Logging to'/home/data/mysql3307/data/data02.err'.
150514 09:36:15 mysqld_safe Starting mysqlddaemon with databases from /home/data/mysql3308/data
150514 09:36:15 mysqld_safe Starting mysqlddaemon with databases from /home/data/mysql3307/data
150514 09:36:15 mysqld_safe Starting mysqlddaemon with databases from /home/data/mysql3309/data
6,查看多实例
[mysql@data02 ~]$ mysqld_multi--defaults-extra-file=/etc/my.cnf report
Reporting MySQL servers
MySQL server from group: mysqld1 is running
MySQL server from group: mysqld2 is running
MySQL server from group: mysqld3 is running
[mysql@data02 ~]$
?
后台日志信息:
Reporting MySQL servers
MySQL server from group: mysqld1 is running
MySQL server from group: mysqld2 is running
MySQL server from group: mysqld3 is running
7,停止多实例
mysqld_multi--defaults-extra-file=/etc/my.cnf stop 1,2,3
?
后台日志信息:
Stopping MySQL servers
?
150514 09:35:43 mysqld_safe mysqld from pidfile /usr/local/mysql3309/mysqld.pid ended
150514 09:35:43 mysqld_safe mysqld from pidfile /usr/local/mysql3307/mysqld.pid ended
150514 09:35:43 mysqld_safe mysqld from pidfile /usr/local/mysql3308/mysqld.pid ended
?
8,各自登录mysql实例
需要指定启动的socket就可以登录到各自的mysql实例,如下所示:
[mysql@data02 ~]$ mysql --socket=/usr/local/mysql3308/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.12-log Sourcedistribution
?
Copyright (c) 2000, 2013, Oracle and/or itsaffiliates. All rights reserved.
?
Oracle is a registered trademark of OracleCorporation and/or its
affiliates. Other names may be trademarksof their respective
owners.
?
Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
?
mysql> select @@port;
+--------+
| @@port |
+--------+
| 3308 |
+--------+
1 row in set (0.00 sec)
?
mysql>
mysql> create database d3308;
Query OK, 1 row affected (0.04 sec)
?
mysql>
?
?
9,可以在多端口上搭建主从、主主服务
9.1,在3307实例建立账号
复制账号
GRANTREPLICATION SLAVE,RELOAD,SUPER ON *.*TO repl@'192.168.52.%' IDENTIFIED BY'repl_1234';
?
备份账号
GRANTRELOAD, SUPER, LOCK TABLES, REPLICATION CLIENT, CREATE TABLESPACE ON *.* TO'backup'@'192.168.%' IDENTIFIED BY '123456';
GRANTALL PRIVILEGES ON `mysql`.* TO 'backup'@'192.168.%';
GRANTEVENT ON *.* TO 'backup'@'192.168.%';
?
?
9.2,将数据从3307实例同步到3308端口
?
备份:
/usr/local/mysql/bin/mysqldump-ubackup --password=123456 --host=192.168.52.138--socket=/usr/local/mysql3307/mysql.sock --port=3307 -R -E --skip-opt--single-transaction --flush-logs --master-data=2 --add-drop-table--create-option --quick --extended-insert=false --set-charset --disable-keys