MySQL server log manage
发表于:2025-11-08 作者:千家信息网编辑
千家信息网最后更新 2025年11月08日,#################Binary Logbinlog_cache_size的大小必须为4096的倍数,不然会有一个warning, "Warning | 1292 | Truncated
千家信息网最后更新 2025年11月08日MySQL server log manage#################
Binary Log
binlog_cache_size的大小必须为4096的倍数,不然会有一个warning, "Warning | 1292 | Truncated incorrect binlog_cache_size value: '33792'",然后向下取最接近n个4096的值。
mysql> show warnings;
+---------+------+------------------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------------------+
| Warning | 1292 | Truncated incorrect binlog_cache_size value: '33792' |
+---------+------+------------------------------------------------------+
1 row in set (0.0
SET GLOBAL binlog_format = 'STATEMENT';
SET GLOBAL binlog_format = 'ROW';
SET GLOBAL binlog_format = 'MIXED';
SET SESSION binlog_format = 'STATEMENT';
SET SESSION binlog_format = 'ROW';
SET SESSION binlog_format = 'MIXED';
set global binlog_cache_size=4096*n;
log_bin = /data/my3306/bin_log/mysql_bin
binlog_format = row
binlog_cache_size=4096*n
#################
general log
mysql> SHOW global variables like '%general%';
+------------------+---------------------------+
| Variable_name | Value |
+------------------+---------------------------+
| general_log | OFF |
| general_log_file | /data/my3306/centos65.log |
+------------------+---------------------------+
set global general_log=1;
set global general_log_file='/data/my3306/centos65_general.log';
mysql> SHOW global variables like '%general%';
+------------------+-----------------------------------+
| Variable_name | Value |
+------------------+-----------------------------------+
| general_log | ON |
| general_log_file | /data/my3306/centos65_general.log |
+------------------+-----------------------------------+
2 rows in set (0.00 sec)
#################
slow_query_log
mysql> show variables like '%slow%';
+---------------------------+--------------------------------+
| Variable_name | Value |
+---------------------------+--------------------------------+
| log_slow_admin_statements | OFF |
| log_slow_slave_statements | OFF |
| slow_launch_time | 2 |
| slow_query_log | OFF |
| slow_query_log_file | /data/my3306/centos65-slow.log |
+---------------------------+--------------------------------+
5 rows in set (0.00 sec)
mysql> set global slow_query_log=1;
Query OK, 0 rows affected (0.33 sec)
mysql> set global long_query_time=1;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%quer%';
+----------------------------------------+--------------------------------+
| Variable_name | Value |
+----------------------------------------+--------------------------------+
| binlog_rows_query_log_events | OFF |
| ft_query_expansion_limit | 20 |
| have_query_cache | YES |
| log_queries_not_using_indexes | OFF |
| log_throttle_queries_not_using_indexes | 0 |
| long_query_time | 1.000000 |
| query_alloc_block_size | 8192 |
| query_cache_limit | 1048576 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 1048576 |
| query_cache_type | OFF |
| query_cache_wlock_invalidate | OFF |
| query_prealloc_size | 8192 |
| slow_query_log | ON |
| slow_query_log_file | /data/my3306/centos65-slow.log |
+----------------------------------------+--------------------------------+
15 rows in set (0.00 sec)
#################
innodb_log_file
To change the number or the size of your InnoDB redo log files, perform the following steps:
1 Stop the MySQL server and make sure that it shuts down without errors.
2 Edit my.cnf to change the log file configuration. To change the log file size,
configure innodb_log_file_size. To increase the number of log files, configure innodb_log_files_in_group.
3 Start the MySQL server again.
If InnoDB detects that the innodb_log_file_size differs from the redo log file size,
it will write a log checkpoint, close and remove the old log files, create new log files at the requested size, and open the new log files.
mysql> show variables like '%innodb%log%';
+----------------------------------+-----------+
| Variable_name | Value |
+----------------------------------+-----------+
| innodb_api_enable_binlog | OFF |
| innodb_flush_log_at_timeout | 1 |
| innodb_flush_log_at_trx_commit | 1 |
| innodb_locks_unsafe_for_binlog | OFF |
| innodb_log_buffer_size | 8388608 |
| innodb_log_compressed_pages | ON |
| innodb_log_file_size | 50331648 |
| innodb_log_files_in_group | 2 |
| innodb_log_group_home_dir | ./ |
| innodb_mirrored_log_groups | 1 |
| innodb_online_alter_log_max_size | 134217728 |
| innodb_undo_logs | 128 |
+----------------------------------+-----------+
12 rows in set (0.00 sec)
innodb_log_group_home_dir = /hbdata/mysqldata/3306/binlog
innodb_log_file_size = 1300M
innodb_log_files_in_group = 3
2016-06-02 11:16:17 4299 [Warning] InnoDB: Resizing redo log from 5*12800 to 4*9600 pages, LSN=23031318
2016-06-02 11:16:17 4299 [Warning] InnoDB: Starting to delete and rewrite log files.
2016-06-02 11:16:17 4299 [Note] InnoDB: Setting log file ./ib_logfile101 size to 150 MB
InnoDB: Progress in MB: 100
2016-06-02 11:16:18 4299 [Note] InnoDB: Setting log file ./ib_logfile1 size to 150 MB
InnoDB: Progress in MB: 100
2016-06-02 11:16:19 4299 [Note] InnoDB: Setting log file ./ib_logfile2 size to 150 MB
InnoDB: Progress in MB: 100
2016-06-02 11:16:20 4299 [Note] InnoDB: Setting log file ./ib_logfile3 size to 150 MB
InnoDB: Progress in MB: 100
2016-06-02 11:16:21 4299 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-06-02 11:16:21 4299 [Warning] InnoDB: New log files created, LSN=23031318
Binary Log
binlog_cache_size的大小必须为4096的倍数,不然会有一个warning, "Warning | 1292 | Truncated incorrect binlog_cache_size value: '33792'",然后向下取最接近n个4096的值。
mysql> show warnings;
+---------+------+------------------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------------------+
| Warning | 1292 | Truncated incorrect binlog_cache_size value: '33792' |
+---------+------+------------------------------------------------------+
1 row in set (0.0
SET GLOBAL binlog_format = 'STATEMENT';
SET GLOBAL binlog_format = 'ROW';
SET GLOBAL binlog_format = 'MIXED';
SET SESSION binlog_format = 'STATEMENT';
SET SESSION binlog_format = 'ROW';
SET SESSION binlog_format = 'MIXED';
set global binlog_cache_size=4096*n;
log_bin = /data/my3306/bin_log/mysql_bin
binlog_format = row
binlog_cache_size=4096*n
#################
general log
mysql> SHOW global variables like '%general%';
+------------------+---------------------------+
| Variable_name | Value |
+------------------+---------------------------+
| general_log | OFF |
| general_log_file | /data/my3306/centos65.log |
+------------------+---------------------------+
set global general_log=1;
set global general_log_file='/data/my3306/centos65_general.log';
mysql> SHOW global variables like '%general%';
+------------------+-----------------------------------+
| Variable_name | Value |
+------------------+-----------------------------------+
| general_log | ON |
| general_log_file | /data/my3306/centos65_general.log |
+------------------+-----------------------------------+
2 rows in set (0.00 sec)
#################
slow_query_log
mysql> show variables like '%slow%';
+---------------------------+--------------------------------+
| Variable_name | Value |
+---------------------------+--------------------------------+
| log_slow_admin_statements | OFF |
| log_slow_slave_statements | OFF |
| slow_launch_time | 2 |
| slow_query_log | OFF |
| slow_query_log_file | /data/my3306/centos65-slow.log |
+---------------------------+--------------------------------+
5 rows in set (0.00 sec)
mysql> set global slow_query_log=1;
Query OK, 0 rows affected (0.33 sec)
mysql> set global long_query_time=1;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%quer%';
+----------------------------------------+--------------------------------+
| Variable_name | Value |
+----------------------------------------+--------------------------------+
| binlog_rows_query_log_events | OFF |
| ft_query_expansion_limit | 20 |
| have_query_cache | YES |
| log_queries_not_using_indexes | OFF |
| log_throttle_queries_not_using_indexes | 0 |
| long_query_time | 1.000000 |
| query_alloc_block_size | 8192 |
| query_cache_limit | 1048576 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 1048576 |
| query_cache_type | OFF |
| query_cache_wlock_invalidate | OFF |
| query_prealloc_size | 8192 |
| slow_query_log | ON |
| slow_query_log_file | /data/my3306/centos65-slow.log |
+----------------------------------------+--------------------------------+
15 rows in set (0.00 sec)
#################
innodb_log_file
To change the number or the size of your InnoDB redo log files, perform the following steps:
1 Stop the MySQL server and make sure that it shuts down without errors.
2 Edit my.cnf to change the log file configuration. To change the log file size,
configure innodb_log_file_size. To increase the number of log files, configure innodb_log_files_in_group.
3 Start the MySQL server again.
If InnoDB detects that the innodb_log_file_size differs from the redo log file size,
it will write a log checkpoint, close and remove the old log files, create new log files at the requested size, and open the new log files.
mysql> show variables like '%innodb%log%';
+----------------------------------+-----------+
| Variable_name | Value |
+----------------------------------+-----------+
| innodb_api_enable_binlog | OFF |
| innodb_flush_log_at_timeout | 1 |
| innodb_flush_log_at_trx_commit | 1 |
| innodb_locks_unsafe_for_binlog | OFF |
| innodb_log_buffer_size | 8388608 |
| innodb_log_compressed_pages | ON |
| innodb_log_file_size | 50331648 |
| innodb_log_files_in_group | 2 |
| innodb_log_group_home_dir | ./ |
| innodb_mirrored_log_groups | 1 |
| innodb_online_alter_log_max_size | 134217728 |
| innodb_undo_logs | 128 |
+----------------------------------+-----------+
12 rows in set (0.00 sec)
innodb_log_group_home_dir = /hbdata/mysqldata/3306/binlog
innodb_log_file_size = 1300M
innodb_log_files_in_group = 3
2016-06-02 11:16:17 4299 [Warning] InnoDB: Resizing redo log from 5*12800 to 4*9600 pages, LSN=23031318
2016-06-02 11:16:17 4299 [Warning] InnoDB: Starting to delete and rewrite log files.
2016-06-02 11:16:17 4299 [Note] InnoDB: Setting log file ./ib_logfile101 size to 150 MB
InnoDB: Progress in MB: 100
2016-06-02 11:16:18 4299 [Note] InnoDB: Setting log file ./ib_logfile1 size to 150 MB
InnoDB: Progress in MB: 100
2016-06-02 11:16:19 4299 [Note] InnoDB: Setting log file ./ib_logfile2 size to 150 MB
InnoDB: Progress in MB: 100
2016-06-02 11:16:20 4299 [Note] InnoDB: Setting log file ./ib_logfile3 size to 150 MB
InnoDB: Progress in MB: 100
2016-06-02 11:16:21 4299 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-06-02 11:16:21 4299 [Warning] InnoDB: New log files created, LSN=23031318
倍数
大小
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
中国5g网络技术和NFV
专硕有网络安全的学校
嵌入式开发和软件开发哪个好
电脑多次关机重启数据库错误
网络安全的童诗童谣五十字
网络技术课程试题
珠海悦泰网络技术
金碟科目余额对应数据库
手抄报网络安全教育图片
网络安全管理制度百科
复旦大学网络安全研究生复试
安全教育网络安全内容包括
域名服务器更改有何影响
镜像网站式的数据库
233 网校三级网络技术
服务器安全狗怎么禁止进程
大力开展全民网络安全宣传教育
浪潮服务器全国
网络技术学习软件初中
肇庆信息软件开发咨询
高科技互联网时代
杭州2011服务器散热器生产商
江北一站式软件开发
电力监控系统网络安全工作
数据库系统答案第四版
大宗现货 软件开发
湖南1u2路机架服务器价格
女孩子学计算机网络安全
成都海锋网络技术服务
命运2的装备数据库