首页 > 其他分享 >pdns部署

pdns部署

时间:2024-05-30 09:23:29浏览次数:22  
标签:powerdns pdns 部署 mysql NULL root id

 

 

一、基础配置

1.1 环境说明

操作系统: Centos 7.6

PDNS: 4.1.11-1.el7

MariaDB: 5.5.65

1.2 关闭防火墙和selinux

setenforce 0

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g'  /etc/selinux/config

systemctl stop firewalld.service && systemctl disable firewalld.service

firewall-cmd  --state

 

二)安装mysql5.6

2.1 安装 MariaDB

1)更改存储目录

mkdir -p /data/mysql/{data,log}

vim /etc/my.cnf

[mysqld]

datadir=/data/mysql/data

socket=/data/mysql/mysql.sock

[mysqld_safe]

log-error=/data/mysql/log/mariadb.log

pid-file=/data/mysql/mariadb.pid

2)默认安装的版本为5.5

#安装

yum install -y epel-release yum-plugin-priorities

yum install -y mariadb-server mariadb

#设置目录权限

cd /data/

chown -R mysql.mysql mysql/

#启动
systemctl enable mariadb.service
systemctl start mariadb.service

2.2) 初始化

1)设置软连接

ln -s /data/mysql/mysql.sock /var/lib/mysql/mysql.sock

2)设置root密码

mysql_secure_installation回车,

y,          #设置root密码

root密码,

重复root密码,

y,          #删除匿名登入

y,          #禁用root远程登入

y,          #删除test库

y          #刷新权限

2.3)设置字符集

#vim /etc/my.cnf

[mysqld]

datadir=/data/mysql/data

socket=/data/mysql/mysql.sock

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

[mysqld_safe]

log-error=/data/mysql/log/mariadb.log

pid-file=/data/mysql/mariadb.pid

[client]

default-character-set=utf8

#

# include all files from the config directory

#

!includedir /etc/my.cnf.d

#vim /etc/my.cnf.d/client.cnf

[client]default-character-set=utf8

#vim /etc/my.cnf.d/mysql-clients.cnf

[mysql]default-character-set=utf8

2.4)重启mariadb

systemctl restart mariadb

 

三)安装PowerDNS

3.1)安装powerdns

yum -y install pdns pdns-backend-mysql

PowerDNS的配置文件位于:/etc/pdns/pdns.conf

3.2)新建数据库

create database powerdns CHARACTER SET utf8 COLLATE utf8_general_ci;

grant all on powerdns.* to 'powerdns'@'192.168.31.%' identified by 'Power@356';

flush privileges;

 

 

3.3)创建数据表

use powerdns;

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)

) Engine=InnoDB;

CREATE UNIQUE INDEX name_index ON domains(name);

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,

  change_date          INT DEFAULT NULL,

  disabled              TINYINT(1) DEFAULT0,

  ordername            VARCHAR(255) BINARY DEFAULT NULL,

  auth                  TINYINT(1) DEFAULT1,

  PRIMARY KEY (id)

) Engine=InnoDB;

CREATE INDEX nametype_index ON records(name,type);

CREATE INDEX domain_id ON records(domain_id);

CREATE INDEX recordorder ON records (domain_id, ordername);

CREATE TABLE supermasters (

  ip                    VARCHAR(64) NOT NULL,

  nameserver            VARCHAR(255) NOT NULL,

  account              VARCHAR(40) NOT NULL,

  PRIMARY KEY (ip, nameserver)

) Engine=InnoDB;

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) NOT NULL,

  comment              VARCHAR(64000) NOT NULL,

  PRIMARY KEY (id)

) Engine=InnoDB;

CREATE INDEX comments_domain_id_idx ON comments (domain_id);

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;

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,

  content              TEXT,

  PRIMARY KEY(id)

) Engine=InnoDB;

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;

CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);

flush privileges;

show databases;

show tables;

3.4)配置powerdns

