MySQL数据库安装
shell > tar zxvf mysql-version.tar.gz -C /tmp
或 gunzip
< mysql-version.tar.gz | tar zxf - -C /tmp
shell > cd
/tmp/mysql-version
shell > ./configure --prefix=/usr/local/mysql \
>
--localstatedir=/usr/local/mysql/data \
>
--libexecdir=/usr/local/mysql/lib \
> --enable-assembler \
>
--with-extra-charsets=complex \
> --enable-thread-safe-client \
>
--with-big-tables \
> --with-readline \
> --with-ssl \
>
--with-embedded-sever \ embedded潜入式
> --enable-local-infile \
>
--disable-shared \
> --with-mysqld-ldflags=-all-static
shell > make
&& make install
shell > groupadd mysql
shell > useradd -g
mysql -s /sbin/nologin -M mysql
shell > cd /usr/local/mysql
shell >
chown -R root .
shell > chgrp -R mysql .
shell > chown -R mysql
data
shell > chown -R mysql lib
shell > ./bin/mysql_install_db
--user=mysql
shell > ./bin/mysqld_safe --user=mysql &
shell > cd
/tmp/mysql-version
shell > cp support-files/my-medium.cnf
/etc/my.cnf
shell > cp support-files/mysql.server
/etc/rc.d/init.d/mysqld
shell > chmod 700 !$
shell > chkconfig --add
mysqld
shell > chkconfig --list mysqld
mysqld 1:off 2:on 3:on 4:on 5:on
6:off
shell > service mysqld start[restart/reload/stop/]
shell > vi
/etc/my.cnf
and add this:
wait_timeout = 86400
interactive_timeout = 86400
:wq save and squid
shell >
/usr/local/mysql/bin/mysqladmin -u root -p password
‘*******’
password:(直接的敲回车,原始密码为空)
shell > /usr/local/mysql/bin/mysql
-u root -p
password: (*******)
mysql > (以root用户登陆mysql数据库)
安装bind
shell>tar zxvf bind-9.5.0-p2.tar.gz
shell>cd
bind-9.5.0-p2
shell>./configure --prefix=/usr/local/bind9
(注意换行符)
--with-dlz-mysql=/usr/local/mysql
--enabl-threads=no
----------------------------------------------------------------------------------
--with-dlz-mysql=/usr/local/mysql
要求bind安装中支持DLZ
--enable-threads=no
关闭多线程
----------------------------------------------------------------------------------
shell>make
shell>make install
创建数据库、表
mysql>create database mydata;
mysql>use
mydata;
mysql>create table other_dns_records (
>zone varchar
(255),
>host varchar (255),
>type varchar (255),
>data varchar
(255),
>ttl int(11),
>mx_priority varchar (255),
>refresh
int(11),
>retry int(11),
>expire int(11),
>minimum
int(11),
>serial bigint(20),
>resp_person varchar
(255),
>primary_ns varchar (255)
>);
mysql>create table
cnc_dns_records (
>zone varchar (255),
>host varchar
(255),
>type varchar (255),
>data varchar (255),
>ttl
int(11),
>mx_priority varchar (255),
>refresh int(11),
>retry
int(11),
>expire int(11),
>minimum int(11),
>serial
bigint(20),
>resp_person varchar (255),
>primary_ns varchar
(255)
>);
>//向表中添加一条记录
>insert into other_dns_records
(zone,host,type,data,ttl,retry)
values
('aaa.com','www','A','192.168.199.2','86400','15');
>insert into
cnc_dns_records (zone,host,type,data,ttl,retry)
values
('bbb.com','www','A','192.199.22.22','86400','13');
编辑/usr/local/bind9/etc/named.conf
>cd
/usr/local/bind9/etc
>../sbin/rndc-config -a
>../sbin/rndc-config
> named.conf
>vi !$
//删除# Use with the following in named.conf,
adjusting the allow list as needed: 以
前的行
将# Use with the following in
named.conf, adjusting the allow list as needed: 和 #
End of named.conf
之间的行前#号
最终的etc/named.conf文件如下:
-----------------------------------------------------------------------------------------------------------------------
# Use with the following in named.conf, adjusting the allow list as
needed:
key "rndc-key" {
algorithm hmac-md5;
secret
"2rkqGUle0VlsawCL2+IKsA==";
};
controls {
inet 127.0.0.1 port
953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
# End of
named.conf
options {
directory "/usr/local/binid/etc/";
pid-file
"/usr/local/binid/var/run/named.pid";
allow-query { any; };
recursion
no;
version "gaint-d1";
};
include
"/usr/local/binid/etc/cnc.cl";
include
"/usr/local/binid/etc/other.cl";
view "cnc-user" {
match-clients { cnc;
};
dlz "Mysql zone" {
database "mysql
{host=localhost dbname=mydb
ssl=false port=3306 user=root pass=abc123!}
{select zone from cnc_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 as mydata from
cnc_dns_records where zone = '%zone%'
and host = '%record%'}";
};
};
view "other-user" {
match-clients {
other; };
dlz "Mysql zone" {
database "mysql
{host=localhost
dbname=mydb ssl=false port=3306 user=root pass=abc123!}
{select zone from
other_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 as mydata from
other_dns_records where
zone = '%zone%' and host = '%record%'}";
};
};
------------------------------------------------------------------------------------------------------------------------
etc/cnc.cl如下:
acl "cnc" {
192.168.9.0/24;
};
-------------------------------------------------------------------------------------------------------------------------
etc/other.cl如下:
acl "other" {
127.0.0.0/18;
};
------------------------------------------------------------------------------------------------------------------------