当前位置:网站首页>Docekr learning - MySQL 8 master-slave replication setup deployment
Docekr learning - MySQL 8 master-slave replication setup deployment
2022-07-25 13:06:00 【Uh huh**】
List of articles
Master and slave copy build
# Download mirroring
docker pull mysql
# First step : Start master MySQL
docker run --name=mysql-master -p 3308:3306 -v /etc/localtime:/etc/localtim -v /www/server/mysql_master-slave/master/data:/var/lib/mysql -v /www/server/mysql_master-slave/master/log:/var/log/mysql -v /www/server/mysql_master-slave/master/conf:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=root --privileged=true -d mysql:latest
# The second step : Add configuration file /www/server/mysql_master-slave/master/conf/my.cnf == The contents are as follows
[mysqld]
## Set up server id, You need to be unique in the same LAN
server_id=101
## Specify the name of the database that does not need to be synchronized
binlog-ignore-db=mysql
## Turn on binary log function
log-bin=mall-mysql-bin
## Set the memory size of binary log ( Business )
binlog_cache_size=1M
## Set the binary log format to use (mixed,statement,row)
binlog_format=mixed
## Binary log expiration cleanup time . The default value is 0, Does not automatically clean up .
# Old edition 5 Configuration of == If it is 8 Remember to replace it with seconds , Otherwise I can't get in mysqld
#expire_logs_days=7
# new edition 8 Configuration of
binlog_expire_logs_seconds=604800
## Skip all errors encountered in master-slave replication or errors of the specified type , avoid slave End copy interrupt .
## Such as :1062 An error is a duplicate of some primary keys ,1032 The error is because the master-slave database data is inconsistent
slave_skip_errors=1062
# The third step : Restart master MySQL
docker restart mysql-master
# Step four : Lord MySQL Created in slave user == Make forever Navicat Or directly enter the container for operation
# Enter the main container mysql:docker exec -it mysql-master mysql -uroot -p
CREATE USER 'slave'@'%' IDENTIFIED BY '123456';
GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'slave'@'%';
SELECT plugin FROM `user` where user = 'slave';
# about mysql8 This step is particularly important , You need to modify the authorization plug-in , Otherwise, from MySQL There is no connection to the master MySQL Pull data synchronously
# If it is MySQL5 You don't need to run this statement
ALTER USER 'slave'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
# Step five : Start from MySQL
docker run --name=mysql-slave -p 3309:3306 -v /etc/localtime:/etc/localtim -v /www/server/mysql_master-slave/slave/data:/var/lib/mysql -v /www/server/mysql_master-slave/slave/log:/var/log/mysql -v /www/server/mysql_master-slave/slave/conf:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=root --privileged=true -d mysql:latest
# Step six : Add configuration file /www/server/mysql_master-slave/slave/conf/my.cnf == The contents are as follows
[mysqld]
## Set up server._id, You need to be unique in the same LAN
server_id=102
# Specify the name of the database that does not need to be synchronized
binlog-ignore-db=mysql
# Turn on binary log function , in preparation for Slave As an instance of another database Masterl When using
log-bin=mall-mysql-slave1-bin
# Set the memory size of binary log ( Business )
binlog_cache_size=1M
# Set the binary log format to use (mixed,statement,row)
binlog_format=mixed
# Binary log expiration cleanup time . The default value is 0, Does not automatically clean up .
# Old edition 5 Configuration of
#expire_logs_days=7
# new edition 8 Configuration of
binlog_expire_logs_seconds=604800
# Skip all errors encountered in master-slave replication or errors of the specified type , avoid slave End copy interrupt .
# Such as :1062 An error is a duplicate of some primary keys ,1032 The error is because the master-slave database data is inconsistent
# Old edition 5 Configuration of
#slave_skip_errors=1062
# new edition 8 Configuration of
replica_skip_errors=1062
#relay_log Configure relay logs
relay_log=mall-mysql-relay-bin
#log_slave_.updates Express slave Write the copy event to your own binary log
# Old edition 5 Configuration of
#log_slave_updates=1
# new edition 8 Configuration of
log_replica_updates=1
##slave Set to read only ( have super Except for users with permission )
read_only=1
# Step seven : Restart from MySQL
docker restart mysql-slave
# Step eight : Look at the main MySQL Of master state
docker exec -it mysql-master mysql -uroot -proot
show master status;
# Step nine : Enter from mysql == Set master MySQL Relevant information
docker exec -it mysql-slave mysql -uroot -proot
# master_log_file、master_log_pos Taken from the Lord MySQL Of show master status Information
# Fill in the main MySQL The port of 、ip Etc
change master to master_host='192.168.80.128',master_user='slave',master_password='123456',master_port=3308,master_log_file='mall-mysql-bin.000002',master_log_pos=156,master_connect_retry=30;
# Step 10 : View from the MySQL Of slave Related information == from MySQL Run in
# It is found that the synchronization switch has not been turned on
show slave status;
# Step 11 : Start from the library and turn on the switch to pull the main library -- from MySQL Run in
start slave;
# The twelfth step : Check whether the synchronization switch of the slave library is on
show slave status;
# Thirteenth Step : Data synchronization test == Be accomplished
Lord MySQL: Chuang Ku 、 Table creation 、 The new data
from MySQL: Check whether the data is synchronized

