Full implementation of Cascade Replication for DB cluster

Source: Internet
Author: User

Pre-Experiment Note:

If you want to enable Cascade replication, you need to enable the following configuration from the server; [mysqld]log_binlog_slave_updateslog_slave_updates: Because the default binary log from the primary server is saved in the relay log from the server and applied to the local database, but the middle of the slave server is even the log on the binary logging function, he is not logged to the local binary log, then the operation of the database can not be transferred to the slave from the server up. When Log_slave_updates is enabled, the binary logs from the server can be executed locally on the primary server as well as in its own binary log, and the database can be cleaned and tested. [[email protected] ~] $systemctl Stop Mariadb[[email protected] ~] $RM-fr/var/lib/mysql/*[[email protected] ~] $systemctl start mariadb


Primary, slave, two-level configuration from the server:

[[email protected] ~] $cat  /etc/my.cnf[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/ mysql.sock# disabling symbolic-links is recommended to prevent assorted  security riskssymbolic-links=0innodb_file_per_tablelog_binserver-id=1[[email protected] ~ ] $cat  /etc/my.cnf[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock# Disabling  symbolic-links is recommended to prevent assorted security  riskssymbolic-links=0# settings user and group are ignored when  systemd is used.innodb_file_per_tableserver_id=2read_onlylog_binlog_slave_updates[[email  Protected] ~] $cat   /etc/my.cnf[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock#  disabling symbolic-links is recommended to prevent assorted security  riskssymbolic-links=0server_id=3



master server and slave server for primary and subordinate replication, configuration and authorization:

Primary server: mariadb [(none)]> grant replication slave on *.* to [email  protected] ' 192.168.27.% '  identified by  ' CentOS '; query ok, 0 rows affected  (0.00 sec) mariadb [(none)]> show  master logs;+--------------------+-----------+| log_name            | file_size |+--------------------+-----------+| mariadb-bin.000001  |       264 | |  mariadb-bin.000002 |       401 |+--------------------+----- ------+2 rows in set  (0.00 SEC) in the middle of the slave server: change master tomaster_host= ' 192.168.27.7 ', master_user= ' repluser ', master_password= ' CentOS ', master_log_file= ' mariadb-bin.000001 ', Master_log_ pos=245; mariadb [(none)]> change master to    -> master_host= ' 192.168.27.7 ',     -> master_user= ' Repluser ',     -> master_ Password= ' CentOS ',     -> master_log_file= ' mariadb-bin.000001 ',     -> MASTER_LOG_POS=245; query ok, 0 rows affected  (0.02 sec) mariadb [(none)]> start  Slave query ok, 0 rows affected  (0.00 sec) mariadb [(none)]> show  slave status\g*************************** 1. row ***************************                slave_io_state: waiting  for master to send event                   Master_Host: 192.168.27.7                   master_user: repluser                   Master_Port: 3306                 Connect_Retry: 60               Master_Log_File: mariadb-bin.000002           Read_Master_Log_Pos: 401                Relay_Log_File: mariadb-relay-bin.000003                 Relay_Log_Pos: 687         Relay_Master_Log_File: mariadb-bin.000002              Slave_IO_Running: Yes             slave_sql_running: yes         exec_master_log_pos: 401               Relay_Log_Space: 1269               Until_Condition: None                Until_Log_File:                  until_log_pos:  0           Master_SSL_Allowed: No            Master_SSL_CA_File:             Master_SSL_CA_Path:                Master_SSL_Cert:             &nbSp master_ssl_cipher:                 Master_SSL_Key:         Seconds_Behind_Master:  0mariadb [(None)]> select user from mysql.user;+----------+| user      |+----------+| root     | |  repluser | |  root     | |           | |  root     | |           | |  root     |+----------+7 rows in set  (0.00 sec) MariaDB  [(None)]> show master logs;+--------------------+-----------+| log_name            | file_size |+--------------------+----- ------+| MARIADB-BIN.000001 | &Nbsp;     401 |+--------------------+-----------+1 row in set   (0.00 SEC)


Secondary from the configuration on the server:

From the server executed from: [Mysqld]innodb_file_per_tableread-onlyserver-id=3change MASTER tomaster_host= ' 192.168.27.17 ', master_ User= ' Repluser ', master_password= ' CentOS ', master_log_file= ' mariadb-bin.000001 ', master_log_pos=401;

Full implementation of Cascade Replication for DB cluster

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.