Mysql复制的几个参数跟命令-备忘

Mysql复制的几个参数和命令–备忘

#开启二进制日志

log-bin=mysql-bin

#开启中继日志

relay-log=mysql-relay

#将Slave的修改记入二进制日志,方便该Slave再作为其他Slaves的Master

log-slave-updates=1

#建立账号

grant replication client, replication slave on *.* to ‘repl’@’10.60.8.%’ identified by ‘p4ssword’;

#建立M-S的联系,目前在配置文件中写死master-port的做法已经被废弃,不推荐用

change master to master_host=’10.60.8.116′,master_port=6306,master_user=’repl’,master_password=’p4ssword’,master_log_file=’mysql-bin.000001′, master_log_pos=4;

#Slave中途切换Master的几个重要参数

show slave status;   

#当前Slave复制到了Master的哪个位置的bin_log

Master_log_pos

#当前Slave重放了Master的哪个位置的bin_log

Exec_master_log_pos

    

#Slave改变其Master的时候,需要执行的操作:

change master to master_host=”;

reset master;

#找到新master上的log_file和log_pos

#1. 新Master是原来Slaves中的一员, 其他Slave和新Master比较Master_log_pos的值,确定相差。

#2. 新Master上show master status, 然后用这个pos减去1中算出的差值,就是新pos的位置

#事务每次commit后,都会写二进制日志,这个日志最初都是在日志缓存里面的,而这个参数就是设定将缓存的日志刷到磁盘文件。 多少个commit刷一次磁盘,这个参数就填多少。

#默认值是0,这样就将控制权交给系统,由操作系统决定

sync_binlog=1

Mysql复制的几个参数跟命令-备忘

相关文章:

你感兴趣的文章:

标签云: