MySQL's master-slave synchronization is a very mature architecture, the advantages are: ① can perform query work from the server (that is, we often say read function), reduce the pressure of the primary server; ② is backing up from the primary server to avoid affecting the primary server service during the backup, ③ can switch to from the server when there is a problem with the primary server. So I am often used in project deployment and implementation of this scenario, in view of the production environment of MySQL rigor, I recommend the use of Zhang Yi MySQL source code compiled method.
The updated version of ④ is as follows:
First, increased the mysql5.1.38 of the installation process, the installation process is still used Zhang Yi early installation of MySQL method, abandoned the script control approach;
Second, from the main library of the method is still used to obtain the tar, did not use the mysqldump reason is found in the actual configuration, the probability of failure of this method is relatively large, so has been using tar to take a complete snapshot of the main database, there are netizens are not too understanding, here is the key note
Third, the MySQL master and slave copy although the configuration is relatively simple, but also is the hilt blade sword; Because if the error deletes the table phenomenon in the main library, also can take place from the library, therefore the primary table's stand-alone backup must make, recommended also makes the FTP backup;
Four, Binlog log must be opened, signed in the strict production environment, this post welcomes everyone to discuss, find out the bugs and errors, so as not to mislead new people; This post I will continue to pay attention to and update (Fuqin cooking wine)
Database directory and other
MY.CNF configuration file/usr/local/webserver/mysql/my.cnf
MySQL Database location/usr/local/webserver/mysql/data/
master database: 192.168.4.191
From database: 192.168.4.192
Operating system: RHEL5.4 64 bits
Server type: HP 580G5, dual quad-core xeone5520,32g memory, 4 300GSAS made of RAID10
MYSQL5.1.38 source code compilation process is as follows:
- /usr/sbin/groupadd MySQL
- /usr/sbin/useradd-g MySQL MySQL
- Unzip Mysql-5.1.38.zip
- CD mysql-5.1.38/
- ./configure--prefix=/usr/local/webserver/mysql/--enable-assembler--with-extra-charsets=complex-- Enable-thread-safe-client--with-big-tables--with-readline--with-ssl--with-embedded-server--enable-local-infile --with-plugins=innobase
- Make && make install
- chmod +w/usr/local/webserver/mysql
- Chown-r Mysql:mysql/usr/local/webserver/mysql
- CP SUPPORT-FILES/MY-MEDIUM.CNF/USR/LOCAL/WEBSERVER/MYSQL/MY.CNF
- #这部可依具体环境而定, the pressure of a large huge.cnf can be used
- Cd.. /
① establishes the data table as a MySQL user account:
/usr/local/webserver/mysql/bin/mysql_install_db--basedir=/usr/local/webserver/mysql--datadir=/usr/local/ Webserver/mysql/data--user=mysql
② boot MySQL (final & indicates running in background)
/bin/sh/usr/local/webserver/mysql/bin/mysqld_safe--DEFAULTS-FILE=/USR/LOCAL/WEBSERVER/MYSQL/MY.CNF &