Mysql master - master database replication

IT kolla

Active member
  • Mar 8, 2022
    171
    168
    43
    මට ඔනේ වෙලා තියෙනවා MySql databse replication එකක් කරගන්න. ඒ කිව්වේ production and backup server දෙකක් තියන්වා. අපි ප්‍රොඩක්ශන් එකේ දාන databases and data ඔක්කොම backup පැත්තෙත් වදින්න ඔනේ. මේක real time වෙන්න ඔනේ. එතකොට production server එක හදිසියෙවත් down උනොත් backup server එක පැත්තේ තියන ඩේටාබේස් එකෙන් ඇප්ලිකේශන් එක රන් වෙන්න ඔනේ. මම මේකට ක්‍රම ගොඩක් බලල කරාට එකක් වත් හරි ගියේ නෑ. මම try කලේ master - master database replication and master slave method. මේකේ කවුරු හරි මේක ගැන දන්න කෙනෙක් ඉන්නවදා. ඉන්ටනෙට් එකේ තිය්න එවා ගොඩක් වැඩ නෑනේ.
     

    IT kolla

    Active member
  • Mar 8, 2022
    171
    168
    43
    ස්ලෝනි රෙප්ලිකේශන්
    ගොඩක් ස්ලෝව් ද? කොහොමත් ස්ලෝ උනාට අවුලක් නෑ. මොකද DR පැත්තේ කරන්නම ඕනේ බන්.

    මේක නම් බැලුවේ නෑ පොඩ්ඩක් මම බලන්නම්.

    MySQL group replication eka try kale nadda?

    Man k8s Wala multiple MySQL pods set up karala tiyenwa me widiyata.
    බැලුවා මචන් ඒත් හරි ගියේ නෑ. RHEL 9 os එක නිසාද දන්නේ නෑ කේස් එක.

    man eka parak master slave kalla thiyanawa mysql 5.6 wala master master nan kalla na.
    Master slave වලදි slave පැත්තේ database eken write කරන්න බෑ නේද? DR පැත්තෙන් ඩේට write කරන්නත් වෙනවා. Anyway මම මේකත් ට්‍රයි කලා. ඒත් මේක වැඩ කලේ නෑ. මේකේ මචන් slave පැත්තේ එක ඩේටබේස් එකයිද හදන්න පුලුවන්?
     
    • Like
    Reactions: siri_ayya and NRTG

    snm1990

    Well-known member
  • Jun 4, 2015
    11,346
    8,478
    113
    production and backup දෙකම තියෙන්නේ එකම data centre එකකද?

    පොඩි අදහසක් තියෙනවා, අපිත් තාම කරලා බලල නෑ... MySQL group replication (single master multi slave) දෙකේම තියෙනවා...

    Production එකේ MySQL slave නෝඩ් එකක් backup එකේ MySQL group replication master node ekata master කරනවා... ඒ දෙක මාස්ටර් ස්ලෙව් තියෙන්නේ... හැබැයි backup එකේ මාස්ටර් වෙන්නේ මේ ස්ලෙව්ම තම.


    හරි ගියොත් කියපන්...

    data centres දෙකකනම් Galera (with maria DB) තම හොදයි කියන්නේ..
     
    • Like
    Reactions: siri_ayya and NRTG

    IT kolla

    Active member
  • Mar 8, 2022
    171
    168
    43
    production and backup දෙකම තියෙන්නේ එකම data centre එකකද?

    පොඩි අදහසක් තියෙනවා, අපිත් තාම කරලා බලල නෑ... MySQL group replication (single master multi slave) දෙකේම තියෙනවා...

    Production එකේ MySQL slave නෝඩ් එකක් backup එකේ MySQL group replication master node ekata master කරනවා... ඒ දෙක මාස්ටර් ස්ලෙව් තියෙන්නේ... හැබැයි backup එකේ මාස්ටර් වෙන්නේ මේ ස්ලෙව්ම තම.


    හරි ගියොත් කියපන්...

    data centres දෙකකනම් Galera (with maria DB) තම හොදයි කියන්නේ..
    නෑ ම්චන් එකම ඩේට සෙන්ටර් එකක තියෙන්නෙ. බලම් මම කරලා බලන්නම්
     

    sirimal1

    Well-known member
  • Jun 7, 2017
    341
    394
    63
    Battaramulla
    MySQL group replication configuration eka lesi na. Hodata concept eka therenne nathuwa configure karanna ba.

    Me blog eke tiyenwa multi master GR ekak gahana hati k8s wala. Kiyawala balanna. MySQL official doc ekath balanna.

     
    • Like
    Reactions: Asmodeus

    dasith077

    Well-known member
  • Jun 18, 2009
    2,003
    1,767
    113
    Ⓔᗩ𝓇ţħ
    ගොඩක් ස්ලෝව් ද? කොහොමත් ස්ලෝ උනාට අවුලක් නෑ. මොකද DR පැත්තේ කරන්නම ඕනේ බන්.


    මේක නම් බැලුවේ නෑ පොඩ්ඩක් මම බලන්නම්.


    බැලුවා මචන් ඒත් හරි ගියේ නෑ. RHEL 9 os එක නිසාද දන්නේ නෑ කේස් එක.


    Master slave වලදි slave පැත්තේ database eken write කරන්න බෑ නේද? DR පැත්තෙන් ඩේට write කරන්නත් වෙනවා. Anyway මම මේකත් ට්‍රයි කලා. ඒත් මේක වැඩ කලේ නෑ. මේකේ මචන් slave පැත්තේ එක ඩේටබේස් එකයිද හදන්න පුලුවන්?
    multiple salves hadanna puluwanna config file eke unique ids denna one for each server echarai. one nan eka db ekak witrak sync wenna hadanna puluwan.

    man karapu eke nan slow une mulin sync wena ekata tikak wela yanwa. habai sync unayin passe near realtime slave eke serama master updates pennuwa.

    uba wada kale na kiyanen mokadda apu error eka?
    salve server eke `show slave status` gahuwama mokadda awe?

    man clustering nui master-master replication nan calla na ewa tikak advance.
     

    Honey Bunch

    Well-known member
  • Nov 24, 2018
    16,967
    26,381
    113
    Kandy
    Chat gpt eken ahuwama mehema kiyanne aniwa chatgpt ekath ekka oka lesiyen kara ganna pluwan wei

    MySQL master-master replication, also known as bi-directional replication, is a configuration where two or more MySQL database servers are set up to act as both master and slave simultaneously. This setup allows for data to be replicated and synchronized between multiple database servers, providing redundancy and high availability.

    Here's an overview of the steps to set up MySQL master-master replication:

    1. **Configure server IDs**: Each MySQL server participating in replication must have a unique server ID. You can set the server ID in the MySQL configuration file (my.cnf) on each server.

    2. **Enable binary logging**: Binary logging is required for replication. Ensure that the `log_bin` directive is uncommented in the configuration file, and set a unique `server-id` and `log_bin` file name for each server.

    3. **Create replication user**: Create a dedicated user on each server that will be used for replication. This user should have the necessary privileges to read and write the replicated data. For example, you can create a user named `replication_user` with appropriate privileges.

    4. **Configure replication settings**: On each server, add the replication configuration settings to the my.cnf file. The settings include `server-id`, `log_bin`, `binlog_do_db` (specify the databases to replicate), and `replicate-do-db` (specify the databases to apply replication).

    5. **Restart MySQL**: Restart the MySQL service on each server to apply the configuration changes.

    6. **Initialize replication**: Choose one server as the initial source of data. On the other server(s), use the `CHANGE MASTER TO` statement to configure replication, specifying the master server's IP address, port, replication user, and password.

    7. **Start replication**: On each server, use the `START SLAVE` statement to start the replication process. Verify the replication status using the `SHOW SLAVE STATUS` command.

    8. **Test replication**: Make changes to the databases on either server and verify that the changes are replicated to the other server(s). Monitor the replication status regularly to ensure it is working correctly.

    It's important to note that setting up master-master replication requires careful planning and consideration of potential conflicts that may arise when simultaneous changes occur on both servers. It's recommended to use an application-level conflict resolution mechanism or design the system in a way that avoids conflicts, such as using separate database schemas for each server or implementing sharding.

    Additionally, it's crucial to have a robust backup and disaster recovery strategy in place to safeguard your data in case of failures or data corruption.

    Please keep in mind that the specific configuration steps may vary depending on your MySQL version and the operating system you are using. Always refer to the official MySQL documentation or consult a MySQL expert for detailed instructions tailored to your environment.