MySQL Tutorial 5 - MySQL Master Slave Replication in Ubuntu

preview_player
Показать описание
PART 1 - In master server
------------------------------------------------

Step 1. Login to Master Server.
Edit & Modify the Configuration file of MySql Server.

# bind-address = 127.0.0.1 #comment this line if you want to remotely access your server

Add below lines at the end of the file.

server-id = 1
relay_log = /var/log/mysql/mysql-relay-bin

Step 2. Restart Mysql Server.
# systemctl restart mysql

Step 3. Login to Mysql Server.
# mysql -u root -p

Step 4. Create a new user for Replication and specify the Password to that user.
mysql ⇒ FLUSH PRIVILEGES;

Step 5. Execute below command to view the File & Position of Master Server.
mysql ⇒ show master status;

+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000006 | 865 | | |
+------------------+----------+--------------+------------------+
1 row in set 0.00 sec

Step 6. Backup all the databases
Step 7. Copy backup file to slave server

PART - 2 - In Slave Server
--------------------------------------------

Step 8. Login to Slave Server. Edit & Modify the Configuration file of MySql Server.

# bind-address = 127.0.0.1 #comment this line if you want to remotely access your server

Add below lines at the end of the file.

server-id = 2
relay_log = /var/log/mysql/mysql-relay-bin

Step 9. Restart Mysql Server.
# systemctl restart mysql

Step 10. Login to Mysql Server.
# mysql -u root -p

Step 10. Unzip and import dbdump to slave server.

Step 11. Specify the following details as given below & make sure to Replace the following settings with your settings.
MASTER_HOST : IP Address of Master server
MASTER_USER : Replication User of Master server that we had created in previous steps.
MASTER_PASSWORD : Replication User Password of Master server that we had created in previous steps.
MASTER_LOG_FILE : Your Value of Master Log File of Master server.
MASTER_LOG_POS : Your Value of Master Log Position of Master server.

mysql ⇒ STOP SLAVE;
mysql ⇒ START SLAVE;
mysql ⇒ show slave status\G;

PART - 3 - Verify Master-Slave Replication
-------------------------------------------------------------

Step 12. Login to Master Server. Login to Mysql Server
# mysql -u root -p

Step 13. For testing a Replication we need to create a new database, it will automatically replicate on Slave Server.
mysql ⇒ create database chirags;

Step 14. Login to Slave Server. Login to Mysql Server
# mysql -u root -p

Step 15. View your Replicated Database by using below command.
mysql ⇒ show databases;

Note: Flow the Process shown in video.

😉Subscribe and like for more videos:
💛Don't forget to, 💘Follow, 💝Like, 💖Share & 💙Comment

Tutorial Link:

Thanks & Regards,
Chitt Ranjan Mahto "Chirag"
_____________________________________________________________________
Note: All scripts used in this demo will be available in our website.
Link will be available in description.

#MySQLTutorial,
#ChiragsMySQLTutorial,
#CreateDatabaseinMySQL,
#CreateTablesinMySQL,
#MasterSlaveReplicationinMySQL,
#MySQLReplication,
#MySQLMasterSlave,
#InstallMySQLinUbuntu,
#InstallMySQLinLinux,
#InstallMySQLinWindows
Рекомендации по теме