Replication

On master

  • In /etc/my.cnf, add these lines under [mysqld] section.
 log-bin=mysql-bin
 server-id=1
  • Restart server.
  • Run in mysql>
 CREATE USER 'mysql_repl'@'%.cehd.tamu.edu' IDENTIFIED BY 'PASSWORD';
 GRANT REPLICATION SLAVE ON *.* TO 'mysql_repl'@'%';
 flush tables with read lock;   /* this locks the tables - database inaccessible */
 show master status;
 | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
 +------------------+----------+--------------+------------------+
 | mysql-bin.000001 |   148940 |              |                  |
 quit /* this unlocks the tables */
  • If needed, do a fresh dump.

On slave

  • In /etc/my.cnf, add these lines under [mysqld] section.
 server-id=2
  • restart server
  • Run in mysql>
 change master to master_host='192.168.128.59',
 master_user = 'mysql_repl', master_password='PASSWORD', 
 master_log_file='mysql-bin.000001', master_log_pos=148940 ;
 show slave status;
 | Slave_IO_State   ...                
 -------------------
 | Waiting for master to send event ...
Taxonomy: