類似於從一台服務器拷貝數據庫到另一台服務器上,但它是通過定義Master 和Slave的關系去實時地保證兩個數據庫的完全同步,這個功能在MySQL的3.23版中開始出現。
Master/Slave模式備份
TestEnv:
Master:MySQL-4.1.12 on Redhat9.0 IP:192.168. 0.217
Slave: MySQL-4.1.12 on Redhat9.0 IP:192.168.10.244
1、編譯,安裝
1. #tar –zxvf MySQL-4.1.12.tar.gz
2. #cd MySQL-4.1.12
3. .#/configure –prefix=/var/eyou/MySQL
4. #make
5. #make install
6. #chown –R root /var/eyou/MySQL
7. # chown –R mysql /var/eyou/MySQL/var
8. #chgrp –R mysql /var/eyou/MySQL
9. #scripts/MySQL_install_db
10. #cp support-files/my-medium.cnf /etc/my.cnf
2、Master 機器設置權限,賦予Slave機器FILE及Replication Slave權利,並打包要同步的數據庫結構。
Master# pwd
/var/eyou/MySQL/bin
Master#./MySQL –u root –p
Enter passWord:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.1.12
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
MySQL> GRANT FILE ON *.* TO
[email protected] IDENTIFIED BY ‘eyou’;
MySQL> GRANT REPLICATION SLAVE ON *.* TO
[email protected] IDENTIFIED BY ‘eyou’;
賦予192.168.10.244也就是Slave 機器有File權限, 這個4.1.12版對replication的權限好像做了調整,只賦予Slave機器有File權限還不行,還要給它REPLICATION SLAVE的權限才可以。
然後打包要復制的數據庫
Master# cd var
Master# tar czvf reptest.tar.gz reptest
這樣,我們得到一個reptest數據庫的打包文件reptest.tar.gz
2設置主服務器Master的my.cnf,