1

Topic: iRedMail MariaDB Database replication issues

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.4.0
- Deployed with iRedMail Easy or the downloadable installer? iRedaMail
- Linux/BSD distribution name and version: Ubuntu 20.0.5
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MariaDB MySQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Hello, i happened to install (2) instances of iRedMail 1.4.0 on two different servers mail1 and mail2, so far no issues on the install, i tried to replicate the databases as master-master but i am getting below error, please help i am new on databases.
if you can tell me step by step how to correct this issue i will appreciated.
Believe i read many articles but no solution to my replication issue - should work by adding the master file from Mail 1 to slave Mail 2 and Mail 2 to slave Mail 1 - but it doesn't work - it's frustrating - thank you

## Mail 1 ##
MariaDB [(none)]> show slave status \G;
*************************** 1. row ***************************
                Slave_IO_State: Waiting for master to send event
                   Master_Host: 192.168.4.25
                   Master_User: replicator
                   Master_Port: 3306
                 Connect_Retry: 60
               Master_Log_File: mariadb-bin.000021
           Read_Master_Log_Pos: 36607
                Relay_Log_File: relay.000003
                 Relay_Log_Pos: 683
         Relay_Master_Log_File: mariadb-bin.000021
              Slave_IO_Running: Yes
             Slave_SQL_Running: Yes
               Replicate_Do_DB:
           Replicate_Ignore_DB: test,information_schema,mysql,iredapd
            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: 36607
               Relay_Log_Space: 26074
               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: 0
Master_SSL_Verify_Server_Cert: No
                 Last_IO_Errno: 0
                 Last_IO_Error:
                Last_SQL_Errno: 0
                Last_SQL_Error:
   Replicate_Ignore_Server_Ids:
              Master_Server_Id: 2
                Master_SSL_Crl:
            Master_SSL_Crlpath:
                    Using_Gtid: No
                   Gtid_IO_Pos:
       Replicate_Do_Domain_Ids:
   Replicate_Ignore_Domain_Ids:
                 Parallel_Mode: conservative
                     SQL_Delay: 0
           SQL_Remaining_Delay: NULL
       Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
              Slave_DDL_Groups: 2
Slave_Non_Transactional_Groups: 0
    Slave_Transactional_Groups: 53
1 row in set (0.000 sec)

ERROR: No query specified


## Mail 2 ##
MariaDB [(none)]> show slave status \G;
*************************** 1. row ***************************
                Slave_IO_State: Waiting for master to send event
                   Master_Host: 192.168.3.25
                   Master_User: replicator
                   Master_Port: 3306
                 Connect_Retry: 60
               Master_Log_File: mariadb-bin.000039
           Read_Master_Log_Pos: 47151
                Relay_Log_File: relay.000002
                 Relay_Log_Pos: 12727
         Relay_Master_Log_File: mariadb-bin.000039
              Slave_IO_Running: Yes
             Slave_SQL_Running: No
               Replicate_Do_DB:
           Replicate_Ignore_DB: test,information_schema,mysql,iredapd
            Replicate_Do_Table:
        Replicate_Ignore_Table:
       Replicate_Wild_Do_Table:
   Replicate_Wild_Ignore_Table:
                    Last_Errno: 1062
                    Last_Error: Error 'Duplicate entry '321' for key 'PRIMARY'' on query. Default database: 'iredadmin'. Query: 'INSERT INTO log (admin, domain, event, ip, loglevel, msg, timestamp, username) VALUES ('postmaster@futurenetwork.com', 'futurenetwork.com', 'create', '192.168.1.156', 'info', 'Create user: fnctest@futurenetwork.com.', '2023-02-17 03:58:43', '')'
                  Skip_Counter: 0
           Exec_Master_Log_Pos: 22013
               Relay_Log_Space: 24658
               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: NULL
Master_SSL_Verify_Server_Cert: No
                 Last_IO_Errno: 0
                 Last_IO_Error:
                Last_SQL_Errno: 1062
                Last_SQL_Error: Error 'Duplicate entry '321' for key 'PRIMARY'' on query. Default database: 'iredadmin'. Query: 'INSERT INTO log (admin, domain, event, ip, loglevel, msg, timestamp, username) VALUES ('postmaster@futurenetwork.com', 'futurenetwork.com', 'create', '192.168.1.156', 'info', 'Create user: fnctest@futurenetwork.com.', '2023-02-17 03:58:43', '')'
   Replicate_Ignore_Server_Ids:
              Master_Server_Id: 1
                Master_SSL_Crl:
            Master_SSL_Crlpath:
                    Using_Gtid: No
                   Gtid_IO_Pos:
       Replicate_Do_Domain_Ids:
   Replicate_Ignore_Domain_Ids:
                 Parallel_Mode: conservative
                     SQL_Delay: 0
           SQL_Remaining_Delay: NULL
       Slave_SQL_Running_State:
              Slave_DDL_Groups: 0
Slave_Non_Transactional_Groups: 0
    Slave_Transactional_Groups: 27
1 row in set (0.001 sec)

ERROR: No query specified

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: iRedMail MariaDB Database replication issues

Either you do Master -> Slave or Master <-> Master

3

Re: iRedMail MariaDB Database replication issues

Please let me know how to solve the issue of master-master or master-slave without getting the following error?

Error 'Duplicate entry '321' for key 'PRIMARY'' on query. Default database: 'iredadmin'. Query: 'INSERT INTO log (admin, domain, event, ip, loglevel, msg, timestamp, username)

4

Re: iRedMail MariaDB Database replication issues

Please advise how to resolve the master-slave or master-master problem without receiving the following error.

duplicate entry "321" for key "PRIMARY" error during query. Database by default: 'iredadmin'. "INSERT INTO log" (admin, domain, event, ip, loglevel, msg, timestamp, username)

5

Re: iRedMail MariaDB Database replication issues

empty database log, since it won't harm anything