Reply To: HA High Availability not syncing the mysql database

VitalPBX Community Support General Discussion HA High Availability not syncing the mysql database Reply To: HA High Availability not syncing the mysql database

    Rodrigo Cuadra
    Keymaster
    US
    Up
    0
    Down
    You need to reconfigurate MariaDB Cluster

    In Server A

    mysql -uroot -e DELETE FROM mysql.user WHERE User=”;

    mysql -uroot -e GRANT REPLICATION SLAVE ON *.* to vitalpbx_replica@’%’ IDENTIFIED BY ‘vitalpbx_replica’;

    mysql -uroot -e FLUSH PRIVILEGES;

    mysql -uroot -e FLUSH TABLES WITH READ LOCK;

    Get the filename and block in server A

    mysql -uroot -e show master status | awk NR==2 {print $1}

    mysql -uroot -e show master status | awk NR==2 {print $2}

    Now in server A copy all the dabatabses

    mysqldump -u root –all-databases > all_databases.sql

    Copy the file all_databases.sql to server B

    scp all_databases.sql root@$ip_server_b:/tmp/all_databases.sql

    Go to Server B and restore the databses

    mysql mysql -u root < /tmp/all_databases.sql

    In Server B create the User

    mysql -uroot -e “GRANT REPLICATION SLAVE ON *.* to vitalpbx_replica@’%’ IDENTIFIED BY ‘vitalpbx_replica’;”

    mysql -uroot -e “FLUSH PRIVILEGES;”

    mysql -uroot -e “FLUSH TABLES WITH READ LOCK;”

    Get the filename and block in server B

    mysql -uroot -e show master status | awk NR==2 {print $1}

    mysql -uroot -e show master status | awk NR==2 {print $2}

    Stop the slave, add Server-A to the Server-B and start slave (replace the three variables, $ip_server_A, $file_server_A, $position_server_A)

    mysql -uroot -e “STOP SLAVE;”

    mysql -uroot -e “CHANGE MASTER TO MASTER_HOST=’$ip_server_A’, MASTER_USER=’vitalpbx_replica’, MASTER_PASSWORD=’vitalpbx_replica’, MASTER_LOG_FILE=’$file_server_A’, MASTER_LOG_POS=$position_server_A;”

    mysql -uroot -e “START SLAVE;”

    Connect to Server A and follow the same steps (replace the three variables, $ip_server_B, $file_server_B, $position_server_B)

    mysql -uroot -e STOP SLAVE;

    mysql -uroot -e CHANGE MASTER TO MASTER_HOST=’$ip_server_B‘, MASTER_USER=’vitalpbx_replica’, MASTER_PASSWORD=’vitalpbx_replica’, MASTER_LOG_FILE=’$file_server_B‘, MASTER_LOG_POS=$position_server_B;

    mysql -uroot -e START SLAVE;

    DONE

     

     

    0