mysql-bind readme
yum install gcc gcc-c++
yum install openssl
yum install libssl-dev
yum install openssl-devel
yum install mysql-devel
#after see
#http://pbraun.nethence.com/doc/net/bind-mysql.html
BIND/MySQL configuration on RHEL
Prerequesties
Make sure you’ve got those installed,
rpm -q
mysql
mysql-server
mysql-devel
openssl
openssl-devel
Make sure MySQL is running (and secure),
service mysqld start
#mysql_secure_installation
Make sure BIND server is NOT installed,
rpm -qa | grep bind
Note. bind-libs and bind-utils pkgs are just fine
Note. bind, bind-chroot and bind-sdb pkgs should NOT be installed
Installation
Get latest BIND tarball (ftp://ftp.isc.org/isc/bind9/cur/).
Get the BIND/MySQL SDB driver (http://sourceforge.net/projects/mysql-bind/)
Extract the archives,
tar xvzf bind-9.7.1-P2.tar.gz
tar xvzf mysql-bind.tar.gz
Deploy the driver,
cp mysql-bind/mysqldb.c bind-9.7.1-P2/bin/named
cp mysql-bind/mysqldb.h bind-9.7.1-P2/bin/named/include
Adapt the makefile,
cd bind-9.7.1-P2/bin/named
vi Makefile.in
change,
DBDRIVER_OBJS = mysqldb.@O@
DBDRIVER_SRCS = mysqldb.c
also see MySQL’s compile flags,
mysql_config –cflags
and copy/paste to,
DBDRIVER_INCLUDES = -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv
also see MySQL’s libraries,
mysql_config –libs
and copy/paste to,
DBRIVER_LIBS = -rdynamic -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib -lssl -lcrypto
Add driver’s include into BIND’s code,
cd bind-9.7.1-P2/bin/named
vi main.c
add,
/*
* Include header files for database drivers here.
*/
/* #include “xxdb.h" */
#include “mysqldb.h"
also search for ‘ns_server_create’ and add mysqldb_init just before,
mysqldb_init();
ns_server_create(ns_g_mctx, &ns_g_server);
also search for ‘ns_server_destroy’ and add mysqldb_clear just after,
ns_server_destroy(&ns_g_server);
mysqldb_clear();
Fix driver’s own include path,
cd bind-9.7.1-P2/bin/named
vi mysqldb.c
change,
/* #include */
#include “include/mysqldb.h"
Note. otherwise you’ll get this error at compile time,
mysqldb.c:41:27: error: named/mysqldb.h: No such file or directory
Compile BIND,
cd ../..
./configure –help
./configure
#./configure –disable-openssl-version-check
make clean
make
make install
Configuration
Configure BIND,
cd /etc
vi named.conf
like,
zone “example.local" {
type master;
notify no;
database “mysqldb bindmysql example_local 127.0.0.1 DBUSER DBPASS";
};
note. change the values accordingly
check,
named-checkconf
Note. also just in case (optional, it reads /etc/named.conf anyway),
cd /usr/local/etc
ln -s ../../../etc/named.conf
Connect to MySQL,
mysql -uDBUSER -p
create a database,
create database if not exists bindmysql;
and create a table per domain in that database,
use bindmysql
create table example_local (
name varchar(255) default NULL,
ttl int(11) default NULL,
rdtype varchar(255) default NULL,
rdata varchar(255) default NULL
) type=MyISAM;
note. underscore instead of a dot for table name as domain name
inject some data e.g.,
insert into example_local values (‘example.local’, 259200, ‘SOA’, ‘example.local. postmaster.example.local. 201007281 28800 7200 86400 28800’);
insert into example_local values (‘example.local’, 259200, ‘NS’, ‘ns0.example.local.’);
insert into example_local values (‘example.local’, 259200, ‘MX’, ’10 mail.example.local.’);
insert into example_local values (‘ns0.example.local’, 259200, ‘A’, ‘10.1.1.1’);
insert into example_local values (‘example.local’, 259200, ‘A’, ‘10.1.1.1’);
insert into example_local values (‘mail.example.local’, 259200, ‘A’, ‘10.1.1.1’);
insert into example_local values (‘www.example.local’, 259200, ‘Cname’, ‘ns0.example.local.’);
Ready go go
Start the daemon,
/usr/local/sbin/named
Note. in case you need to reload named.conf,
kill -HUP XXXX
Check everything’s fine,
host example.local 127.0.0.1
host www.example.local 127.0.0.1
References
mysql-bind/README
bind-9.7.1-P2/README
bind-9.7.1-P2/doc/misc/SDB
http://mysql-bind.sourceforge.net/
http://goes-gsoc.zerothree.net/2009/05/09/mysql-bind-sdb-driver/