mysql 双机热备配置

mysql 双机热备配置

mysql 双机热备配置

1.下载mysql-noinstall-5.0.45-win32.zip
2.解压到E:\mysql,然后将文件夹E:\mysql\mysql-noinstall-5.0.45-win32改为E:\mysql\master
3.再解压到E:\mysql,然后将文件夹E:\mysql\mysql-noinstall-5.0.45-win32改为E:\mysql\slave
4.复制E:\mysql\master\my-small.ini为E:\mysql\master\my.ini
编辑内容:,增加log-bin和binlog-do-db参数
示例如下:
#skip-networking
server-id = 1

# Uncomment the following if you want to log updates
#log-bin=mysql-bin

log-bin=mysql-bin
binlog-do-db = testdb1 #需同步数据库  testdb1
binlog-do-db = testdb2 #需同步数据库  testdb2

5.复制E:\mysql\slave\my-small.ini为E:\mysql\slave\my.ini
编辑内容:,修改端口,
port  = 3310

示例如下:

[client]
#password = your_password
port  = 3310
socket  = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port  = 3310
socket  = /tmp/mysql.sock
skip-locking
key_buffer = 16K
max_allowed_packet = 1M
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K


#skip-networking
server-id = 2

# Uncomment the following if you want to log updates
#log-bin=mysql-bin

master-host=127.0.0.1
master-user=root
master-password=
master-port=3306
replicate-do-db=testdb1
replicate-do-db=testdb2

6.保存 E:\mysql\master\my.ini.和E:\mysql\slave\my.ini

7.在命令行下运行E:\mysql\master\bin\mysqld.exe,

Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

E:\mysql\master\bin>mysqld

8.再新开命令行,运行E:\mysql\slave\bin\mysqld.exe

Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

E:\mysql\slave\bin>mysqld
071013 21:41:06 [Warning] The syntax for replication startup options is deprecat
ed and will be removed in MySQL 5.2. Please use 'CHANGE MASTER' instead.

9.用mysql 客户端 HeidiSQL连接到 127.0.0.1的3306,创建数据库testdb1和testdb2,
并在数据库中新建表,然后插入一些数据.

10.客户端连接 到 127.0.0.1的3310,可以看见数据库testdb1和testdb2,且数据库中的数据与master的数据库数据一致.

11.t查看 E:\mysql\master\data\mysql-bin.000001 和E:\mysql\master\data\mysql-bin.index,可以看到被记录的sql操作,

 




你可能感兴趣的:(mysql 双机热备配置)