[] Mysql mysql basic experimental replication (asynchronous replication)

Keywords: mysql replication (asynchronous replication), mysql asynchronous replication

 

#mysql master basic experiments

Premise: centos6.5, mysql5.26

  (1) network can ping each other: ping 192.168.135.158

  (2) whether the port is listening on both sides open: netstat -an | grep 3306

  (3) the firewall policy: service iptables stop; (this is just a test, I'll just shut Kazakhstan)

  (4) selinux policy: getenforce (View Status) setenforce 0 (closed)

  (5) completely shut down the boot from the start:

  Firewall ~~ chkconfig iptables off  

    

  selinux ~~ vim / etc / selinux / config, then selinux = disabled, as in FIG.

    

 


# [0] master and slave are open binlog, set the server-id

Replication ## 
log -bin = MySQL- bin 
Server - ID = . 1 # from to Server- ID = 2 
binlog_format = the ROW 
#gtid_mode = ON 
#enforce_gtid_consistency = . 1 
log_slave_updates = . 1 # log write was copied from the library Binlog 
master - info -repository = TABLE 
Relay -log- info -repository = TABLE

[1] # account ready copy

  mysql :( here the operation from the host ip library IP)
  Main: ON Grant Slave Replication * to * 'repl'@'192.168.135.159' IDENTIFIED by '123456';.

# [2] on the master library set reading lock effective. In order to get a consistent snapshot

  mysql :( operation in the lock table, acquires consistency)
  the flush Read Lock with Tables;

# [3] show master status; Obtaining primary current binary library name and the position offset pos.

  Master Status Show;
  - view the log name: MySQL-bin.000002, postion: 881

# [4] to restore the backup master library from the library
  cp direct physical backup, the backup logic mysqldump. Scp then copy the past.

  Physically: direct copy, backup, delete the original data from the library catalog, and then the main library data directory replication in the past, remember to copy from the library auto.cnf delete the copied data / under , or uuid will be the same, making it impossible to copy [8] fault occurs.

# [5] skip from start Mysql thread
  mysqld_safe --skip-slave-start &

# [6] configuration from a thread in the mysql database replication

-- mysql环境下
change master to
master_host='192.168.135.158',
master_port=3306,
master_user='repl',
master_password='123456',
master_log_file='mysql-bin.000002',
master_log_pos=881;

# [7] In mysql start from the thread and validate
  start slave;

  show processlist; - generally follows two threads, the basic is no problem, but to confirm it, or starting the following command;

    

 

  show slave status \ G - This band error word field or no information is 0, that is right!

    

 



#【8】故障诊断
【8.1】The slave I/O thread stops because master and slave have equal MySQL server UUIDs
原因就是直接用主库的文件覆盖到从库的,导致auto.cnf中的uuid相同;

 

参考:深入浅出mysql开发、优化与管理维护书目

Guess you like

Origin www.cnblogs.com/gered/p/11239898.html