当前位置:网站首页>MySQL service 1 master 2 slave, master master, MHA configuration detailed steps
MySQL service 1 master 2 slave, master master, MHA configuration detailed steps
2022-07-24 03:52:00 【ELIAUK``】
Mysql Master slave configuration method :
PS: Change database password :
ALTER USER USER() IDENTIFIED BY "123456";Master slave construction steps :
1. Configure on the primary server :
Enter into my.cnf In the configuration file :
vim /etc/my.cnfEnter the following :
[mysqld]
# The master configuration
log-bin = mysql-bin
server-id=10
binlog-ignore-db=mysql
binlog_format=mixed
expire_logs_days=10Restart after configuration mysql
systemctl restart mysqlAccess to database :
mysql -uroot -p123456
# You can also use
mysql -uroot -p### Authorized to Slave The server ###
# This server address
GRANT REPLICATION SLAVE ON *.* to 'test'@'192.168.174.133' identified by 'giiso';grant all on *.* to [email protected]"%" identified by "123456";flush privileges; --- Refresh the permissions ### Query the status of the primary database ###
mysql> show master status;
2. Slave Library Configure on :
Also enter the vi /etc/my.cnf In the configuration file , Enter the following :
# From configuration
log-bin = mysql-bin
server-id=11
Enter the database :
### Perform synchronization SQL sentence ###
# Enter the IP Address , and mysql-bin Serial number of
change master to master_host = '192.168.174.133', master_user = 'rep', master_port=3306, master_password='123456', master_log_file = 'mysql-bin.000002',master_log_pos=120;### start-up Slave Synchronization process ####
start slave;#### Master slave synchronization check ####
mysql> show slave status\G If i0 Thread is no sql Thread is yes
problem 01:
processing method :
flush logs; Clear the log
mysql> stop slave;change master to master_log_file='mysql-bin.000001',master_log_pos=120;mysql> start slave;1 Lord 2 From the building steps :

