From 3cf5a36fb85b196f6a7446b042769c7e5b7bc05a Mon Sep 17 00:00:00 2001
From: tu <2843180578@qq.com>
Date: Wed, 29 May 2024 10:18:43 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20=E7=AC=AC=E5=9B=9B?=
=?UTF-8?q?=E7=AB=A0=EF=BC=9A=E6=95=B0=E6=8D=AE=E5=BA=93=E6=97=A5=E5=BF=97?=
=?UTF-8?q?=E7=AE=A1=E7=90=86.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
第四章:数据库日志管理.md | 135 --------------------------------------
1 file changed, 135 deletions(-)
delete mode 100644 第四章:数据库日志管理.md
diff --git a/第四章:数据库日志管理.md b/第四章:数据库日志管理.md
deleted file mode 100644
index 974d4e0..0000000
--- a/第四章:数据库日志管理.md
+++ /dev/null
@@ -1,135 +0,0 @@
-
数据库日志管理
-
-**作者:行癫(盗版必究)**
-
-------
-
-## 一:日志管理
-
-
-
-#### 1.日志分类
-
- 错误日志 :启动,停止,关闭失败报错。rpm安装日志位置 /var/log/mysqld.log
-
- 通用查询日志:所有的查询都记下来
-
- 二进制日志:实现备份,增量备份。只记录改变数据,除了select都记
-
- 中继日志:读取主服务器的binlog,在本地回放。保持一致
-
- slow log:慢查询日志,指导调优,定义某一个查询语句,定义超时时间,通过日志提供调优建议给开发人员
-
- DDL log: 定义语句的日志
-
-#### 2.Error Log
-
-```shell
-log-error=/var/log/mysqld.log
-```
-
-#### 3.Binary Log
-
-```
-log-bin=/var/log/mysql-bin/slave2
-server-id=2
-
-[root@slave2 ~]# mkdir /var/log/mysql-bin
-[root@slave2 ~]# chown mysql.mysql /var/log/mysql-bin/
-[root@slave2 ~]# systemctl restart mysqld
-```
-
-注意:
-
- 需要提前开启
-
-查看binlog日志:
-
-```shel
-[root@slave2 ~]# mysqlbinlog slave2-bin.000001 -v --base64-output=decode-rows
- 时间点 : 141126 14:04:49
- 位置点 : at 106
-注:
-1. 重启mysqld 会截断
-2. flush logs 会截断
-3. reset master 删除所有binlog rm -rf /var/lib/mysql/*.000001
-4. 删除部分
-PURGE BINARY LOGS TO 'mysql-bin.010';
-PURGE BINARY LOGS BEFORE '2019-04-02 22:46:26';
-
-截取binlog
-all:
-# mysqlbinlog mysql.000002
-
-datetime:
-# mysqlbinlog mysql.000002 --start-datetime="2018-12-05 10:02:56"
-# mysqlbinlog mysql.000002 --stop-datetime="2018-12-05 11:02:54"
-# mysqlbinlog mysql.000002 --start-datetime="2018-12-05 10:02:56" --stop-datetime="2018-12-05 11:02:54"
-
-position:
-# mysqlbinlog mysql.000002 --start-position=260
-# mysqlbinlog mysql.000002 --stop-position=260
-# mysqlbinlog mysql.000002 --start-position=260 --stop-position=930
-```
-
-#### 4.Slow Query Log
-
-开启慢查询日志:
-
-```shell
-[root@xingdian ~]# vim /etc/my.cnf
-slow_query_log=1
-slow_query_log_file=/var/log/mysql-slow/slow.log
-long_query_time=3 设置慢查询超时时间 单位是:秒
-```
-
-创建对应目录:
-
-```shell
-[root@xingdian ~]# mkdir /var/log/mysql-slow
-[root@xingdian ~]# chown mysql.mysql mysql-slow
-```
-
-重启服务:
-
-```shell
-[root@xingdian ~]# systemctl restart mysqld
-```
-
-验证:
-
-```shell
-[root@xingdian ~]# mysql -uroot -pQianFeng@123
-mysql: [Warning] Using a password on the command line interface can be insecure.
-Welcome to the MySQL monitor. Commands end with ; or \g.
-Your MySQL connection id is 2
-Server version: 5.7.39-log MySQL Community Server (GPL)
-
-Copyright (c) 2000, 2022, Oracle and/or its affiliates.
-
-Oracle is a registered trademark of Oracle Corporation and/or its
-affiliates. Other names may be trademarks of their respective
-owners.
-
-Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
-
-mysql> select sleep(6);
-+----------+
-| sleep(6) |
-+----------+
-| 0 |
-+----------+
-1 row in set (6.00 sec)
-
-mysql> exit
-Bye
-[root@xingdian ~]# cat /var/log/mysql-slow/slow.log
-/usr/sbin/mysqld, Version: 5.7.39-log (MySQL Community Server (GPL)). started with:
-Tcp port: 0 Unix socket: /var/lib/mysql/mysql.sock
-Time Id Command Argument
-# Time: 2022-09-25T06:58:05.496205Z
-# User@Host: root[root] @ localhost [] Id: 2
-# Query_time: 6.007094 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0
-SET timestamp=1664089085;
-select sleep(6);
-```