分类: Mysql/postgreSQL
2011-08-02 17:09:27
BIND 与 MySQL结合,在BIND9里面已经集成了与数据库连接的模块dlz,但是dlz与mysql结合有一个很致命的缺点就是只能将bind编译
成单线程,这就大大降低了bind的性能,所以选择了其他模块MySQL BIND SDB Driver
在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().
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. 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 ('', 259200, 'Cname', 'w0.mydomain.com.');
INSERT INTO mydomain VALUES ('ftp.mydomain.com', 259200, 'Cname', 'w0.mydomain.com.');