1. Configure on the primary server :
Follow the previous master-slave replication method
2. The first 1 Slave server configuration :
Follow the previous master-slave replication method
3. The first 2 Slave server configuration :
Also enter our my.cnf In the configuration file , Enter the following :
# From configuration
log-bin = mysql-bin
server-id=12
### Perform synchronization SQL sentence ###
# Pay attention to our IP The address should be consistent with the main database ,mysql-bin Remember that the modification is consistent with the main database
change master to master_host = '192.168.174.133', master_user = 'rep', master_port=3306, master_password='123456', master_log_file = 'mysql-bin.000003',master_log_pos=120;### start-up Slave Synchronization process ####
start slave; #### Master slave synchronization check ####
mysql> show slave status\G
Main construction steps :
It needs to be built on the basis of master-slave :
1.133 Configure on the primary server :
Enter into vi /etc/my.cnf The following files are configured inside :
log-bin = mysql-bin
server-id=1
binlog-ignore-db=mysql
auto_increment_increment=2 # Progress value auto_imcrement. Generally speaking, there are n Taiwan leader Mysql Just fill in n
auto_increment_offset=1 # Starting value , Generally fill in the second part n Taiwan leader mysql, This is the second master mysql
Restart mysql:
systemctl restart mysql2.134 Configure on the primary server :
Enter into vi /etc/my.cnf The following files are configured inside :
log-bin = mysql-bin
server-id=2
binlog-ignore-db=mysql
auto_increment_increment=2 # Progress value auto_imcrement. Generally speaking, there are n Taiwan leader Mysql Just fill in n
auto_increment_offset=2 # Starting value , Generally fill in the second part n Taiwan leader mysql, This is the second master mysql
Restart mysql:
systemctl restart mysqlGet into 134 Create an account in the server database :
GRANT REPLICATION SLAVE ON *.* TO 'sally1'@'%' IDENTIFIED BY '123456';FLUSH PRIVILEGES;Create good after , Switch to 133 Server :
mysql -h 192.168.174.134 -usally1 -p123456
# Pay attention to the change of account If you can log in 134 Database , use root Users log in again 133 database , Notice that it's all in 133 Operation on the server
mysql -uroot -pBefore that, check them separately 133 and 134 The database of master Whether the information can come out , Then let's remember 134 Of master Information
show master status;
We can see here is 505
So we are 133 The authorization operation on the server is Poistion505
CHANGE MASTER TO MASTER_HOST='192.168.174.134', MASTER_USER='sally1', MASTER_PASSWORD='123456', MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS=505;start-up slave
start slave;see 133 and 134 The server slave\G Inside IO and SQL whether YES
show slave status\Gtest : stay 133 and 134 Create databases on the server to see if they can be synchronized
create database ll;Lord -keepalived Steps to build :
It needs to be built on the basis of master :
To configure keepalived High availability , With mysql-01 For example , There are marks where attention should be paid 5.1 install keepalived
yum install keepalived -y
#( Both need to be installed )1.133 Configure on the primary server :
Modify the configuration file
vi /etc/keepalived/keepalived.confThe contents of the configuration file are as follows :
! Configuration File for keepalived
global defs {
notification_email {
[email protected]
}
notification_email_from [email protected]
smtp_server 192.168.174.133
smtp_connect_timeout 30
router_id mysql-01 # stay MYSQL-02 Change the configuration to MYSQL
}
vrrp_script check_mysqld {
script “/etc/keepalived/check_mysql.sh”
interval 2
weight -2
}restart mysql
systemctl restart mysql2.134 Configure on the primary server :
Modify the configuration file
vi /etc/keepalived/keepalived.confThe contents of the configuration file are as follows :
! Configuration File for keepalived
global defs {
notification_email {
[email protected]
}
notification_email_from [email protected]
smtp_server 192.168.174.133
smtp_connect_timeout 30
router_id mysql-02 # stay MYSQL-02 Change the configuration to MYSQL
}
vrrp_script check_mysqld {
script “/etc/keepalived/check_mysql.sh”
interval 2
weight -2
}restart mysql
systemctl restart mysql边栏推荐
- 值为 0 流程,另一部分看括但不限于如下这题是
- Leetcode-382. random nodes of linked list
- Mongo from start to installation and problems encountered
- C language classic exercises (2) - "bubble sort"“
- Worthington's test of hepatocyte separation system and related optimization schemes
- D2dengine edible tutorial (3) -- export rendering targets as image files
- How emqx 5.0 under the new architecture of mria + rlog realizes 100million mqtt connections
- Machine learning notes - image homography estimation based on deep learning (homographynet)
- Experiment 6 MPEG
- 6-14 vulnerability exploitation rpcbind vulnerability exploitation
猜你喜欢

Sqlserver backup restore

RTOS internal skill cultivation (10) | in depth analysis of RTOS kernel context switching mechanism

The local picture cannot be displayed after the uniapp H5 is packaged

MLP - Multilayer Perceptron

Extend the connection boundary, expand the business scope, and comprehensively move towards the era of Intelligent Cloud network 2.0
![[novice] develop a tab component that is easy to expand by hand](/img/67/ac0a0a4861f933e447a84c24f62e79.gif)
[novice] develop a tab component that is easy to expand by hand

Worthington: characteristics and other parameters of hexokinase from yeast

svg图片颜色的修改 没有花里胡哨

Experiment 6 MPEG

Matlab Fractional Order PID control
随机推荐
Pat grade a 1041 be unique
于最rs]在下面指发送到远程大的返回结构推境
Leetcode-382. random nodes of linked list
Worthington lysozyme technical description and literature reference
Bet on the whole scene, what is the odds of glory?
三菱转以太网模块远创智控YC8000-FX 连接 MCGS操作方法
Worthington hydroxysteroid dehydrogenase technical description and determination scheme
Using global data to realize data sharing in wechat applet
MySQL message queue list structure
DOM related method concepts
Common properties and traversal of trees and binary trees
Matlab Fractional Order PID control
How safe is Volvo XC90? Come and have a look
How to efficiently install the GPU version of mindspire
4. Hezhou air32f103_ LCD
Paper reading: the perfect match: 3D point cloud matching with smoothed densities
MLP - Multilayer Perceptron
IO stream sorting
Leetcode (Sword finger offer) - 11. Minimum number of rotation array
MySQL cannot be accessed. Navicat prompt: is not allowed to connect to this MySQL server