mysql主从复制

本文详细介绍了如何配置MySQL5.5版本的从库,包括通过命令行指定配置参数的方法,以及如何设置复制所需的各项参数。文章还提供了具体的示例,如设置server-id、binlog格式等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

从库的配置,mysql5.5不支持配置文件的配置了,问了数据库的人,用命令行指定

如下

参考
http://hi.baidu.com/hero0524/item/5280630bbf0ad7eb3599028f


修改从库的配置
#default-storage-engine = InnoDB
#修改
default-storage-engine = blackhole

server-id = 11215004
#新增
replicate-do-db = test

log-bin = mysql-bin
#新增
binlog_format = row

★★★★★★★★★★★★★★★★★
在主库
show master status
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 2615 | | |
+------------------+----------+--------------+------------------+

记录master_log_file和master_log_pos
在从库 ,
5004:
change master to
master_host='10.73.11.21',master_user='databus',master_password='databus', master_port=5000, master_log_file='mysql-bin.000001',master_log_pos=2615;

5005:
change master to master_host='10.73.11.21',master_user='databus',master_password='databus', master_port=5001, master_log_file='mysql-bin.000003',master_log_pos=389;
5006:
change master to master_host='10.73.11.21',master_user='databus',master_password='databus', master_port=5002, master_log_file='mysql-bin.000003',master_log_pos=389;
5007:
change master to master_host='10.73.11.21',master_user='databus',master_password='databus', master_port=5003, master_log_file='mysql-bin.000003',master_log_pos=389;

start slave;

show slave status\G;

注意一定要是
[color=red]Slave_IO_Running: Yes
Slave_SQL_Running: Yes[/color]

查看Relay_Log_File: relay-bin.000002
在slave目录 tailf relay-bin.000002

在主库
CREATE TABLE test(i INT, c CHAR(10));
INSERT INTO test VALUES(1,'record one1111'),(2,'record 11111');

观察从库的log

★★★★★★★★★★
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值