MySQL master-slave

  1. On master add to /etc/mysql/my.cnf
    log-bin=mysql-bin
    server-id                       = 1
    innodb_flush_log_at_trx_commit  = 1
    sync_binlog                     = 1
    
  2. On slave add to /etc/mysql/my.cnf
    server-id               = 2
    read-only
  3. On master create replication user and get log status (will need in 7th step)
    CREATE USER 'slave-user'@'slaveIP' IDENTIFIED BY 'slavePass';
    GRANT REPLICATION SLAVE ON *.* TO 'slave-user'@'slaveIP';
    FLUSH TABLES WITH READ LOCK;
    SHOW MASTER STATUS;
  4. Dump databases on master
  5. Unlock tables on master
    UNLOCK TABLES;
  6. Import databases on slave
  7. Set master configuration on slave
    STOP SLAVE;
    CHANGE MASTER TO
      MASTER_HOST='masterIP',
      MASTER_USER='slave-user',
      MASTER_PASSWORD='slavePass',
      MASTER_LOG_FILE='mysql-bin.000062',
      MASTER_LOG_POS=107;
    START SLAVE;
    

© 2003-24 iNeta d.o.o. | Koroška cesta 31, SI-4000 Kranj | info@ineta.si | Pravno obvestilo
Powered by BravoCMS