[root@ops-tmp-app-2~]#cat/etc/redhat-release
CentOSLinuxrelease7.4.1708(Core)
[root@ops-tmp-app-2~]#getenforce
Disabled
[root@ops-tmp-app-2~]#systemctlstatusfirewalld.service
●firewalld.service-firewalld-dynamicfirewalldaemon
Loaded:loaded(/usr/lib/systemd/system/firewalld.service;disabled;vendorpreset:enabled)
Active:inactive(dead)
Docs:man:firewalld(1)
第2章安装pdns
yuminstall-ypdnspdns-backend-mysql
[root@ops-tmp-app-2~]#rpm-qa|greppdns
pdns-4.0.6-2.el7.x86_64
pdns-backend-mysql-4.0.6-2.el7.x86_64
启动pdns就可以了,这里粘贴一下配置文件
[root@ops-tmp-app-2PowerDNS-Admin]#cat/etc/pdns/pdns.conf
api=yes
api-key=changeme
api-logfile=/var/log/pdns.log
cache-ttl=20
daemon=yes
default-ttl=30
guardian=no
launch=gmysql
gmysql-host=10.3.2.15
gmysql-port=3306
gmysql-user=powerdns
gmysql-dbname=powerdns
gmysql-password=powerdns
local-address=10.3.2.15
master=yes
setgid=pdns
setuid=pdns
webserver=yes
webserver-address=0.0.0.0
webserver-allow-from=0.0.0.0/0
webserver-port=8081
write-pid=yes
allow-axfr-ips=10.3.2.15,10.3.2.5
also-notify=10.3.2.15,10.3.2.5
only-notify=10.3.2.15,10.3.2.5
slave=no
slave-cycle-interval=60
log-dns-details=yes
log-dns-queries=yes
loglevel=6pdns日志默认输出到message的系统日志中了,调试中可以把日志打印级别开大一点
第3章后端数据库配置
3.1数据库安装
yuminstallmariadb-servermariadb–y
systemctlenablemariadb.service
systemctlstartmariadb.service
3.2设置密码
mysql_secure_installation
首先是设置密码,会提示先输入密码
Enter current password for root (enter for none):<–初次运行直接回车
Set root password [Y/n] <–是否设置root用户密码,输入y并回车或直接回车
New password: <–设置root用户的密码(比如123456)
Re-enter new password: <–再输入一次你设置的密码
3.3其他配置
Remove anonymous users [Y/n] <–是否删除匿名用户,回车
Disallow root login remotely [Y/n] <–是否禁止root远程登录,回车,
Remove test database and access to it [Y/n] <–是否删除test数据库,回车
Reload privilege tables now [Y/n] <–是否重新加载权限表,回车
3.4统一字符集
->首先是配置文件/etc/my.cnf,在[mysqld]标签下添加
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
->接着配置文件/etc/my.cnf.d/client.cnf,在[client]中添加
default-character-set=utf8
->然后配置文件/etc/my.cnf.d/mysql-clients.cnf,在[mysql]中添加
default-character-set=utf8
systemctl restart mariadb.service
3.5创建数据
[root@ops-tmp-app-2~]#mysql-p123456
WelcometotheMariaDBmonitor.Commandsendwith;org.
YourMariaDBconnectionidis2
Serverversion:5.5.60-MariaDBMariaDBServer
Copyright(c)2000,2018,Oracle,MariaDBCorporationAbandothers.
Type'help;'or'h'forhelp.Type'c'toclearthecurrentinputstatement.
MariaDB[(none)]>source/root/pdns.sql
Sql文件的内容如下,复制一下自己创建sql文件即可
CREATEDATABASEpowerdns;
GRANTALLONpowerdns.*TO'powerdns'@'10.3.%'IDENTIFIEDBY'powerdns';
FLUSHPRIVILEGES;
usepowerdns;
CREATETABLEdomains(
idINTAUTO_INCREMENT,
nameVARCHAR(255)NOTNULL,
masterVARCHAR(128)DEFAULTNULL,
last_checkINTDEFAULTNULL,
typeVARCHAR(6)NOTNULL,
notified_serialINTDEFAULTNULL,
accountVARCHAR(40)DEFAULTNULL,
PRIMARYKEY(id)
)Engine=InnoDB;
CREATEUNIQUEINDEXname_indexONdomains(name);
CREATETABLErecords(
idBIGINTAUTO_INCREMENT,
domain_idINTDEFAULTNULL,
nameVARCHAR(255)DEFAULTNULL,
typeVARCHAR(10)DEFAULTNULL,
contentVARCHAR(64000)DEFAULTNULL,
ttlINTDEFAULTNULL,
prioINTDEFAULTNULL,
change_dateINTDEFAULTNULL,
disabledTINYINT(1)DEFAULT0,
ordernameVARCHAR(255)BINARYDEFAULTNULL,
authTINYINT(1)DEFAULT1,
PRIMARYKEY(id)
)Engine=InnoDB;
CREATEINDEXnametype_indexONrecords(name,type);
CREATEINDEXdomain_idONrecords(domain_id);
CREATEINDEXrecordorderONrecords(domain_id,ordername);
CREATETABLEsupermasters(
ipVARCHAR(64)NOTNULL,
nameserverVARCHAR(255)NOTNULL,
accountVARCHAR(40)NOTNULL,
PRIMARYKEY(ip,nameserver)
)Engine=InnoDB;
CREATETABLEcomments(
idINTAUTO_INCREMENT,
domain_idINTNOTNULL,
nameVARCHAR(255)NOTNULL,
typeVARCHAR(10)NOTNULL,
modified_atINTNOTNULL,
accountVARCHAR(40)NOTNULL,
commentVARCHAR(64000)NOTNULL,
PRIMARYKEY(id)
)Engine=InnoDB;
CREATEINDEXcomments_domain_id_idxONcomments(domain_id);
CREATEINDEXcomments_name_type_idxONcomments(name,type);
CREATEINDEXcomments_order_idxONcomments(domain_id,modified_at);
CREATETABLEdomainmetadata(
idINTAUTO_INCREMENT,
domain_idINTNOTNULL,
kindVARCHAR(32),
contentTEXT,
PRIMARYKEY(id)
)Engine=InnoDB;
CREATEINDEXdomainmetadata_idxONdomainmetadata(domain_id,kind);
CREATETABLEcryptokeys(
idINTAUTO_INCREMENT,
domain_idINTNOTNULL,
flagsINTNOTNULL,
activeBOOL,
contentTEXT,
PRIMARYKEY(id)
)Engine=InnoDB;
CREATEINDEXdomainidindexONcryptokeys(domain_id);
CREATETABLEtsigkeys(
idINTAUTO_INCREMENT,
nameVARCHAR(255),
algorithmVARCHAR(50),
secretVARCHAR(255),
PRIMARYKEY(id)
)Engine=InnoDB;
CREATEUNIQUEINDEXnamealgoindexONtsigkeys(name,algorithm);
flushprivileges;
第4章安装powerDNS-admin的web管理界面
这里没有使用官方提供的poweradmin,是基于LAMP的,太重,部署很不方便
4.1为powerDNS-admin准备数据库和用户
MariaDB[(none)]>CREATEDATABASEpowerdnsadminCHARACTERSETutf8COLLATEutf8_general_ci;
QueryOK,1rowaffected(0.00sec)
MariaDB[(none)]>GRANTALLPRIVILEGESONpowerdnsadmin.*TO'pdnsadminuser'@'%'IDENTIFIEDBY'p4ssw0rd';
QueryOK,0rowsaffected(0.00sec)
MariaDB[(none)]>FLUSHPRIVILEGES;
QueryOK,0rowsaffected(0.00sec)
4.2克隆powerDNS-admin代码
gitclone
https://github.com/ngoduykhanh/PowerDNS-Admin.git
4.3进入主目录修改.env配置文件,配置数据库连接信息
[root@ops-tmp-app-2PowerDNS-Admin]#cat.env
ENVIRONMENT=development
PDA_DB_HOST=10.3.2.15
PDA_DB_NAME=powerdnsadmin
PDA_DB_USER=pdnsadminuser
PDA_DB_PASSWORD=p4ssw0rd
PDA_DB_PORT=3306
PDNS_DB_HOST=10.3.2.15
PDNS_DB_NAME=powerdns
PDNS_DB_USER=powerdns
PDNS_DB_PASSWORD=powerdns
PDNS_HOST=10.3.2.15
PDNS_API_KEY=changeme
PDNS_WEBSERVER_ALLOW_FROM=0.0.0.0
4.4使用docker-compose构建
docker-composebuild
4.5启动容器
docker-compose up
PS:只要powerdns-admin这个容器起来就可以了,其他都可以忽略或者直接干掉,因为数据库是使用自己的,没用compose文件中构建的
[root@ops-tmp-app-2 PowerDNS-Admin]# docker ps
CONTAINER IDIMAGECOMMANDCREATEDSTATUSPORTSNAMES
56b74d880448powerdns-admin"/entrypoint.sh"6 days agoUp 1 second0.0.0.0:9191->9191/tcppowerdns-admin
打开浏览器访问9191端口就可以了