MARIADB Learning notes-master-slave replication

Source: Internet
Author: User

MARIADB Master-slave replication
    • MySQL extension mode: master-slave

    • Read-write separation based on MHA implementation

Primary server Configuration

* Modify configuration file

[Email protected] ~]# VIM/ETC/MY.CNF.D/SERVER.CNF

    • Start mariadb service

[[email protected] ~]# systemctl start mariadb[[email protected] ~]#  mysql welcome to the mariadb monitor.  commands end with ;  or \g.your mariadb connection id is 2server version: 5.5.44- mariadb-log mariadb servercopyright  (c)  2000, 2015, Oracle, MariaDB  Corporation ab and others. type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement. mariadb [(None)]> show binary logs;+-------------------+-----------+| log_name           | file_size |+-------------------+------ -----+| master-log.000001 |       245 |+-------------------+ -----------+1 row in set  (0.00 sec) mariadb [(None)]> grant replication slave,replication client on *.*  to  ' repluser ' @ ' 172.16.%.% '  identified by  ' replpass '; query ok, 0 rows affected  (0.00 sec) mariadb [(none)]> flush  privileges; query ok, 0 rows affected  (0.00 sec) mariadb [(none)]> show  binary logs;+-------------------+-----------+| log_name           | file_size |+-------------------+-----------+| master-log.000001 |        496 |+-------------------+-----------+1 row in  set  (0.00 sec) mariadb [(none)]>
From server configuration
    • Modifying a configuration file

[Email protected] ~]# VIM/ETC/MY.CNF.D/SERVER.CNF

    • Start the server and authorize

[[email protected] ~]# systemctl start mariadb[[email protected] ~]#  Mysqlwelcome to the mariadb monitor.  commands end with ; or  \g.your mariadb connection id is 2server version: 5.5.44-mariadb  MariaDB ServerCopyright  (c)  2000, 2015, oracle, mariadb corporation  ab and others. type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement. mariadb [(none)]> change master to master_host= ' ', master_user= ' Repluser ', master_password= ' Replpass ', master_log_file= ' master-log.000003,master_log_pos=496 '; query ok, 0 rows affected  (0.01 sec) mariadb [(none)]>
    • Two files are generated when authorization is complete

/var/lib/mysql/ this file records which logs from the primary server start copying
/var/lib/mysql/ this file records the primary server address, account password information

    • Start the replication function from the server

mariadb [(None)]> start slave; query ok, 0 rows affected  (0.00 sec) mariadb [(none)]> show  slave status\g;*************************** 1. row ***************************                Slave_IO_State:                    master_ host:                   Master_User: repluser                   Master_Port: 3306                 Connect_Retry: 60               master_log_file: master-log.000001,master_log_pos=496          read_master_log_pos:  4               relay_log_file:  relay-log.000001                 Relay_Log_Pos: 4        Relay_Master_Log_File:  master-log.000001,master_log_pos=496              slave_io_running: no            slave_ sql_running: yes               replicate_do_db:           replicate_ignore_db:             Replicate_Do_Table:         replicAte_ignore_table:       replicate_wild_do_table:   replicate _wild_ignore_table:                     Last_Errno: 0                    Last_Error:                   Skip_Counter: 0           Exec_Master_Log_Pos: 4               Relay_Log_Space: 245               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:              Master_SSL_Cipher:                 Master_SSL_Key:          seconds_behind_master: nullmaster_ssl_verify_server_cert:  no                last_ io_errno: 1236                 last_io_error: got&Nbsp;fatal error 1236 from master when reading data from binary  log:  ' Could not find first log file name in binary log  index file '                 Last_SQL_Errno: 0                Last_SQL_Error:   Replicate_Ignore_Server_Ids:               master_server_id: 1

At this point, the slave_io_running,slave_sql_running should be yes to begin copying from the primary server

Main main Mode

is to use the AB dual server respectively authorization;

This article is from the "Guo_ruilin" blog, make sure to keep this source

MARIADB Learning notes-master-slave replication

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: 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.