码迷,mamicode.com
首页 > 数据库 > 详细

bind9+mysql dlz(Dynamically Loadable Zones)

时间:2014-11-19 18:25:42      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:io   ar   os   sp   for   数据   on   art   log   

yum install openssl openssl-devel

groupadd mysql
useradd -g mysql -s /sbin/nologin -M mysql
chown -R mysql:mysql /usr/local/mysql

./configure  --prefix=/usr/local/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client -with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg

make && make install

/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql
cd /usr/local/mysql
cp share/mysql/my-medium.cnf /etc/my.cnf


nphup ./mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/usr/local/mysql/var &
登录mysql /usr/local/mysql/bin/mysql

insert into mysql.user(Host,User,Password) values("localhost","dns",password("dns"));
insert into mysql.user(Host,User,Password) values("%","dns",password("dns"));
GRANT ALL PRIVILEGES ON *.* TO ‘dns‘@‘%‘ IDENTIFIED BY ‘dns‘ WITH GRANT OPTION;
flush privileges;

CREATE TABLE `dns_records` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `zone` varchar(255) NOT NULL,
  `host` varchar(255) NOT NULL default ‘@‘,
  `type` enum(‘MX‘,‘CNAME‘,‘NS‘,‘SOA‘,‘A‘) NOT NULL,
  `data` varchar(255) default NULL,
  `ttl` int(11) NOT NULL default ‘800‘,
  `mx_priority` varchar(255) default NULL,
  `refresh` int(11) default NULL,
  `retry` int(11) default NULL,
  `expire` int(11) default NULL,
  `minimum` int(11) default NULL,
  `serial` bigint(20) default NULL,
  `resp_person` varchar(255) default NULL,
  `primary_ns` varchar(255) default NULL,
  PRIMARY KEY  (`id`),
  KEY `id` (`id`),
  KEY `type` (`type`),
  KEY `host` (`host`),
  KEY `zone` (`zone`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

--soa
INSERT INTO dns_records (zone,host,type,serial,refresh,retry,expire,minimum,primary_ns,resp_person)
VALUES (‘linuxtone.org‘, ‘@‘, ‘SOA‘, 2009030200, 172800, 800, 1209600, 3600 , ‘ns1.linuxtone.org‘, ‘root.linuxtone.org.‘);

--linuxtone.org redirection for any host to linuxtone.org.
INSERT INTO dns_records (zone,host,type,DATA)
VALUES (‘linuxtone.org‘, ‘*‘, ‘CNAME‘, ‘linuxtone.org.‘);

--nameserver for zone
INSERT INTO dns_records (zone,host,type,DATA)
VALUES (‘linuxtone.org‘, ‘@‘, ‘NS‘, ‘ns1.linuxtone.org.‘);

--toplevel-ip-address of zone itself
INSERT INTO dns_records (zone,host,type,DATA)
VALUES (‘linuxtone.org‘, ‘@‘, ‘A‘, ‘192.168.0.103‘);

2.#host anlegen:
--ip nameserver (resp_person can be NULL)
INSERT INTO dns_records (zone,host,type,DATA,resp_person)
VALUES (‘linuxtone.org‘, ‘ns1‘, ‘A‘, ‘192.168.0.103‘, ‘root.linuxtone.org.‘);

A:www.linuxtone.org
INSERT INTO dns_records (zone,host,type,DATA)
VALUES (‘linuxtone.org‘, ‘www‘, ‘A‘, ‘192.168.0.108‘);

A:bbs.linuxtone.org
INSERT INTO dns_records (zone,host,type,DATA)
VALUES (‘linuxtone.org‘, ‘bbs‘, ‘A‘, ‘192.168.0.109‘);

3.#host alias anlegen:
--ns2 directs to ns1
INSERT INTO dns_records (zone,host,type,DATA,resp_person)
VALUES (‘linuxtone.org‘, ‘ns2‘, ‘CNAME‘, ‘ns1.linuxtone.org.‘, ‘root.linuxtone.org.‘);

alias:man.linuxtone.org cname www
INSERT INTO dns_records (zone,host,type,DATA)
VALUES (‘linuxtone.org‘, ‘man‘, ‘CNAME‘, ‘www‘);

alias: host.linuxton.org cname bbs
INSERT INTO dns_records (zone,host,type,DATA)
VALUES (‘linuxtone.org‘, ‘host‘, ‘CNAME‘, ‘bbs.linuxtone.org.‘);

4.#mailserver anlegen:
--ns2 directs to ns1
INSERT INTO dns_records (zone,host,type,DATA,mx_priority, resp_person)
VALUES (‘linuxtone.org‘, ‘*‘, ‘MX‘, ‘mail.linuxtone.org.‘, ‘80‘, ‘root.linuxtone.org.‘);


安装bind,9.4.0以上版本都有DLZ补丁了,DLZ(Dynamically Loadable Zones),允许区域记录放置在数据库中,并且支持多种数据库。
./configure --with-dlz-mysql --enable-largefile --enable-threads=no --prefix=/usr/local/bind --disable-openssl-version-check
make && make install

cd /usr/local/bind/etc/
../sbin/rndc-confgen >rndc.conf
tail -n10 rndc.conf | head -n9 | sed -e s/#\//g >named.conf

dig > named.root  //这一步没做成功也没关系 貌似


vi /usr/local/bind/etc/named.conf
dlz "Mysql zone" {
   database "mysql
   {host=127.0.0.1 dbname=dns ssl=false port=3306 user=root pass= }  
   {select zone from dns_records where zone = ‘$zone$‘ limit 1}
   {select ttl, type, mx_priority, case when lower(type)=‘txt‘ then concat(‘\"‘, data, ‘\"‘)
        else data end from dns_records where zone = ‘$zone$‘ and host = ‘$record$‘
        and not (type = ‘SOA‘ or type = ‘NS‘)}
   {select ttl, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum
        from dns_records where zone = ‘$zone$‘ and (type = ‘SOA‘ or type=‘NS‘)}
   {select ttl, type, host, mx_priority, data, resp_person, serial, refresh, retry, expire,
        minimum from dns_records where zone = ‘$zone$‘ and not (type = ‘SOA‘ or type = ‘NS‘)}
   {select zone from xfr_table where zone = ‘$zone$‘ and client = ‘$client$‘}
   {update data_count set count = count + 1 where zone =‘$zone$‘}";
};

启动
/usr/local/bind/sbin/named -c /usr/local/bind/etc/named.conf

bind9+mysql dlz(Dynamically Loadable Zones)

标签:io   ar   os   sp   for   数据   on   art   log   

原文地址:http://www.cnblogs.com/fanweiwei/p/4094958.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!