首页 > 数据库 >MySQL8主从搭建

MySQL8主从搭建

时间:2024-09-29 17:20:56浏览次数:10  
标签:rows Log MySQL8 SSL sec mysql Master 主从 搭建

MySQL8主从搭建

基础环境

基本信息:

虚拟化软件:Oracle VM VirtualBox

1C/2G

1个网卡

80G系统盘

oracle:mysql-8.0.20

yum:CentOS-7.6-x86_64-DVD-1810.iso

服务器IP规划:

主机名mysql1mysql 2mysql 3
系统CentOS-7.6CentOS-7.6CentOS-7.6
IP192.168.56.41192.168.56.42192.168.56.43

操作系统配置

修改主机名

hostnamectl set-hostname mysql1

hostnamectl set-hostname mysql2

修改hosts文件

/etc/hosts

192.168.56.41 mysql1

192.168.56.42 mysql2

关闭防火墙和SELINUX

systemctl stop firewalld && systemctl disable firewalld

setenforce 0

vim /etc/selinux/config #将SELINUX设置为disabled

配置网络

网卡:enp0s3

按照前期规划的服务器IP规划正常配置就行

配置本地yum

将CentOS-7.6-x86_64-DVD-1810.iso文件传到/iso文件夹

执行mount -t iso9660 -o loop /iso/CentOS-7.6-x86_64-DVD-1810.iso /mnt

创建

[oracle@bsgrac2:/etc/yum.repos.d]$vim Centos7.repo

[local]

name=Centos7

baseurl=file:///mnt

gpgcheck=0

enabled=1

yum clean all&&yum makecache

安装依赖

查看是否安装mariadb,有的话卸载

[root@mysql1 soft]# rpm -qa|grep mariadb

mariadb-libs-5.5.60-1.el7_5.x86_64

[root@mysql1 soft]# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

检查依赖,没有的话需要安装

rpm -qa|grep libaio

rpm -qa|grep numactl

安装mysql

解压mysql包

cd /soft

tar -zxvf mysql-8.0.20-el7-x86_64.tar.gz

创建文件夹和授权目录

mkdir -p /usr/local/mysql

