High available DNS with PowerDNS and MySQL

PDF
PowerDNS is an advanced high performance authoritative nameserver and can work with several backends. We will setup PowerDNS on two servers both will read the DNS records from a MySQL database replicated backend. As MySQL will do the replication, PowerDNS doesn't need zone transfers. To setup MySQL replication please read this article published in the MySQL section of this website. Make sure MySQL is setup to use the InnoDB storage engine. To install PowerDNS from the EPEL repository. If you haven't setup the EPEL repository follow the instructions explained on their website.
yum install yum install pdns pdns-backend-mysql
Now we can create the database and its structure. Connect to the MySQL server with a poweruser:
mysql -u USERNAME -p
Create the database:
CREATE DATABASE powerdns;
Create a separate user (powerdns_admin) for the PowerDNS database:
GRANT SELECT ON supermasters TO 'powerdns_admin'@'127.0.0.1' IDENTIFIED BY 'PASSWORD';
GRANT ALL ON domains TO 'powerdns_admin'@'127.0.0.1' IDENTIFIED BY 'PASSWORD';
GRANT ALL ON records TO 'powerdns_admin'@'127.0.0.1' IDENTIFIED BY 'PASSWORD';
FLUSH PRIVILEGES;
Next create the tables:
create table domains (
 id     INT auto_increment,
 name     VARCHAR(255) NOT NULL,
 master     VARCHAR(128) DEFAULT NULL,
 last_check   INT DEFAULT NULL,
 type     VARCHAR(6) NOT NULL,
 notified_serial INT DEFAULT NULL, 
 account         VARCHAR(40) DEFAULT NULL,
 primary key (id)
)type=InnoDB;
CREATE UNIQUE INDEX name_index ON domains(name);
CREATE TABLE records (
CONSTRAINT `records_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `domains`
(`id`) ON DELETE CASCADE,
  id              INT auto_increment,
  domain_id       INT DEFAULT NULL,
  name            VARCHAR(255) DEFAULT NULL,
  type            VARCHAR(6) DEFAULT NULL,
  content         VARCHAR(255) DEFAULT NULL,
  ttl             INT DEFAULT NULL,
  prio            INT DEFAULT NULL,
  change_date     INT DEFAULT NULL,
  primary key(id)
)type=InnoDB;
CREATE INDEX domain_id ON records(domain_id);
create table supermasters (
  ip VARCHAR(25) NOT NULL,
  nameserver VARCHAR(255) NOT NULL,
  account VARCHAR(40) DEFAULT NULL
);
Now create the indexes:
CREATE INDEX rec_name_index ON records(name);
CREATE INDEX nametype_index ON records(name,type);
As we have a MySQL master/slave replication the database and table should also be on the slave server. Next on both server edit /etc/powerdns/pdns.conf on and add or edit the lines:
deamon=yes
launch=gmysql
gmysql-host=127.0.0.1
gmysql-user=powerdns_admin
gmysql-password=PASSWORD
gmysql-dbname=powerdns
On both server make sure MySQL and PowerDNS will startup at boot time:
/sbin/chkconfig --levels 2345 mysql on
/sbin/chkconfig --levels 2345 pdns on

 

Please login first before adding a comment.

Search






You are here: Home Howtos and FAQs DNS High available DNS with PowerDNS and MySQL