cp /etc/pdns/pdns.conf /etc/pdns/pdns.conf.bak

#vim /etc/pdns/pdns.conf

daemon=yes

guardian=no

cache-ttl=20

default-ttl=600

launch=gmysql

gmysql-host=192.168.31.62

gmysql-port=3306

gmysql-dbname=powerdns

gmysql-user=powerdns

gmysql-password=Power@356

master=yes

setgid=pdns

setuid=pdns

#pdns API

webserver=yes

webserver-address=0.0.0.0

webserver-allow-from=0.0.0.0/0

webserver-port=8081

write-pid=yes

api=yes

api-key=ziiofficedns

api-logfile=/var/log/pdns-api.log

#

allow-axfr-ips=192.168.31.62,192.168.31.63

also-notify=192.168.31.62,192.168.31.63

only-notify=192.168.31.62,192.168.31.63

slave=no

slave-cycle-interval=60

log-dns-details=yes

log-dns-queries=yes

loglevel=6

3.5)开机启动

systemctl enable pdns.service

systemctl start pdns.service

systemctl status pdns.service

#查看端口8081和53端口

[root@powerdns ~]# ss -tunlp | grep pdns_server
udp UNCONN 0 0 *:53 *:* users:(("pdns_server",pid=3991,fd=5))
udp UNCONN 0 0 :::53 :::* users:(("pdns_server",pid=3991,fd=6))
tcp LISTEN 0 10 *:8081 *:* users:(("pdns_server",pid=3991,fd=9))
tcp LISTEN 0 128 *:53 *:* users:(("pdns_server",pid=3991,fd=7))
tcp LISTEN 0 128 :::53 :::* users:(("pdns_server",pid=3991,fd=8)) 

 

四)安装PowerDNS-Admin工具

参考文档: https://github.com/ngoduykhanh/PowerDNS-Admin/wiki/Running-PowerDNS-Admin-on-Centos-7

4.1)Install required packages

# 找到~/.pip/pip.conf,如果不存在就创建,加入内容如下

 

[global]

timeout = 10

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]

trusted-host=pypi.tuna.tsinghua.edu.cn

 

 

yum install -y epel-release

yum install -y https://centos7.iuscommunity.org/ius-release.rpm
yum install -y python36u python36u-devel python36u-pip

pip3.6 install -U pip

pip install -U virtualenv

rm -f /usr/bin/python3 && ln -s /usr/bin/python3.6/usr/bin/python3

4.2)Install required packages for building python libraries from requirements.txt file

--> If you use MariaDB ( from MariaDB "upstream" repositorys (10.x) )

$ yum install gcc MariaDB-devel MariaDB-shared openldap-devel xmlsec1-devel xmlsec1-openssl libtool-ltdl-devel

--> Otherwise ( If you use default Centos mariadb (5.5) )

$ yum install gcc mariadb-devel openldap-devel xmlsec1-devel xmlsec1-openssl libtool-ltdl-devel

--> NOTE: I am using MySQL Comunity server as the database backend.

          So `mysql-community-devel` is required. For MariaDB,

          and PostgreSQL the required package will be different.

4.3)install yarn to build asset files + Nodejs 12

cd /usr/local

wget  http://download.51yuki.cn/node-v12.2.0-linux-x64.tar.xz

tar xf node-v12.2.0-linux-x64.tar.xz

ln -s node-v12.2.0-linux-x64 nodejs

echo "export NODEJS_HOME=/usr/local/nodejs"  >> /etc/profile
echo " export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/nodejs/bin " >> /etc/profile
echo "export NODEJS_PATH=/usr/local/nodejs/lib/node_modules"  >> /etc/profile

source /etc/profile

[root@powerdns local]# node -v
 v12.2.0
 [root@powerdns local]# npm -v
 6.9.0

 npm config set registry https://registry.npm.taobao.org

npm install -g yarn

4.4) Checkout source code and create virtualenv

git clone https://github.com/ngoduykhanh/PowerDNS-Admin.git /data/web/powerdns-admin

