MySQL主从配置和gtid主从配置
文章目录
- 1、为什么需要主从复制?
- 2、什么是mysql的主从复制?
- 3、GTID的工作原理:
- 4、GTID与传统主从复制的区别是什么
- 5、mysql主从
- 5. 1mysql主从配置
- 5.1.1 确保从数据库与主数据库里的数据一样
- 5.1.2 在主数据库里创建一个同步账号授权给从数据库使用
- 5.1.3 配置主数据库
- 5.1.4 配置从数据库
- 5.1.5 测试验证
- 6. GTID主从
- 6.1 GTID主从配置
- 7. 报错问题解决:
1、为什么需要主从复制?
1、在业务复杂的系统中,有这么一个情景,有一句sql语句需要锁表,导致暂时不能使用读的服务,那么就很影响运行中的业务,使用主从复制,让主库负责写,从库负责读,这样,即使主库出现了锁表的情景,通过读从库也可以保证业务的正常运作。
2、做数据的热备
3、架构的扩展。业务量越来越大,I/O访问频率过高,单机无法满足,此时做多库的存储,降低磁盘I/O访问的频率,提高单个机器的I/O性能。
2、什么是mysql的主从复制?
MySQL 主从复制是指数据可以从一个MySQL数据库服务器主节点复制到一个或多个从节点。MySQL 默认采用异步复制方式,这样从节点不用一直访问主服务器来更新自己的数据,数据的更新可以在远程连接上进行,从节点可以复制主数据库中的所有数据库或者特定的数据库,或者特定的表。
2、mysql复制原理
原理:
(1)master服务器将数据的改变记录二进制binlog日志,当master上的数据发生改变时,则将其改变写入二进制日志中;
(2)slave服务器会在一定时间间隔内对master二进制日志进行探测其是否发生改变,如果发生改变,则开始一个I/OThread请求master二进制事件
(3)同时主节点为每个I/O线程启动一个dump线程,用于向其发送二进制事件,并保存至从节点本地的中继日志中,从节点将启动SQL线程从中继日志中读取二进制日志,在本地重放,使得其数据和主节点的保持一致,最后I/OThread和SQLThread将进入睡眠状态,等待下一次被唤醒。
也就是说:
从库会生成两个线程,一个I/O线程,一个SQL线程;
I/O线程会去请求主库的binlog,并将得到的binlog写到本地的relay-log(中继日志)文件中;
主库会生成一个log dump线程,用来给从库I/O线程传binlog;
SQL线程,会读取relay log文件中的日志,并解析成sql语句逐一执行;
3、GTID的工作原理:
1、master更新数据时,会在事务前产生GTID,一同记录到binlog日志中。
2、slave端的i/o 线程将变更的binlog,写入到本地的relay log中。
3、sql线程从relay log中获取GTID,然后对比slave端的binlog是否有记录。
4、如果有记录,说明该GTID的事务已经执行,slave会忽略。
5、如果没有记录,slave就会从relay log中执行该GTID的事务,并记录到binlog。
6、在解析过程中会判断是否有主键,如果没有就用二级索引,如果没有就用全部扫描。
server_uuid是MySQL Server的只读变量,保存在数据目录下的auto.cnf中,可直接通过cat命令查看。MySQL第一次启动时候创建auto.cnf文件,并生成server_uuid(MySQL使用机器网卡,当前时间,随机数等拼接成一个128bit的uuid,可认为在全宇宙都是唯一的,在未来一百年,使用同样的算法生成的uuid是不会冲突的)。之后MySQL再启动时不会重复生成uuid,而是使用auto.cnf中的uuid。
#存放mysql的唯一ID号
vim /usr/local/mysql/mydata/auto.cnf
[auto]
server-uuid=ef254080-1aea-11e9-88ba-000c295ac6a7
在同一个集群内,每个MySQL实例的server_uuid必须唯一,否则同步时,会造成IO线程不停的中断,重连。在通过备份恢复数据时,一定要将var目录中的auto.cnf删掉,让MySQL启动时自己生成uuid
GTID中还有一部分是transaction_id,同一个server_uuid下的transaction_id一般是递增的。如果一个事务是通过用户线程执行,那么MySQL在生成的GTID时,会使用它自己的server_uuid,然后再递增一个transaction_id作为该事务的GTID。当然,如果事务是通过SQL线程回放relay-log时产生,那么GTID就直接使用binlog里的了。在MySQL 5.6中不用担心binlog里没有GTID,因为如果从库开启了GTID模式,主库也必须开启,否则IO线程在建立连接的时候就中断了。5.6的GTID对MySQL的集群环境要求是非常严格的,要么主从全部开启GTID模式,要么全部关闭GTID模式。
使用server_uuid:transaction_id共同组成一个GTID的好处是,由于server_uuid唯一,即使一个集群内多个节点同时有写入,也不会造成GTID冲突。
GTID优势:
更简单的实现 failover,不用以前那样在需要找 log_file 和 log_Pos。
更简单的搭建主从复制。
复制集群有一个统一的方式识别复制位置,给集群管理带来了便利。
正常情况下,GTID 是连续没有空洞的,因此主从库出现数据冲突时,可以用添加空事物的方式进行跳过。
GTID的限制:
1、在一个事务里面混合使用引擎,如 Innodb(支持事务)、MyISAM(不支持事务), 造成多个 GTIDs 和同一个事务相关联出错
2、CREATE TABLE……SELECT 不能使用,该语句产生的两个 event 在某一情况 会使用同一个 GTID(同一个 GTID 在 slave 只能被使用一次)
1th event:创建表语句 create table
2th event:插入数据语句 insert
3、CREATE TEMPORARY TABLE and DROP TEMPORARY TABLE 不能在事务内使用 (启用了–enforce-gtid-consistency 参数)。
GTID就是uuid与transaction_id的组合
Transaction_ID:是提交事务的序号
4、GTID与传统主从复制的区别是什么
普通主从复制主要是基于二进制日志文件位置的复制,因此主必须启动二进制日志记录并建立唯一的服务器ID,复制组中的每个服务器都必须配置唯一的服务器ID
全局事务标识符(GTID)是创建的唯一标识符,并与在源(主)服务器上提交的每个事务相关联。此标识符不但是唯一的,而且在给定复制设置中的所有服务器上都是唯一的。所有交易和所有GTID之间都有一对一的映射关系 。它由服务器ID以及事务ID组合而成。这个全局事务ID不仅仅在原始服务器上唯一,在所有存在主从关系 的mysql服务器上也是唯一的。正是因为这样一个特性使得mysql的主从复制变得更加简单,以及数据库一致性更可靠。一个GTID在一个服务器上只执行一次,避免重复执行导致数据混乱或者主从不一致。
5、mysql主从
mysql安装
分别在主从两台服务器上安装mysql-5.7版本,此处略过安装步骤,若有疑问请参考《mysql基础》与《mysql进阶》两篇文章。
5. 1mysql主从配置
5.1.1 确保从数据库与主数据库里的数据一样
为确保从数据库与主数据库里的数据一样,先全备主数据库并还原到从数据库中
//先查看主库有哪些库
[root@localhost ~]# mysql -uroot -pwangqing123! -e 'show databases;'
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| student |
| sys |
| teacher |
+--------------------+//再查看从库有哪些库
[root@localhost ~]# mysql -uroot -pwangqing123! -e 'show databases;'
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+//全备主库
//全备主库时需要另开一个终端,给数据库加上读锁,避免在备份期间有其他人在写入导致数据不一致
mysql> FLUSH TABLES WITH READ LOCK;
Query OK, 0 rows affected (0.00 sec)
//此锁表的终端必须在备份完成以后才能退出//备份主库并将备份文件传送到从库
[root@localhost ~]# mysqldump -uroot -pwangqing123! --all-databases > /opt/all-201808191200.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
[root@localhost ~]# ls /opt/
all-201808191200.sql
[root@localhost ~]# scp /opt/all-201808191200.sql root@172.16.12.129:/opt/
root@172.16.12.129's password:
all-201808191200.sql 100% 786KB 10.6MB/s 00:00 //解除主库的锁表状态,直接退出交互式界面即可
mysql> quit
Bye//在从库上恢复主库的备份并查看从库有哪些库,确保与主库一致
[root@localhost ~]# mysql -uroot -pwangqing123! < /opt/all-201808191200.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost ~]# mysql -uroot -pwangqing123! -e 'show databases;'
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| student |
| sys |
| teacher |
+--------------------+
5.1.2 在主数据库里创建一个同步账号授权给从数据库使用
先命名一台虚拟机为主一台为从,master为主,slave为从
[root@localhost ~]# hostnamectl set-hostname master
[root@localhost ~]# bash
[root@master ~]# [root@localhost ~]# hostnamectl set-hostname slave
[root@localhost ~]# bash
[root@slave ~]#
mysql> grant replication slave on *.* to 'repl'@'192.168.223.144' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql>
5.1.3 配置主数据库
[root@master ~]# vim /etc/my.cnf
[root@master ~]# cat /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
sql-mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTIONlog-bin=mysql-bin //启用binlog日志
server-id=10 //数据库服务器唯一标识符,主库的server-id值必须比从库的大
[root@master ~]#
重启mysql服务
[root@master ~]# systemctl restart mysqld
[root@master ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 80 *:3306 *:*
查看主库的状态
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 154 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)mysql>
5.1.4 配置从数据库
[root@slave ~]# vim /etc/my.cnf
[root@slave ~]# cat /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
sql-mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTIONserver-id=20 //设置从库的唯一标识符,从库的server-id值必须大于主库的该值
relay-log=myrelay //启用中继日志relay-log
重启从库的mysql服务
[root@slave ~]# systemctl restart mysqld
配置并启动主从复制
mysql> change master to-> master_host='192.168.223.141',-> master_user='repl',-> master_password='123456',-> master_log_file='mysql-bin.000001',-> master_log_pos=154;
Query OK, 0 rows affected, 2 warnings (0.00 sec)mysql> start slave-> ;
Query OK, 0 rows affected (0.00 sec)
查看从服务器状态
mysql> show slave status \G
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.223.141Master_User: replMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000001Read_Master_Log_Pos: 154Relay_Log_File: myrelay.000003Relay_Log_Pos: 320Relay_Master_Log_File: mysql-bin.000001Slave_IO_Running: Yes //此处必须为YesSlave_SQL_Running: Yes //此处必须为YesReplicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0Last_Error: Skip_Counter: 0Exec_Master_Log_Pos: 154Relay_Log_Space: 519Until_Condition: NoneUntil_Log_File: Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_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: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 10Master_UUID: 122cece8-1202-11ed-bb64-000c29c18f69Master_Info_File: /opt/data/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version:
1 row in set (0.00 sec)mysql>
5.1.5 测试验证
在主服务器的student库的bj2表中插入数据:
mysql> create database runtime;
Query OK, 1 row affected (0.01 sec)mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| runtime |
| sys |
+--------------------+
5 rows in set (0.00 sec)mysql> create table student(id int not null,name varchar(50));
Query OK, 0 rows affected (0.00 sec)mysql> insert student values (1,'tom'),(2,'wangwu'-> );
Query OK, 2 rows affected (0.03 sec)
Records: 2 Duplicates: 0 Warnings: 0mysql> select * from student;
+----+--------+
| id | name |
+----+--------+
| 1 | tom |
| 2 | wangwu |
+----+--------+
2 rows in set (0.00 sec)
在从数据库中查看数据是否同步:
mysql> use runtime;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changedmysql> select * from student;
+----+--------+
| id | name |
+----+--------+
| 1 | tom |
| 2 | wangwu |
+----+--------+
2 rows in set (0.00 sec)mysql>
6. GTID主从
6.1 GTID主从配置
主库配置。vi /etc/my.cnf,添加以下配置,重启mysql。
[root@master ~]# vim /etc/my.cnf
log-bin=mysql_bin
server-id=10
gtid_mode=on
enforce-gtid-consistency=true
log-slave-updates=on
[root@master ~]# systemctl restart mysqld
[root@master ~]#
从库配置。vi /etc/my.cnf, 添加以下配置,重启mysql。
[root@salve ~]# vim /etc/my.cnfserver-id=20
relay-log=myrelay
gtid_mode=on
enforce-gtid-consistency=true
log-slave-updates=on
read_only=on
master-info-repository=TABLE
relay-log-info-repository=TABLE[root@salve ~]# systemctl restart mysqld.service
主库授权复制用户。
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
mysql> grant replication slave on *.* to 'repl'@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql>
从库设置要同步的主库信息,并开启同步。
mysql> change master to-> master_host='192.168.223.141',-> master_port=3306,-> master_user='repl',-> master_password='123456',-> master_auto_position=1;
Query OK, 0 rows affected, 2 warnings (0.01 sec)mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql> show slave status\G
*************************** 1. row ***************************Slave_IO_State: Waiting to reconnect after a failed registration on masterMaster_Host: 192.168.223.141Master_User: replMaster_Port: 3306Connect_Retry: 60Master_Log_File: Read_Master_Log_Pos: 4Relay_Log_File: myrelay.000001Relay_Log_Pos: 4Relay_Master_Log_File: Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0Last_Error: Skip_Counter: 0Exec_Master_Log_Pos: 0Relay_Log_Space: 154Until_Condition: NoneUntil_Log_File: Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_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: NoLast_IO_Errno: 1597Last_IO_Error: Master command COM_REGISTER_SLAVE failed: Access denied for user 'repl'@'192.168.223.144' (using password: YES) (Errno: 1045)Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 10Master_UUID: 122cece8-1202-11ed-bb64-000c29c18f69Master_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: 220802 11:21:24Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 1Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version:
1 row in set (0.00 sec)
检查验证是否成功
//主库删除一个数据库
mysql> drop database runtime;
Query OK, 2 rows affected (0.19 sec)mysql>
mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)//从库查看
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)mysql>
7. 报错问题解决:
克隆出来的机器会有问题因为它们uuid是一样的所有会配置不成功
mysql> show slave status\G
*************************** 1. row ***************************Slave_IO_State: Master_Host: 192.168.223.141Master_User: replMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000001Read_Master_Log_Pos: 154Relay_Log_File: myrelay.000001Relay_Log_Pos: 4Relay_Master_Log_File: mysql-bin.000001Slave_IO_Running: NoSlave_SQL_Running: YesReplicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0Last_Error: Skip_Counter: 0Exec_Master_Log_Pos: 154Relay_Log_Space: 154Until_Condition: NoneUntil_Log_File: Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 1593Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 10Master_UUID: Master_Info_File: /opt/data/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: 220802 10:17:45Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version:
1 row in set (0.00 sec)
解决方法:
mysql> select uuid(); //随机生成uuid
+--------------------------------------+
| uuid() |
+--------------------------------------+
| a15e6fe0-1209-11ed-bcd2-000c294df6b8 |
+--------------------------------------+
1 row in set (0.00 sec)mysql> show variables like 'datadir';
+---------------+------------+
| Variable_name | Value |
+---------------+------------+
| datadir | /opt/data/ |
+---------------+------------+
1 row in set (0.00 sec)mysql> exit
Bye
[root@slave ~]# cd /opt/data/
[root@slave data]# ls
auto.cnf ib_logfile1 performance_schema
ca-key.pem ibtmp1 private_key.pem
ca.pem localhost.localdomain.err public_key.pem
client-cert.pem master.info relay-log.info
client-key.pem myrelay.000001 server-cert.pem
ib_buffer_pool myrelay.index server-key.pem
ibdata1 mysql slave.err
ib_logfile0 mysql.pid sys
[root@slave data]# vim auto.cnf
[root@slave data]# cat auto.cnf
[auto]
server-uuid=a15e6fe0-1209-11ed-bcd2-000c294df6b8 //使用刚刚随机的uuid
[root@slave data]#
//重启服务
[root@slave data]# systemctl restart mysqld.service
//进入MySQL在启动一次
[root@slave ~]# mysql -uroot -p123456
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 4
Server version: 5.7.38 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> start slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)//就解决了
mysql> show slave status \G
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.223.141Master_User: replMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000001Read_Master_Log_Pos: 154Relay_Log_File: myrelay.000003Relay_Log_Pos: 320Relay_Master_Log_File: mysql-bin.000001Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0Last_Error: Skip_Counter: 0Exec_Master_Log_Pos: 154Relay_Log_Space: 519Until_Condition: NoneUntil_Log_File: Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_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: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 10Master_UUID: 122cece8-1202-11ed-bb64-000c29c18f69Master_Info_File: /opt/data/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version:
1 row in set (0.00 sec)
gtid主库授权复制用户
报错原因:
mysql> set global validate_password_policy=0;
ERROR 1193 (HY000): Unknown system variable 'validate_password_policy'
解决方法:输入这两个命令就可以了
mysql> install plugin validate_password soname 'validate_password.so';
Query OK, 0 rows affected (0.00 sec)mysql> select plugin_name, plugin_status from information_schema.plugins where plugin_name like 'validate%';
+-------------------+---------------+
| plugin_name | plugin_status |
+-------------------+---------------+
| validate_password | ACTIVE |
+-------------------+---------------+
1 row in set (0.00 sec)
实验一下
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MySQL主从配置和gtid主从配置相关推荐
- mysql主从配置 GTID 主从配置
mysql一主多从配置 查看主库的数据库 [root@localhost ~]# mysql -P3306 -h127.0.0.1 -e 'show databases;' +------------ ...
- mysql一主多从的配置gtid主从配置
mysql一主多从配置>id主从配置 mysql一主多从的配置 环境: 主数据库 centOS8IP=192.168.147.10 从数据库 从库1: centOS8IP=192.168. ...
- MySQL主从同步详解与配置
https://zhuanlan.zhihu.com/p/335142300 MySQL主从同步详解与配置 第一部分[原理解析] * 应用背景* MySQL数据库自身提供的主从复制功能可以方便的实现数 ...
- mysql 5.6 互为主从_mysql5.6主从同步,互为主从配置
由于业务需要,需要做主从同步,互为主从等的mysql设置.主从设置主要涉及主从同步时使用的账号密码配置,my.cnf的配置,进入数据库进行master,slave配置.主要是这四个配置. 1,账号密码 ...
- mysql slave 配置_【mysql5.6】 数据库主从(Master/Slave)配置记录
freddon 发表于2018-04-01 阅读 661 | 评论 0 前一段时间迫于服务器的捉急内存,将redis数据库停掉了,鉴于redis的主从配置,在centos配置下mysql记录下过程. ...
- mysql 从库_mysql数据库主从配置
在一篇文章<离线安装mysql数据库>,讲解了离线安装mysql数据库的过程,本文将讲解mysql数据库的主从配置方法.mysql数据库进行主从配置后,可以实现数据库的备份.同时应用也可以 ...
- linux中mysql主主搭建_mysql 主从配置 主主配置
MySQL 主从( MySQL Replication) ,主要用于 MySQL 的时时备份或者读写分离.在配置之前先做一下准备工作,配置两台 mysql 服务器,如果你的机器不能同时跑两台 Linu ...
- mysql服务器架构_Mysql的主从服务器架构配置
所谓主从Mysql服务器架构,就是在主服务器上的操作同时也拷贝一份到从服务器上来. 接下来我使用两台机器做一下这个过程, 复制的作用: 1.数据分部 2.实现读的负载均衡 3.备份(本身不能备份,但是 ...
- mysql1.2.17,17.1 MySQL主从介绍17.2 准备工作17.3 配置主17.4 配置从17.5 测试主从同步...
- 17.1 MySQL主从介绍 - 17.2 准备工作 - 17.3 配置主 - 17.4 配置从 - 17.5 测试主从同步 # 17.1 MySQL主从介绍 - MySQL主从又叫做Repli ...
最新文章
- java系统教程_Java 教程(开发环境配置+基础语法)
- 百分点集团被APAC CIO Outlook杂志评选为亚太区大数据企业25强
- wxWidgets:wxAuiNotebook类用法
- JS的Object.keys
- 1.5-1.6 oozie部署
- SAP成都研究院大卫哥:SAP C4C中国本地化之微信小程序集成
- python如何输入一个数停止输出可循环部分_Python 第04周:控制与循环
- 这是一个沙雕题II(思维好题)
- cf1491C. Pekora and Trampoline
- 前端学习(2850):简单秒杀系统学习之绝对定位
- Spring Boot中使用@Async实现异步调用
- c语言 指针_C 语言指针详解
- OJ(Online Judge)系统汇总
- DockOne微信分享(一三一):Juice——一种基于MesosFramework的任务云框架
- 国际版抖音TikTok平台怎么样?
- DB9串口定义及含义
- H264视频编码原理
- vs2015 vc14编译libcurl
- cmake使用教程(十)-关于file,真是恍然大悟啊
- 如何简单快速的写出幸运转盘抽奖