|
环境:
OS: Red Hat Linux As5
DB: 5.5.25
下面通过一个简单的例子说明下在mysql上配置复制的过程.
1.在master机器上修改my.cnf文件添加如下内容
[mysqld]
log-bin=master-bin
log-bin-index=master-bin.index
server-id=1
2.重启动master上的mysql服务
3.创建复制用户(master)
grant replication slave, replication client on *.* to repl@'192.168.0.%' identified by 'mysql';
4.修改slave机器上的my.cnf文件添加如下内容
[mysqld]
server-id=2
relay-log-index=slave-relay-bin.index
relay-log=slave-relay-bin
5.找到master当前的logfile
mysql> SHOW MASTER STATUS;
+-------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| master-bin.000002 | 1285 | | |
+-------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
下面将从file=master-bin.000002开始复制
6.在slave上连接master
change master to master_host='192.168.1.104',
master_port=3306,
master_user='repl',
master_password='mysql',
master_log_file='master-bin.000002',
master_log_pos=0;
7.启动slave
start slave
完成以上步骤后,在master上做的操作,将直接复制到slave.
-- The End -- |
|