The second part of proxysql ~ Interpretation of read-write separation

Points to pay attention to in mysql read-
write separation The core points of read-write separation
1. Read and write within the same transaction need to go to the main library.
2. A single specified query needs to be forced to go to the main library.
3. When the slave library is delayed or the service of the slave library is abnormal Go to the main library
1. When the slave library is down, the main library provides services. The solution
is to insert a record of the main library in the hostgroup of mysql_servers, and then set the weight to a small value. When the slave library cannot be read, go back to the main library to query.
That is to say, the main library also provides read services, but the weight is low, so the service
configuration method
of insert into mysql_servers(hostgroup_id,hostname,port,weight,max_connections,max_replication_lag,comment) values(1000,'', 3306,99,1000,10,'slave backup');
The same weight of hostgroup_id is lower than that of the slave library.
2 The limit value of the slave library delay/a replication error occurs in the slave library.
mysql_servers.max_replication_lag=60
When the delay is greater than this value or NULL In this case, proxysql thinks that the slave is unavailable and refuses to provide services.
Proxysql will periodically check the health of the back-end slave.
Note: Since the master also participates in reading, it is not afraid that the slave cannot be read due to failure.
Program account
GRANT all ON *.* TO 'god'@'%' identified by 'god';

GRANT SUPER, REPLICATION CLIENT ON *.* TO 'proxysql'@'192.168.200.24' IDENTIFIED BY 'proxysql';
Common query statement
select hostgroup,schemaname,username,substr(digest_text,120,-120),count_star from stats_mysql_query_digest Query execution Statement
save command
load mysql servers to run;
save mysql servers to disk;

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324783070&siteId=291194637