Home > other >  A master-slave replication
A master-slave replication

Time:10-09

Concept
Will a master database data, synchronous replication to multiple databases, lessen the pressure caused by the data query,
The principle of
Any modification on the primary server will be saved to the binary file
Starting an I/O threads above from the server, the connection to the main server above request read binary log (Bin - log), and then to read to the binary log writes local Realy - log (relay logs),
From the server at the same time open a SQL thread above, Realy read - log (relay logs), if found to have update immediately to update the content of the above the database of the native execution again


Syntax
1 first configuration parsing
Vim/etc/hosts.
192.168.16.136 mysql - master (main
192.168.16.135 master - slavel (from
2 configuration main server configuration
Vimqu/etc/my, CNF
The log - bin=/var/log/mysql/mysql - bin # the location of the binary log
Server - id=1 # main library from the library is not the same as
3 create a directory
The mkdir/var/log/mysql
4 mysql do not have permission to read the root need authorization
Chown mysql. Mysql/var/log/mysql
5 on the master server to create user and authorize
# syntax grant replication slave on the library. The table name to 'user name' @ 'hostname' identified by 'password'. # password
6 in from the server to log in test connection
Mysql -u username - p 'login password' success can
7 configuration from the server configuration
Vim/etc/my CNF
Serverid=2
8 on the primary server
Show master status \ G;
File: specifies the binlog log which is
Position: specify the location of the binlog point
Login from server
MASTER_HOST: master server host name or IP address
MASTER_USER: master server user name, we set the repl
MASTER_PASSWORD: password
MASTER_LOG_FILE: log file is which
MASTER_LOG_POS: the location of the log

  • Related