#wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.54.tar.gz //获取mysql源码包
#tar zxvf mysql-5.1.54.tar.gz
#cd mysql-5.1.54
#./configure --prefix=/usr/local/mysql //指定mysql安装路径
--with-mysqld-ldflags=-all-static //以静态方式编译服务器端
--with-client-ldflags=-all-static //以静态方式编译客户端
--with-extra-charsets=utf8,gbk //添加utf8、gbk字符集
--with-plugins=innobase,myisam //添加mysql存储引擎
--with-server-suffix=-community //为mysqld版本字符串添加后缀
--with-unix-socket-path=/usr/local/mysql/sock/mysql.sock
--enable-thread-safe-client //以线程方式编译客户端,提高性能
--enable-assembler //使用汇编,提高性能
--enable-profiling //启用profile功能
--without-embedded-server //去除embedded
--without-debug //去除debug模式,提高性能
--without-bench //去除bench模式,提高性能
#make && make install //编译并安装
#cp support-files/my-medium.cnf /etc/my.cnf //复制mysql配置文件
#/usr/local/mysql/bin/mysql_install_db --user=mysql & //初始化mysql
#/usr/local/mysql/bin/mysqld_safe --user=mysql & //启动mysql
#/usr/local/mysql/bin/mysqladmin -uroot password 123456 //设置mysql管理员密码
#echo "/usr/local/mysql/bin/mysqld_safe --user=mysql &" >>/etc/rc.local //加入开机自启动
#echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile //加入环境变量
#source /etc/profile //更新环境变量
#tar zxvf bind-9.6.0-P1.tar.gz 解压源码包
#cd bind-9.6.0-P1 进入解压目录
#./configure --prefix=/usr/local/named –with-dlz-mysql --enable-threads=no --with-openssl=no 编译前配置
#make && make install 编译并安装
#/usr/local/named/sbin/rndc-confgen > /usr/local/named/etc/rndc.conf 生成rndc控制命令的key文件
#tail -10 /usr/local/named/etc/rndc.conf |head -9|sed s/#\ //g > /usr/local/named/etc/named.conf 从rndc.conf中提取named.conf用的key
准备BIND DLZ所需的数据库
create table xfr_table(zone text,client text); 创建BIND DLZ所组要的表
database "mysql 区域数据使用mysql数据库存储
{host=localhost dbname=named ssl=false user=named pass=namedpass} 链接数据库
{select zone from dns_records where zone = '%zone%'}
{select ttl, type, mx_priority, case when lower(type)='txt' then concat('\"', data, '\"') when lower(type) = 'soa' then concat_ws(' ', data, resp_person, serial, refresh, retry, expire, minimum) else data end from dns_records where zone = '%zone%' and host = '%record%'}"; 查询的信息
Oct 11 23:24:15 localhost named[2185]: max open files (1024) is smaller than max sockets (4096)
Oct 11 23:24:15 localhost named[2185]: using default UDP/IPv4 port range: [1024, 65535]
Oct 11 23:24:15 localhost named[2185]: using default UDP/IPv6 port range: [1024, 65535]
Oct 11 23:24:15 localhost named[2185]: no IPv6 interfaces found
Oct 11 23:24:15 localhost named[2185]: listening on IPv4 interface lo, 127.0.0.1#53
Oct 11 23:24:15 localhost named[2185]: listening on IPv4 interface eth0, 192.168.81.128#53
Oct 11 23:24:15 localhost named[2185]: Loading 'Mysql zone' using driver mysql
Oct 11 23:24:15 localhost named[2185]: automatic empty zone: 0.IN-ADDR.ARPA
Oct 11 23:24:15 localhost named[2185]: automatic empty zone: 127.IN-ADDR.ARPA
Oct 11 23:24:15 localhost named[2185]: automatic empty zone: 254.169.IN-ADDR.ARPA
Oct 11 23:24:15 localhost named[2185]: automatic empty zone: 2.0.192.IN-ADDR.ARPA
Oct 11 23:24:15 localhost named[2185]: automatic empty zone: 255.255.255.255.IN-ADDR.ARPA
Oct 11 23:24:15 localhost named[2185]: automatic empty zone: 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA
Oct 11 23:24:15 localhost named[2185]: automatic empty zone: 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA
Oct 11 23:24:15 localhost named[2185]: automatic empty zone: D.F.IP6.ARPA
Oct 11 23:24:15 localhost named[2185]: automatic empty zone: 8.E.F.IP6.ARPA
Oct 11 23:24:15 localhost named[2185]: automatic empty zone: 9.E.F.IP6.ARPA
Oct 11 23:24:15 localhost named[2185]: automatic empty zone: A.E.F.IP6.ARPA
Oct 11 23:24:15 localhost named[2185]: automatic empty zone: B.E.F.IP6.ARPA
Oct 11 23:24:15 localhost named[2185]: command channel listening on 127.0.0.1#953
Oct 11 23:24:15 localhost named[2185]: running
> server 127.0.0.1
Default server: 127.0.0.1
Address: 127.0.0.1#53
> mail.xiaocui.com
Server: 127.0.0.1
Address: 127.0.0.1#53
Address: 10.1.1.100
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
> server 127.0.0.1
Default server: 127.0.0.1
Address: 127.0.0.1#53
> mail.xiaocui.com
Server: 127.0.0.1
Address: 127.0.0.1#53
Address: 10.0.1.200