当前位置:网站首页>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
边栏推荐
- Short math guide for latex by Michael downs
- MySQL data query optimization -- data structure of index
- I stepped on a foundation pit today
- WP collection plug-in free WordPress collection hang up plug-in
- 2006 translation
- [database I] database overview, common commands, view the table structure of 'demo data', simple query, condition query, sorting data, data processing function (single row processing function), groupi
- Solve the problems encountered by the laravel framework using mongodb
- Have you entered the workplace since the first 00???
- Record a problem that soft deletion fails due to warehouse level error
- [source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
猜你喜欢

Contest3145 - the 37th game of 2021 freshman individual training match_ 1: Origami
![[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush](/img/94/2bdc31ec05595dbbc8a7a8d6b22252.jpg)
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush

Defensive programming skills

MySQL query

National standard gb28181 protocol platform easygbs fails to start after replacing MySQL database. How to deal with it?

Practical multifunctional toolbox wechat applet source code / support traffic master

If you have just joined a new company, don't be fired because of your mistakes

Don't disagree, this is the most powerful "language" of the Internet

Unity controls the selection of the previous and next characters

Audio and video technology development weekly | 232
随机推荐
No clue about the data analysis report? After reading this introduction of smartbi, you will understand!
JVM family -- monitoring tools
Résumé des outils communs et des points techniques de l'examen PMP
How to use STR function of C language
2022-07-03:数组里有0和1,一定要翻转一个区间,翻转:0变1,1变0。 请问翻转后可以使得1的个数最多是多少? 来自小红书。3.13笔试。
MySQL is dirty
[.NET + mqtt]. Mise en œuvre de la communication mqtt dans l'environnement net 6 et démonstration de code pour l'abonnement et la publication de messages bilatéraux du serveur et du client
PID of sunflower classic
Session learning diary 1
Contest3145 - the 37th game of 2021 freshman individual training match_ 1: Origami
warning: LF will be replaced by CRLF in XXXXXX
96% of the collected traffic is prevented by bubble mart of cloud hosting
Have you entered the workplace since the first 00???
投资深度思考
Is it really so difficult to learn redis? Today, a fan will share his personal learning materials!
Eh, the log time of MySQL server is less than 8h?
How to use websocket to realize simple chat function in C #
Backpropagation formula derivation [Li Hongyi deep learning version]
Typical applications of minimum spanning tree
What is cloud primordial?





