Home > Database > Mysql Tutorial > MYSQL5 masterslave数据同步配置方法第1/3页

MYSQL5 masterslave数据同步配置方法第1/3页

WBOY
Release: 2016-06-07 18:00:41
Original
1018 people have browsed it

因线路或安全需要我们不得不考虑mysql的备份,特把mysql数据备份的方法整理下。

测试环境.基本上数据是瞬间同步,希望对大家有帮助
RedHat ES 3 update 3
MYSQL 5.0.15
MYSQL数据同步备份
A服务器: 192.168.1.2 主服务器master

B服务器: 192.168.1.3 副服务器slave

A服务器设置

  #mysql –u root –p

  mysql>GRANT FILE ON *.* TO backup@192.168.1.3 IDENTIFIED BY ‘1234';

  mysql>exit

  上面是Master开放一个账号backup密码1234给IP:192.168.1.3有档案处理的权限

  mysqladmin –u root –p shutdown

  导出Master的数据库到slave的机器,可以选择导出需要同步的数据库

  在A机器上修改/etc/my.cnf

  在[mysqld]区段内加入参数

  log-bin=mysql-bin

  server-id=1

  binlog_do_db = gbbbs(要同步的数据库)

  binlog_ignore_db = mysql,test,information_schema (不需要同步的库,5.0 有information_schema这个库)

  sql-bin-update-same

  重启A服务器mysql

  B服务器设置

  设定/etc/my.cnf

  在[mysqld]区段加入

  server-id = 2 (如果还有slave用户,他们的ID也随之增加,如server-id=3)

  master-host = 192.168.112.71

  master-user = backup

  master-password = 1234

  replicate-do-db = gbbbs

  #replicate-do-db = database2

  log-warnings

  master-port=3306

  master-connect-retry = 60

  重启B服务器的MYSQL

  在数据库的文件夹里有master.info文件,用来查看同步信息

  其实就是MYSQL Replication

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template