MySQL database master-slave synchronization version 4

Source: Internet
Author: User

MySQL master-slave synchronization is a mature architecture with the following advantages: ① the query can be performed on the slave server (that is, the READ function we often call) to reduce the pressure on the master server; ② back up data from the master server to avoid affecting the services of the master server during the backup process; ③ when the master server encounters problems, you can switch to the slave server. So I often use this solution in project deployment and implementation. In view of the rigor of mysql in the production environment, I recommend using the MySQL source code compilation method of brother Zhang banquet.

Version 4 is updated as follows:

I. added the mysql5.1.38 compilation and installation process. The installation process still adopted the mysql Installation Method in the early stage of Zhang banquet, and abandoned the script control method;

2. The method for retrieving the master database from the database is still obtained using tar. The reason for not using mysqldump is that the actual configuration shows that this method has a high chance of failure, therefore, we have been using tar to take the complete snapshot of the primary database. Some netizens do not understand it too well. Here we will focus on it;

Iii. Although the configuration of mysql master-slave replication is relatively simple, it is also a handle blade. Because if the mistaken deletion of the image occurs on the master database, the slave database will also happen; therefore, standalone backup of the master table must be performed. FTP backup is also recommended;

4. binlog must be enabled, and the compliance with the production environment is strict. You are welcome to discuss this post and find out the bugs and errors to avoid misleading new users; I will keep an eye on and update this post (fuqin cooking)

Database directory and others

My. cnf configuration file/usr/local/webserver/mysql/my. cnf

Mysql database location/usr/local/webserver/mysql/data/

Primary Database: 192.168.4.191

Slave Database: 192.168.4.192

Operating System: RHEL5.4 64-bit

Server Type: HP 580G5, dual-core XeonE5520, 32 GB memory, 4 300GSAS into RAID 10

The compilation process of mysql5.1.38 source code is as follows:

 

 
 
  1. /Usr/sbin/groupadd mysql
  2. /Usr/sbin/useradd-g mysql
  3. Unzip mysql-5.1.38.zip
  4. Cd mysql-5.1.38/
  5. . /Configure -- prefix =/usr/local/webserver/mysql/-- enable-starter er -- with-extra-charsets = complex -- enable-thread-safe-client -- with-big-tables -- with-readline -- with-ssl -- with-embedded-server -- enable-local-infile -- with-plugins = innobase
  6. Make & make install
  7. Chmod + w/usr/local/webserver/mysql
  8. Chown-R mysql: mysql/usr/local/webserver/mysql
  9. Cp support-files/my-medium.cnf/usr/local/webserver/mysql/my. cnf
  10. # This depends on the specific environment. huge. cnf can be used for high-pressure conversion.
  11. Cd ../

① Create a 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

② Start MySQL (last & indicates running in the background)

/Bin/sh/usr/local/webserver/mysql/bin/mysqld_safe -- defaults-file =/usr/local/webserver/mysql/my. cnf &

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.