powerDNS 数据库表记录简要说明

简介: 数据库连接方法 [root@gd02-qa-plxt2-nodomain /]# mysql -u vipdns -pvipdns -h 10.0.3.99mysql> show databases;+--------------------+| Database |+--------------------+| information_schema

数据库连接方法

 
[root@gd02-qa-plxt2-nodomain /]# mysql -u vipdns -pvipdns -h 10.0.3.99

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| pdns               |
+--------------------+
2 rows in set (0.00 sec)

注:
-u 指定用户名 (vipdns)
-p 指定密码 (vipdns)
-h 指定主机 (10.0.3.99)
默认端口 3306

表信息

 
mysql> show tables;
+--------------------+
| Tables_in_pdns     |
+--------------------+
| cryptokeys         |
| domainmetadata     |
| domains            |
| perm_items         |
| perm_templ         |
| perm_templ_items   |
| records            |
| supermasters       |
| tsigkeys           |
| users              |
| zone_templ         |
| zone_templ_records |
| zones              |
+--------------------+
13 rows in set (0.00 sec)

重点关注: domain 表 records 表

 

domain 表结构

 
mysql> desc domains;
+-----------------+--------------+------+-----+---------+----------------+
| Field           | Type         | Null | Key | Default | Extra          |
+-----------------+--------------+------+-----+---------+----------------+
| id              | int(11)      | NO   | PRI | NULL    | auto_increment |
| name            | varchar(255) | NO   | UNI | NULL    |                |
| master          | varchar(128) | YES  |     | NULL    |                |
| last_check      | int(11)      | YES  |     | NULL    |                |
| type            | varchar(6)   | NO   |     | NULL    |                |
| notified_serial | int(11)      | YES  |     | NULL    |                |
| account         | varchar(40)  | YES  |     | NULL    |                |
+-----------------+--------------+------+-----+---------+----------------+
7 rows in set (0.01 sec)

当前 domains 表中数据

 
mysql> select * from domains;
+----+---------------------+--------+------------+--------+-----------------+---------+
| id | name                | master | last_check | type   | notified_serial | account |
+----+---------------------+--------+------------+--------+-----------------+---------+
|  1 | vclound.com         | NULL   |       NULL | MASTER |            NULL | NULL    |
|  2 | 3.0.10.in-addr.arpa | NULL   |       NULL | MASTER |            NULL | NULL    |
+----+---------------------+--------+------------+--------+-----------------+---------+
2 rows in set (0.00 sec)

说明:

 
id - 主键
name - 域名(当前已添加两个), 先关注 vclound.com 
master -  未知
last_check -  未知
type - 是否主域服务器 (通常只有一个 DNS 情况都是 MASTER)
notified_serial - 修改版本信息
account - 未知

添加 163.com 域名 , 调用 sql 例

 
 insert into pdns.domains (name, type) values ( '163.com', 'MASTER');

更新, 删除, (略)

records 表结构

 
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| id          | int(11)      | NO   | PRI | NULL    | auto_increment |
| domain_id   | int(11)      | YES  | MUL | NULL    |                |
| name        | varchar(255) | YES  | MUL | NULL    |                |
| type        | varchar(10)  | YES  |     | NULL    |                |
| content     | mediumtext   | YES  |     | NULL    |                |
| ttl         | int(11)      | YES  |     | NULL    |                |
| prio        | int(11)      | YES  |     | NULL    |                |
| change_date | int(11)      | YES  |     | NULL    |                |
| ordername   | varchar(255) | YES  |     | NULL    |                |
| auth        | tinyint(1)   | YES  |     | NULL    |                |
+-------------+--------------+------+-----+---------+----------------+
10 rows in set (0.00 sec)

注: records.domain_id 是 domains 的外键

