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-mysqlNow we can create the database and its structure. Connect to the MySQL server with a poweruser:
mysql -u USERNAME -pCreate 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';Next create the tables:
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;
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=powerdnsOn both server make sure MySQL and PowerDNS will startup at boot time:
/sbin/chkconfig --levels 2345 mysql on
/sbin/chkconfig --levels 2345 pdns on
