powerdns 安裝部署備忘

來源:互聯網
上載者:User

PowerDNS

一種 DNS 伺服器, 優點, 支援 PHP 網頁管理, 支援直接在資料庫中添加 DNS 地址記錄, 比較靈活, 方便

 

參見資訊

主機名稱 PDNS 中記錄的主機名稱 本機 ip 地址 浮動 IP 位址 作業系統版本 備忘 1 備忘2   
gd02-qa-plxt2-nodomain.ddns.vclound.com pdnsweb.vclound.com 10.0.3.105 192.168.86.172 centOS 5.8 網頁伺服器(nginx, php)  NULL
gd02-qa-plx2-ddns-web-99.vclound.com pdnsdb.vclound.com 10.0.3.99 null centOS 6.5 pdns 伺服器+mysql5.5 NULL

 

下載 ddns 軟體包

http://downloads.powerdns.com/releases/pdns-3.3.1.tar.gz

下載網頁管理頁面

wget https://github.com/downloads/poweradmin/poweradmin/poweradmin-2.1.6.tgz

解壓至 /apps/dat/web 目錄下

[root@gd02-qa-plxt2-nodomain web]# cd /apps/dat/web[root@gd02-qa-plxt2-nodomain web]# tar xf poweradmin-2.1.6.tgz [root@gd02-qa-plxt2-nodomain web]# mv poweradmin-2.1.6 pdns


 

註明: 當前編譯方法只適合於我的生產環境, 各位可參考並進行自行調整

參見 下面 ddns-3.3.1.spec 檔案, 該 rpm 包整合了 pdns (程式) 與 poweradmin (網頁管理) 的自動安裝

 

程式名稱 安裝路徑 作用
poweradmin /apps/dat/web/pdns/ 網頁管理
pdns /apps/sh/pdns 啟動進程
NULL /apps/conf/pdns/pdns.sql 資料庫自動添加表指令碼
NULL /apps/conf/pdns/pdns.conf 設定檔
pdns_server /apps/lib/pdns-3.3.1/sbin/pdns_server 服務端程式

 

ddns-3.3.1.spec 檔案

Name: pdnsVersion: 3.3.1Release:    20140129.vipclound.centos65Summary:    use for monitor openstack VM.Group:          Applications/SystemLicense:        GPLURL:            http://downloads.powerdns.com/releases/pdns-3.3.1.tar.gzSource0:        pdns-3.3.1.tar.bz2BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)#BuildRequires:#Requires:%define _prefix                 /apps/svr/pdns-3.3.1%define _exec-prefix            /apps/svr/pdns-3.3.1%define _bindir                 /apps/svr/pdns-3.3.1/bin%define _sbindir                /apps/svr/pdns-3.3.1/sbin%define _sysconfdir             /apps/lib/pdns-3.3.1%define _includedir             /apps/lib/pdns-3.3.1%define _libexecdir             /apps/lib/pdns-3.3.1%define _infodir                /apps/lib/pdns-3.3.1%define _oldincludedir          /apps/lib/pdns-3.3.1%define _libdir                 /apps/lib/pdns-3.3.1%define _defaultdocdir          /apps/lib/pdns-3.3.1%define _docdir                 /apps/lib/pdns-3.3.1%define _mandir                 /apps/lib/pdns-3.3.1%define _datadir                /apps/lib/pdns-3.3.1%define _sharedstatedir         /apps/lib/pdns-3.3.1%define _localstatedir          /apps/lib/pdns-3.3.1%define _datarootdir            /apps/lib/pdns-3.3.1%define _infodir                /apps/lib/pdns-3.3.1%define _localedir              /apps/lib/pdns-3.3.1%define _htmldir                /apps/lib/pdns-3.3.1%define _dvidir                 /apps/lib/pdns-3.3.1%define _pdfdir                 /apps/lib/pdns-3.3.1%define _psdir                  /apps/lib/pdns-3.3.1%descriptionuse for dns server.%prep%setup -q%build%configure --enable-pdns_server --enable-tools --with-lua --with-boost=/usr  --enable-pdns_server --enable-tools --with-dynmodules="gmysql" --with-mysql=/apps/svr/mysqlsed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtoolsed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtoolmake %{?_smp_mflags}%installrm -rf %{buildroot}make install DESTDIR=%{buildroot}mkdir %{buildroot}/apps/dat/web/pdns -pmkdir %{buildroot}/apps/sh -pmkdir %{buildroot}/apps/conf/pdns -pmkdir %{buildroot}/apps/run/zabbix -pcp -rp $RPM_BUILD_DIR/pdns-3.3.1/padmin/*  %{buildroot}/apps/dat/web/pdns/.cp -rp $RPM_BUILD_DIR/pdns-3.3.1/conf/pdns.conf  %{buildroot}/apps/conf/pdns/pdns.confcp -rp $RPM_BUILD_DIR/pdns-3.3.1/sh/pdns  %{buildroot}/apps/sh/pdnscp -rp $RPM_BUILD_DIR/pdns-3.3.1/conf/pdns.sql  %{buildroot}/apps/conf/pdns/pdns.sql%cleanrm -rf %{buildroot}%files%defattr(-,root,root,-)%doc%config /apps/dat/web/pdns/*%config /apps/conf/pdns/pdns.conf%config /apps/sh/pdns%config /apps/conf/pdns/pdns.sql%{_libdir}/*%{_mandir}/man8/*%{_bindir}/*%{_sbindir}/*%changelog* Wed Jan 29 2014 terrytsang  <signmem@hotmail.com>-- use for vipclound.com ddns service


