分类:
2007-09-19 10:19:18
三.Dns数据在Berkeley中的关系以及存储方式
1.数据结构
定义:typedef struct bdb_instance {
DB_ENV *dbenv;
DB *data;
DBC *cursor;
DBC *cursor2;
DBC *cursor3;
DBC *cursor4;
DB *zone;
DB *xfr;
DB *client;
} bdbhpt_instance_t;
1. 表及算法
包括:dns_data
dns_zone
dns_host
dns_client
Dns_data |
Hash |
key |
Zone+a space+host |
value |
Dns data | ||
Dns_xfr |
Hash |
key |
zone |
value |
host | ||
Dns_zone |
Btree |
key |
Reverse zone |
value |
NULL | ||
Dns_client |
Hash |
key |
Zone |
|
value |
Xfr ip |
3. dns data字段:
Order |
Name |
Data Type |
Description |
1 |
replication_id |
string |
a unique alpha-numeric id for this record. |
2 |
host |
string |
DNS host name |
3 |
ttl |
string (num) |
Time to live (string must convert to number) |
4 |
type |
string |
DNS data type |
5 |
mx_priority |
string (num) |
MX Priority (only for MX DNS types) |
6 |
data |
string |
IP address / Host name / Full domain name |
7 |
primary_ns |
string |
Primary name server SOA record (SOA ONLY) |
8 |
resp_person |
string |
Responsible person SOA record (SOA ONLY) |
9 |
serial |
string (num) |
Serial # for SOA record (SOA ONLY) |
10 |
refresh |
string (num) |
Refresh timefor SOA record (SOA ONLY) |
11 |
retry |
string (num) |
Retry time for SOA record (SOA ONLY) |
12 |
expire |
string (num) |
Expire time for SOA record (SOA ONLY) |
13 |
minimum |
string (num) |
Minimum time for SOA record (SOA ONLY) |
4.各表之间的逻辑关系
Dns_client是控制客户端多台同步
Dns_xfr是Dns_client允许增量传输的zone和host
Dns_zone是reverse zone能提高查询速度,其值为空,当查询zone的时候其关系为:
Dns_zone--àdns_xfràdns_data
Dns_data 是最终数据集,当查host时的关系为:
Dns_xfràdns_data
5.实例数据
注:bind+bdbhpt官方文档有几个错误,数据要严格按照下面的来定义
[dns_zone] key: moc.tset , data:
[dns_client] key: test.com , data: 127.0.0.1
[dns_client] key: test.com , data: 192.168.1.10
[dns_xfr] key: test.com , data: @
[dns_data] key: test.com @ , data: 1 @ 86400 SOA ns1.test.com. hostmaster.test.com. 2006112401 28800 7200 604800 86400
[dns_xfr] key: test.com , data: download
[dns_data] key: test.com download , data: 18 download
[dns_data] key: test.com download , data: 19 download
[dns_xfr] key: test.com , data: video
[dns_data] key: test.com video , data: 20 video
[dns_data] key: test.com video , data: 21 video
[dns_xfr] key: test.com , data: www
[dns_data] key: test.com www , data: 10 www
[dns_data] key: test.com www , data: 11 www
[dns_data] key: test.com www , data: 12 www