mysql slaving

  • install MySQL on all boxes
  • add the slave repl users@ips into mysql on the master
  • Install percona-xtrabackup and run it on the master

    1
    mkdir /root/bak; innobackupex --user=root --password=blahblah /root/bak
  • apply the log

    1
    innobackupex --user=root --password=blahblah --apply-log /root/bak/$date/
  • copy the backup over to the slaves

  • stop mysql and mv the copy over

    1
    service mysql stop; mv /var/lib/mysql{,.old}; mv /root/bak/$date /var/lib/mysql; chown -R mysql. /var/lib/mysql; service mysql start</pre>
  • Grab the position and binlog name innobackup provided in /var/lib/mysql/xtrabackup_binlog_info

  • Set the master on the slaves

    1
    mysql> CHANGE MASTER TO   MASTER_HOST='$master_ip', MASTER_USER='repl', MASTER_PASSWORD='something', MASTER_PORT=3306,   MASTER_LOG_FILE='mysql-bin.$number', MASTER_LOG_POS=$position,   MASTER_CONNECT_RETRY=10
  • start the slaving

    1
    mysql> slave start
  • Watch the seconds behind counter on the slave

    1
    mysql -e 'show slave status\G'