18, mysql implemented method of separate read and write


18.1, mysql separate read and write methods implemented:

1, a program implemented by separate read and write:

php java program and read and write separation (performance, optimum efficiency, it is recommended);

php and java program can be provided by connecting a plurality of read and write the database files for easy separation, i.e. when

select yes, go to the library to read the file connection, when the connection update, insert, delete when you write database connection

file;

2, separate read and write software:

mysql-proxy such as proxy software can also read and write separation function, but the most common or easy to use program to achieve

Separate read and write;

3, development dbproxy;

18.2, separate read and write items to note:

All updates to the database content must be carried out on the master server from the copy when configured mysql Lord, because

Single, only in the main library updated copy of data in order to avoid the user to update the contents of a database on the primary server and

For the same content from the updated database on the server, without conflict;

18.3, separate read and write implementation strategies:

1, read and write separation strategies:


Write library

Competence

password

The port number

ip address

web

select, insert, delete, updata the mysql synchronized to the main library from the library;

123456

3306

172.16.1.41

Reading Library

web

Recovered insert, delete, updata permission (from the main switch is inconvenient); or not withdraw permission to modify the configuration parameters read-only;

123456

3306

172.16.1.42



2, note that:

(1) If the primary library is down modifications need to be removed from the read-only parameter library my.cnf configuration file;

(2) read-only users and super users parameters 'all privileges' rights invalid;

(3) the start time plus --read-only parameters and configurations my.cnf the effect is the same;

3, write command authorization main library:

grant selelct,insert,update,delete on blog.* to 'blog'@'172.16.1.%' identified by '123456';

4, read command authorization from the library

grant select on blog.* to 'blog'@'172.16.1.%' identified by '123456';

5, when synchronization is provided from the primary library and the synchronization is not synchronized on the primary library:

#binlog-do-db = test

# Allow database synchronization, the default allows all database synchronization;

#binlog-ignore-db = information_schema

#binlog-ignore-db = performance_schema

# Set the primary synchronization when synchronization is not necessary from the library;








Guess you like

Origin www.cnblogs.com/LiuChang-blog/p/12315868.html