当前位置:网站首页>Mysql5.7 master-slave database deployment (offline deployment)
Mysql5.7 master-slave database deployment (offline deployment)
2022-07-25 10:24:00 【Puffiness is also strong】
Mysql5.7.24tar
link :https://pan.baidu.com/s/1W21ew4LY_i3AGMzALho1zw?pwd=1234
Extraction code :1234
Linux CentOS7 7.6_1810
link :https://pan.baidu.com/s/1NV4MjfORIj290Q3scy6iYQ?pwd=pzse
Extraction code :pzse
Mind mapping tools
free , Succinct can be “ Mind mapping ” Copy and paste the article to get a mind map ( No joy, no spray. )

You need two databases with the same version mysql
2. Installation steps
When the formal environment is deployed , Keep the data of master database and slave database consistent in advance
Main library
modify mysql The configuration file :vi /etc/my.cnf
newly added :
server-id = 1 Unique code of the service
log-bin = mysql-bin Turn on mysql,binlog function
binlog_format = ROW binlog The way of recording (ROW Record each line )
binlog_row_image = minimal Reduce the amount of logging , Only the affected columns are recorded
binlog-do-db = The name of the database that needs data synchronization Specify the database name that needs data synchronization

Restart the database :service mysql restart
Enter the database background :cd /usr/local/mysql/bin
Log on to the terminal :./mysql -uroot -p123456( Here is mysql Account and password )
Create an account and password for the synchronization database :
grant replication slave on *.* to ' user id'@' From database ip Address ' identified by ' User password ';
![]()
Refresh database :flush privileges;
Check the database status :show master status\G;
Record the values in the figure , From the library, you need to use

Slave Library
modify mysql To configure :vi /etc/my.cnf
newly added :
server-id = 2 Unique code of the service
log-bin = mysql-bin Turn on mysql,binlog function
binlog_format = ROW binlog The way of recording (ROW Record each line )
binlog_row_image = minimal Reduce the amount of logging , Only the affected columns are recorded
binlog-do-db = The name of the database that needs data synchronization Specify the database name that needs data synchronization

Restart the database :service mysql restart
Enter the database background :cd /usr/local/mysql/bin
Log on to the terminal :./mysql -uroot -p123456( Here is mysql Account and password )
Set the login account and password of the main database 、 Synchronize location information, etc :
change master to master_host=’ Main library IP Address ’,master_user=’ user id’,master_password=’ User password ’,master_log_file=’ Put the main warehouse File Fill in the value after ’,master_log_pos=Position Fill in the value after
![]()
Turn on the synchronization function :start slave;
View synchronization status :show slave status\G;
( As shown in the figure, the master-slave configuration is successful )

Enter the visualization tool test synchronization :
Any new table created in the set database will be synchronized into the slave database
Modifying any information will also be synchronized into the slave database

Mysql The master-slave is to synchronize the data of the master database to the slave database in real time , It can also be understood that it will be active and standby , In the active / standby architecture system, only the primary database provides services , The slave library is only used for real-time data backup ; Another concept that can be extended here is the dual master architecture , Dual master architecture is also called dual active architecture in storage , Common in 3DC( Three centers in different places )
3DC: It is divided into production business centers , Local disaster backup center and remote disaster backup center , Three centers are three data centers with the same infrastructure ( Computer room ).
边栏推荐
猜你喜欢
随机推荐
部署主从数据库
DHCP的配置(以华为eNSP为例)
Redis使用场景
四、TestFixture测试夹具,或者测试固件
Open虚拟专线网络负载均衡
Mouse monitor, Paintbrush
Copy the old project into a web project
Swing组件之单选与多选按钮
UE4 LoadingScreen动态加载启动动画
The first week of the fifth stage
21. Merge Two Sorted Lists
strut2 表单标签
Ansible Deployment Guide
CentOS install redis
4、 Testfixture test fixture, or test firmware
3、 Five operation modes of unittest test cases
Angr(四)——angr_ctf
语音自监督预训练模型 CNN Encoder 调研总结
常用类的小知识
Ansible部署指南









