Tag Archives: Database

MySQL Replication

Setting MySQL Master

  1. Modify my.cnf (usually located in /etc/mysql/my.cnf)
    1. Update bind-address entry from 127.0.0.1 to the regular IP
      • bind-address = 127.0.0.1
      • bind-address = 123.234.12.13
    2. Set server-id to 1
    3. Uncomment the line with log_bin
    4. Designate the database to be replicated on to the slave server
      • binlog_do_db = db_to_replicate
    5. Save my.cnf and restart mysql
  2. Grant privileges to the slave (mysql command line)
    • GRANT REPLICATION SLAVE ON *.* to ‘slave_user’@’%’ IDENTIFIED BY ‘password’;
    • FLUSH PRIVILEGES;
  3. ss

Setting MySQL Slave

  1. Modify my.cnf
    1. Set server-id to 2
    2. relay-log = /var/log/mysql/mysql-relate-bin.log (need to be added manually)
    3. log_bin = /var/log/mysql/mysql-bin.log
    4. binlog_do_db = <newdatabase>
  2. Set pw

– manzoor

Related Reading

Advertisement

DB Programming

DB not limited to MySQL and Postgress but includes Redis, MongoDB, elasticsearch etc.

The goal is to find the lowest possible tool – i.e., scheel commands would be the lowest and dedicated DB tool would be the highest. Python, Ruby, PHP would be on the lower end of the middle and Java would be on the higher.

– manzoor