注:
lnmp 架構編譯(忽略描述)
所有的軟體, 庫檔案都安裝到 /apps 與 /apps/lib 目錄中
當前使用 mysql-5.5 版本

 

1. 安裝依賴包

yum install -y lua-devel.x86_64 boost-devel


2. rpm 方法安裝 pdns (注意使用 --nodeps 參數)

[root@gd02-qa-plx2-ddns-web-99 ~]# rpm -ivh  --nodeps pdns-3.3.1-20140128.vipclound.centos65.x86_64.rpmPreparing...                ########################################### [100%]   1:pdns                   ########################################### [100%]

3.  參見下面編譯時間的 $SOURCE/sh/pdns 檔案

#!/bin/sh# chkconfig: - 80 75# description: PDNS is a versatile high performance authoritative nameserver### BEGIN INIT INFO# Provides:          pdns# Required-Start:    $remote_fs $network $syslog# Required-Stop:     $remote_fs $network $syslog# Should-Start:# Should-Stop:# Default-Start:     2 3 4 5# Default-Stop:      0 1 6# Short-Description: PowerDNS authoritative server# Description:       PowerDNS authoritative server### END INIT INFOset -econfigdir=/apps/conf/pdnsprefix=/apps/svr/pdns-3.3.1exec_prefix=${prefix}BINARYPATH=${exec_prefix}/binSBINARYPATH=${exec_prefix}/sbinSOCKETPATH=/apps/run/pdns/[ -f "$SBINARYPATH/pdns_server" ] || exit 0[ -r /etc/default/pdns ] && . /etc/default/pdnscd $SOCKETPATHsuffix=$(basename $0 | cut -d- -f2- -s)if [ -n "$suffix" ]then        EXTRAOPTS=--config-name=$suffix        PROGNAME=pdns-$suffixelse        PROGNAME=pdnsfipdns_server="$SBINARYPATH/pdns_server $EXTRAOPTS" doPC(){        ret=$($BINARYPATH/pdns_control $EXTRAOPTS $1 $2 2> /dev/null)}NOTRUNNING=0doPC ping || NOTRUNNING=$?case "$1" in        status)                if test "$NOTRUNNING" = "0"                 then                        doPC status                        echo $ret                else                        echo "not running"                         exit 3                fi        ;;        stop)                echo -n "Stopping PowerDNS authoritative nameserver: "                 if test "$NOTRUNNING" = "0"                 then                        doPC quit                        echo $ret                else                        echo "not running"                 fi        ;;        force-stop)                echo -n "Stopping PowerDNS authoritative nameserver: "                 killall -v -9 pdns_server                echo "killed"         ;;        start)                echo -n "Starting PowerDNS authoritative nameserver: "                 if test "$NOTRUNNING" = "0"                 then                        echo "already running"                 else                        if $pdns_server --daemon --guardian=yes --config-dir=$configdir                        then                                echo "started"                         else                                echo "starting failed"                                 exit 1                        fi                fi        ;;        force-reload | restart)                echo -n "Restarting PowerDNS authoritative nameserver: "                 if test "$NOTRUNNING" = "1"                 then                        echo "not running, starting"                 else                        echo -n stopping and waiting..                        doPC quit                        sleep 3                        echo done                fi                $0 start        ;;        reload)                echo -n "Reloading PowerDNS authoritative nameserver: "                 if test "$NOTRUNNING" = "0"                 then                        doPC cycle                        echo requested reload                else                        echo not running yet                        $0 start                fi        ;;        monitor)                if test "$NOTRUNNING" = "0"                 then                        echo "already running"                 else                        $pdns_server --daemon=no --guardian=no --control-console --loglevel=9                fi        ;;        dump)                if test "$NOTRUNNING" = "0"                 then                        doPC list                        echo $ret                else                        echo "not running"                 fi        ;;        show)                if [ $# -lt 2 ]                then                        echo Insufficient parameters                        exit                fi                if test "$NOTRUNNING" = "0"                 then                        echo -n "$2="                         doPC show $2 ; echo $ret                else                        echo "not running"                 fi        ;;        mrtg)                if [ $# -lt 2 ]                then                        echo Insufficient parameters                        exit                fi                if test "$NOTRUNNING" = "0"                 then                        doPC show $2 ; echo $ret                        if [ "$3x" != "x" ]                        then                                doPC show $3 ; echo $ret                        else                                echo 0                        fi                        doPC uptime ; echo $ret                        echo PowerDNS daemon                else                        echo "not running"                 fi        ;;        cricket)                if [ $# -lt 2 ]                then                        echo Insufficient parameters                        exit                fi                if test "$NOTRUNNING" = "0"                 then                        doPC show $2 ; echo $ret                else                        echo "not running"                 fi        ;;        *)        echo pdns [start\|stop\|force-reload\|reload\|restart\|status\|dump\|show\|mrtg\|cricket\|monitor]        ;;esac

