# Creating a multimaster MariaDB replica This topic will cover the process to create a two node Maria DB cluster. The cluster will be configured to allow Soffid console to use either database node, which in turn will replicate data changes to the other one.
Node 1 action
Node 2 action
**Create and setup a Maria DB in node 1.**
Configure Maria DB to generate binary log files. Add the following lines to /etc/mysql/my.cnf: *server-id = **1** log-bin binlog-format=row expire\_logs\_days = 15 max\_binlog\_size = 1000M replicate-ignore-table = soffid.SC\_SEQUENCE slave-skip-errors = 1032,1053,1062*
Restart MariaDB: ``` service mysql restart ```
**Create and setup a Maria DB in node 2.**
Configure Maria DB to generate binary log files. Add the following lines to /etc/mysql/my.conf: *server-id = **2** log-bin binlog-format=row expire\_logs\_days = 15 max\_binlog\_size = 1000M replicate-ignore-table = soffid.SC\_SEQUENCE slave-skip-errors = 1032,1053,1062*
Restart MariaDB: ``` service mysql restart ```
Dump current database contents: *mysqldump soffid -u soffid -p >soffid.data* Load current database contents *mysql -u soffid -p < soffid.data*
Create a user for node 1 to fetch data from node 2. From mysql, execute: *grant replication slave on \*.\* to [replication\_user@](mailto:replication_user@logpmgid02v.toolfactory.net)<NODE1-IP>* *set password for [replication\_user@1](mailto:replication_user@192.168.2.171)<NODE1-IP> = password('<NODE1-PASS>')*
Create a user for node 2 to fetch data from node 1. From mysql, execute: *grant replication slave on \*.\* to [replication\_user@](mailto:replication_user@logpmgid02v.toolfactory.net)<NODE2-IP>* *set password for [replication\_user@1](mailto:replication_user@192.168.2.171)<NODE2-IP> = password('<NODE2-PASS>')*
Query current binary log position: MariaDB \[(none)\]> *show master status;* The result should look like this:
File
Position
Binlog_Do_DB
Binlog_Ignore_DB
mysqld-bin.00003068175
The got values will be used on node 2 to start replica process.
Start replication from node 1 to node 2. From mysql, execute the following sentence, replacing proper values: *CHANGE MASTER TO MASTER\_HOST='<NODE1-IP>', MASTER\_USER='replication\_user', MASTER\_PASSWORD='<NODE2-PASS>', MASTER\_PORT=3306, MASTER\_LOG\_FILE='<NODE1-FILE>' , /\*\* i.e. mysql-bin.000030 \*\*/ MASTER\_LOG\_POS=<NODE1-POSITION>, /\*\* i.e. 68175 \*\*/ MASTER\_CONNECT\_RETRY=10;*
Verify replica is working right, by executing *SHOW SLAVE STATUS \\G* Check following lines: Slave\_IO\_Running: Yes Slave\_SQL\_Running: Yes Seconds\_Behind\_Master: 0
Query current binary log position: MariaDB \[(none)\]> *show master status;* The result should look like this:
File
Position
Binlog_Do_DB
Binlog_Ignore_DB
mysqld-bin.00006098325
The got values will be used on node 1 to start replica process.
Now, start replication from node 2 to node 1. From mysql, execute the following sentence, replacing proper values: *CHANGE MASTER TO MASTER\_HOST='<NODE2-IP>', MASTER\_USER='replication\_user', MASTER\_PASSWORD='<NODE1-PASS>', MASTER\_PORT=3306, MASTER\_LOG\_FILE='<NODE2-FILE>', /\*\* i.e. mysql-bin.000060 \*\*/ MASTER\_LOG\_POS=<NODE2-POSITION>, /\*\* i.e. 98325 \*\*/ MASTER\_CONNECT\_RETRY=10;*
Verify replica is working right, by executing *SHOW SLAVE STATUS \\G* Check following lines: Slave\_IO\_Running: Yes Slave\_SQL\_Running: Yes Seconds\_Behind\_Master: 0
Now, create and start SC\_SEQUENCE table in node 1. This sequence will generate values 1, 11, 21, 31, 41, and so on: *CREATE TABLE `SC\_SEQUENCE` (* *`SEQ\_NEXT` bigint(20) NOT NULL,* *`SEQ\_CACHE` bigint(20) NOT NULL,* *`SEQ\_INCREMENT` bigint(20) NOT NULL* *);* *INSERT INTO SC\_SEQUENCE VALUES (1, 100, 10);*
Now, create and start SC\_SEQUENCE table in node 2. This sequence will generate values 2, 12, 22, 32, 42, and so on:: *CREATE TABLE `SC\_SEQUENCE` (* *`SEQ\_NEXT` bigint(20) NOT NULL,* *`SEQ\_CACHE` bigint(20) NOT NULL,* *`SEQ\_INCREMENT` bigint(20) NOT NULL* *);* *INSERT INTO SC\_SEQUENCE VALUES (2, 100, 10);*
Now, configure the Console to use the following jdbc URL: jdbc:mariadb:sequential://mariadb-host-1,mariadb-host-2/soffid