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

nohup ./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)的更多相关文章

  1. bind9+dlz+mysql连接断开问题

    前言 关于bind-dlz介绍:http://bind-dlz.sourceforge.net/ DLZ(Dynamically Loadable Zones)与传统的BIND9不同,BIND的不足之 ...

  2. Bind+DLZ构建企业智能DNS/DNS

    Bind+DLZ构建企业智能DNS   目录:一.简介二.服务规划三.安装BIND及基本环境四.配置Bind-View-DLZ-MYSQL五.添加相关记录并进行测试六.配置从DNS七.补充 一.简介: ...

  3. MySQL的多存储引擎架构

    支持多种存储引擎是众所周知的MySQL特性,也是MySQL架构的关键优势之一.如果能够理解MySQL Server与存储引擎之间是怎样通过API交互的,将大大有利于理解MySQL的核心基础架构.本文将 ...

  4. Adding New Functions to MySQL(User-Defined Function Interface UDF、Native Function)

    catalog . How to Add New Functions to MySQL . Features of the User-Defined Function Interface . User ...

  5. BIND9配置文件详解模板[转载]

    在CU上看到了一篇关于BIND9配置文件详解的文章,感觉不错,现转载了分享一下. //named.conf 注释说明 by shellyxz@163.com// 此文件对bind9的默认配置文件的说明 ...

  6. MySql的多存储引擎架构, 默认的引擎InnoDB与 MYISAM的区别(滴滴)

    1.存储引擎是什么? MySQL中的数据用各种不同的技术存储在文件(或者内存)中.这些技术中的每一种技术都使用不同的存储机制.索引技巧.锁定水平并且最终提供广泛的不同的功能和能力.通过选择不同的技术, ...

  7. 嵌入式web服务

    :boa.thttpd.mini_httpd.shttpd.lighttpd.goaheand.appweb和apache等. Boa 1.介绍 Boa诞生于1991年,作者Paul Philips. ...

  8. 类handler

    /** The handler class is the interface for dynamically loadable storage engines. Do not add ifdefs a ...

  9. python代码优化技巧

    转自:http://www.douban.com/group/topic/31478102/ 这个资料库还有些不错的好文章: http://www.ibm.com/developerworks/cn/ ...

随机推荐

  1. 【STM32F4】读取芯片ID和芯片Flash Size

    首先声明,手册上给出的FlashSize地址是错误的,正确的应该是0x1FFF7A20,取高16位.确切说应该是(0x1FFF7A23,0x1FFF7A22两个字节), 芯片的这96位ID是产品唯一身 ...

  2. The server encountered an internal error that prevented it from fulfilling this request.

    type Exception report message Request processing failed; nested exception is org.mybatis.spring.MyBa ...

  3. [Maven]Maven详解

    转自:http://www.cnblogs.com/hongwz/p/5456578.html 一.前言     以前做过的项目中,没有真正的使用过Maven,只知道其名声很大,其作用是用来管理jar ...

  4. vue.js 2.0开发(2)

    如果我们想实时的显示我们todos的长度这个业务逻辑可以这样: <h1>{{message}} ({{todos.length}})</h1> 直接展示todos的length ...

  5. [转载]《民航科技》2012年4月专家论坛:罗喜伶《SWIM技术国际研究动态及对中国民航的借鉴意义》

    专家介绍:罗喜伶,北京航空航天大学电子信息工程学院副教授,工学博士,硕士生导师,国家空管新航行系统技术重点实验室和协同式网络化空中交通管理系统研究教育部创新团队核心成员,民航空管广域信息系统专家组成员 ...

  6. 71. Merge k Sorted Lists

    Merge k Sorted Lists Merge k sorted linked lists and return it as one sorted list. Analyze and descr ...

  7. ubuntu12.04下一个简单的conky安装

    这个conky用一些漂亮的圆圈来显示cpu,时钟,内存,交换空间,硬盘信息,网络及天气信息(不需要登陆任何网站噢).而且,提供多种色彩方案供选择,带发行版标记(fedora,mint,debian,o ...

  8. Linux学习四:UDP编程(上)

    关于UDP和TCP对比优缺,这里就不说了. 使用UDP代码所掉用的函数和用于TCP的函数非常类似,这主要因为套接口库在底层的TCP和UDP的函数上加了一层抽象,通过这层抽象使得编程更容易,但失去了一些 ...

  9. 带有静态方法的类(java中的math类)

    带有静态方法的类通常(虽然不一定是这样)不打算被初始化. 可以用私有构造函数来限制非抽象类被初始化. 例如,java中的math类.它让构造函数标记为私有,所以你无法创建Math的实例.但Math类却 ...

  10. Have Fun with Numbers及循环链表(约瑟夫问题)

    1. 循环链表(约瑟夫问题) https://github.com/BodhiXing/Data_Structure 2. Have Fun with Numbers https://pta.pate ...