MariaDB replication using vagrant - part 2

This is a follow up from the other posts I have done

 

This is the actual DB replication set up and testing, so now we have two vagrant machines and MariaDB is installed.

Now on both the Master and the Slave machine, login to MySQL and create a blank database

mysql
create database replication_test

Now you have the database that we will replicate. 

To start we will work on the Master host, you need to edit the my.cnf file and then restart MariaDB, all the commands and how the file should look like is below.

vagrant@localhost yum.repos.d]$ vi /etc/my.cnf
[mysqld]
log-bin
server_id=1
replicate-do-db=replication_test
bind-address=192.168.33.10

[vagrant@localhost ~]$ sudo service mariadb restart

Now we will set the slave database up

[vagrant@localhost ~]$ sudo vi /etc/my.cnf
[mysqld]
log-bin
server_id=2
replicate-do-db=replication_test
bind-address=192.168.33.11
[vagrant@localhost ~]$ sudo service mariadb restart

Now we are going back to the master as we need to setup the user and the permissions for the replication, on the master host, all the commands and the output are listed below.

MariaDB [(none)]> create user 'slave'@'localhost' IDENTIFIED BY 'SlavePassword';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant replication slave on *.* to slave identified by 'SlavePassword' with grant option;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush tables with read lock;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show master status
    -> ;
+----------------------+----------+--------------+------------------+
| File                 | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+----------------------+----------+--------------+------------------+
| localhost-bin.000001 |      788 |              |                  |
+----------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
MariaDB [(none)]> exit

Now setup the user etc on the Slave database.

MariaDB [(none)]> create user 'slave'@'localhost' IDENTIFIED BY 'SlavePassword';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on replication_test.* to 'slave'@'localhost' with grant option;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye

Now we are ready for the final steps, this will be step 3

I am always interested in your thoughts so if you have any comments or feedback then please feel free to add any comments, or you can mail me  here.

Related Posts Plugin for WordPress, Blogger... 

 

Swann camera can be hacked

iOS Update 11.4