OpenSUSE 12.1 에서 powerdns 3.2 & pdns_gui with MySQL backend 설치/설정 과정 정리


[사전 환경 점검]

- DB server: MySQL(5.1 or 5.5) 설치

- Web server: 

  Apache2 + php + poweradmin 2.1.6 or pdns gui 0.3.3

  또는 lighttpd with php(php-fpm)(http://bryans.tistory.com/76, http://bryans.tistory.com/77 참고) + poweradmin 2.1.6


* 본 문서에서는 pdns 3.2 + MySQL(Percona 5.5.*) + Apache2 + php + pdns gui 0.3.3 을 채택한다


[pdns 3.2 설치]


1. libz.so 소프트 링크 설정


# cd /lib64/

# ln -s libz.so.1 libz.so

# ldconfig

# ls -l /lib64/libz.so*

lrwxrwxrwx 1 root root     9 Feb  8 15:34 /lib64/libz.so -> libz.so.1

lrwxrwxrwx 1 root root    13 Apr  1  2012 /lib64/libz.so.1 -> libz.so.1.2.5

-rwxr-xr-x 1 root root 96488 Feb  9  2012 /lib64/libz.so.1.2.5


2. MySQL, LUA 를 위한 라이브러리 설정


# zypper in -y libmysqlclient18 libmysqlclient-devel libmysqlclient18-32bit  libmysqlclient_r18 libmysqlclient_r18-32bit gcc-c++ boost-devel

# zypper in -y lua lua-devel


3. pdns 3.2 소스 다운로드 및 설치

설치 디렉토리는 /user/service/powerDNS 로 가정


# cd /user/service/download

# wget http://downloads.powerdns.com/releases/pdns-3.2.tar.gz

# tar xvzf pdns-3.2.tar.gz

# cd pdns-3.2

./configure --with-modules="gmysql" --prefix=/user/service/powerDNS

# make

# make install


4. pdns 설정


# vi /etc/init.d/pdns

#!/bin/sh

# chkconfig: 345 80 75

# description: PDNS is a versatile high performance authoritative nameserver


prefix=/user/service/powerDNS

exec_prefix=${prefix}

BINARYPATH=${exec_prefix}/bin

SBINARYPATH=${exec_prefix}/sbin

SOCKETPATH=/var/run


[ -f "$SBINARYPATH/pdns_server" ] || exit 0


cd $SOCKETPATH

suffix=`basename $0 | awk -F- '{print $2}'`

if [ $suffix ] 

then

EXTRAOPTS=--config-name=$suffix

PROGNAME=pdns-$suffix

else

PROGNAME=pdns

fi


pdns_server="$SBINARYPATH/pdns_server $EXTRAOPTS"


doPC()

{

ret=$($BINARYPATH/pdns_control $EXTRAOPTS $1 $2 2> /dev/null)

}


doPC ping

NOTRUNNING=$?


case "$1" in

status)

if test "$NOTRUNNING" = "0" 

then 

doPC status

echo $ret

else

echo "not running"

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

$pdns_server --daemon --guardian=yes

if test "$?" = "0"

then

echo "started"

fi

fi 

;;

force-reload | restart)

echo -n "Restarting PowerDNS authoritative nameserver: "

echo -n stopping and waiting.. 

doPC quit

sleep 3

echo done

$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\|restart\|status\|dump\|show\|mrtg\|cricket\|monitor]

;;

esac


# chmod a+x /etc/init.d/pdns


# cd /user/service/powerDNS/etc

# cp pdns-dist.conf pdns.conf

## 주의: linux 에서 설치시 pdns-dist.conf 파일에 CR 문자가 포함되어 pdns.conf 의 설정을 pdns_server가 읽지 못하는 경우가  생길 수 있다.

# /etc/init.d/pdns monitor

Feb 12 17:35:23 Reading random entropy from '/dev/urandom'

Feb 12 17:35:23 Unable to launch, no backends configured for querying

 이 때는 pdns.conf 파일의 모든 라인을 지우고, pdns-dist.conf 의 내용만 복사(Copy/Paste)하여 사용한다.


# vi pdns.conf -- 파일 마지막에 내용 추가, 저장

launch                    =gmysql

gmysql-host            =127.0.0.1

gmysql-user            =pdns

gmysql-password    =password

gmysql-dbname       =pdnsdb

#recursor=a.b.c.d


MySQL 에 root로 접속하여 pdnsdb 데이터베이스를 생성(또는 기존 스키마 사용도 가능)하고 아래의 테이블들을 생성한다.

CREATE TABLE domains (

  ID INT(11) NOT NULL AUTO_INCREMENT,

  NAME VARCHAR(255) NOT NULL,

  MASTER VARCHAR(128) DEFAULT NULL,

  TYPE VARCHAR(6) NOT NULL,

  ACCOUNT VARCHAR(40) DEFAULT NULL,

  LAST_CHECK INT(11) DEFAULT NULL,

  NOTIFIED_SERIAL INT(11) DEFAULT NULL,

  PRIMARY KEY (ID),

  UNIQUE KEY XPKT_DNS_DOMAINS (ID),

  UNIQUE KEY XAK1T_DNS_DOMAINS (NAME)

) Engine=InnoDB;


