当前位置:网站首页>MySQL maxscale realizes read-write separation
MySQL maxscale realizes read-write separation
2022-07-04 03:34:00 【yzm4399】
1. If work
Understand and deploy Master slave copy
2. download MaxScale middleware
Download Online
wget https://dlm.mariadb.com/1065384/MaxScale/2.3.20/centos/7/x86_64/maxscale-2.3.20-1.centos.7.x86_64.rpm

install
yum -y install maxscale-2.3.20-1.centos.7.x86_64.rpm

3.master Main library creation user
Master slave replication has been realized : Users created by the main library , Can be synchronized to the slave Library
Create monitoring users
create user 'maxmon'@'%' identified by 'maxmon';
ALTER USER 'maxmon'@'%' IDENTIFIED WITH mysql_native_password BY 'maxmon';
grant replication slave,replication client on *.* to 'maxmon'@'%';
Create routing users
create user 'maxrou'@'%' identified by 'maxrou';
ALTER USER 'maxrou'@'%' IDENTIFIED WITH mysql_native_password BY 'maxrou';
grant all on *.* to 'maxrou'@'%';
flush privileges;


4. To configure MaxScale
vim /etc/maxscale.cnf
find [server1] part , Modify the address and port, Point to master Of IP And port
Copy 2 Time [server1] The whole content of , Change it to [server2] And [server3], Also modify the address and port, Point to respectively slave1 and slave2
[MariaDB-Monitor] part , modify servers by server1,server2,server3, modify user and password Information for previously created monitoring users
Comment out [Read-Only-Service] part , Read and write by maxscale Control is enough
[Read-Write Service] part , modify servers by server1,server2,server3, modify user and password Information for the previously created routing user
notes [Read-Only-Listener] part , stay [MaxAdmin-Listener] Final addition port=6603
5. start-up MaxScale
establish maxscale Related contents , The user is mysql
mkdir /usr/local/mysql/maxscale
mkdir /usr/local/mysql/maxscale/data
mkdir /usr/local/mysql/maxscale/logs
mkdir /usr/local/mysql/maxscale/cache

Under reconfiguration
vim /etc/maxscale.cnf
logdir=/usr/local/mysql/maxscale/logs
datadir=/usr/local/mysql/maxscale/data
piddir=/usr/local/mysql/maxscale/logs
cachedir=/usr/local/mysql/maxscale/cache

start-up , Can't use root User start , Designated here mysql user
maxscale --config=/etc/maxscale.cnf --user=mysql
netstat -ntelp

Sign in MaxScale Manager
maxadmin --user=admin --password=mariadb
View service
list servers

6. test
Create a test user
create user 'rtest'@'%' identified by 'rtest';
ALTER USER 'rtest'@'%' IDENTIFIED WITH mysql_native_password BY 'rtest';
grant select,insert on testdb.* to 'rtest'@'%';
flush privileges;

mysql Connect MaxScale
mysql -urtest -prtest -h'192.168.192.128' -P4006
View the current server name
Select @@hostname;

Open transaction ,MaxScale Switch to master
start transaction;

Roll back
rollback;

Write operations go to the main library , Read operation from the library , It can realize the separation of reading and writing
边栏推荐
- Zlmediakit compilation and webrtc push-pull flow testing
- Zhihu million hot discussion: why can we only rely on job hopping for salary increase? Bosses would rather hire outsiders with a high salary than get a raise?
- (column 23) typical C language problem: find the minimum common multiple and maximum common divisor of two numbers. (two solutions)
- Enhanced for loop
- Add IDM to Google browser
- Rhcsa day 3
- XSS prevention
- The 37 year old programmer was laid off, and he didn't find a job for 120 days. He had no choice but to go to a small company. As a result, he was confused
- Li Chuang EDA learning notes 13: electrical network for drawing schematic diagram
- MySQL backup notes
猜你喜欢

MySQL query

PID of sunflower classic

Constantly changing harmonyos custom JS components during the Spring Festival - Smart Koi

Have you entered the workplace since the first 00???

Easy to win insert sort

Unity controls the selection of the previous and next characters

渗透实战-guest账户-mimikatz-向日葵-sql提权-离线解密

(column 23) typical C language problem: find the minimum common multiple and maximum common divisor of two numbers. (two solutions)

What are the virtual machine software? What are their respective functions?

Fudan released its first review paper on the construction and application of multimodal knowledge atlas, comprehensively describing the existing mmkg technology system and progress
随机推荐
The first spring of the new year | a full set of property management application templates are presented, and Bi construction is "out of the box"
The property of judging odd or even numbers about XOR.
How about the ratings of 2022 Spring Festival Gala in all provinces? Map analysis helps you show clearly!
Www 2022 | taxoenrich: self supervised taxonomy complemented by Structural Semantics
2022 attached lifting scaffold worker (special type of construction work) free test questions and attached lifting scaffold worker (special type of construction work) examination papers 2022 attached
WordPress collection WordPress hang up collection plug-in
Keepalived set the master not to recapture the VIP after fault recovery (it is invalid to solve nopreempt)
logistic regression
機器學習基礎:用 Lasso 做特征選擇
Monitoring - Prometheus introduction
[PaddleSeg 源码阅读] PaddleSeg 自定义数据类
Easy to win insert sort
Unity controls the selection of the previous and next characters
How to use STR function of C language
I stepped on a foundation pit today
SQL injection (1) -- determine whether there are SQL injection vulnerabilities
Add IDM to Google browser
Zhihu million hot discussion: why can we only rely on job hopping for salary increase? Bosses would rather hire outsiders with a high salary than get a raise?
What are the virtual machine software? What are their respective functions?
CSP drawing





