Home  >  Article  >  Database  >  Mysql master/slave测试过程

Mysql master/slave测试过程

WBOY
WBOYOriginal
2016-06-07 16:53:00928browse

1.测试环境:gt;gt;Master:物理机,Debian(testing) + mysql5.0 + ip:192.168.40.223gt;gt;slave: 虚拟机,CentOS(4.0) + mys

Linux公社

首页 → 数据库技术

背景:

阅读新闻

Mysql master/slave测试过程

[日期:2008-09-20] 来源:Linux社区  作者:Linux编辑 [字体:]

1.测试环境:

>>Master:物理机,Debian(testing) + mysql5.0 + ip:192.168.40.223

>>slave: 虚拟机,CentOS(4.0) + mysql5.0 + ip:192.168.40.225

2.Master修改(192.168.40.223)

1).修改/etc/mysql/my.cnf

在[mysqld]节作如下改动

>>将bind-address由127.0.0.1改为192.168.40.223

>>add:server-id = 1

>>add:log-bin

>>add:binlog-do-db = test

>>add:binlog-ignore-db = mysql

2).创建复制数据帐号:

>>grant replication slave on *.* to ‘slave_server’@192.168.40.225 identified by ’vobile’;

3).重启mysql

>>/etc/init.d/mysql restart

3.Slave修改(192.168.40.225)

1).修改/etc/my.cnf

在[mysqld]节作如下改动:

>>add:server-id = 2

>>add:master-host = 192.168.40.223

>>add:master-user = slave_server

>>add:master_password = vobile

>>master-port = 3306

2).重启mysql

>>/etc/init.d/mysqld restart

4.数据导入

1).导出master(192.168.40.223)中的test数据库: mysqldump -uroot test > test.sql

2).将test.sql导入slave数据库:

>>mysql -uroot -e'create database test;'

>>mysql -uroot test

5.启用slave

1).在slave(192.168.40.255)上面的mysql里面输入start slave;

2).查看slave状态(192.168.40.225 mysql): show slave status\G;

>>在状态值中Slave_IO_Running和Slave_SQL_Running为Yes

3).查看master状态(192.168.40.223 mysql): show master status;

6.检测结果

1).在master中数据库test有一个表human,只有3条记录,slave中同样的数据库同样的表中也有3条记;

2).master中插入一条记录;

3).slave对应的加入了同样一条记录.

linux

  • 0
  • 在Linux下配置Struts中的Oracle数据源

    Oracle帐户管理

    相关资讯       MySQL教程 

    图片资讯      

    本文评论   查看全部评论 (0)

    评论声明

    最新资讯

    本周热门

    Linux公社简介 - 广告服务 - 网站地图 - 帮助信息 - 联系我们
    本站(LinuxIDC)所刊载文章不代表同意其说法或描述,仅为提供更多信息,,也不构成任何建议。


    Copyright © 2006-2011 Linux公社 All rights reserved 浙ICP备06018118号

    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn