赞
踩
sudo vi /usr/local/etc/my.cnf //添加内容如下:
[mysqld]
#log_bin
log-bin = mysql-bin #开启binlog
binlog-format = ROW #选择row模式
server_id = 1 #配置mysql replication需要定义,不能和canal的slaveId重复
mysql.server restart // 重启mysql
localhost:~ shaozeming$ mysql.server restart
Shutting down MySQL
.... SUCCESS!
Starting MySQL
. SUCCESS!
show variables like '%log_bin%';查看是否开启
mysql> show variables like '%log_bin%';
+---------------------------------+--------------------------------------+
| Variable_name | Value|
+---------------------------------+--------------------------------------+
| log_bin | ON |
| log_bin_basename| /usr/local/var/mysql/mysql-bin |
| log_bin_index | /usr/local/var/mysql/mysql-bin.index |
| log_bin_trust_function_creators | OFF|
| log_bin_use_v1_row_events | OFF|
| sql_log_bin | ON |
+---------------------------------+--------------------------------------+
6 rows in set (0.00 sec)
mysql>
show master status; 查看日志状态
mysql> show master status;
+——————+———-+————–+——————+——————-+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+——————+———-+————–+——————+——————-+
| mysql-bin.000001 |154 ||| |
+——————+———-+————–+——————+——————-+
1 row in set (0.00 sec)
mysql>
flush logs; 刷新日志,刷新之后会新建一个新的Binlog日志
mysql> flush logs;
Query OK, 0 rows affected (0.05 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000002 |154 ||| |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql>
reset master; 清空日志文件
mysql> reset master;
Query OK, 0 rows affected (0.05 sec)
mysql>
mysqlbinlog /usr/local/var/mysql/mysql-bin.000001; 查看日志文件
localhost:~ shaozeming$ mysqlbinlog /usr/local/var/mysql/mysql-bin.000001;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#190228 11:59:35 server id 1end_log_pos 123 CRC32 0x1b83b191 Start: binlog v 4, server v 5.7.23-log created 190228 11:59:35 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
BINLOG '
p1x3XA8BAAAAdwAAAHsAAAABAAQANS43LjIzLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAACnXHdcEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA
AZGxgxs=
'/*!*/;
# at 123
#190228 11:59:35 server id 1end_log_pos 154 CRC32 0xeeba1546 Previous-GTIDs
# [empty]
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
localhost:~ shaozeming$
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。