Daisy Chain Replication Setup

 

Daisy Chain Replication Setup

These instructions are for setting up Replication in a daisy chain configuration should only be attempted by experienced users.

This is a very complex configuration and should only be attempted by users who are experienced with replication.  Incorrect setup can result in corrupt data, computer crashes, or other serious consequences.  For a simpler configuration, see One-Way Replication Setup.

Notes:

  • It is recommended to use a folder replication software for the EZ2000 Plus  Dental A to Z folders when using replication. 
  • If replication is currently setup and you are trying to re-create the replication setup, you must first stop the existing slave service by running the "SLAVE STOP;" while the MySQL service is started.

Instructions:

  1. Stop the MySQL service on all replication servers. ("net stop mysql"). On some operating systems, such as Windows Vista, this will require you go into the system services in Control Panel, Administrative Tools, Services and stop the MySQL service manually. If the MySQL service is started on any replication server before step 5, then replication will fail.
  2. On all replication servers, wipe out all loose files in the mysql data directory which do not reside in a subfolder, except for any files beginning with "ib" (e.g. iblog_file0, ib_logfile1, ibdata1).
  3. Make an identical database copy on all replication servers.  The replicated database must be exactly the same on all replication servers before replication begins the first time.
  4. Enable Replication by setting up the my.ini file on all replication servers involved before going to the next step.
    Option 1:  For MySQL 5.0, add the following lines to the "my.ini" file:
    log-bin=mysql-bin
    server-id=2
    log-slave-updates
    master-connect-retry=30
    replicate-do-db=opendental
    relay-log=server-relay-bin

    Alter the "server-id" and "replicate-do-db" as needed. 
    The "replicate-do-db" must be the name of the database to replicate.
    Replace 'server' within the "relay-log" value to the name of the server. ex) relay-log=SlaveComputer-relay-bin

    Option 2: For MySQL 5.5, add the following lines to the "my.ini" file:
    log-bin=mysql-bin
    server-id=2
    log-slave-updates
    replicate-do-db=opendental
    relay-log=server-relay-bin
    skip-name-resolve


    Alter the "server-id" and "replicate-do-db" as needed.
    The "replicate-do-db" must be the name of the database to replicate.
    Replace 'server' within the "relay-log" value to the name of the server. ex) relay-log=SlaveComputer-relay-bin
  5. Start the MySQL service on all replication servers ("net start mysql"). On some operating systems, such as Windows Vista, this will require you go into the system services in Control Panel, Administrative Tools, Services and start the MySQL service manually.
  6. Set each replication server's master server by running a command similar to the following (run the following MySQL queries):
    Go the the command line and change the directory to "C:Program FilesMySQLMySQL Server 5.0in" and type the following: "mysql -u root opendental" (where opendental is the name of the database).

    CHANGE MASTER TO
    MASTER_HOST = ‘MASTER_OF_THIS_SERVER’,
    MASTER_USER = 'repl',
    MASTER_PASSWORD = 'od1234';


    Set "MASTER_HOST" to either the IP address or computer name of the replication master of this server.
  7. For each replication server, run the following queries to grant permission for any replication slave to read data.

    GRANT CREATE TEMPORARY TABLES ON opendental.* TO
    'repl' IDENTIFIED BY 'od1234';
    GRANT SUPER ON *.* TO
    'repl' IDENTIFIED BY 'od1234';
    GRANT REPLICATION SLAVE ON *.* TO
    'repl' IDENTIFIED BY 'od1234'
    ;

    The "opendental.*" should be the name of your mysql database, and the ".*" means everything within the specified database.
  8. Run the "START SLAVE;" in the mysql command interface for each replication server in the chain.

  9. Run the "SHOW SLAVE STATUS;" in the mysql command interface for each replication server in the chain.
    Make sure that the Slave IO Running and Slave SQL Running columns both say 'YES'.

mysql> show slave status;

---------------- ----------------------------

| Slave_IO_State | Master_Host | Master_User | Master_Port | Connect_Retry | Master_Log_File | Read_Master_Log_Pos | Relay_Log_File | Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Running |Replicate_Do_DB | Replicate_Ignore_DB | Replicate_Do_Table | Replicate_Ignore_T able | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | Last _Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Condition | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File | Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seconds_Behind_Master |

---------------- -----------------------

| Waiting for master to send event | 192.168.1.3 | repl | 3306 | 30 | mysql-bin.000002 | 98 | open-relay-bin.000005 | 235 | mysql-bin.000002 | Yes | Yes | replicate | | | | | | 0 | | 0 | 98 | 235 | None | |

  1. How to test replication between two replication servers. Only test two replication servers at a time. We recommend testing the first replication server in the chain with the last replication server in the chain. If the test fails, make several smaller tests between consecutive replication servers.
    1. From server1, run the following SQL to create a junk temporary table: CREATE TABLE tmp123 (Col1 VARCHAR(1));
    2. From server2, verify that table tmp123 was created by running the following SQL: SELECT * FROM tmp123;
    3. From server2, run the following SQL to create a junk temporary table: CREATE TABLE tmp456 (Col1 VARCHAR(1));
    4. From server1, verify that table tmp456 was created by running the following SQL: SELECT * FROM tmp456;
    5. From server1, delete table tmp456 by running the following SQL: DROP TABLE tmp456;
    6. From server2, verify that table tmp456 was dropped by running the following SQL and verifying that tmp456 does NOT show up: SHOW TABLES LIKE 'tmp456%';
    7. From server2, delete table tmp123 by running the following SQL: DROP TABLE tmp123;
    8. From server1, verify that table tmp123 was dropped by running the following SQL and verifying that tmp123 does NOT show up: SHOW TABLES LIKE 'tmp123%';
  Server_1 IP 192.168.0.1
database=databasename
Server_2 IP 192.168.0.2
database=databasename
Check the log files to make sure the files were created and time stamps are recent.  C:mysqldata

C:mysqldata>dir

02/22/2008 01:25 PM 57 relay-log.info

02/22/2008 09:12 PM 235 server-relay-bin.000043

02/22/2008 09:12 PM 26 server-relay-bin.index

02/22/2008 01:22 PM 17,642 server.err

02/22/2008 01:22 PM 5 server.pid

C:mysqldata>dir

02/22/2008 01:25 PM 57 relay-log.info

02/22/2008 09:12 PM 235 server-relay-bin.000043

02/22/2008 09:12 PM 26 server-relay-bin.index

02/22/2008 01:22 PM 17,642 server.err

02/22/2008 01:22 PM 5 server.pid


 

EZ2000 Plus Dental Software 800-273-5033