cd /data/web/powerdns-admin

virtualenv -p python3 flask

[root@powerdns powerdns-admin]# source ./flask/bin/activate
(flask) [root@powerdns powerdns-admin]# pip install python-dotenv

(flask) [root@powerdns powerdns-admin]#  pip install -r requirements.txt

 

 

4.5)安装配置powerdnsadmin

MariaDB [(none)]> CREATE DATABASE powerdnsadmin CHARACTER SET utf8 COLLATE utf8_general_ci;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON powerdnsadmin.* TO 'powerdnsadmin'@'%' identified by 'PowerAdmin@356';

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

[root@powerdns powerdns-admin]# export FLASK_CONF=../configs/development.py

[root@powerdns powerdns-admin]# export FLASK_APP=powerdnsadmin/__init__.py

[root@powerdns powerdns-admin]# flask/bin/flask db upgrade

INFO  [alembic.runtime.migration] Context impl MySQLImpl.

INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

INFO  [alembic.runtime.migration] Running upgrade  -> 787bdba9e147, Init DB

INFO  [alembic.runtime.migration] Running upgrade 787bdba9e147 -> 59729e468045, Add view column to setting table

INFO  [alembic.runtime.migration] Running upgrade 59729e468045 -> 1274ed462010, Change setting.value data type

INFO  [alembic.runtime.migration] Running upgrade 1274ed462010 -> 4a666113c7bb, Adding Operator Role

INFO  [alembic.runtime.migration] Running upgrade 4a666113c7bb -> 31a4ed468b18, Remove all setting in the DB

INFO  [alembic.runtime.migration] Running upgrade 31a4ed468b18 -> 654298797277, Upgrade DB Schema

INFO  [alembic.runtime.migration] Running upgrade 654298797277 -> 0fb6d23a4863, Remove user avatar

INFO  [alembic.runtime.migration] Running upgrade 0fb6d23a4863 -> 856bb94b7040, Add comment column in domain template record table

INFO  [alembic.runtime.migration] Running upgrade 856bb94b7040 -> b0fea72a3f20, Update domain serial columns type

INFO  [alembic.runtime.migration] Running upgrade b0fea72a3f20 -> 3f76448bb6de, Add user.confirmed column

#创建资产文件

yarn config set registry https://registry.npm.taobao.org

yarn config delete proxy
npm config rm proxy
npm config rm https-proxy

yarn install --pure-lockfile

[root@powerdns powerdns-admin]# flask/bin/flask assets build

Building bundle: generated/login.js

[2020-05-07 15:20:18,703] [script.py:167] INFO - Building bundle: generated/login.js

Building bundle: generated/validation.js

[2020-05-07 15:20:18,935] [script.py:167] INFO - Building bundle: generated/validation.js

Building bundle: generated/login.css

[2020-05-07 15:20:18,938] [script.py:167] INFO - Building bundle: generated/login.css

Building bundle: generated/main.js

[2020-05-07 15:20:55,512] [script.py:167] INFO - Building bundle: generated/main.js

Building bundle: generated/main.css

[2020-05-07 15:20:56,583] [script.py:167] INFO - Building bundle: generated/main.css

#启动

(flask) [root@powerdns powerdns-admin]# nohup ./run.py &

[1] 6223

(flask) [root@powerdns powerdns-admin]# nohup: ignoring input and appending output to ‘nohup.out’

(flask) [root@powerdns powerdns-admin]# ss -tunlp|grep 9191

tcp    LISTEN    0      128      *:9191                  *:*                  users:(("python3",pid=6225,fd=4),("python3",pid=6225,fd=3),("python3",pid=6223,fd=3))



 
链接:https://www.jianshu.com/p/dd16f90081c4

标签:powerdns,pdns,部署,mysql,NULL,root,id
From: https://www.cnblogs.com/machangwei-8/p/18221613