mv mysql-8.0.20-el7-x86_64/* /usr/local/mysql

cd /usr/local/mysql

mkdir data logs

groupadd mysql

useradd -r -g mysql -s /sbin/nologin mysql

chown -R mysql:mysql /usr/local/mysql/

编辑my.cnf文件

vi /etc/my.cnf

[mysqld]

port = 3306

server-id = 41

user = mysql

socket = /tmp/mysql.sock

# 安装目录

basedir=/usr/local/mysql

# 数据存放目录

datadir=/usr/local/mysql/data

log-bin=/usr/local/mysql/logs/mysql-bin

innodb_data_home_dir =/usr/local/mysql/data

innodb_log_group_home_dir =/usr/local/mysql/data

#日志及进程数据的存放目录

log-error=/usr/local/mysql/logs/mysql.log

pid-file =/usr/local/mysql/data/mysql.pid

slow_query_log=1

slow_query_log_file=/usr/local/mysql/logs/slow.log

long_query_time=0.1

log_queries_not_using_indexes=1

安装初始化数据库,生成密码

cd /usr/local/mysql/bin

./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql

[root@mysql1 logs]# cat /usr/local/mysql/logs/mysql.log |grep pass

2024-05-29T06:10:36.259908Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: KadcpFZ%T2p#

配置mysql服务

vim /usr/lib/systemd/system/mysqld.service

[Unit]

Description=MySQL Server

Documentation=man:mysqld(8)

After=network.target

After=syslog.target

[Install]

WantedBy=multi-user.target

[Service]

User=mysql

Group=mysql

ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf

LimitNOFILE = 65536

LimitNPROC = 65536

systemctl daemon-reload ##重新加载 systemctl

添加软连接

[root@mysql1 logs]# ln -s /usr/local/mysql/bin/mysql /usr/bin/

[root@mysql1 logs]# ln -s /usr/local/mysql/bin/mysqldump /usr/bin/

开启mysql数据库

[root@mysql1 logs]# systemctl start mysqld

[root@mysql1 logs]# systemctl status mysqld

● mysqld.service - MySQL Server

Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)

Active: active (running) since Wed 2024-05-29 14:15:32 CST; 12s ago

Docs: man:mysqld(8)

http://dev.mysql.com/doc/refman/en/using-systemd.html

Main PID: 13993 (mysqld)

Tasks: 39

CGroup: /system.slice/mysqld.service

└─13993 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf

May 29 14:15:32 mysql1 systemd[1]: Started MySQL Server.

修改root用户密码

[root@mysql1 logs]# mysql -u root -p

mysql> ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘bsg123’;

Query OK, 0 rows affected (0.00 sec)

改成远程连接update user set host=‘%’ where user=‘root’;

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

离线创建GTID主从复制

创建复制用户

mysql> create user ‘repl’@‘%’ identified with mysql_native_password by ‘bsg_123’;

Query OK, 0 rows affected (0.01 sec)

mysql> grant replication slave on *.* to ‘repl’@‘%’;

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

查看用户

mysql> use mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> select Host,User,plugin from user;

±----------±-----------------±----------------------+

| Host | User | plugin |

±----------±-----------------±----------------------+

| % | repl | mysql_native_password |

| % | root | mysql_native_password |

| localhost | mysql.infoschema | caching_sha2_password |

| localhost | mysql.session | caching_sha2_password |

| localhost | mysql.sys | caching_sha2_password |

±----------±-----------------±----------------------+

5 rows in set (0.00 sec)

打开gtid,mysql1和mysql2都需要做

vi /etc/my.cnf

#末尾添加

开启gtid模式

gtid_mode = on

#强制gtid一致性

enforce_gtid_consistency = on

检查用户是否可以登录

[root@mysql2 logs]# mysql -u repl -p -h 192.168.56.41

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 11

Server version: 8.0.20 MySQL Community Server - GPL

Copyright © 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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> quit

Bye

开启slave

mysql> change master to master_host=‘192.168.56.41’, master_user=‘repl’, master_password=‘bsg_123’, master_port=3306,master_auto_position = 1;

Query OK, 0 rows affected, 2 warnings (0.23 sec)

mysql> start slave;

Query OK, 0 rows affected (0.01 sec)

mysql> show slave status\G

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.56.41

Master_User: repl

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000004

Read_Master_Log_Pos: 156

Relay_Log_File: mysql2-relay-bin.000002

Relay_Log_Pos: 371

Relay_Master_Log_File: mysql-bin.000004

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB:

Replicate_Ignore_DB:

Replicate_Do_Table:

Replicate_Ignore_Table:

Replicate_Wild_Do_Table:

Replicate_Wild_Ignore_Table:

Last_Errno: 0

Last_Error:

Skip_Counter: 0

Exec_Master_Log_Pos: 156

Relay_Log_Space: 581

Until_Condition: None

Until_Log_File:

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

Last_IO_Errno: 0

Last_IO_Error:

Last_SQL_Errno: 0

Last_SQL_Error:

Replicate_Ignore_Server_Ids:

Master_Server_Id: 41

Master_UUID: 29fbefde-1d82-11ef-972b-080027fadd9d

Master_Info_File: mysql.slave_master_info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates

Master_Retry_Count: 86400

Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp:

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set:

Executed_Gtid_Set:

Auto_Position: 1

Replicate_Rewrite_DB:

Channel_Name:

Master_TLS_Version:

Master_public_key_path:

Get_master_public_key: 0

Network_Namespace:

1 row in set (0.00 sec)

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

io thread和sql thread两个均已开启完成

Seconds_Behind_Master: 0

验证同步结果

创建数据库bsg和表test

mysql1创建

mysql> create database bsg;

mysql> CREATE TABLE test (

-> id VARCHAR(100),

-> name VARCHAR(100));

Query OK, 0 rows affected (0.27 sec)

mysql2查询

mysql> show databases;

±-------------------+

| Database |

±-------------------+

| bsg |

| information_schema |

| mysql |

| performance_schema |

| sys |

±-------------------+

5 rows in set (0.00 sec)

mysql> use bsg

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;

±--------------+

| Tables_in_bsg |

±--------------+

| test |

±--------------+

1 row in set (0.01 sec)

在线创建GTID主从复制

mysql主库检查为开启状态

[root@mysql2 soft]# systemctl status mysqld

● mysqld.service - MySQL Server

Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)

Active: active (running) since Wed 2024-05-29 14:34:24 CST; 2h 42min ago

Docs: man:mysqld(8)

http://dev.mysql.com/doc/refman/en/using-systemd.html

Main PID: 2530 (mysqld)

Tasks: 44

CGroup: /system.slice/mysqld.service

└─2530 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf

从库上执行在线GTID

开启gtid一致性

mysql> set global ENFORCE_GTID_CONSISTENCY = ON;

Query OK, 0 rows affected (0.00 sec)

开启GTID_MODE宽松模式

mysql> set global GTID_MODE = ON_PERMISSIVE;

Query OK, 0 rows affected (0.22 sec)

检查有无事务没有结束

mysql> SHOW STATUS LIKE ‘ONGOING_ANONYMOUS_TRANSACTION_COUNT’;

±------------------------------------±------+

| Variable_name | Value |

±------------------------------------±------+

| Ongoing_anonymous_transaction_count | 0 |

±------------------------------------±------+

1 row in set (0.00 sec)

检查从库状态

mysql> show slave status\G;

Empty set (0.00 sec)

ERROR:

No query specified

开启全局GTID_MODE

mysql> set global GTID_MODE = ON;

Query OK, 0 rows affected (0.03 sec)

停止slave

mysql> stop slave;

Query OK, 0 rows affected, 1 warning (0.00 sec)

添加向主库同步的账号开启实时同步

mysql> change master to master_host=‘192.168.56.42’, master_user=‘repl2’, master_password=‘bsg123’, master_port=3306,master_auto_position = 1;

Query OK, 0 rows affected, 2 warnings (0.35 sec)

开启slave

mysql> start slave;

Query OK, 0 rows affected (0.03 sec)

检查slave状态

mysql> show slave status\G;

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.56.42

Master_User: repl2

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000004

Read_Master_Log_Pos: 6961

Relay_Log_File: mysql3-relay-bin.000002

Relay_Log_Pos: 7176

Relay_Master_Log_File: mysql-bin.000004

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB:

Replicate_Ignore_DB:

Replicate_Do_Table:

Replicate_Ignore_Table:

Replicate_Wild_Do_Table:

Replicate_Wild_Ignore_Table:

Last_Errno: 0

Last_Error:

Skip_Counter: 0

Exec_Master_Log_Pos: 6961

Relay_Log_Space: 7386

Until_Condition: None

Until_Log_File:

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

Last_IO_Errno: 0

Last_IO_Error:

Last_SQL_Errno: 0

Last_SQL_Error:

Replicate_Ignore_Server_Ids:

Master_Server_Id: 42

Master_UUID: 7668155c-1d82-11ef-94dc-0800273a2bb9

Master_Info_File: mysql.slave_master_info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates

Master_Retry_Count: 86400

Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp:

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set: 29fbefde-1d82-11ef-972b-080027fadd9d:1-10,

7668155c-1d82-11ef-94dc-0800273a2bb9:1-15

Executed_Gtid_Set: 29fbefde-1d82-11ef-972b-080027fadd9d:1-10,

7668155c-1d82-11ef-94dc-0800273a2bb9:1-15

Auto_Position: 1

Replicate_Rewrite_DB:

Channel_Name:

Master_TLS_Version:

Master_public_key_path:

Get_master_public_key: 0

Network_Namespace:

1 row in set (0.00 sec)

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

io thread和sql thread两个均已开启完成

Seconds_Behind_Master: 0

完成GTID模式后,需要在my.cnf文件添加

gtid_mode = on

enforce_gtid_consistency = on

验证结果

mysql2主库插入一条数据

mysql> INSERT INTO bsg.test

-> (id, name)

-> VALUES(‘4’, ‘bao’);

Query OK, 1 row affected (0.01 sec)

mysql3查询bsg.test表验证

mysql> select * from test;

±-----±-----+

| id | name |

±-----±-----+

| 1 | q |

| 2 | w |

| 3 | e |

| 4 | bao |

±-----±-----+

同步完成

主从切换

mysql1和mysql2设置只读模式

mysql> set global read_only=ON;

Query OK, 0 rows affected (0.00 sec)

mysql> set global super_read_only=ON;

Query OK, 0 rows affected (0.01 sec)

查看备库复制进程状态

mysql> show slave status\G

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.56.41

Master_User: repl

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000004

Read_Master_Log_Pos: 2832

Relay_Log_File: mysql2-relay-bin.000002

Relay_Log_Pos: 3047

Relay_Master_Log_File: mysql-bin.000004

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB:

Replicate_Ignore_DB:

Replicate_Do_Table:

Replicate_Ignore_Table:

Replicate_Wild_Do_Table:

Replicate_Wild_Ignore_Table:

Last_Errno: 0

Last_Error:

Skip_Counter: 0

Exec_Master_Log_Pos: 2832

Relay_Log_Space: 3257

Until_Condition: None

Until_Log_File:

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

Last_IO_Errno: 0

Last_IO_Error:

Last_SQL_Errno: 0

Last_SQL_Error:

Replicate_Ignore_Server_Ids:

Master_Server_Id: 41

Master_UUID: 29fbefde-1d82-11ef-972b-080027fadd9d

Master_Info_File: mysql.slave_master_info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates

Master_Retry_Count: 86400

Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp:

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set: 29fbefde-1d82-11ef-972b-080027fadd9d:1-10

Executed_Gtid_Set: 29fbefde-1d82-11ef-972b-080027fadd9d:1-10

Auto_Position: 1

Replicate_Rewrite_DB:

Channel_Name:

Master_TLS_Version:

Master_public_key_path:

Get_master_public_key: 0

Network_Namespace:

1 row in set (0.00 sec)

状态正常

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Seconds_Behind_Master: 0

比对主备两边的GTID是否一致

mysql1:

mysql> select @@global.gtid_executed;

±------------------------------------------+

| @@global.gtid_executed |

±------------------------------------------+

| 29fbefde-1d82-11ef-972b-080027fadd9d:1-10 |

±------------------------------------------+

1 row in set (0.00 sec)

mysql2:

mysql> select @@global.gtid_executed;

±------------------------------------------+

| @@global.gtid_executed |

±------------------------------------------+

| 29fbefde-1d82-11ef-972b-080027fadd9d:1-10 |

±------------------------------------------+

1 row in set (0.00 sec)

mysql1和mysql2的gtid一致

从库停掉复制进程清空主从信息取消只读

mysql> stop slave;

Query OK, 0 rows affected (0.01 sec)

mysql> reset slave all;

Query OK, 0 rows affected (0.04 sec)

mysql> set global read_only=OFF;

Query OK, 0 rows affected (0.00 sec)

mysql> set global super_read_only=OFF;

Query OK, 0 rows affected (0.00 sec)

创建复制用户

mysql> create user ‘repl2’@‘%’ identified with mysql_native_password by ‘bsg123’;

Query OK, 0 rows affected (0.01 sec)

mysql> grant replication slave,replication client on *.* to ‘repl2’@‘%’;

Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

mysql1验证用户

[root@mysql1 ~]# mysql -u repl2 -p -h 192.168.56.42

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 16

Server version: 8.0.20 MySQL Community Server - GPL

Copyright © 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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> quit

Bye

原主库变为从库,并取消只读

mysql> stop slave;

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> change master to master_host=‘192.168.56.42’, master_user=‘repl2’, master_password=‘bsg123’, master_port=3306,master_auto_po

sition = 1;Query OK, 0 rows affected, 2 warnings (0.05 sec)

mysql> start slave;

Query OK, 0 rows affected (0.01 sec)

查看现从库mysql1状态

mysql> show slave status \G

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.56.42

Master_User: repl2

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000004

Read_Master_Log_Pos: 3546

Relay_Log_File: mysql1-relay-bin.000002

Relay_Log_Pos: 1111

Relay_Master_Log_File: mysql-bin.000004

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB:

Replicate_Ignore_DB:

Replicate_Do_Table:

Replicate_Ignore_Table:

Replicate_Wild_Do_Table:

Replicate_Wild_Ignore_Table:

Last_Errno: 0

Last_Error:

Skip_Counter: 0

Exec_Master_Log_Pos: 3546

Relay_Log_Space: 1321

Until_Condition: None

Until_Log_File:

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

Last_IO_Errno: 0

Last_IO_Error:

Last_SQL_Errno: 0

Last_SQL_Error:

Replicate_Ignore_Server_Ids:

Master_Server_Id: 42

Master_UUID: 7668155c-1d82-11ef-94dc-0800273a2bb9

Master_Info_File: mysql.slave_master_info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates

Master_Retry_Count: 86400

Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp:

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set: 7668155c-1d82-11ef-94dc-0800273a2bb9:1-3

Executed_Gtid_Set: 29fbefde-1d82-11ef-972b-080027fadd9d:1-10,

7668155c-1d82-11ef-94dc-0800273a2bb9:1-3

Auto_Position: 1

Replicate_Rewrite_DB:

Channel_Name:

Master_TLS_Version:

Master_public_key_path:

Get_master_public_key: 0

Network_Namespace:

1 row in set (0.00 sec)

查看状态

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Seconds_Behind_Master: 0

取消只读

mysql> set global read_only=off;

Query OK, 0 rows affected (0.00 sec)

mysql> set global super_read_only=off;

Query OK, 0 rows affected (0.00 sec)

主从切换完成

验证同步结果

mysql2向bsg.test表中插入一条数据

mysql> INSERT INTO bsg.test

-> (id, name)

-> VALUES(‘1’, ‘q’);

Query OK, 1 row affected (0.01 sec)

mysql1查询验证

mysql> select * from test;

±-----±-----+

| id | name |

±-----±-----+

| 1 | q |

±-----±-----+

1 row in set (0.00 sec)

同步完成

mysql将binlog转成sql

./mysqlbinlog -vv /usr/local/mysql/logs/mysql-bin.000004

选项:

-h, --host=:连接MySQL服务器的主机名。

-P, --port=<port_num>:连接MySQL服务器的端口号。

-u, --user=:连接MySQL服务器的用户名。

-p, --password=:连接MySQL服务器的密码。

–ssl-ca=<ca_file>:使用指定的CA证书文件进行SSL连接。

–ssl-cert=<cert_file>:使用指定的SSL证书文件进行SSL连接。

–ssl-key=<key_file>:使用指定的SSL密钥文件进行SSL连接。

-R, --read-from-remote-server:从远程MySQL服务器读取二进制日志。

-r, --result-file=<file_name>:将解析后的日志输出到指定的文件。

–base64-output[=value]:将blob字段以Base64编码的形式输出。

-v, --verbose:详细输出解析后的日志内容。

-d, --database=<database_name>:仅输出指定数据库的日志内容。

-t, --to-last-log:从当前日志文件开始读取,直到最新的日志文件结束。

-s, --start-datetime=:从指定的日期和时间开始读取日志。

-e, --stop-datetime=:在指定的日期和时间停止读取日志。

–start-position=:从指定的位置开始读取日志。

–stop-position=:在指定的位置停止读取日志。

–skip-gtids[=value]:跳过指定的GTID(全局事务标识符)。

–include-gtids[=value]:仅包括指定的GTID。

–hexdump:以十六进制格式输出日志内容。

–no-defaults:不读取默认的配置文件。

mysql开启审计日志

mysql> show variables like ‘%general_log%’;

±-----------------±---------------------------------+

| Variable_name | Value |

±-----------------±---------------------------------+

| general_log | OFF |

| general_log_file | /usr/local/mysql/data/mysql1.log |

±-----------------±---------------------------------+

2 rows in set (0.00 sec)

mysql> set global general_log=on

-> ;

Query OK, 0 rows affected (0.00 sec)

mysql> show variables like ‘%general_log%’;

±-----------------±---------------------------------+

| Variable_name | Value |

±-----------------±---------------------------------+

| general_log | ON |

| general_log_file | /usr/local/mysql/data/mysql1.log |

±-----------------±---------------------------------+

2 rows in set (0.00 sec)

标签:rows,Log,MySQL8,SSL,sec,mysql,Master,主从,搭建
From: https://blog.csdn.net/kkkbbbsg/article/details/142639774

相关文章

  • 从0到1搭建权限管理系统系列四 .net8 中Autofac的使用(附源码)
    说明  该文章是属于OverallAuth2.0系列文章,每周更新一篇该系列文章(从0到1完成系统开发)。   该系统文章,我会尽量说的非常详细,做到不管新手、老手都能看懂。   说明:OverallAuth2.0是一个简单、易懂、功能强大的权限+可视化流程管理系统。友情提醒:本篇文章是属于系......
  • Hexo搭建个人博客
    新建git项目首先在GitHub新建一个仓库(Repository),名称为https://username}.github.io,注意这个名比较特殊,必须要是github.io为后缀结尾的。比如我的GitHub用户名就叫qzy123456,那我就新建一个qzy123456.github.io,新建完成之后就可以进行后续操作了。安装Hexonpminstall-......
  • 图灵完备攻略:第一部分——基础逻辑电路搭建(附带游戏压缩包)
    作者在学习计算机组成原理时了解到了一款名为图灵完备的游戏,这是一款学习处理器架构的游戏,在游戏中你需要从门电路开始,最终搭建出属于自己的计算机。由于学习计算机组成原理的最后目的就是想让我们学会如何搭建一个CPU,因此这款游戏可以作为想要构建属于自己的CPU的前置练习,......
  • 线上培训中的知识库搭建:标准化与定制化的平衡
    在数字化时代,线上培训已成为企业提升员工技能、促进知识传承与创新的重要手段。而构建一个高效、实用的线上培训知识库,则是实现这一目标的关键。然而,在知识库的建设过程中,如何平衡内容的标准化与员工的定制化学习需求,成为了一个亟待解决的问题。本文将从标准化奠定基石、定......
  • 小主机虚拟化平台搭建记录
    小主机搭建虚拟化的一些记录:1,如果主机是Intel平台,目前建议还是使用VMwareEsxi6.7,如果你的主机网卡驱动没有包含在ESXI官方安装包内,去恩山找封装了网卡驱动的版本https://www.right.com.cn/FORUM/thread-7881507-1-1.html 2,如果你的主机是AMD平台,并且是ZEN系列,那么优先选......
  • Vue脚手架搭建及vue项目创建
    文章目录Vue脚手架搭建及vue项目创建一、引言二、环境搭建1、安装Node.js和npm2、安装VueCLI2.1、切换npm镜像源2.2、全局安装VueCLI三、创建Vue项目1、创建项目目录2、使用VueCLI创建项目3、安装项目依赖4、运行项目四、项目结构与运行流程1、项目目录......
  • 生产数据恢复系列之使用my2sql恢复MySQL8 误删数据
    生产数据恢复系列之使用my2sql恢复MySQL8误删数据原创 我科绝伦 小周的数据库进阶之路  2024年09月25日00:00 重庆热衷于分享各种干货知识,大家有想看或者想学的可以评论区留言,秉承着“开源知识来源于互联网,回归于互联网”的理念,分享一些日常工作中能用到或者频率......
  • pbootcms如何搭建多语言站?
    1.使用步骤添加数据区域在后台“系统管理>数据区域”中添加相应的区域。具体参考默认区域的设置。放置多语言模板将多语言的模板放入模板目录 template 下。不同语言的模板均放在 template 目录下。设置站点信息在后台选择不同的语言,分别设置:站点信息......
  • pbootcms多语言建站常见问题(如何搭建中英文站)
    添加数据区域在后台“系统管理>数据区域”中添加相应的区域。参考默认区域的设置。放置多语言模板将多语言的模板放入模板目录 template 下。不同语言的模板均放在 template 目录下。设置站点信息在后台选择不同的语言,分别设置:站点信息(注意选择模板)公......
  • 鸿蒙harmonyos纯flutter开发环境搭建
            公司app是用纯flutter开发的,目前支持android和iOS,后续估计也会支持鸿蒙harmonyos。目前谷歌flutter并没有支持咱们国产手机操作系统鸿蒙harmonyos,于是乎国内有个叫OpenHarmony-SIG的组织,去做了鸿蒙harmonyos适配flutter开发的工作。本文就是基于OpenHarmony-SI......