当前位置:网站首页>Mysql database master-slave cluster construction
Mysql database master-slave cluster construction
2022-07-06 05:43:00 【Python's path to immortality】
List of articles
1 preparation
1 Choose a server as the master server , Back up the data needed on the server
2 Install from library MySQL, It needs to be consistent with the version of the main server
3 Synchronize the data on the master server to the slave Library ( The master-slave cluster will only synchronize the data operations after the cluster is created , The original data will not be synchronized )
2 Configure the main database
Modify the configuration file
vim /etc/my.cnf
Add the configuration
[mysqld]
log-bin=mysql-bin
server-id=1
restart mysql service (centOS 7+)
systemctl restart mysqld
Use the command line to root User access MySQL
mysql -u root -p
Input password , Get into
Create a user with synchronization permission from the node
GRANT REPLICATION SLAVE ON *.* TO 'userName'@'%' IDENTIFIED BY 'yourPassword';
among userName
Username ,yourPassword
Is password
Refresh the permissions
FLUSH PRIVILEGES;
Query the main database status
show master status;
Record File
、Position
Value of field
among File
For operation log file ,Position
Is the pointer position , These two fields are the key to data synchronization
3 Configure slave
Modify the configuration file
vim /etc/my.cnf
Add the configuration
[mysqld]
server-id=2
Be careful : Of every server server-id
Can't repeat
restart mysql service (centOS 7+)
systemctl restart mysqld
Use the command line to root User access MySQL
mysql -u root -p
Input password , Get into
Execute synchronization statements
CHANGE MASTER TO MASTER_HOST='masterServerIp', MASTER_PORT=masterPort, MASTER_USER='masterUser', MASTER_PASSWORD='masterPassword', MASTER_LOG_FILE='masterLogFile', MASTER_LOG_POS=masterPosition;
among masterServerIp
Main library server address (ip Or domain name )
masterPort
Give priority to the library mysql port ( You need to ensure that the Internet is accessible )
masterUser
For the user just created to synchronize data to the slave Library
masterPassword
It is the user password just created for synchronizing data to the slave Library
masterLogFile
Log file name of the main library , Corresponding fields File
masterPosition
Main library pointer position , Corresponding fields Position
Start synchronization from the library
start slave;
Query the synchronization status of the slave Library
show slave status\G;
Mainly focus on fields : Slave_IO_Running
,Slave_SQL_Running
, The values of these two fields are Yes
Then the slave library synchronization status is good
thus , The configuration of the master-slave cluster has been basically completed
4 Set a read-only user from the Library
Log in from library , Add read only users
GRANT SELECT ON *.* TO 'userName'@'%' IDENTIFIED BY 'yourPassword';
among userName
User name for database ,yourPassword
For the user password
Refresh the permissions
FLUSH PRIVILEGES;
Use a read-only user when connecting from the Library
5 Recommended references
MySQL Cluster deployment ( The use of multiple MySQL Example simulation )
边栏推荐
- First knowledge database
- JDBC calls the stored procedure with call and reports an error
- Solution of QT TCP packet sticking
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- 实践分享:如何安全快速地从 Centos迁移到openEuler
- 备忘一下jvxetable的各种数据集获取方法
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Notes, continuation, escape and other symbols
- Classes and objects (I) detailed explanation of this pointer
- HAC集群修改管理员用户密码
猜你喜欢
Sword finger offer II 039 Maximum rectangular area of histogram
Problems encountered in installing mysql8 on MAC
P2802 回家
How to download GB files from Google cloud hard disk
RustDesk 搭建一个自己的远程桌面中继服务器
类和对象(一)this指针详解
05. 博客项目之安全
Promise summary
- [email protected]树莓派"/>
[email protected]树莓派
【SQL server速成之路】——身份驗證及建立和管理用戶賬戶
随机推荐
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Detailed summary of SQL injection
Auto.js学习笔记17:基础监听事件和UI简单的点击事件操作
B站刘二大人-数据集及数据加载 Lecture 8
【经验】UltralSO制作启动盘时报错:磁盘/映像容量太小
B站刘二大人-线性回归 Pytorch
Questions d'examen écrit classiques du pointeur
Anti shake and throttling are easy to understand
B站刘二大人-多元逻辑回归 Lecture 7
[Jiudu OJ 08] simple search x
Web Security (V) what is a session? Why do I need a session?
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Redis消息队列
02. 开发博客项目之数据存储
Problems encountered in installing mysql8 on MAC
01. Project introduction of blog development project
ArcGIS应用基础4 专题图的制作
移植InfoNES到STM32
【华为机试真题详解】统计射击比赛成绩
[QNX hypervisor 2.2 user manual]6.3.3 using shared memory (shmem) virtual devices