zoukankan      html  css  js  c++  java
  • Ubuntu14.04安装PowerDNS踩坑实录

    公司要使用PowerDNS,作为内网域名解析的工具。让我和另一组的同事学一下如何配置及调优。所以先找了两台服务器试着安装一下。这一装就是一个礼拜,经历了大大小小的坑,记下来以后可能需要参考。安装过程如下:
     
    1、安装mysql:
    尽量使用源码安装,不要使用apt-get,安装的版本不完全,缺少相关的库,会导致后面缺少mysql.h、mysql_config等等文件。我手里这台机器已经装好了mysql,这步就直接略过了。
     
    2、安装php:
    在php官网http://www.php.net/ 中下载的5.6.16包,解压后配置如下:
    sudo ./configure --prefix=/usr/local/php-5.6.16 --enable-exif --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-mbstring --with-mysql=/usr --with-mysql-sock=/tmp/mysql.socket  --enable-sqlite-utf8 --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --enable-zip --with-pcre-dir --enable-maintainer-zts --enable-zend-multibyte --with-config-file-path=/usr/local/php-5.6.16/etc/ --with-mysqli=/usr/bin/mysql_config --with-gettext --with-mcrypt
    配置问题:
    (1)configure: error: jpeglib.h not found
    缺少libjpeg库。到 http://www.ijg.org/ 去下载。tar解压,./configure配置,make编译,make install安装。后面三步都需要sudo。记得要下最新版的库安装。
    (2)configure: error: png.h not found.
    缺少 libpng包。
    sudo apt-get -y install libpng12-dev
    (3)configure: error: libjpeg.(a|so) not found.
    装好了libjpeg包,可能还会找不到libjpeg.so文件,这时候可以先
    sudo find / -name libjpeg.so
    然后增加一条链接到/usr/lib:
    sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/libjpeg.so
     (我的 libjpeg.so 在/usr/lib/x86_64-linux-gnu/ 目录下,64位Ubuntu/Debian还有可能在/usr/lib64下)
    jpeg换成png解决方法类似
    (4)configure: error: mcrypt.h not found. Please reinstall libmcrypt.
    缺少libmcrypt库。到 http://mcrypt.hellug.gr/lib/ 下载。tar解压,./configure配置,make编译,make install安装。后面三步都需要sudo。记得要下最新版的库安装。
    也可以
    sudo apt-get -y install libmcrypt-dev
    (5)configure: error: Cannot find MySQL header files under /usr/bin/mysql.
    Note that the MySQL client library is not bundled anymore!
    --with-mysql=/usr:mysql.h没找到头文件,无法配置mysql.socket。find搜索一下,然后改一下--with-mysql后面的路径。(centos下如果找不到的话,需要安装一个mysql-devel)
    (6)configure: error: Please reinstall the mysql distribution
    --with-mysqli=/usr/bin/mysql_config:mysql_config没找到配置文件,find搜索一下,更改路径。
    (7)configure: error: wrong mysql library version or lib not found. Check config.log for more information.
    --enable-embedded-mysqli:原文中的这个编译参数,跟--with-mysqli冲突,删掉即可
    (8)configure: error: Cannot find libz.
    没有找到zlib。到 http://www.zlib.net/ 去下载,tar解压,./configure配置,make编译,make install安装。后面三步都需要sudo。记得要下最新版的库安装。
    (9)configure: error: freetype-config not found.
    缺少libfreetype6包。
    sudo apt-get -y install libfreetype6 libfreetype6-dev

    幸好后面的make和make install都没有出问题。安装好之后,需要复制一下配置文件:

    sudo cp php.ini-production /usr/local/php-5.6.16/etc/php.ini
    (没错,拷个文件也需要sudo)
     
    3、安装PowerDNS:
    PowerDNS官网 https://www.powerdns.com/ 不要去github上下载源码,因为——跟安装文档都对不上啊喂!在PowerDNS官网Older versions can be found on downloads.powerdns.com/releases. (链接https://downloads.powerdns.com/releases/) ,找了一个3.3.0(因为是.tar.gz包,并没有那么花哨的后缀)。下载,解压,然后配置参数
    sudo ./configure --prefix=/etc/powerdns --enable-verbose-logging --enable-static-binaries --enable-pdns_server --enable-nedmalloc --with-mysql=/usr
    配置问题:
    (1)要装lua。
    在官网下载lua(http://www.lua.org/)装的时候要装readline库。
    sudo apt-get -y install libreadline-dev

    或者

    sudo apt-get -y install lua5.1

    (powerdns要求lua版本要在5.1以上,但是我安装5.2和5.3都遇到莫名其妙的问题)

    装完之后需要配置环境变量:
    sudo vim /etc/profile
    在结尾加上:
    export LUA_CFLAGS="-I/usr/local/lua/include"
    export LUA_LIBS="-L/usr/local/lua/lib -llua -ldl"
    我也不知道为啥这两个就好使啊!明明lua并没有装在这里啊!!
    (此方法不一定成功,装lua的过程中我已经把机器搞的很乱了,不知道哪里蒙对的)
    (2)configure: error: cannot find Boost headers version >= 1.35.0
    缺少libboost。
    sudo apt-get -y install libboost-all-dev
     
    ***后记:在我都装好之后,同事给我个地址:http://www.unixmen.com/how-to-install-powerdns-on-ubuntu-14-04/ 你倒是早给我啊喂!
     
    4、都装好了,开始设置。
    (1)设置my.cnf
    sudo vim /etc/mysql/my.cnf
    里面有一句 bind-address           = 127.0.0.1  需要注释掉
    (查了一下,在 http://blog.chinaunix.net/uid-24500107-id-2602917.html 中说, msyql默认的bind-address是127.0.0.1,这样的话就算你创建的用户有可以remote访问的话 也不能通过-h 来访问,mysql只接受localhost,错误提示为:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)bind-address后面增加远程访问IP地址或者禁掉这句话就可以让远程机登陆访问了)
    然后重启mysql服务:
    sudo service mysql restart

    (2)进入mysql建立powerdns相关表

    建立powerdns数据库:
    CREATE DATABASE powerdns;
    为数据库授权(我这里没有新建用户,直接授权给root,没有什么卵用):
    GRANT ALL ON powerdns.* TO 'root'@'localhost' IDENTIFIED BY 'password';

    这里powerdns是数据库,root是授权给这个用户,password是这个用户的密码:

    之后可以使用
    FLUSH PRIVILEGES; 

    更新一下用户设置。

    然后使用
    USE powerdns; 

    进入数据库中。创建表和记录。

    创建domains表:
    CREATE TABLE domains (
      id INT auto_increment,
      name VARCHAR(255) NOT NULL,
      master VARCHAR(128) DEFAULT NULL,
      last_check INT DEFAULT NULL,
      type VARCHAR(6) NOT NULL,
      notified_serial INT DEFAULT NULL,
      account VARCHAR(40) DEFAULT NULL,
      primary key (id)
    );

    给domains表创建一个索引:

    CREATE UNIQUE INDEX name_index ON domains(name);

    创建records表:

    CREATE TABLE records (
      id INT auto_increment,
      domain_id INT DEFAULT NULL,
      name VARCHAR(255) DEFAULT NULL,
      type VARCHAR(6) DEFAULT NULL,
      content VARCHAR(255) DEFAULT NULL,
      ttl INT DEFAULT NULL,
      prio INT DEFAULT NULL,
      change_date INT DEFAULT NULL,
      primary key(id)
    );

    给records表创建三个索引:

    CREATE INDEX rec_name_index ON records(name);
    CREATE INDEX nametype_index ON records(name,type);
    CREATE INDEX domain_id ON records(domain_id);

    创建supermasters表;

    CREATE TABLE supermasters (
      ip VARCHAR(25) NOT NULL,
      nameserver VARCHAR(255) NOT NULL,
      account VARCHAR(40) DEFAULT NULL
    );

    OK,mysql建表完成。quit(个人还是比较喜欢mysql在退出时候这个Bye的)

     
    (3)设置powerdns:
    cd /etc/powerdns

    这里面有pdns.d目录,但是进不去,因为权限不够,可使用chmod 755 pdns.d提权,之后cd pdns.d进入

    ls可看到这个目录里面有两个文件:pdns.local和pdns.local.gmysql,这两个文件是要删除掉的。但是为保险起见,备份一下先。
    sudo cp pdns.local pdns.local.gmysql ~/
    sudo rm *.*  #删的时候一定要记得只是把这两个文件删掉,要注意是在这个目录里使用,要是删掉其他什么东西可就开心了!
    sudo vim pdns.local.gmysql.conf 

    建立新文件,在里面输入以下内容:

    # MySQL Configuration
    #
    # Launch gmysql backend
    launch=gmysql
    # gmysql parameters
    gmysql-host=localhost
    gmysql-dbname=powerdns
    gmysql-user=poweruser
    gmysql-password=ubuntu

    (后面三行是刚才数据库建表时候给权限的,数据库名、用户名、密码注意对应)

    保存退出,最后启动powerdns:
    sudo service pdns start

    用ps -ef |grep pdns检查一下看看pdns有没有启动。启动正常,完成!

     
    至此一个礼拜的大坑终于特么让我填上了。简直开心。
     
    最后,尝试安装poweradmin,用来管理powerdns。可参考这两篇:
    php版本有点乱,一直没装明白,最后同事都重装了遍,我没参与。很惭愧,答应同事给装好结果拖拖拉拉好几天最后还装的乱七八糟的。
    算个遗憾,以后有空补上~(才怪咧!)
  • 相关阅读:
    jq 自定义动画案例
    jq 左右轮播图案例
    hdu-5728 PowMod(数论)
    UVA-11892(组合游戏)
    UVA-12293(组合游戏)
    LA-5059(组合游戏)
    hdu-5724 Chess(组合游戏)
    hdu-5750 Dertouzos(数论)
    hdu-5748 Bellovin(LIS)
    hdu-5747 Aaronson(水题)
  • 原文地址:https://www.cnblogs.com/anpengapple/p/5107898.html
Copyright © 2011-2022 走看看