MySQL Master-slave Replication (Data Recovery recovery)---forum that stuff

Source: Internet
Author: User


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/53/wKioL1V5WH6jsbivAAGIBVcF1HA899.jpg "title=" 2.png " alt= "Wkiol1v5wh6jsbivaagibvcf1ha899.jpg"/>

MySQL master and slave synchronization to build up, and finally do not worry about data loss, but such data is really foolproof can not be wrong, of course not, for example, if the master before master in the book there is a library BBS exists, and slave does not have this library, library BBS is included in the establishment of synchronization, When the master on the BBS to modify data, slave will be unable to find the BBS this library and error, then the establishment of synchronization will be destroyed, resulting in a synchronization stop. What's more, when the master database server suddenly fails, how do we make the data recovery work for the forum? Here we will solve both of these problems.

I. Master and Slave server synchronization exception resolution due to inconsistent data before synchronization:

In fact, the best way to solve this problem is to establish a master-slave synchronization, then set up a forum and write the data to master, so that master is in its initial state, all operations on master from the initial state will be synchronized to the slave, and there will be no data discrepancy conflicts.

But also can not avoid the database has data in the case of the data from synchronous backup to ensure the security and recoverability of data. In this case, you can handle this:

1. Make a backup of the database on master:

Mysqldump-uroot-p discuz >/data/20150611.sql

2. Execute in slave mysql:

mysql> stop Slave;

mysql> set global sql_slave_skip_counter=1;

mysql> start slave;

3. Create a database on master and import the north wind database file into the database:

Mysql> CREATE database Discuz Charset=utf8;

Mysql-uroot-p Discuz </data/20150611.sql

The database is then synchronized to the slave.

Two. How does the master server fail to recover the website data after the machine?

Access page http://192.168.1.100/upload/forum.php, the failure message appears:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/58/wKiom1V5YSXx_pVUAAFjOHu3Pqk398.jpg "title=" Site database failure. png "alt=" wkiom1v5ysxx_pvuaafjohu3pqk398.jpg "/>

1. Modify the Web server's configuration file and point the database IP to slave:

(1) Find the ip:192.168.1.111 file information in the Site directory:

Grep-r "192.168.1.111"/var/www/html/upload/config/*

config_global.php:$_config[' db ' [' 1 '] [' dbhost '] = ' 192.168.1.111 ';

Config_ucenter.php:define (' Uc_dbhost ', ' 192.168.1.111 ');

(2) Backup configuration file to prevent misoperation and easy recovery:

CP config_global.php Config_global.php.bak

CP config_ucenter.php Config_ucenter.php.bak

(3) Enter the configuration file to change all the ip:192.168.1.111 that point to master to slave ip:192.168.1.131:

Vim config_global.php

Vim config_ucenter.php

:%s/192.168.1.111/192.16.1.131/g

(4) Restart HTTPD service:

/ETC/INIT.D/HTTPD restart

(5) Data authorization on Slave for Web server access on slave:

Mysql> Grant all on discuz.* to ' Liupengfang ' @ ' 192.168.1.100 ' identified by ' Liupengfang ';

(6) Refresh permissions:

mysql> flush Privileges;

(7) Test visit http://192.168.1.100/upload/forum.php again:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/58/wKiom1V5a8nCmdnfAAF5NbN1EtQ165.jpg "title=" Wct7jfge]eed39byuu60$ev.png "alt=" Wkiom1v5a8ncmdnfaaf5nbn1etq165.jpg "/>

The page can be accessed normally, and the data is returned to normal




This article is from the IT Network blog, so be sure to keep this source http://lpf1015.blog.51cto.com/6627801/1660980

MySQL Master-slave Replication (Data Recovery recovery)---forum that stuff

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.