In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to complete the deployment of GTID-based master-slave replication of MySQL8 under docker. The content of the article is carefully selected and edited by the author, which is targeted and of great significance to everyone. Let's learn how to complete the deployment of GTID-based master-slave replication of MySQL8 under docker with the author.
Install docker
# yum install docker
Add docker Image Warehouse
# vim / etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]"
}
Pull mysql image
* # docker pull mysql
Create a mysql container
# docker run-dit-- name lisamysql001-p 33307 MYSQLROOTPASSWORD=123456 mysql 3307-e MYSQLROOTPASSWORD=123456 mysql
# docker run-dit-- name lisamysql002-p 33308 MYSQLROOTPASSWORD=123456 mysql 3308-e MYSQLROOTPASSWORD=123456 mysql
Enter the mysql container
# docker exec-it lisamysql001 / bin/bash
# docker exec-it lisamysql002 / bin/bash
Log in to mysql in the mysql container, but it's still the mysql8.0 version. It smells good!
Let's go to the container to deploy GTID-based master-slave replication:
Container lisa_mysql001 is the master library and lisa_mysql002 is the slave library
Go to the main library (lisa_mysql001) to install vim for the docker container (it is convenient for me to modify the my.cnf file)
# docker exec-it lisa_mysql001 / bin/bash
# apt-get update
# apt-get install vim-y
Install the package for ifconfig and check the container IP address
# apt-get install net-tools-y
Install the ping command
# apt-get install inetutils-ping-y
The IP address of the main library (lisa_mysql001) is 172.17.0.2
Configure the my.cnf of the main library and add the following
# cat / etc/mysql/my.cnf
Server-id=001
Gtid-mode=on
Enforce-gtid-consistency=on
Log_bin = binlog
After modifying the configuration file of the main library, exit the mysql container and restart mysql
* # docker restart lisamysql001
Establish a synchronization account for the slave database
# mysql-uroot-p123456
Mysql > create user 'repl'@'172.17.0.%' identified by' 1225119'
Mysql > grant replication slave on. To 'repl'@'172.17.0.%'
Mysql > flush privileges
Check the uuid and status of the main library
Mysql > show global variables like'% uuid%'
After the slave library is successfully configured, test whether the master-slave replication can be synchronized.
Slave library configuration
# docker exec-it lisamysql002 / bin/bash
# apt-get update
# apt-get install vim-y
Install the ifconfig command to view the container IP address
# apt-get install net-tools-y
Install the ping command
# apt-get install inetutils-ping-y
The IP address of the slave library (lisa_mysql001) is 172.17.0.3
Test whether you can communicate with the main library
# ping 172.17.0.2
To configure the my.cnf of the slave library, add the following
Server-id=002
Gtid-mode=on
Enforce-gtid-consistency=on
Log-slave-updates = on
After modifying the configuration file of the slave library, exit the mysql container and restart mysql
* # docker restart lisamysql002
Test whether the account we set up in the master database can log in from the slave database.
* # mysql-urepl-h272.17.0.2-p
Configure the slave library to specify the master library
Mysql > change master to master_host='172.17.0.2',master_user='repl',master_password='1225119'
Mysql > start slave
Mysql > show slave status\ G
After the main library has built a library named songlisha, it is accepted from the library.
After reading the above about how to deploy the master-slave replication of MySQL8 based on GTID under docker, many readers must have some understanding. If you need to get more industry knowledge and information, you can continue to follow our industry information column.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.