03Mariadb - amagerard/PowerDNS GitHub Wiki
1- Network | 2- Pdns | 3- Mariadb | 4- PowerAdmin | 5- PdnsRecursor | 6- Selinux |
---|---|---|---|---|---|
7- GnomeShell | 8-Synoptic | 09-ManageDns | 10-Update |
Mariadb update added to the repositories.
curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | bash
dnf update
dnf install MariaDB-server
systemctl enable --now mariadb
It is the version MariaDB 11.6.2.
The mysql command is replaced by mariadb.
If you want to use the MySQL command, you must install MariaDB-client-compat.
Secure MariaDB.
Example for root password: XTG56AB50!
mariadb-secure-installation
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Switch to unix_socket authentication [Y/n] n
Change the root password? [Y/n] y
New password:XTG56AB50!
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
... Success!
Example: create the powerdns database and adminpdns@locahost password: 641fqAB4d
mariadb -u root -e "create database powerdns;"
mariadb -u root -e "CREATE USER 'adminpdns'@'localhost' IDENTIFIED BY '641fqAB4d';"
mariadb -u root -e "grant all privileges on *.* to adminpdns@localhost;"
mariadb -u root -e "flush privileges;"
It is for version pdns 4.7. and more.
The tables have changed.
Be careful if you had pdns 4.6 for one upgrade to 4.7.
Connect to mariadb as a user with sufficient privileges and issue the following commands.
mariadb -u root -p
use powerdns ;
Copy and paste.
Be careful if there is an error you will have to start all over again.
CREATE TABLE domains (
id INT AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(8) NOT NULL,
notified_serial INT UNSIGNED DEFAULT NULL,
account VARCHAR(40) CHARACTER SET 'utf8' DEFAULT NULL,
options VARCHAR(64000) DEFAULT NULL,
catalog VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';
CREATE UNIQUE INDEX name_index ON domains(name);
CREATE INDEX catalog_idx ON domains(catalog);
CREATE TABLE records (
id BIGINT AUTO_INCREMENT,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(10) DEFAULT NULL,
content VARCHAR(64000) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
disabled TINYINT(1) DEFAULT 0,
ordername VARCHAR(255) BINARY DEFAULT NULL,
auth TINYINT(1) DEFAULT 1,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
CREATE INDEX ordername ON records (ordername);
CREATE TABLE supermasters (
ip VARCHAR(64) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) CHARACTER SET 'utf8' NOT NULL,
PRIMARY KEY (ip, nameserver)
) Engine=InnoDB CHARACTER SET 'latin1';
CREATE TABLE comments (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
type VARCHAR(10) NOT NULL,
modified_at INT NOT NULL,
account VARCHAR(40) CHARACTER SET 'utf8' DEFAULT NULL,
comment TEXT CHARACTER SET 'utf8' NOT NULL,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';
CREATE INDEX comments_name_type_idx ON comments (name, type);
CREATE INDEX comments_order_idx ON comments (domain_id, modified_at);
CREATE TABLE domainmetadata (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
kind VARCHAR(32),
content TEXT,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';
CREATE INDEX domainmetadata_idx ON domainmetadata (domain_id, kind);
CREATE TABLE cryptokeys (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
flags INT NOT NULL,
active BOOL,
published BOOL DEFAULT 1,
content TEXT,
PRIMARY KEY(id)
) Engine=InnoDB CHARACTER SET 'latin1';
CREATE INDEX domainidindex ON cryptokeys(domain_id);
CREATE TABLE tsigkeys (
id INT AUTO_INCREMENT,
name VARCHAR(255),
algorithm VARCHAR(50),
secret VARCHAR(255),
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';
CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);
To display all tables.
MariaDB [powerdns]>show tables;
+--------------------+
| Tables_in_powerdns |
+--------------------+
| comments |
| cryptokeys |
| domainmetadata |
| domains |
| records |
| supermasters |
| tsigkeys |
+--------------------+
7 rows in set (0.00 sec
vi /etc/pdns/pdns.conf
Add to end of file.
launch=gmysql
#gmysql parameters
gmysql-host=127.0.0.1
gmysql-port=3306
gmysql-dbname=powerdns
gmysql-user=adminpdns
gmysql-password=641fqAB4d
We now have a database and an empty table.
PowerDNS should now be able to launch in monitor mode and
display no errors.
Stopping the pdns service.
systemctl stop pdns
Start in monitor mode.
/usr/sbin/pdns_server --daemon=no --guardian=no --loglevel=9
gmysql Connection successful. Connected to database 'powerdns' on '127.0.0.1'
"Normal" start pdns.
systemctl start pdns
Save the powerdns database.
mariadb-dump -u root -p powerdns > backup_powerdns.sql
Restore the powerdns database.
mariadb -u root -p powerdns < backup_powerdns.sql