MySQL初识复制

2017-12-14  本文已影响0人  显卡hg

MySQL复制简介

理解binary log

statement格式

Row格式

row复制解析

mixed格式

GTID

[mysqld]
#GTID
gtid_mode=on
enforce-gtid-consistency=on
#bin log
log-bin=mysql-bin
log-slave-updates=1

基于binary log+file position方式的复制

master:
[mysqld]
log-bin=mysql-bin
server-id=1003306
slave:
[mysqld]
server-id=1013306
mysql>create user 'repl'@'%' identified by 'repl4slave';
mysql>grant replication slave on *.* to 'repl'@'%';

提示:确认GTID关闭

mysql>show global variables like 'gtid_moed';
gtid_mod=off
slave >change master to master_host='masterip',
master_port=3306,
master_user='repl',
master_password='repl4slave',
master_log_file='mysql-bin.xxxx',
master_log_pos=xxxx;

GTID环境搭建

msater:
[mysqld]
log-bin=mysql-bin
server-id=1003306
gtid-mode=on
enforce-gtid-consistency=1
slave:
[mysqld]
server-id=1013306
gtid-mode=on
enforce-gtid-consistency=1
mysql>create user 'repl'@'%' identified by 'repl4slave';
mysql>grant replication slave on *.* to 'repl'@'%';

备份文件的名称格式:dbname-port-full|incr-`%Y-%m%d-%h%m`.sql

备份时-A参数并不能全部包括,如果要全部备份要加上--all-databases --triggers --routines --events,备份时建议将表结构,数据文件,触发器,存储过程,事件分开来备份

上一篇下一篇

猜你喜欢

热点阅读