How to Setup MySQL (Master-Slave) Replication in RHEL, CentOS, Fedora

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

156 Responses

  1. vish says:

    After changing slave server changes on my.cnf and restore the required database. Then slave server mysql service is not starting.

  2. satyapal Kumar says:

    Hi,

    MySQL service failed on Slave node when trying to configure CentOS 6.3 with MYSQL Server version: 5.7.22-log MySQL Community Server (GPL).

  3. sujith says:

    Hi, I am getting error, status show connecting and last i/o shows error connecting to master ip address.

    Please help me..

  4. Russell Scattone says:

    So like the simplicity of the setup. However it did not work and was frustrating as everything seemed to be set up correctly. Took some time to find the problem is due to the “binlog-do-db“.

    Problem for me was there was a “test” DB and even though I was creating a “test” table in different DB it wasn’t being replicated. Read this post about why it’s dangerous: https://www.percona.com/blog/2009/05/14/why-mysqls-binlog-do-db-option-is-dangerous/ . Other than that thanks for your contributions

  5. prashant kumar says:

    my master slave was running perfectly but once master got shutdown due to power failure (breakdown ) and it stop replication how to overcome this situation ? or restart replication with minimum downtime

    • Ravi Saive says:

      @Prashant,

      Never faced such power failure issues, but I think there nothing to worry, once you master started its automatically starts replicating to slave..

  6. Tudor says:

    To put master host and so on slave in /etc/my.cnf is officially deprecated.

    Instead run in mysql

    Extract from official website
    “2.2.5.2 Setting the Master Configuration on the Slave

    To set up the slave to communicate with the master for replication, configure the slave with the necessary connection information. To do this, execute the following statement on the slave, replacing the option values with the actual values relevant to your system:

    mysql> CHANGE MASTER TO
        ->     MASTER_HOST='master_host_name',
        ->     MASTER_USER='replication_user_name',
        ->     MASTER_PASSWORD='replication_password',
        ->     MASTER_LOG_FILE='recorded_log_file_name',
        ->     MASTER_LOG_POS=recorded_log_position;
    
  7. Arun Mohan says:

    I got the same error..

    ERROR 1794 (HY000) at line 22: Slave is not configured or failed to initialize properly. You must at least set –server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log

  8. James says:

    mysql -u root -p < /root/dbdump.db
    Enter password:
    ERROR 1794 (HY000) at line 22: Slave is not configured or failed to initialize properly. You must at least set –server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log.

    I got this when I tried to do the restore on the slave.

    • Ravi Saive says:

      @James,

      Have you properly configured Slave server? added correct server-id in slave my.cnf file? please check and confirm..

      • Gulab Pasha says:

        Hi Ravi,

        I have followed your article its good, I have done the configuration in Master no issue but getting an error on slave while importing DB

        ERROR 1794 (HY000) at line 22: Slave is not configured or failed to initialize properly. You must at least set –server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.