Install
apt install mariadb-server
Run the setup
mysql_secure_installation
Login to MariaDB
mysql
Create a new DB user. PDNS will use this user to query the DB.
CREATE USER 'pdns'@'localhost' IDENTIFIED BY '***********************';
Grant select
privilege on the pdns
DB to the pdns
user
GRANT SELECT ON pdns.* TO 'pdns'@'localhost';
Import the DB (that's a dump from the primary)
mysql -u root < mastersql_dump.sql
Modify the MariaDB /etc/mysql/mariadb.conf.d/50-server.cnf
config file. Make sure to set the server-id accordingly.
bind=0.0.0.0
[mariadb]
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
log_bin_index =/var/log/mysql/mysql-bin.log.index
relay_log = /var/log/mysql/mysql-relay-bin
relay_log_index = /var/log/mysql/mysql-relay-bin.index
Restart MariaDB
systemctl restart mariadb.service
Login to MariaDB
mysql
Stop the slave threads as shown below:
STOP SLAVE;
Setup the slave to replicate the master:
CHANGE MASTER TO MASTER_HOST='your-master-host-ip', MASTER_USER='replication', MASTER_PASSWORD='your-password', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=313;
Start the slave threads and show the slave status
START SLAVE;
SHOW SLAVE STATUS\G
Add PDNS repo. Use the official downloads page to find the repo you need.
echo "deb [arch=amd64] http://repo.powerdns.com/debian bullseye-auth-46 main" > /etc/apt/sources.list.d/pdns.list
Add APT preference
bash -c "cat > /etc/apt/preferences.d/pdns" <<EOF
Package: pdns-*
Pin: origin repo.powerdns.com
Pin-Priority: 600
EOF
Add the repo key
curl https://repo.powerdns.com/FD380FBB-pub.asc | apt-key add -
Install PDNS and PDNS MySQL Backend
apt update
apt install pdns-server pdns-backend-mysql
Stop PowerDNS
systemctl stop pdns.service
Remove the BIND config
rm /etc/powerdns/pdns.d/bind.conf
Create a new config file for the MySQL backend
vim /etc/powerdns/pdns.d/mysql.conf
Use the following config
# Define the gmysql backend
launch+=gmysql
# Details MariaDB database for PowerDNS
gmysql-host=127.0.0.1
gmysql-port=3306
gmysql-dbname=pdns
gmysql-user=pdns
gmysql-password=***********
gmysql-dnssec=yes
# gmysql-socket=
Modify the permissions of the new config file
chown pdns:pdns /etc/powerdns/pdns.d/mysql.conf
chmod 640 /etc/powerdns/pdns.d/mysql.conf
Start and check the status of PowerDNS
systemctl start pdns.service
systemctl status pdns.service