我的编程空间,编程开发者的网络收藏夹
学习永远不晚

MySQL server log manage

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

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


免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

MySQL server log manage

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

2024-04-02

MySQL日志系统bin log、redo log和undo log

MySQL日志系统bin log、redo log和undo log     今人不见古时月,今月曾经照古人。 简介:日志是MySQL数据库的重要组成部分,记录着数据库运行期间各种状态信息,主要包括错误日志、查询日志、慢查询日志、事务日志、二进制日志几大类。在
MySQL日志系统bin log、redo log和undo log
2019-07-22

MySQL系列之redo log、undo log和binlog详解

事务的实现 redo log保证事务的持久性,undo log用来帮助事务回滚及MVCC的功能。 InnoDB存储引擎体系结构redo log Write Ahead Log策略 事务提交时,先写重做日志再修改页;当由于发生宕机而导致数据丢
2022-05-26

MySQL中的redo log和undo log日志详解

MySQL日志系统中最重要的日志为重做日志redo log和归档日志bin log,后者为MySQL Server层的日志,前者为InnoDB存储引擎层的日志。 1 重做日志redo log 1.1 什么是redo log redo log
2022-05-13

mac 开启mysql bin-log

vim /usr/local/etc/my.cnf 添加以下配置expire_logs_days = 5 定期清理log-bin = /usr/local/var/mysql/mysql_bin_log/mysql-bin #开启binlog,指定文件闻之s
mac 开启mysql bin-log
2020-10-26

mysql日志文件undo log和redo log怎么设置

本篇内容主要讲解“mysql日志文件undo log和redo log怎么设置”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“mysql日志文件undo log和redo log怎么设置”吧!1
2023-06-30

编程热搜

目录