1. Install MySQL first, direct yum installation
Yum-y install MySQL Mysql-server
2. Re-install some dependent packages
Yum-y install OpenSSL openssl-devel libss-dev gcc gcc-c++ mysql-devel
3. Download bind, bind website (https://www.isc.org/)
wget ftp://ftp.isc.org/isc/bind9/bind-9.10.3-P2/bind-9.10.3-P2.tar.gz
4. Download Mysql-bind Patch source code
wget http://nchc.dl.sourceforge.net/project/mysql-bind/mysql-bind/mysql-bind-0.2%20src/mysql-bind.tar.gz
5. Unzip the bind and Mysql-bind source Zip files
Tar zxvf bind-9.10.3-p2.tar.gz
Tar zxvf mysql-bind.tar.gz
6. Copy the MYSQLDB.C and mysqldb.h under the Mysql-bind source directory to the bin/named and bin/named/include/directories under the Bind source directory
CD Mysql-bind
Cp-f MYSQLDB.C mysqldb.h. /bind-9.10.3-p2/bin/named/
Cp-f MYSQLDB.C mysqldb.h. /bind-9.10.3-p2/bin/named/include/
7. Modify the Bind source directory bin/named/makefile.in file
Cd.. /bind-9.10.3-p2
Vim bin/named/makefile.in
Add the following lines:
DBDRIVER_OBJS =
Dbdriver_srcs =
Dbdriver_includes =
Dbdriver_libs =
Modified to:
DBDRIVER_OBJS = [email protected]@
Dbdriver_srcs = MYSQLDB.C
Dbdriver_includes =-i/usr/include/mysql-g-pipe-wp,-d_fortify_source=2-fexceptions-fstack-protector--param= Ssp-buffer-size=4-m64-d_gnu_source-d_file_offset_bits=64-d_largefile_source-fno-strict-aliasing-fwrapv-fpic- Duniv_linux-duniv_linux
Dbdriver_libs =-rdynamic-l/usr/lib64/mysql-lmysqlclient-lz-lcrypt-lnsl-lm-lssl-lcrypto
The value of the dbdriver_includes is obtained through the Mysql_config--cflags command.
The value of the dbdriver_libs is obtained through the Mysql_config--libs command.
8. Modify the Main.c file under the Bin/named directory in the Bind source directory
Vim BIN/NAMED/MAIN.C
Join #include "mysqldb.h"
As follows:
#include <config.h>
#include "mysqldb.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
Then in the comment code snippet/* Xxdb_init (); * * after adding mysqldb_init ();
In the comment code snippet/* Xxdb_clear (); * * after adding mysqldb_clear ();
9. Modify the # include <named/mysqldb.h> in MYSQLDB.C to #include <include/mysqldb.h>
10. Install bind
./configure--prefix=/usr/local/bind--enable-threads # Specify the installation directory and turn on multithreading processing power
Make
Make install
11. Configure Bind
Cd/usr/local/bind-9.10/etc
/usr/local/bind/sbin/rndc-confgen-r/dev/urandom>rndc.conf
Cat Rndc.conf|tail |head-9 |sed "s/^#//g" >named.conf # build configuration file
12. Create a Database
Create database mydomain;
Create a data table
CREATE TABLE Dnsrecord (
Name varchar (255) Default NULL,
TTL int (one) default NULL,
Rdtype varchar (255) Default NULL,
Rdata varchar (255) default NULL) Type=myisam;
Insert some test data
INSERT into Dnsrecord VALUES (' test.net ', 259200, ' SOA ', ' test.net '. Www.test.net 200505101 28800 7200 86400 28800 ');
INSERT into Dnsrecord VALUES (' test.net ', 259200, ' NS ', ' ns1.test.net. ');
INSERT into Dnsrecord VALUES (' ns1.test.net ', 259200, ' A ', ' 192.168.2.2 ');
INSERT into Dnsrecord VALUES (' www.test.net ', 259200, ' A ', ' 192.168.2.1 ');
13. Continue to configure bind
Vim/usr/local/bind/etc/named.conf
Follow the form below to add
Zone "mydomain.com" {
Type master;
Notify No;
Database "MySQLdb dbname tablename hostname user password"; };
MyDomain.com for the domain name to be resolved
dbname for Database name
Hostname is the database server address
User is the database username that can manipulate the preceding database table
Password the password for the corresponding database user name
Configuration complete
Run under the command line
/usr/local/bind/sbin/named-c/usr/local/bind/etc/named.conf-g
After viewing the problem
/usr/local/bind/sbin/named-c/usr/local/bind/etc/named.conf
Run bind
Write system service
Vim/etc/init.d/named
####################################################################
#!/bin/bash
#
# description:named Daemon Description Information
# Chkconfig:-25 88 start and shutdown levels
#
# start named pid file, actually file path we can specify the
Pidfile=/usr/local/bind/var/run/named.pid
# Start the service lock file, determine if a service is started by this lock file
Lockfile=/var/lock/subsys/named
# config file path for named
Conffile=/usr/local/bind/etc/named.conf
# determine if the Functios exists in the/etc/rc.d/init.d/functions path, and it sources come in.
[-r/etc/rc.d/init.d/functions] &&. /etc/rc.d/init.d/functions
# define the Startup method
Start () {
# Determine if the lock file exists, if it exists, the service has been started and exited.
If [-e $lockFile]; Then
echo "named is already running ..."
Exit 0
Fi
# The Print service has started the information
Echo-n "Starting named:"
# Call the Daemon method in functions, use the--pidfile to specify where the PID file is, specify the user and configuration file, we would have directly enabled the named, now take advantage of the daemon function to enable the service, he will get a lot of extra properties, If successful, will help us print what [OK], but also can make a judgment
Daemon--pidfile "$pidFile"/usr/local/bind/sbin/named-c "$confFile"
Retval=$?
Echo
# Determine if the above command succeeds, stating that the start was successful
If [$RETVAL-eq 0]; Then
# If the decision is successful, create a lock file
Touch $lockFile
Return $RETVAL
Else
# Otherwise, it's a failure, then delete the lock file and the PID file
Rm-f $lockFile $pidFile
Return 1
Fi
}
# define Stop method
Stop () {
# If the lock file does not exist
if [!-e $lockFile]; Then
# Description Service Not yet started
echo "named is stopped."
Fi
Echo-n "Stopping named:"
Killproc named
Retval=$?
Echo
# Determine if the above command execution stops successfully, if successful
If [$RETVAL-eq 0];then
# Delete lock file and PID file
Rm-f $lockFile $pidFile
return 0
Else
# Otherwise the print says it's not going to stop properly
echo "cannot stop named."
# Calling a function in functions, printing fails
Failure
Return 1
Fi
}
# define Restart Service
Restart () {
# Call Stop method
Stop
# sleep 2 seconds
Sleep 2
# Invoke Startup method
Start
}
# define the Reload service method
Reload () {
Echo-n "Reloading named:"
# Killprco HUP signal, named process signal
Killproc Named-hup
Retval=$?
Echo
Return $RETVAL
}
# define Service Status
Status () {
If pidof named &>/dev/null; Then
Echo-n "named is running ..."
Success
Echo
Else
Echo-n "named is stopped ..."
Success
Echo
Fi
}
# define error message
Usage () {
echo "usage:named {start|stop|restart|status|reload}"
}
Case $ in
Start
start;;
Stop
stop;;
Restart
restart;;
Status
status;;
Reload
reload;;
*)
Usage
Exit 4;;
Esac
####################################################################################
This article is from the "Desert Lone Eagle" blog, please make sure to keep this source http://yangji.blog.51cto.com/1155906/1732842
CentOS6 system BIND9 + MySQL configuration installation