相关文章

  • Springboot计算机毕业设计学生实习考勤的打卡小程序【附源码】开题+论文+mysql+程序+
    本系统(程序+源码)带文档lw万字以上 文末可获取一份本项目的java源码和数据库参考。系统程序文件列表开题报告内容研究背景:随着高等教育的发展,学生实习已成为培养应用型人才的重要环节。然而,在学生实习管理过程中,考勤是一个关键环节,也是确保实习质量和学生安全的基础。传统......
  • Springboot计算机毕业设计学生食代小程序【附源码】开题+论文+mysql+程序+部署
    本系统(程序+源码)带文档lw万字以上 文末可获取一份本项目的java源码和数据库参考。系统程序文件列表开题报告内容研究背景:在当今数字化时代,随着移动互联网的普及和智能化技术的发展,学生群体的生活方式和消费习惯也在发生着深刻的变化。特别是在校园餐饮领域,学生们对于便捷......
  • 在开发系统中将 .net core 6.0 Web API 部署到 IIS 无法正常工作
    发布到本地文件夹并配置到IIS进行测试的.netcore6.0Webapi无法正常工作。Thissitecan'tbereachedlocalhostrefusedtoconnect.请尝试:检查连接检查代理和防火墙ERR_CONNECTION_REFUSED已执行步骤......
  • 部署发布blazor server 网站
    1、在服务器端安装dotnet-hosting-8.0.6-win,很关键2、在iis创建网站,端口可选80或8080应用程序池NETCLR选无托管代码,注意64位的则要启用32位程序改为false3、启动时可能有错,例如缺少builder.Services.AddResponseCompression();app.UseResponseCompression();在program中添......
  • 使用Dockerfile部署go项目
    主旨就是先拉代码,再删旧容器和镜像,再起Dockerfile的容器并执行出go的二进制文件,再运行Dockerfile文件如下FROMgolang:alpine#为我们的镜像设置必要的环境变量ENVGO111MODULE=on\GOPROXY=https://goproxy.cn,direct\CGO_ENABLED=0\GOOS=linux\GO......
  • Windows和Linux系统部署Docker(2)
    目录一、Linux系统部署docker前置环境:1.安装需要的软件包,yum-util提供yum-config-manager功能2.添加阿里云docker-ce 仓库3.安装docker软件包4.启动docker并设置开机自启5.查看版本:二、windows系统部署docker1.查看是否拥有bioss虚拟化功能2.开启虚拟化功能3.......
  • clickhouse安装部署
    clickhouse安装部署下载地址:百度网盘下载链接:https://pan.baidu.com/s/1YdGmhGND5qA3qzBpRQaI1w提取码:sybkclickhouse-common-static-21.9.4.35.tgzclickhouse-common-static-dbg-21.9.4.35.tgzclickhouse-server-21.9.4.35.tgzclickhouse-client-21.9.4.35.tgz安装:......
  • Docker_Docker应用部署4
    一、MySQL部署案例:需求在Docker容器中部署MySQL,并通过外部mysql客户端操作MySQLServer。案例:实现步骤1.搜索mysql镜像dockersearchmysql2.拉取mysql镜像dockerpullmysql:5.63.创建容器创建容器,设置端口映射、目录映射#在/root目......
  • 软RAID部署
    目录资源列表基础环境关闭防火墙关闭内核安全机制一、安装mdadm工具二、磁盘分区三、创建RAID        本文记录了软RAID的部署流程,希望能够帮到大家。资源列表操作系统配置主机名IP备注CentOS7.3.16112C4Gnode1192.168.207.131需要添加2块磁盘基础环境关......
  • 部署LAMP平台
    目录一、LAMP简介与概述1.1各组件作用1.2LAMP平台搭建时各组件安装顺序1.3httpd服务的目录结构1.4 httpd.conf配置文件二、编译安装Apachehttpd服务2.1关闭防火墙,将安装Apache所需软件包传到/opt目录下 2.3配置软件模块2.6修改httpd服务配置文件2.7浏览......