Mariadb
Mariadb Master-Master replication
Master-1: 150.236.189.166
Master-2: 150.236.189.124
Step 1: Master-1 configuration file add following portion
log-bin
server_id=1
#replicate-do-db=replicate
bind-address=150.236.189.166
Step 2: Restart mariadb
# systemctl restart mariadb
Step 3: Create user and grant user
# Create user 'mst_mst_rep'@'%' identified by 'mst_mst_rep'
# grant replication slave on *.* to 'mst_mst_rep'@'%';
# flush privileges;
Step 4: Show master status
MariaDB [(none)]> show master status;
+--------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+--------------------+----------+--------------+------------------+
| mariadb-bin.000007 | 1061 | | |
+--------------------+----------+--------------+------------------+
1 row in set (0.000 sec)
Master-2 Server configuration
===============================
Step 5: Add following in configuration file
log-bin
server_id=2
#replicate-do-db=replicate
bind-address=150.236.189.124
Step 6: Create user and grant permission
# Create user 'mst_mst_rep'@'%' identified by 'mst_mst_rep'
# grant replication slave on *.* to 'mst_mst_rep'@'%';
# flush privileges;
Step 7: Execute below command
# stop slave;
# change master to master_host='150.236.189.166', master_user='mst_mst_rep', master_password='mst_mst_rep',
master_log_file='mariadb-bin.000007', master_log_pos=1061;
# start slave;
@ Show slave status
MariaDB [(none)]> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 150.236.189.166
Master_User: mst_mst_rep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mariadb-bin.000007
Read_Master_Log_Pos: 1061
# Show master status
MariaDB [(none)]> show master status;
+--------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+--------------------+----------+--------------+------------------+
| mariadb-bin.000006 | 1061 | | |
+--------------------+----------+--------------+------------------+
Step 8: Go to master-1 server and execute below command
# stop slave;
# change master to master_host='150.236.189.124', master_user='mst_mst_rep', master_password='mst_mst_rep',
master_log_file='mariadb-bin.000006', master_log_pos=1061;
# start slave;
# check slave status
MariaDB [(none)]> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 150.236.189.124
Master_User: mst_mst_rep
Master_Port: 3306
MariaDB Master master replication is done!!
Master-2: 150.236.189.124
Step 1: Master-1 configuration file add following portion
log-bin
server_id=1
#replicate-do-db=replicate
bind-address=150.236.189.166
Step 2: Restart mariadb
# systemctl restart mariadb
Step 3: Create user and grant user
# Create user 'mst_mst_rep'@'%' identified by 'mst_mst_rep'
# grant replication slave on *.* to 'mst_mst_rep'@'%';
# flush privileges;
Step 4: Show master status
MariaDB [(none)]> show master status;
+--------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+--------------------+----------+--------------+------------------+
| mariadb-bin.000007 | 1061 | | |
+--------------------+----------+--------------+------------------+
1 row in set (0.000 sec)
Master-2 Server configuration
===============================
Step 5: Add following in configuration file
log-bin
server_id=2
#replicate-do-db=replicate
bind-address=150.236.189.124
Step 6: Create user and grant permission
# Create user 'mst_mst_rep'@'%' identified by 'mst_mst_rep'
# grant replication slave on *.* to 'mst_mst_rep'@'%';
# flush privileges;
Step 7: Execute below command
# stop slave;
# change master to master_host='150.236.189.166', master_user='mst_mst_rep', master_password='mst_mst_rep',
master_log_file='mariadb-bin.000007', master_log_pos=1061;
# start slave;
@ Show slave status
MariaDB [(none)]> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 150.236.189.166
Master_User: mst_mst_rep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mariadb-bin.000007
Read_Master_Log_Pos: 1061
# Show master status
MariaDB [(none)]> show master status;
+--------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+--------------------+----------+--------------+------------------+
| mariadb-bin.000006 | 1061 | | |
+--------------------+----------+--------------+------------------+
Step 8: Go to master-1 server and execute below command
# stop slave;
# change master to master_host='150.236.189.124', master_user='mst_mst_rep', master_password='mst_mst_rep',
master_log_file='mariadb-bin.000006', master_log_pos=1061;
# start slave;
# check slave status
MariaDB [(none)]> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 150.236.189.124
Master_User: mst_mst_rep
Master_Port: 3306
MariaDB Master master replication is done!!
Post a Comment
0 Comments