We know that MySQL read and write in the performance of the cost difference is larger, generally speaking the server top 20% write pressure, the other 80% of the pressure from reading, of course, it depends on the actual business situation.
This article prepares to configure a master three from, in fact, how much has never anything to do with, a master more from actually is a master one from the extension, because there is no communication between the library, specifically using which way to look at bandwidth load and specific traffic.
MySQL master and slave replication principle is actually the master constantly write binary log, slave to read the log, follow the SQL record inside to execute! Such as:
MySQL master-slave configuration is inherent to the function, just do a simple configuration can be, well, nonsense less say, start it!
My environment is like this, four machines are on VMware, all using bridge, with DHCP direct access to dynamic IP
master:192.168.83.61
slave1:192.168.83.87
slave2:192.168.83.88
slave3:192.168.83.89
The MySQL version of all four machines is MySQL 5.5.40
First, configure the master
Vi/etc/my.cnf
Server-id = 61log-bin=mysql-binbinlog-do-db=test//database that needs to be synchronized Binlog-ignore-db=mysql//ignored database binlog-ignore-db= Information-schema//Ignored database
Add a sync account for three slave on master
Mysql> Grant Replication Slave1 on * * to ' slave1 ' @ ' 192.168.83.87 ' identified ' slave1 ';//landing on SLAVE1 success Mysql> Gran T replication Slave on * * to ' slave2 ' @ ' 192.168.83.88 ' identified by ' slave2 ';//landing on slave2 successful <pre name= "code" class= "PL Ain ">mysql> grant replication Slave on * * to ' slave3 ' @ ' 192.168.83.89 ' identified by ' slave3 ';//successful landing on Slave3
Restart MySQL service after saving
Service mysqld Restart
Then, in MySQL command line mode, use the
Mysql> Show Master Status\g;
1. Row ***************************file:mysql-bin.000001position:106binlog_do_db:testbinlog_ignore_db:mysql, INFORMATION-SCHEMA1 row in Set (0.00 sec)
Second, add the configuration on three slave:
Vi/etc/my.cnf
Replicate-do-db=test//Synchronized database Replicate-ignore-db=mysql//ignored database Replicate-ignore-db=information-schema//ignored database
Server-id look at the default has no configuration is generally used if you do not add the general IP after a broken name
Note the most important point to configure the main library information, MySQL 5.1 began to discard the my.cnf of this writing
Master-host=192.168.83.61master-user= slave1master-password=slave1master-port=3306
So the version after 5.1 should be written like this:
Change Master to master_host= ' 192.168.83.61 ', master_user= ' slave1 ', master_password= ' slave1 ';
Then restart the MySQL service
MySQL command line mode:
Mysql>start slave;mysql>show slave status\g;
If these two variables are yes, the master and slave are working properly.
Slave_IO_Running:YesSlave_SQL_Running:Yes
Slave_io_running: Connect to the main library and read logs from the main library to local, generate local log files
Slave_sql_running: Reads the local log file and executes the SQL command in the log.
Shang Insert data found three updated from library, that's it!
Mysql 5.5.40 implements a master multiple from One-master Muil-slave