Solve the problems encountered in master-slave replication
MY-010095 - Boot failure
2022-07-21 05:10:09+00:00 [Note] [Entrypoint]: Starting temporary server
mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
2022-07-21T05:10:09.822859Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
2022-07-21 05:10:09+00:00 [ERROR] [Entrypoint]: Unable to start server.

Solution - Change run Mapping configuration of configuration file
// Original startup configuration == Encounter the above startup error
docker run --name=mysql-master -p 3308:3306 -v /etc/localtime:/etc/localtim -v /www/server/mysql_master-slave/master/data:/var/lib/mysql -v /www/server/mysql_master-slave/master/log:/var/log/mysql -v /www/server/mysql_master-slave/master/conf:/etc/mysql -e MYSQL_ROOT_PASSWORD=root --privileged=true -d mysql:latest
// Start the configuration after correction == Can be started normally == Change mysql Mapping directory
docker run --name=mysql-master -p 3308:3306 -v /etc/localtime:/etc/localtim -v /www/server/mysql_master-slave/master/data:/var/lib/mysql -v /www/server/mysql_master-slave/master/log:/var/log/mysql -v /www/server/mysql_master-slave/master/conf:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=root --privileged=true -d mysql:latest
Failed to connect from the library to the main library - Not IP、 Account and password problems
Last_IO_Error: error connecting to master 'slave@192.168.80.128:3308' - retry-time: 30 retries: 17 message: Authentication plugin 'caching_sha2_password' reported error: Authentication requires secure connection.
Run from the machine :show slave status
Solution
-- In the main MySQL Run the following in the machine SQL == Modify the authorization plug-in
-- There is no need to restart after modification Lord MySQL、 from MySQL
SELECT plugin FROM `user` where user = 'slave';
ALTER USER 'slave'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
Run from the machine :show slave status
边栏推荐
- Seven lines of code made station B crash for three hours, but "a scheming 0"
- Force deduction 83 biweekly T4 6131. The shortest dice sequence impossible to get, 303 weeks T4 6127. The number of high-quality pairs
- [machine learning] experimental notes - emotion recognition
- [review SSM framework series] 15 - Summary of SSM series blog posts [SSM kill]
- 全球都热炸了,谷歌服务器已经崩掉了
- AtCoder Beginner Contest 261 F // 树状数组
- mysql函数汇总之日期和时间函数
- Excuse me, using data integration to import data from PostgreSQL to MySQL database, emoj appears in some data fields
- Shell常用脚本:获取网卡IP地址
- 零基础学习CANoe Panel(14)——二极管( LED Control )和液晶屏(LCD Control)
猜你喜欢

卷积神经网络模型之——GoogLeNet网络结构与代码实现

G027-OP-INS-RHEL-04 RedHat OpenStack 创建自定义的QCOW2格式镜像

Introduction to web security UDP testing and defense

Zero basic learning canoe panel (12) -- progress bar

【AI4Code】《Contrastive Code Representation Learning》 (EMNLP 2021)

The larger the convolution kernel, the stronger the performance? An interpretation of replknet model

【重温SSM框架系列】15 - SSM系列博文总结【SSM杀青篇】

cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘

OAuth,JWT ,OIDC你们搞得我好乱啊

Zero basic learning canoe panel (16) -- clock control/panel control/start stop control/tab control
随机推荐
【历史上的今天】7 月 25 日:IBM 获得了第一项专利;Verizon 收购雅虎;亚马逊发布 Fire Phone
网络空间安全 渗透攻防9(PKI)
工业互联网的内涵及其应用
零基础学习CANoe Panel(13)—— 滑条(TrackBar )
Software testing interview question: Please list the testing methods of several items?
卷积神经网络模型之——LeNet网络结构与代码实现
[problem solving] ibatis.binding BindingException: Type interface xxDao is not known to the MapperRegistry.
Requirements specification template
Moving Chinese figure liushenglan
ECCV 2022 | 登顶SemanticKITTI!基于二维先验辅助的激光雷达点云语义分割
【视频】马尔可夫链原理可视化解释与R语言区制转换MRS实例|数据分享
跌荡的人生
Zero basic learning canoe panel (15) -- CAPL output view
Common operations for Yum and VIM
程序员奶爸自制AI喂奶检测仪,预判宝宝饿点,不让哭声影响老婆睡眠
Emqx cloud update: more parameters are added to log analysis, which makes monitoring, operation and maintenance easier
力扣 83双周赛T4 6131.不可能得到的最短骰子序列、303 周赛T4 6127.优质数对的数目
2022.07.24 (lc_6124_the first letter that appears twice)
使用vsftpd服务传输文件(匿名用户认证、本地用户认证、虚拟用户认证)
The world is exploding, and the Google server has collapsed