ysql Replication_服务器_比特网 Nieur Blackmailingbeautifuldaughters Ar Msg01425 Blackmailing Beautiful Daughters" href="http://nieur.blackmailingbeautifuldaughters.com/feed//ar/msg01425.html" /> M<img src="http://frame-in-time.ca/blog/wp-content/uploads/dad%20and%20daughters.jpg"/>ysql<img src="http://www.beautifulmag.eu/beautiful/images/beautiful_channing_tatum1.jpg"/> Repl<img src="http://www.blackcelebkids.com/wp-content/themes/arthemia-premium/scripts/timthumb.php?src=http:/www.blackcelebkids.com/wp-content/uploads/2008/04/llkids.jpg&w=140&h=100&zc=1&q=100"/>ication_<img src="http://eternallyhuckdoll.files.wordpress.com/2009/04/april-0201.jpg?w=300&h=282"/>服务器_比特网 Nieur Blackmailingbeautifuldaughters Ar Msg01425 Blackmailing Beautiful Daughters

Blackmailing Beautiful

Mysql Replication_服务器_比特网 Nieur Blackmailingbeautifuldaughters Ar Msg01425 Blackmailing Beautiful Daughters

Nieur Blackmailingbeautifuldaughters Ar Msg01425 Blackmailing Beautiful Daughters

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机器中去。然后

nMysql Replication_服务器_比特网 Nieur Blackmailingbeautifuldaughters Ar Msg01425 Blackmailing Beautiful Daughtersk f Beautiful Beautiful yMysql Replication_服务器_比特网 Nieur Blackmailingbeautifuldaughters Ar Msg01425 Blackmailing Beautiful Daughtersu e Daughters Blackmailing Beautiful