How to setup master and slave MyDNS server

Monday, 26 October 2009.

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

Master 192.168.0.101

Setup MyDNS master server – here

1. Configure mysql database on master server

1
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
 
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

2. Restart MySQL

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

3
4
5
6
7
8
9
10
11
12
13
14
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

15
16
cd /home/username
mysqldump -u root -p mydns --lock-all-tables > dbdump.db

5. Copy the dump to your slave server

17
scp dbdump.db username @ 192.168.0.102:~/.
Slave 192.168.0.102

6. Create mydns database

18
19
20
mysql -u root -p
mysql> CREATE DATABASE mydns;
mysql> exit

7. Configure mysql database on slave server

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

22
/etc/init.d/mysqld restart

9. Import the MySQL dump copied from the master

23
24
cd /home/username
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

25
26
27
28
29
mysql -u root -p
mysql> stop slave;
mysql> CHANGE MASTER TO MASTER_HOST='192.168.0.101', MASTER_USER='slave_user', 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

30
31
32
33
cd /usr/src
wget http://mydns.bboy.net/download/mydns-mysql-1.1.0-1.i386.rpm
rpm -ivh mydns-mysql-1.1.0-1.i386.rpm
/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.

34
vi /etc/mydns.conf
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

13. Turn on MyDNS and change the sequence of the startup scripts

35
36
37
38
39
40
41
/etc/init.d/mydns start
cd /etc/rc.d/rc3.d
mv S52mydns S99mydns
cd /etc/rc.d/rc4.d
mv S52mydns S99mydns
cd /etc/rc.d/rc5.d
mv S52mydns S99mydns

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WP Hashcash