BIND9 + MySQL (MySQL BIND SDB Driver)

BIND 与 MySQL结合,在BIND9里面已经集成了与数据库连接的模块dlz,但是dlz与mysql结合有一个很致命的缺点就是只能将bind编译

成单线程,这就大大降低了bind的性能,所以选择了其他模块MySQL BIND SDB Driver

 

http://mysql-bind.sourceforge.net/

 

在Project Page里面下载 mysql-bind.tar.gz (包里面的README文件其实有讲如何编译)

 

cp mysqldb.c and mysqldb.h to bind9/bin/named and bind9/bin/named/include/named

 

vim bind9/bin/named/Makefile.in

 

DBDRIVER_OBJS = mysqldb.@O@
DBDRIVER_SRCS = mysqldb.c

DBDRIVER_INCLUDES = -I'/usr/include/mysql'

DBDRIVER_LIBS = -L'/usr/lib/mysql' -lmysqlclient -lz -lcrypt -lnsl -lm -lc -lnss_files -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv

 

#如果是x64的机器,需要修改/usr/lib64

 

In bind9/bin/named/main.c

add an include to mysqldb.h (e.g. #include "mysqldb.h") Then you must register the driver in setup(), by adding mysqldb_init(); before the call to ns_server_create().

 

Unregistration should be in cleanup(), by adding the call mysqldb_clear(); after the call to ns_server_destroy().

 

查找 xxdb_init();
在 注释文件 xxdb_init();
下添加 mysqldb_init();
然后查找查找 xxdb_clear();
再下面添加mysqldb_clear();
修改完后wq 保存退出,然后开始编译安装

./configure --enable-threads --prefix=/opt/bind9

cd /opt/bind9
/opt/bind9/sbin/rndc-confgen > /opt/bind9/etc/rndc.conf
将生产的
key "rndc-key" {
algorithm hmac-md5;
secret "?????????????????";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
copy到named.conf文件
例如
options {
 
        directory "/var/cache/bind";
 
        // If there is a firewall between you and nameservers you want
        // to talk to, you may need to fix the firewall to allow multiple
        // ports to talk.  See http://www.kb.cert.org/vuls/id/800113
 
        // If your ISP provided one or more IP addresses for stable
        // nameservers, you probably want to use them as forwarders. 
        // Uncomment the following block, and insert the addresses replacing
        // the all-0's placeholder.
 
        // forwarders {
        //      0.0.0.0;
        // };
 
        auth-nxdomain no;    # conform to RFC1035
        listen-on-v6 { any; };
 
        allow-recursion { any; };
        allow-query { any; };
        recursion yes;
};
 
key "rndc-key" {
        algorithm hmac-md5;
        secret "9OTliFcI9vkDlNuDws5IVA==";
};
 
controls {
        inet 127.0.0.1 port 953
        allow { 127.0.0.1; } keys { "rndc-key"; };
};

编辑named.conf

zone "mydomain.com" {
  type master;
  notify no;
  database "mysqldb dbname tablename hostname user password";
};

 

CREATE TABLE mydomain (
  name varchar(255) default NULL,
  ttl int(11) default NULL,
  rdtype varchar(255) default NULL,
  rdata varchar(255) default NULL
) TYPE=MyISAM;

 

INSERT INTO mydomain VALUES ('mydomain.com', 259200, 'SOA', 'mydomain.com. www.mydomain.com. 200309181 28800 7200 86400 28800');
INSERT INTO mydomain VALUES ('mydomain.com', 259200, 'NS', 'ns0.mydomain.com.');
INSERT INTO mydomain VALUES ('mydomain.com', 259200, 'NS', 'ns1.mydomain.com.');
INSERT INTO mydomain VALUES ('mydomain.com', 259200, 'MX', '10 mail.mydomain.com.');
INSERT INTO mydomain VALUES ('w0.mydomain.com', 259200, 'A', '192.168.1.1');
INSERT INTO mydomain VALUES ('w1.mydomain.com', 259200, 'A', '192.168.1.2');
INSERT INTO mydomain VALUES ('mydomain.com', 259200, 'Cname', 'w0.mydomain.com.');
INSERT INTO mydomain VALUES ('mail.mydomain.com', 259200, 'Cname', 'w0.mydomain.com.');
INSERT INTO mydomain VALUES ('ns0.mydomain.com', 259200, 'Cname', 'w0.mydomain.com.');
INSERT INTO mydomain VALUES ('ns1.mydomain.com', 259200, 'Cname', 'w1.mydomain.com.');
INSERT INTO mydomain VALUES ('www.mydomain.com', 259200, 'Cname', 'w0.mydomain.com.');
INSERT INTO mydomain VALUES ('ftp.mydomain.com', 259200, 'Cname', 'w0.mydomain.com.');

 

你可能感兴趣的:(Algorithm,mysql,server,null,insert,recursion)