标签:
主:reset master;
从:reset slave all;
mysql主从配置:
1.MySQL主配置文件增加如下:
default-storage-engine = innodb
innodb_flush_log_at_trx_commit = 2
sort_buffer_size = 2M
server-id = 1
log-bin=/data1/mysql3336/mysql3336-bin
binlog-do-db=tc_selflot
binlog-ignore-db=mysql
2.MySQL从配置文件增加如下:
default-storage-engine = innodb
innodb_flush_log_at_trx_commit = 2
sort_buffer_size = 2M
server-id = 2
log-bin=/data1/mysql3336/mysql3336-bin
binlog-do-db=tc_selflot
binlog-ignore-db=mysql
3.重启主从mysql服务
4.进入MySQL主数据库授权同步账号;
use mysql;
grant file,select,replication slave on *.* to slave@‘192.168.188.%‘ identified by ‘111111‘;
flush privileges;
5.查看主库状态并记录File 及Position值,以便配置从库时用到
show master status;
6.进入从库设置slave信息;
mysql> change master to
-> master_host=‘192.168.188.11‘,
-> master_user=‘slave‘,
-> master_password=‘111111‘,
-> master_port=3336,
-> master_log_file=‘mysql3336-bin.000001‘,
-> master_log_pos=120;
7.启动salve开始同步
mysql> start slave;
8.查看从库状态
mysql> show slave status \G
Slave_IO_Running: Yes 代表成功连接到master并且下载日志
Slave_SQL_Running: Yes 代表成功执行日志中的SQL语句
标签:
原文地址:http://www.cnblogs.com/liqing1009/p/5007544.html