MySQL 5.6.12切换binlog二进制日志路径

前言:
有一个MySQL学生说他们因为binlog产生太大了,需要把日志路径放到另外的磁盘上面去,问我有啥时机的操作方案,share弄了一个mysql的binlog的日志路径切换的例子给他。正好今天有空,就拿mysql5.6.12来做个实例,给大家演示一下。

1,查看binlog地址 [root@mysql5612 ~]# more /usr/local/mysql/my.cnf |grep log-bin log-bin =/home/data/mysql/binlog/mysql-bin.log [root@mysql5612 ~]# 2,验证binlog的正常使用 [root@mysql5612 binlog]# pwd /home/data/mysql/binlog [root@mysql5612 binlog]# mysql Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 390217 Server version: 5.6.12-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create table z2 select 2 as a; ERROR 1046 (3D000): No database selected mysql> create table test.z2 select 2 as a; Query OK, 1 row affected (0.04 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> exit Bye [root@mysql5612 binlog]# ll 总用量 6240204 -rw-rw----. 1 mysql mysql 1073742187 6月 8 2015 mysql-bin.000048 -rw-rw----. 1 mysql mysql 1073741968 6月 8 2015 mysql-bin.000049 -rw-rw----. 1 mysql mysql 1073742063 6月 8 2015 mysql-bin.000050 -rw-rw----. 1 mysql mysql 1073741957 6月 8 2015 mysql-bin.000051 -rw-rw----. 1 mysql mysql 1073742142 6月 8 2015 mysql-bin.000052 -rw-rw----. 1 mysql mysql 1021194604 12月 10 20:44 mysql-bin.000053 -rw-rw----. 1 mysql mysql 615 6月 8 2015 mysql-bin.index [root@mysql5612 binlog]#

看到binlog日志更新了,在20:44时间处,binlog日志mysql-bin.000053有更新记录。然后冲洗mysql服务,看看binlog是否会重新生成:

[root@mysql5612 binlog]# service mysqld56 restart Shutting down MySQL................. [确定] Starting MySQL..... [确定] [root@mysql5612 binlog]# [root@mysql5612 binlog]# ll 总用量 997276 -rw-rw----. 1 mysql mysql 1021194627 12月 10 20:46 mysql-bin.000053 -rw-rw----. 1 mysql mysql 399 12月 10 20:47 mysql-bin.000054 -rw-rw----. 1 mysql mysql 82 12月 10 20:46 mysql-bin.index [root@mysql5612 binlog]#

果然,有新的mysql-bin.000054日志生成了。

3,去修改binlog日志路径

建立新的binlog日志路径:

[root@mysql5612 binlog]# mkdir -p /home/data/mysql/binlog_new [root@mysql5612 binlog]# [root@mysql5612 binlog]# chown -R mysql.mysql /home/data/mysql/binlog_new [root@mysql5612 binlog]#

然后修改my.cnf,设置新的log-bin路径:

[root@mysql5612 binlog]# vim /usr/local/mysql/my.cnf log-bin =/home/data/mysql/binlog_new/mysql-bin

查看配置文件的binlog路径:

[root@mysql5612 mysql]# more /usr/local/mysql/my.cnf |grep log-bin log-bin =/home/data/mysql/binlog_new/mysql-bin [root@mysql5612 mysql]# 4,重启mysql服务 [root@mysql5612 mysql]# service mysqld56 restart Shutting down MySQL.. [确定] Starting MySQL..... [确定] [root@mysql5612 mysql]# 5,验证新的binlog

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/7a9d88cd86ad6a1129c89e571aaff244.html