mysql show master status为空值

问题

执行show master status,输出结果为空:

mysql> show master status;
Empty set (0.00 sec)

原因

mysql没有开启日志。
查看log_bin选项:

mysql> show variables like '%log_bin%';
+---------------------------------+-------+
| Variable_name                   | Value |
+---------------------------------+-------+
| log_bin                         | OFF   |
| log_bin_basename                |       |
| log_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)

可以看到log_bin是OFF.

解决方法

在mysql 配置文件 /etc/my.cnf中

[mysqld]下添加:

log-bin=mysql-bin

log-bin配置项表示binlog的base name,产生的日志文件名称类似,mysql-bin.00001,mysql-bin.00002,mysql-bin.00003。

保存,重启mysql服务。

mysql> SHOW MASTER STATUS\G
*************************** 1. row ***************************
             File: master-bin.000002
         Position: 1307
     Binlog_Do_DB: test
 Binlog_Ignore_DB: manual, mysql
Executed_Gtid_Set: 3E11FA47-71CA-11E1-9E33-C80AA9429562:1-5
1 row in set (0.00 sec)

show master status命令列出了日志位点信息,包括binlog file,binlog position等。

如果使用了GTID(global transaction ID),Executed_Gtid_Set表示已经在这个master上执行的GTID集合,与这个server上的系统变量gtid_executed 含义相同。

在这个server执行show slave status中是输出的对应列Executed_Gtid_Set含义相同。

参考

http://www.vsbclub.com/info/1024/1673.htm
show master status
17.1.4.4 Binary Log Options and Variables

猜你喜欢

转载自www.cnblogs.com/lanyangsh/p/10164657.html