Master Slave

Download as pdf or txt
Download as pdf or txt
You are on page 1of 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


[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


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


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
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


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

You might also like