MySQL5 master slave安装配置全过程

数据库 MySQL
以下的文章主要讲述的是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段加入

要同步的数据库)

  1. binlog_do_db = test 

并确保

 

  1. server-id=1 
  2. log-bin=MySQL(和PHP搭配之最佳组合)-bin  
  3. step2) 授权slave  
  4. 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线程不工作

报了很怪的错误

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(和PHP搭配之最佳组合)-bin.000001' position 98

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

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

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

 

  1. replicate-do-db=test 

MySQL5 master slave安装配置日志中需要重启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

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

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

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

【编辑推荐】

  1. 实现MySQL双机热备的实际操作步骤
  2. MySQL root密码重置的三步骤
  3. 查看MySQL连接数的实际操作流程
  4. MySQL数据库在实际应用一些方面的介绍
  5. MySQL数据库日志的文件维护流程
责任编辑:佚名 来源: 博客园
相关推荐

2010-06-10 12:55:18

MySQL5 mast

2011-02-22 10:46:02

Samba配置

2009-12-08 17:56:16

WCF配置

2011-01-21 17:51:52

2011-09-06 15:38:20

QT安装

2011-04-02 09:20:23

freebsdmrtg安装

2011-03-11 10:39:02

YUM安装LAMP

2009-06-10 16:55:42

cygwin netb安装

2010-03-10 13:24:45

Zend Debugg

2010-03-30 10:11:53

CentOS源

2010-03-26 14:48:03

Ylmf OS 2.0

2010-11-19 09:30:29

2009-06-09 16:17:45

SQL Server

2009-04-13 12:37:18

2011-04-18 15:56:10

软件测试

2009-10-21 09:14:26

Visual Stud

2009-03-04 10:10:49

PVS服务器桌面虚拟化Xendesktop

2011-08-30 13:08:55

Mysql ProxyLua分离

2010-06-12 10:03:20

Ubuntu Grub

2019-05-14 15:27:31

MongoDB自动备份数据库
点赞
收藏

51CTO技术栈公众号