Home > Database > Mysql Tutorial > Mysql master-slave server architecture configuration

Mysql master-slave server architecture configuration

高洛峰
Release: 2016-12-02 14:52:00
Original
1301 people have browsed it

The so-called master-slave Mysql server architecture means that operations on the master server are also copied to the slave server.
Next, I will use two machines to do this process.
The role of replication:
1. Data division
2. Implement read load balancing
3. Backup (it cannot back up itself, but it can provide a backup machine)
4 .High availability and failover capabilities
5. Test Mysql upgrade
Types of replication:
a. Statement-based replication
b. Row-based replication
c. Mixed replication (combination of a and b)
Server Address planning
Master server IP: 192.168.1.108
Slave server IP: 192.168.1.110
Experimental topology:
master_mysql-----------------client_mysql
1. Install Mysql
#mkdir -vp /mydata/data
#groupadd -g 3306 mysql                                                                                                                                                    mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local
#ln -vs /usr/local/mysql-5.5.15-linux2.6-i686 /usr/local/mysql
# cd /usr/local/mysql
#chown -R mysql:mysql .
#scripts/mysql_install_db --user=mysql --datadir=/mydata/data
#chown -R root .
#cp support-files/mysql. server /etc/init.d/mysqld​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ /data
service mysqld start ​
Specify the mysql binary file: ​
#export PATH=$PATH:/usr/local/mysql/bin (temporary) ​
#vim /etc/profile ​
Add PATH=$PATH:/usr/local /mysql/bin also works (permanent)                                                                                                                                                                                                                               to be                                  | GREP mysql m header file:
#LN -SV/USR/LOCAL/MySQL/Include/USR/Include/MySQL
Help information:#vim /etc/man.config man
This configuration needs to be configured on both servers
2. Next, start the real master-slave mysql server configuration
The configuration of the main server is as follows
#vim /etc/my.cnf Add the following information
log-bin=mysql-bin
log-bin-index=mysql-bin.index
binlog-format=maxed
server id = 1
Save after modification is completed, restart Mysql
#service mysqld restart
Then log in to Mysql pair 192.168 .1.110 Host Authorization
#mysql
mysql> GRANT REPLICATION CLIENT,REPLICATION SLAVE ON *.* TO repl@'192.168.1.110'IDENTIFIED BY 'redhat';
mysql> FLUSH PRIVILEGES;
3. Configuration from file
#vim / etc/my.cnf
Comment out log-bin=mysql-bin, binlog-format=maxed
Add relay-log=relay-bin.index, relay-log=relay-bin, replicate-ignore-db=mysql
Modify server-id = 2
Restart Mysql after saving the configuration file
#service mysqld restart
#mysql
mysql> CHANGE MASTER TO MASTER_HOST='192.168.1.108',MASTER_USER='repl',MASTER_PASSWORD='redhat';
mysql> START SLAVE;
mysql> SHOW SLAVE STATUSG;Check the running status of the slave server
If the following information appears, you can be sure that the information has been copied from the master server to the slave server


mysql> SHOW DATABASES;
+--------------------------+
| Database |
+-------------------------- -----+
| information_schema |
| luowei                                                                                        mysql> SELECT * FROM st;
+----+------+
| ID | Name |
+----+------+
| 1 | a |
| 2 | b |
| 3 | c |
| 5 | E |
+----+------+
At this time, the databases on the master and slave servers are synchronized, and the experiment was successful! !



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template