master slave

6
How to setup master and slave MyDNS server Quote; MyDNS is a free DNS server for UNIX. Master and slave setup is done using MySQL. http://mydns.bboy.net For the below tutorial MyDNS server resides at 192.168.0.101 and slave at 192.168.0.102 Master 192.168.0.101 1. Setup MyDNS master server - here 2. Configure mysql database on master server centos$ vi /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Default to using old password format for compatibility with mysql 3.x # clients (those using the mysqlclient10 compatibility package). old_passwords=1 log-bin = mysql-bin binlog-do-db=mydns server-id=1 [mysql.server] user=mysql basedir=/var/lib http://www.tuxoz.com - www.tuxoz.com Powered by Mambo Generated:20 January, 2009, 02:10

Upload: rajesh-sharma

Post on 10-Apr-2015

107 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Master Slave

How to setup master and slave MyDNS server

Quote; MyDNS is a free DNS server for UNIX. Master and slave setup is done using MySQL. http://mydns.bboy.net

 

 

For the below tutorial MyDNS server resides at 192.168.0.101 and slave at 192.168.0.102

Master 192.168.0.101

1. Setup MyDNS master server - here

2. Configure mysql database on master server centos$ vi /etc/my.cnf

[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Default to using old password format for compatibility with mysql 3.x # clients (those using the mysqlclient10 compatibility package). old_passwords=1

log-bin = mysql-bin binlog-do-db=mydns server-id=1

[mysql.server] user=mysql basedir=/var/lib http://www.tuxoz.com - www.tuxoz.com Powered by Mambo Generated:20 January, 2009, 02:10

Page 2: Master Slave

[mysqld_safe] err-log=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid

2. Restart MySQL centos$ /etc/init.d/mysqld restart

3. Login to MySQL and grant slave privileges, remember the following data needed for slave configuration MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS= 79 centos$ mysql -u root -p mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY 'slave_password'; mysql> use mydns; mysql> FLUSH TABLES WITH READ LOCK; mysql> SHOW MASTER STATUS; mysql> +------------------+----------+--------------+------------------+ mysql> | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | mysql> +------------------+----------+--------------+------------------+ mysql> | mysql-bin.000002 | 79 | mydns | | mysql> +------------------+----------+--------------+------------------+ mysql> 1 row in set (0.00 sec) mysql> exit

4. Change to home directory and perform a mysql dump centos$ cd /home/username centos$ mysqldump -u root -p mydns --lock-all-tables > dbdump.db http://www.tuxoz.com - www.tuxoz.com Powered by Mambo Generated:20 January, 2009, 02:10

Page 3: Master Slave

5.Copy the dump to your slave server centos$ scp dbdump.db username @ 192.168.0.102:~/.

 

Slave 192.168.0.102

6. Create mydns database centos$ mysql -u root -p mysql> CREATE DATABASE mydns; mysql> exit

7. Configure mysql database on slave server centos$ vi /etc/my.cnf

[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Default to using old password format for compatibility with mysql 3.x # clients (those using the mysqlclient10 compatibility package). old_passwords=1

server-id=2 http://www.tuxoz.com - www.tuxoz.com Powered by Mambo Generated:20 January, 2009, 02:10

Page 4: Master Slave

master-host=192.168.0.101 master-user=slave_user master-password=slave_password master-connect-retry=60 replicate-do-db=mydns

[mysql.server] user=mysql basedir=/var/lib

[mysqld_safe] err-log=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid

8. Reload MySQL centos$ /etc/init.d/mysqld restart

9. Import the MySQL dump copied from the master centos$ cd /home/username centos$ mysql -u root -p mydns < dbdump.db

10. Login to MySQL stop slave, configure it and start it up make sure to use correct date for the following - MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS= 79 centos$ mysql -u root -p mysql> stop slave; mysql> CHANGE MASTER TO MASTER_HOST='192.168.0.101', MASTER_USER='slave_user',http://www.tuxoz.com - www.tuxoz.com Powered by Mambo Generated:20 January, 2009, 02:10

Page 5: Master Slave

MASTER_PASSWORD='slave_password', MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS= 79; mysql> start slave; mysql> exit

11. Download MyDNS, install the RPM and configure to turn it on at startup centos$ cd /usr/src centos$ wget http://mydns.bboy.net/download/mydns-mysql-1.1.0-1.i386.rpm centos$ rpm -ivh mydns-mysql-1.1.0-1.i386.rpm centos$ /sbin/chkconfig --levels 235 mydns on

12. Edit mydns.conf, change username and password and add the following lines to the end of the file.

db-host = localhost # SQL server hostname db-user = username # SQL server username db-password = password # SQL server password database = mydns # MyDNS database name

allow-axfr = yes allow-tcp = yes recursive = 123.456.789.012 # Location of recursive resolver centos$ vi /etc/mydns.conf

13. Turn on MyDNS and change the sequence of the startup scripts centos$ /etc/init.d/mydns start http://www.tuxoz.com - www.tuxoz.com Powered by Mambo Generated:20 January, 2009, 02:10

Page 6: Master Slave

centos$ cd /etc/rc.d/rc3.d centos$ mv S52mydns S99mydns centos$ cd /etc/rc.d/rc4.d centos$ mv S52mydns S99mydns centos$ cd /etc/rc.d/rc5.d centos$ mv S52mydns S99mydns

http://www.tuxoz.com - www.tuxoz.com Powered by Mambo Generated:20 January, 2009, 02:10