CREATE TABLE records (

  ID INT(11) NOT NULL AUTO_INCREMENT,

  DOMAIN_ID INT(11) DEFAULT NULL,

  NAME VARCHAR(255) DEFAULT NULL,

  TYPE VARCHAR(6) DEFAULT NULL,

  CONTENT VARCHAR(255) DEFAULT NULL,

  TTL INT(11) DEFAULT NULL,

  PRIO INT(11) DEFAULT NULL,

  CHANGE_DATE INT(11) DEFAULT NULL,

  PRIMARY KEY (ID),

  UNIQUE KEY XPKT_DNS_RECORDS (ID),

  KEY XIE1T_DNS_RECORDS (NAME),

  KEY XIE2T_DNS_RECORDS (NAME,TYPE),

  KEY XIE3T_DNS_RECORDS (DOMAIN_ID)

) Engine=InnoDB;


CREATE TABLE supermasters (

  SUPERMASTERS_SEQ INT(11) NOT NULL AUTO_INCREMENT,

  IP VARCHAR(25) NOT NULL,

  NAMESERVER VARCHAR(255) NOT NULL,

  ACCOUNT VARCHAR(40) DEFAULT NULL,

  PRIMARY KEY (SUPERMASTERS_SEQ),

  UNIQUE KEY XPKT_DNS_SUPERMASTERS (SUPERMASTERS_SEQ)

) Engine=InnoDB;


pdns 계정으로 해당 테이블들을 처리할 수 있도록 권한을 설정한다.

> GRANT SELECT ON supermasters TO pdns;

> GRANT ALL ON domains TO pdns;

> GRANT ALL ON records TO pdns;

> flush privileges;


pdns 정상 설치 확인

# /etc/init.d/pdns monitor

Feb 12 18:22:30 Reading random entropy from '/dev/urandom'

Feb 12 18:22:30 This is a standalone pdns

Feb 12 18:22:30 UDP server bound to 0.0.0.0:53

Feb 12 18:22:30 TCP server bound to 0.0.0.0:53

Feb 12 18:22:30 PowerDNS 3.2 (C) 2001-2013 PowerDNS.COM BV (Feb  8 2013, 16:53:55, gcc 4.6.2) starting up

Feb 12 18:22:30 PowerDNS comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it according to the terms of the GPL version 2.

Feb 12 18:22:30 Creating backend connection for TCP

% Feb 12 18:22:30 gmysql Connection successful

Feb 12 18:22:30 gmysql Connection successful

Feb 12 18:22:30 About to create 3 backend threads for UDP

Feb 12 18:22:30 gmysql Connection successful

Feb 12 18:22:30 gmysql Connection successful

Feb 12 18:22:30 gmysql Connection successful

Feb 12 18:22:30 gmysql Connection successful

Feb 12 18:22:30 gmysql Connection successful

Feb 12 18:22:30 gmysql Connection successful

Feb 12 18:22:30 Done launching threads, ready to distribute questions


위와 같은 메시지를 확인하였다면, ctrl-C로 종료한 후 아래와 같이 pdns 데몬을 시작하고 프로세스를 확인한다.

# /etc/init.d/pdns start

Starting PowerDNS authoritative nameserver: started


# ps -eaf | grep -v grep | grep pdns

root     15998     1  0 18:54 ?        00:00:00 /user/service/powerDNS/sbin/pdns_server --daemon --guardian=yes

root     16000 15998  0 18:54 ?        00:00:00 /user/service/powerDNS/sbin/pdns_server-instance --daemon --guardian=yes



[pdns gui 설치]


1. Apache2 설치, mod_rewrite 모듈 추가

# zypper in -y apache2 apache2-mod_php5 apache2-mod_dnssd apache2-prefork apache2-utils

# chkconfig --add apache2

# chkconfig apache2 on

# service apache2 start


# a2enmod rewrite

# service apache2 restart


2. php5 및 기본 & 추가 패키지 설치

# zypper in -y php5 apache2-mod_php5 php5-bz2 php5-ctype php5-curl php5-devel php5-fpm php5-gettext php5-iconv php5-mcrypt php5-mysql php5-openssl php5-pcntl php5-pdo php5-pear php5-zlib

# zypper in -y php5-pear-MDB2, php5-pear-MDB2_Driver_mysql


3. pdns_gui 다운로드 및 압축 해제, 설치

http://code.google.com/p/pdns-gui 에서 pdns-gui.0.3.3.tgz 다운로드

MYSQL> create database pdns;


# cd /srv/www/htdocs

# tar xvzf DOWNLOADED_DIR/pdns-gui.0.3.3.tgz

# cd pdns-gui.0.3.3/batch

# ./install.sh

DB접속ip(local서버일 경우 localhost가 아닌 127.0.0.1 사용), database명, DB계정/암호 입력


4. apache2 설정 및 pdns_gui 웹 기동

# vi /etc/apache2/default-server.conf

DocumentRoot "/srv/www/htdocs"


<VirtualHost *:8888>

  DocumentRoot /srv/www/htdocs/pdns-gui.0.3.3/web

  DirectoryIndex index.php

  <Directory /srv/www/htdocs/pdns-gui.0.3.3/web>

    AllowOverride All

  </Directory>

</VirtualHost>


# service apache2 restart


http://pdns-gui webserver ip:8888/ 접속


저작자 표시 비영리 변경 금지
신고
블로그 이미지

Barracuda

Bryan의 MemoLog. 쉽게 익혀 보는 IT 실습과 개념원리, 코딩 세계의 얕은 맛보기들, 평범한 삶 주변의 현상 그리고 進上, 眞想, 진상들