用户名: 密码: 免费注册 忘记密码? 网站地图 | 加入收藏 | 设为首页
首页 | 新闻 | 工具 | 系统 | 办公 | 聊天 | 多媒体 | 网页 | 运营 | 平面 | 欣赏 | 数据库 | 程序 | 服务器 | 组网
网页 | 3dmax | Ghost | Windows Xp| Dreamweaver | photoshop | Flash | office | Alexa | Css | QQ | Asp | PHP | Jsp | Access
Flash MX 2004入门 | 网站推广策略 | CorelDRAW入门 | ASP学习 | 网站建设大师功 | Word入门
  iTbulo.com > 学院 > 数据库开发教程 > MySQL教程 > Mysql使用技巧 > 文章正文
mysql5 master slave安装配置日志
iTbulo.COM 2007-3-8 网页制作教学网()

背景:

master:192.168.100.231 mysql5.0.19 Linux

slave:    192.168.100.234 mysql5.0.18 linux

step1) 配置master

在/etc/init.d mysqld段加入

#(要同步的数据库
binlog_do_db = test

并确保

server-id=1

log-bin=mysql-bin

step2) 授权slave

GRANT REPLICATION SLAVE ON *.* TO test@192.168.100.234 IDENTIFIED BY '123';

重启master

step3)配置slave

vi /etc/my.cnf

设置下面4行

server-id       = 2

master-host     =   192.168.100.231

master-user     =   test

master-password =   123

重启发现slave的I/O线程工作正常,而SQL线程不工作

报了很怪的错误

070307 16:30:27 [ERROR] Slave: Error 'Table 'passport.loginuser' doesn't exist' on query. Default database: 'passport'. Query: 'delete from loginuser where tokenRefreshTime<='2006-07-03 07:00:00'', Error_code: 1146
070307 16:30:27 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000001' position 98

因该是relay log中的数据有问题,于是在

将master机器上的数据拷到244,发现还是有问题。

于是在/etc/my.cnf中加入

replicate-do-db=test

重启slave,

show slave status发现两个线程工作正常

5)测试

在master的test数据的user表中添加了一条记录

然后在slave上通过show processlist看slave工作情况一切正常,

再查数据库数据似乎没有更新,查看slave错误日志

070307 16:45:16 [ERROR] Slave: Error 'Can't create database 'test'; database exists' on query. Default database: 'test'. Query: 'create database test', Error_code: 1007
070307 16:45:16 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000040' position 70671

原来都是我当初拷贝数据惹的祸,因为主机日志在我建数据库的时候就开始了,所以我拷贝数据多此一举,于是

我删除拷贝的数据库,一切ok

文章搜索
相关资讯
相关文章 相关下载
mysql5.0 绿色安装
MySQL的AUTO_INCREMENT
经验之谈:MySQL与ASP.NET配合更强大
SQLSERVER,ORACLE,MYSQL高效分页查询
连接mysql的javabean实例+简单分页
焦点信息