mysql多实例的安装以及主从复制配置(2)

来源:未知 责任编辑:责任编辑 发表时间:2013-11-18 20:56 点击:

c.在master的配置文件/etc/my.cnf.multi中的[mysqld1]增加如下配置:
server-id=1 //master的id,通常为1
log-bin=mysql-bin  //打开Binary Log功能
binlog-do-db=repl  //需要同步的数据库,如果没有这个参数,表示通报所有数据库
d.在master机上为slave机添加一同步帐号
mysql> grant replication slave on *.* to ‘repl’@’192.168.100.22′ identified by ‘repl’;
-
e.在slave的配置文件/etc/my.cnf.multi中的[mysqld1]增加如下配置:
server-id=2  //slave id
master-host=192.168.100.19  //master ip
master-user=repl   //连接master的账号
master-password=repl  //连接master的密码
master-port=3306      //master port
master-connect-retry=60
replicate-do-db=repl   //需要同步的数据库
-
f.重启master
mysqld_multi –config-file=/etc/my.cnf.multi stop 1
mysqld_multi –config-file=/etc/my.cnf.multi start 1
用show master status 命令查看如下:
mysql> show master status;
+————+———-+————–+——————+
| File       | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+————+———-+————–+——————+
| log.000002 |      626 | repl         |                  |
+————+———-+————–+——————+
g.重启slave
mysqld_multi –config-file=/etc/my.cnf.multi stop 1
mysqld_multi –config-file=/etc/my.cnf.multi start 1
用show slave status查看如下:(如果Slave_IO_Running、Slave_SQL_Running状态为Yes则表明设置成功)
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.100.19
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: log.000002
Read_Master_Log_Pos: 626
Relay_Log_File: mysql-relay-bin.000004
Relay_Log_Pos: 229
Relay_Master_Log_File: log.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: repl
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 626
Relay_Log_Space: 229
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • /etc/fstab 详解
  • nginx主主集群
  •  LVS-NAT和LVS-DR模式的实现详解
  •  RHCE考试之磁盘配额
  • 学习笔记:ACL详解
  • suse linux双网卡双网关配置
  •  LVM逻辑卷管理器
  •  Nginx主主负载均衡架构
  • ubuntu学习Mysql

快速直达

操作系统导航

LinuxWindows虚拟机
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1