表说明

 
id - 主键
domain_id - domains 表(id) 的外键
name - 域名(vclound.com), 正向解析(ddns.vcloudn.com), 反向解析的主机名(105.3.0.10.in-addr.arpa)
type - 定义 name 字段的说明, 如 (SOA [dns 域名) A [正向解析] PTR [反向解析], MX [邮件服务器], CNAME [主机别名] 字段必须大写
content - 定义 name 所对应的 DNS 解析 [对于 type 为 SOA 时, 比较复杂, 不过可参考当前变量值作为固定值]
ttl - 缓存时候, 可作为固定值
prio - 优先级别, 忽略
change_date - 时间戳
ordername - 忽略
auth - 未知道

当前表单中的正向解析数据

mysql> select id, name, type, content, ttl, change_date from records where domain_id=1;
+----+---------------------+------+----------------------------------------------------------------------+-------+-------------+
| id | name                | type | content                                                              | ttl   | change_date |
+----+---------------------+------+----------------------------------------------------------------------+-------+-------------+
|  1 | vclound.com         | SOA  | ddns.vclound.com ddns.vclound.com 2014013003 28800 7200 604800 86400 | 86400 |  1391015078 |
|  4 | pdnsweb.vclound.com | A    | 10.0.3.103                                                           | 86400 |  1391015359 |
|  5 | pdns.vclound.com    | A    | 10.0.3.99                                                            | 86400 |  1391015379 |
|  6 | pdnsdb.vclound.com  | A    | 10.0.3.99                                                            | 86400 |  1391015391 |
+----+---------------------+------+----------------------------------------------------------------------+-------+-------------+


反向解析数据

 
mysql> select id, name, type, content, ttl, change_date from records where domain_id=2;
+----+-------------------------+------+----------------------------------------------------------------------+-------+-------------+
| id | name                    | type | content                                                              | ttl   | change_date |
+----+-------------------------+------+----------------------------------------------------------------------+-------+-------------+
|  2 | 3.0.10.in-addr.arpa     | SOA  | ddns.vclound.com ddns.vclound.com 2014013002 28800 7200 604800 86400 | 86400 |  1391015099 |
|  3 | 99.3.0.10.in-addr.arpa  | PTR  | pdnsdb.vclound.com                                                   | 86400 |  1391015270 |
|  7 | 103.3.0.10.in-addr.arpa | PTR  | pdnsweb.vcloud.com                                                   | 86400 |  1391018671 |
+----+-------------------------+------+----------------------------------------------------------------------+-------+-------------+
3 rows in set (0.00 sec)

 

模拟添加 163.com 的正向解析方法
这个是域名记录

 
insert into records (name, type, content, ttl, change_date) values ('163.com, 'SOA', 'dns.163.com dns.163.com 2014013002 28800 7200 604800 86400', '86400');

这个是主机名记录
 
insert into records (name, type, content, ttl, change_date) values ('dns.163.com, 'A', '192.168.0.1', '86400');
insert into records (name, type, content, ttl, change_date) values ('www.163.com, 'A', '192.168.0.2', '86400');

这样就可以增加两个主机记录了

反向同理, 切记域名为 0.168.192.in-addr.arpa 即可

验证 dns 方法
/etc/resolv.conf
nameserver 10.0.3.99 <-必须指向他

 
[root@gd02-qa-plxt2-nodomain /]# nslookup vclound.com
Server:         10.0.3.99
Address:        10.0.3.99#53

*** Can't find vclound.com: No answer

[root@gd02-qa-plxt2-nodomain /]# nslookup pdnsweb.vclound.com
Server:         10.0.3.99
Address:        10.0.3.99#53

Name:   pdnsweb.vclound.com
Address: 10.0.3.103

[root@gd02-qa-plxt2-nodomain /]# nslookup pdnsdb.vclound.com
Server:         10.0.3.99
Address:        10.0.3.99#53

Name:   pdnsdb.vclound.com
Address: 10.0.3.99

参考, 上述例子, 注: 不可以直接解析域名

参考反向解析例子

 
[root@gd02-qa-plxt2-nodomain /]# nslookup 10.0.3.99
Server:         10.0.3.99
Address:        10.0.3.99#53

99.3.0.10.in-addr.arpa  name = pdnsdb.vclound.com.

[root@gd02-qa-plxt2-nodomain /]# nslookup 10.0.3.103
Server:         10.0.3.99
Address:        10.0.3.99#53

103.3.0.10.in-addr.arpa name = pdnsweb.vcloud.com.

目录
相关文章
|
10月前
|
关系型数据库 MySQL 分布式数据库
阿里云PolarDB云原生数据库收费价格:MySQL和PostgreSQL详细介绍
阿里云PolarDB兼容MySQL、PostgreSQL及Oracle语法,支持集中式与分布式架构。标准版2核4G年费1116元起,企业版最高性能达4核16G,支持HTAP与多级高可用,广泛应用于金融、政务、互联网等领域,TCO成本降低50%。
|
10月前
|
SQL 关系型数据库 MySQL
Mysql数据恢复—Mysql数据库delete删除后数据恢复案例
本地服务器,操作系统为windows server。服务器上部署mysql单实例,innodb引擎,独立表空间。未进行数据库备份,未开启binlog。 人为误操作使用Delete命令删除数据时未添加where子句,导致全表数据被删除。删除后未对该表进行任何操作。需要恢复误删除的数据。 在本案例中的mysql数据库未进行备份,也未开启binlog日志,无法直接还原数据库。
|
10月前
|
关系型数据库 MySQL 数据库
阿里云数据库RDS费用价格:MySQL、SQL Server、PostgreSQL和MariaDB引擎收费标准
阿里云RDS数据库支持MySQL、SQL Server、PostgreSQL、MariaDB,多种引擎优惠上线!MySQL倚天版88元/年,SQL Server 2核4G仅299元/年,PostgreSQL 227元/年起。高可用、可弹性伸缩,安全稳定。详情见官网活动页。
1612 152
|
10月前
|
关系型数据库 分布式数据库 数据库
阿里云数据库收费价格:MySQL、PostgreSQL、SQL Server和MariaDB引擎费用整理
阿里云数据库提供多种类型,包括关系型与NoSQL,主流如PolarDB、RDS MySQL/PostgreSQL、Redis等。价格低至21元/月起,支持按需付费与优惠套餐,适用于各类应用场景。
|
10月前
|
关系型数据库 MySQL 数据库
阿里云数据库RDS支持MySQL、SQL Server、PostgreSQL和MariaDB引擎
阿里云数据库RDS支持MySQL、SQL Server、PostgreSQL和MariaDB引擎,提供高性价比、稳定安全的云数据库服务,适用于多种行业与业务场景。
1115 156
|
10月前
|
缓存 关系型数据库 BI
使用MYSQL Report分析数据库性能(下)
使用MYSQL Report分析数据库性能
604 158
|
10月前
|
缓存 监控 关系型数据库
使用MYSQL Report分析数据库性能(中)
使用MYSQL Report分析数据库性能
704 156
|
10月前
|
Ubuntu 安全 关系型数据库
安装与配置MySQL 8 on Ubuntu,包括权限授予、数据库备份及远程连接指南
以上步骤提供了在Ubuntu上从头开始设置、配置、授权、备份及恢复一个基础但完整的MySQL环境所需知识点。
1146 7