MARIADB Master-slave replication
Primary server Configuration
* Modify configuration file
[Email protected] ~]# VIM/ETC/MY.CNF.D/SERVER.CNF
[Mysqld]server-id=1log-bin=master-loginnodb_file_per_table=onskip_name_resolve=on
[[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
[Email protected] ~]# VIM/ETC/MY.CNF.D/SERVER.CNF
[Mysqld]server-id=2relay-log=relay-loginnodb_file_per_table=onskip_name_resolve=on
[[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= ' 172.16.80.6 ', 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)]>
/var/lib/mysql/relay-log.info this file records which logs from the primary server start copying
/var/lib/mysql/relay-master.info this file records the primary server address, account password information
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: 172.16.80.6 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 http://guoruilin198.blog.51cto.com/12567311/1908306
MARIADB Learning notes-master-slave replication