檔案已修複之前上一版本不可以正常啟動 PDNS 問題

安裝後啟動方法

/apps/sh/pdns start


關閉

/apps/sh/pdns stop

4. 確保系統中使用到 mysqlclient.18.0 庫檔案, 資料庫授權並匯入 sql 指令碼

*授權 pdns 使用者能夠訪問 pdns 資料庫

mysql> create database pdns;Query OK, 1 row affected (0.00 sec)mysql> grant all on pdns.* to 'pdns'@'localhost' identified by 'pdns';Query OK, 0 rows affected (0.00 sec)mysql> grant all on pdns.* to 'pdns'@'127.0.0.1' identified by 'pdns';Query OK, 0 rows affected (0.00 sec)mysql> grant all on pdns.* to 'pdns'@'0.0.0.0' identified by 'pdns';Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)

2. 確保系統中使用到 mysqlclient.18.0 庫檔案, 資料庫授權並匯入 sql 指令碼

*授權 pdns 使用者能夠訪問 pdns 資料庫

mysql> create database pdns;Query OK, 1 row affected (0.00 sec)mysql> grant all on pdns.* to 'pdns'@'localhost' identified by 'pdns';Query OK, 0 rows affected (0.00 sec)mysql> grant all on pdns.* to 'pdns'@'127.0.0.1' identified by 'pdns';Query OK, 0 rows affected (0.00 sec)mysql> grant all on pdns.* to 'pdns'@'0.0.0.0' identified by 'pdns';Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)

 

匯入 pdns 所需要的 sql

[root@station140 mysql5]# /apps/svr/mysql5/bin/mysql -u pdns -ppdns pdns <  /apps/conf/pdns/pdns.sql

5. 配置 pdns 伺服器
/apps/conf/pdns/pdns.conf

daemon=yesrecursor=192.168.86.37launch=gmysqlgmysql-host=127.0.0.1gmysql-user=pdnsgmysql-dbname=pdnsgmysql-password=pdns

6. 啟動 pdns 伺服器

/apps/sh/pdns start

 

7. 測試方法

 a. 檢測連接埠 53/tcp 是否使用中 b. 檢測防火牆關閉, selinux 關閉 c. /etc/resolv.conf 是否指向自己 d. nslookup localhost 是否能夠返回 127.0.0.1

8. nginx 啟動配置忽略, 但需要吧 webroot 指向 /app/dat/web 下

 

9. 配置  php
只修改下面 /apps/conf/php5/php.ini 兩部分

session.save_path = "/tmp/session" date.timezone Asia/Chongqing

 

執行命令

mkdir /tmp/sessionchown apps:apps /tmp/session


10. 啟動 nginx,  (啟動 php 略)

[root@gd02-qa-plxt2-nodomain /]# lsof -i:80COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAMEnginx   3105 root    7u  IPv4  42727      0t0  TCP *:http (LISTEN)nginx   3106 apps    7u  IPv4  42727      0t0  TCP *:http (LISTEN)

可通過介面方法進行組態管理





 








上述抓圖用於 POWERADMIN 對 PDNS 安裝

安裝完成後可看見這個管理頁面

 


添加主域

 



添加反向域

 


添加主機記錄方法






調用 ADD RECORD 按鈕可以添加多個網域名稱

 

完成資料添加後可馬上調用 nslookup 進行驗證. 非常方便

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.