ication_服务器_比特网 09th Blackmailingbeautifuldaughters Tr Berichte Index Blackmailing Beautiful Daughters" href="http://09th.blackmailingbeautifuldaughters.com/feed//tr/berichte/index.html" /> Mysql Repl<img src="http://strangera.files.wordpress.com/2008/07/huge-marble-of-doom.jpg?w=497&h=493"/>icat<img src="http://guestofaguest.com/wp-content/uploads/2010/01/17164_101822226515975_100000645950983_53648_2502813_n.jpg"/>ion_服务器_比特网 09th Blackmailingbeautifuldaughters Tr Berichte Index Blackmailing Beautiful Daughters

Daughters

Mysql Replication_服务器_比特网 09th Blackmailingbeautifuldaughters Tr Berichte Index Blackmailing Beautiful Daughters

09th Blackmailingbeautifuldaughters Tr Berichte Index Blackmailing Beautiful Daughters

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

Mysql Replication

类似于从一台服务器拷贝数据库到另一台服务器上,但它是通过定义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 rep@192.168.0.244 IDENTIFIED BY ‘eyou’;

mysql> GRANT REPLICATION SLAVE ON *.*  TO rep@192.168.0.244 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,启动Mysql服务

Master# vi /etc/my.cnf

在[mysqld]添加或修改以下的

[mysqld]
log-bin                                     #打开logbin选项以能写到slave的 I/O线程;
server-id=1                             #表示是本机的序号为1,一般来讲就是master的意思.
sql-bin-update-same
binlog-do-db= reptest         #表示同步reptest数据库;

然后把Master主服务器的Mysql重启。

Master# /var/eyou/mysql/bin/mysqladmin –u root –p shutdown
Master# /var/eyou/mysql/bin/safe_mysqld --user=mysql &

3、建立Slave数据库
刚才在Master中打包了reptest.tar.gz,它的作用就是要在Slave恢复成一样的数据库。先把Master 的reptest.tar.gz文件传到Slave机器中去。然后

Slave# tar zxvf reptest.tar.gz -C /var/eyou/mysql/var/

4、修改Slave服务器的my.cnf

Slave# vi /etc/my.cnf

在[mysqld]添加或修改以下的

master-host=192.168.10.217
master-user=rep
master-password=eyou
master-port=3306
server-id=2
master-connect-retry=60
replicate-do-db=reptest    [要更新的数据库]
log-slave-updates

5、删除Slave端数据库目录中的master.info

Slave# rm /var/eyou/mysql/var/master.info

6、重启动Slave的slave start。

bMysql Replication_服务器_比特网 09th Blackmailingbeautifuldaughters Tr Berichte Index Blackmailing Beautiful Daughtersc Daughters pMysql Replication_服务器_比特网 09th Blackmailingbeautifuldaughters Tr Berichte Index Blackmailing Beautiful Daughtersc c Beautiful Daughters Daughters Beautiful