Note|Docker启动mysql 容器后增加binlog日志过程记录

2022-09-261367

mysql 开启binlog ● version:5.7 开启 binlog 配置 ● 问题

  1. File '/usr/local/mysqk/log.index' not found (Errcode: 2 - No such file or directory) ○ 原因: ■ binlog 指定的文件没有权限 chown -R mysql:mysql /usr/lcoal/mysql/sql chmod 755 /usr/lcoal/mysql/sql v1 [mysqld] #log_bin datadir=/usr/local/mysql/log log_bin=bin log_bin_index=bin.index server_id=1 expire_logs_days=7 ● 配置后重启容器 ○ binlog 文件能够生成在指定目录下面 root@96f8d8c94322:/usr/local/mysql/log# ls -alh total 188M drwxr-sr-x 5 mysql mysql 4.0K Sep 7 08:26 . drwxr-sr-x 3 mysql mysql 4.0K Sep 7 08:21 ..

-rw-r----- 1 mysql mysql 56 Sep 7 08:26 auto.cnf -rw-r----- 1 mysql mysql 177 Sep 7 08:26 bin.000001 -rw-r----- 1 mysql mysql 2.9M Sep 7 08:26 bin.000002 -rw-r----- 1 mysql mysql 154 Sep 7 08:26 bin.000003 -rw-r----- 1 mysql mysql 39 Sep 7 08:26 bin.index -rw------- 1 mysql mysql 1.7K Sep 7 08:26 ca-key.pem -rw-r--r-- 1 mysql mysql 1.1K Sep 7 08:26 ca.pem -rw-r--r-- 1 mysql mysql 1.1K Sep 7 08:26 client-cert.pem -rw------- 1 mysql mysql 1.7K Sep 7 08:26 client-key.pem -rw-r----- 1 mysql mysql 1.4K Sep 7 08:26 ib_buffer_pool -rw-r----- 1 mysql mysql 48M Sep 7 08:27 ib_logfile0 -rw-r----- 1 mysql mysql 48M Sep 7 08:26 ib_logfile1 -rw-r----- 1 mysql mysql 76M Sep 7 08:27 ibdata1 -rw-r----- 1 mysql mysql 12M Sep 7 08:27 ibtmp1 drwxr-s--- 2 mysql mysql 4.0K Sep 7 08:26 mysql drwxr-s--- 2 mysql mysql 4.0K Sep 7 08:26 performance_schema -rw------- 1 mysql mysql 1.7K Sep 7 08:26 private_key.pem -rw-r--r-- 1 mysql mysql 451 Sep 7 08:26 public_key.pem -rw-r--r-- 1 mysql mysql 1.1K Sep 7 08:26 server-cert.pem -rw------- 1 mysql mysql 1.7K Sep 7 08:26 server-key.pem drwxr-s--- 2 mysql mysql 12K Sep 7 08:26 sys

+----------------------------------------+--------------------------------+ | Variable_name | Value | +----------------------------------------+--------------------------------+ | log_bin | ON | | log_bin_basename | /usr/local/mysql/log/bin | | log_bin_index | /usr/local/mysql/log/bin.index | | log_bin_trust_function_creators | OFF | | log_bin_use_v1_row_events | OFF | | log_builtin_as_identified_by_password | OFF | | log_error | stderr | | log_error_verbosity | 3 | | log_output | FILE | | log_queries_not_using_indexes | OFF | | log_slave_updates | OFF | | log_slow_admin_statements | OFF | | log_slow_slave_statements | OFF | | log_statements_unsafe_for_binlog | ON | | log_syslog | OFF | | log_syslog_facility | daemon | | log_syslog_include_pid | ON | | log_syslog_tag | | | log_throttle_queries_not_using_indexes | 0 | | log_timestamps | UTC | | log_warnings | 2 | +----------------------------------------+--------------------------------+

v2 [mysqld]

#log_bin log_bin=/usr/local/mysql/log log_bin_index=/usr/local/mysql/log.index server_id=1 expire_logs_days=7 mysql> show variables like 'log_%'; +----------------------------------------+----------------------------+ | Variable_name | Value | +----------------------------------------+----------------------------+ | log_bin | ON | | log_bin_basename | /usr/local/mysql/log | | log_bin_index | /usr/local/mysql/log.index | | log_bin_trust_function_creators | OFF | | log_bin_use_v1_row_events | OFF | | log_builtin_as_identified_by_password | OFF | | log_error | stderr | | log_error_verbosity | 3 | | log_output | FILE | | log_queries_not_using_indexes | OFF | | log_slave_updates | OFF | | log_slow_admin_statements | OFF | | log_slow_slave_statements | OFF | | log_statements_unsafe_for_binlog | ON | | log_syslog | OFF | | log_syslog_facility | daemon | | log_syslog_include_pid | ON | | log_syslog_tag | | | log_throttle_queries_not_using_indexes | 0 | | log_timestamps | UTC | | log_warnings | 2 | +----------------------------------------+----------------------------+

● 注意点 ○ binlog 放在了/usr/local/mysql下,相当于log就是log_bin_basename root@96f8d8c94322:/usr/local/mysql# ls -alh total 40K drwxr-sr-x 3 mysql mysql 4.0K Sep 7 08:50 . drwxr-sr-x 1 mysql mysql 4.0K Sep 7 08:08 .. drwxr-sr-x 5 mysql mysql 4.0K Sep 7 08:48 log -rw-r----- 1 mysql mysql 177 Sep 7 08:04 log-bin.000001 -rw-r----- 1 mysql mysql 32 Sep 7 07:58 log-bin.index -rw-r----- 1 mysql mysql 177 Sep 7 08:26 log.000001 -rw-r----- 1 mysql mysql 177 Sep 7 08:50 log.000002 -rw-r----- 1 mysql mysql 154 Sep 7 08:50 log.000003 -rw-r----- 1 mysql mysql 84 Sep 7 08:50 log.index

分享
点赞0
打赏
上一篇:Docker常用命令笔记(一)
下一篇:如何搭建接口自动化框架(四)-pytest之测试用例标记