MySQL5 master slave安装与配置日志很简单

数据库 MySQL
以下的文章主要向大家描述的是MySQL5 master slave安装与配置日志的实际操作流程,下面就是文章的详细内容的讲述。

此文文章主要向大家讲述的是MySQL5 master slave安装与配置日志的实际操作步骤,首先我们是从MySQL5 master slave安装与配置日志的背景开始讲起的,下面就是文章的主要内容的具体描述。

MySQL5 master slave安装配置日志背景:

master:192.168.100.231 MySQL(和PHP搭配之最佳组合)5.0.19 linux

slave: 192.168.100.234 MySQL(和PHP搭配之最佳组合)5.0.18 linux

step1) 配置master

在/etc/init.d MySQL(和PHP搭配之最佳组合)d段加入

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

并确保

server-id=1

log-bin=MySQL(和PHP搭配之最佳组合)-bin

step2) 授权slave

 

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

重启master

step3)配置slave

vi /etc/my.cnf

设置下面4行

 

  1. server-id = 2 
  2. master-host = 192.168.100.231  
  3. master-user = test 
  4. master-password = 123 

 

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

报了很怪的错误

 

  1. 070307 16:30:27 [ERROR] Slave: Error 'Table 'passport.  
  2. loginuser' doesn't exist' on query. Default database: 'passport'.   
  3. Query: 'delete from loginuser where tokenRefreshTime<='2006-07-03 07:00:00'', Error_code: 1146  
  4. 070307 16:30:27 [ERROR] Error running query,   
  5. slave SQL thread aborted. Fix the problem,   
  6. and restart the slave SQL thread with "SLAVE START".   
  7. We stopped at log 'MySQL(和PHP搭配之最佳组合)-bin.000001' position 98  

MySQL5 master slave安装配置日志中因该是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(和PHP搭配之最佳组合)-bin.000040' position 70671

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

以上的相关内容就是对MySQL5 master slave安装配置日志的介绍,望你能有所收获。

【编辑推荐】

  1. 使用PHP+MySQL来对图书管理系统进行构建
  2. MySQL数据库文件坏掉,不用急!
  3. MySQL 5 中易忘的使用性较强的命令
  4. 实现MySQL定时执行并不难!
  5. 巧用c# 连接MySQL中文乱码问题
责任编辑:佚名 来源: 博客园
相关推荐

2010-05-13 16:15:21

MySQL5 mast

2010-06-11 16:16:59

2010-06-12 17:06:44

2010-06-10 13:19:15

2010-06-13 17:20:58

MySQL maste

2010-06-09 13:55:24

设置MySQL同步

2010-05-19 16:45:26

MySQL自动启动

2010-06-13 16:09:28

MySQL maste

2010-09-07 11:14:56

DB2配置向导

2010-06-12 15:46:56

MySQL5

2010-06-12 10:10:55

2010-05-11 19:02:24

MySQL5 绿色版

2010-06-11 16:46:20

MySQL5

2011-04-06 09:39:49

mysql5存储

2019-12-13 09:48:48

开源技术 软件

2010-06-04 19:57:09

2010-05-19 16:10:49

MySQL连接数

2010-10-09 16:51:47

2010-10-08 14:29:21

ASA防火墙

2010-09-13 17:04:21

防火墙故障
点赞
收藏

51CTO技术栈公众号