| 关键词: nbsp mysql mydns local devel crazylinux usr NULL UNSIGNED 172.16 |
环境: Centos 5.4 使用软件: wget http://mydns.bboy.net/download/mydns-1.1.0.tar.gz wget http://soft.vpser.net/datebase/mysql/mysql-5.1.54.tar.gz 安装前准备: yum -y install gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip 一、安装mysql数据库 tar zxvf mysql-5.1.54.tar.gz cd mysql-5.1.54 ./configure --prefix=/usr/local/mysql --with-extra-charsets=all --enable-thread-safe-client --enable-assembler --with-charset=utf8 --with-extra-charsets=all --with- big-tables --with-readline --with-ssl --with-embedded-server --enable-thread-safe-client --enable-local-infileser make make install groupadd mysql useradd -s /sbin/nologin -M -g mysql mysql cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf sed -i 's/skip-locking/skip-external-locking/g' /etc/my.cnf /usr/local/mysql/bin/mysql_install_db --user=mysql chown -R mysql /usr/local/mysql/var chgrp -R mysql /usr/local/mysql/. cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql chmod 755 /etc/init.d/mysql vim /etc/ld.so.conf.d/mysql.conf添加如下: /usr/local/mysql/lib/mysql /usr/local/lib ldconfig ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql ln -s /usr/local/mysql/include/mysql /usr/include/mysql /etc/init.d/mysql start ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump ln -s /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk /usr/local/mysql/bin/mysqladmin -u root password 123456 设置密码 二、安装mydns: tar zxvf mydns-1.1.0.tar.gz ./configure --prefix=/usr/local/mydns --with-mysql-lib=/usr/local/mysql/lib/mysql/ --with-mysql-include=/usr/local/mysql/include/mysql/ make && make install /usr/local/mysql/bin/mysqladmin -uroot -p create mydns 创建dns数据库 mysql>insert into mysql.user (host,user,password) values ('localhost','mydns',password('mydns')); //建立用户mydns,密码mydns mysq>flush privileges; //重载MySQL授权表 mysql>grant all on mydns.* to mydns@'localhost' identified by 'mydns'; 把数据mydns授权于用户mydns 生成主配置文件: /usr/local/mydns/sbin/mydns --dump-config > /etc/mydns.conf 三、配置mydns: 修改mydns.conf如下: # DATABASE INFORMATION db-host = localhost # SQL server hostname db-user = mydns # SQL server username db-password = mydns # SQL server password database = mydns # MyDNS database name # GENERAL OPTIONS user = mydns # Run with the permissions of this user group = mydns # Run with the permissions of this group listen = 172.16.6.200 # Listen on these addresses ('*' for all) no-listen = # Do not listen on these addresses # CACHE OPTIONS zone-cache-size = 1024 # Maximum number of elements stored in the zone cache zone-cache-expire = 60 # Number of seconds after which cached zones expires reply-cache-size = 1024 # Maximum number of elements stored in the reply cache reply-cache-expire = 30 # Number of seconds after which cached replies expire # ESOTERICA log = LOG_DAEMON # Facility to use for program output (LOG_*/stdout/stderr) pidfile = /var/run/mydns.pid # Path to PID file timeout = 120 # Number of seconds after which queries time out multicpu = 1 # Number of CPUs installed on your system recursive = 8.8.8.8 # Location of recursive resolver把解析不了的转发到8.8.8 recursive-timeout = # Number of seconds before first retry recursive-retries = # Number of retries before abandoning recursion recursive-algorithm = # Recursion retry algorithm one of: linear, exponential, progressive allow-axfr = yes # Should AXFR be enabled? allow-tcp = yes # Should TCP be enabled? allow-update = no # Should DNS UPDATE be enabled? ignore-minimum = no # Ignore minimum TTL for zone? soa-table = soa # Name of table containing SOA records rr-table = rr # Name of table containing RR data soa-where = # Extra WHERE clause for SOA queries rr-where = # Extra WHERE clause for RR queries /usr/local/mydns/sbin/mydns --background 放入后台运行mydns /usr/local/mydns/sbin/mydns reload 重新加载配置文件 /usr/local/mydns/sbin/mydns restart 重新启动mydns 四、测试添加相应记录: use mydns; CREATE TABLE soa ( id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, origin CHAR(255) NOT NULL, ns CHAR(255) NOT NULL, mbox CHAR(255) NOT NULL, serial INT UNSIGNED NOT NULL DEFAULT '20110601', refresh INT UNSIGNED NOT NULL DEFAULT '1800', retry INT UNSIGNED NOT NULL DEFAULT '7200', expire INT UNSIGNED NOT NULL DEFAULT '604800', minimum INT UNSIGNED NOT NULL DEFAULT '300', ttl INT UNSIGNED NOT NULL DEFAULT '1800' ) TYPE=MyISAM; 创建soa表 CREATE TABLE rr ( id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, zone INT UNSIGNED NOT NULL, name CHAR(64) NOT NULL, type ENUM('A','AAAA','CNAME','HINFO','MX','NS','PTR','RP','SRV','TXT') NOT NULL, data CHAR(128) NOT NULL, aux INT UNSIGNED NOT NULL, ttl INT UNSIGNED NOT NULL DEFAULT '36000' ) TYPE=MyISAM; 创建rr表 添加数据: insert into soa values (1,'crazylinux.cn.','ns.crazylinux.cn.','root.crazylinux.cn.',2011060114,1800,7200,604800,360,1800); insert into rr values (1,1,'www','A','172.16.6.202',0,360);添加条A记录www.crazylinux.cn解析到172.16.6.202 insert into rr values (2,1,'so','CNAME','so.crazylinux.cn.test.com.',0,360);添加条cname记录so.crazylinux.cn解析到so.crazylinux.cn.test.com. mysql> select * from rr; +----+------+------+-------+----------------------------+-----+-----+ | id | zone | name | type | data | aux | ttl | +----+------+------+-------+----------------------------+-----+-----+ | 1 | 1 | www | A | 172.16.6.202 | 0 | 360 | | 2 | 1 | so | CNAME | so.crazylinux.cn.test.com. | 0 | 360 | +----+------+------+-------+----------------------------+-----+-----+ 2 rows in set (0.00 sec) 测试: [root@localhost ~]# dig @172.16.6.200 www.crazylinux.cn ; <<>> DiG 9.3.4-P1 <<>> @172.16.6.200 www.crazylinux.cn ; (1 server found) ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58196 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.crazylinux.cn. IN A ;; ANSWER SECTION: www.crazylinux.cn. 360 IN A 172.16.6.202 ;; Query time: 3 msec ;; SERVER: 172.16.6.200#53(172.16.6.200) ;; WHEN: Thu Jun 2 23:29:11 2011 ;; MSG SIZE rcvd: 51 [root@localhost ~]# dig @172.16.6.200 so.crazylinux.cn ; <<>> DiG 9.3.4-P1 <<>> @172.16.6.200 so.crazylinux.cn ; (1 server found) ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19345 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;so.crazylinux.cn. IN A ;; ANSWER SECTION: so.crazylinux.cn. 360 IN CNAME so.crazylinux.cn.test.com. ;; Query time: 3 msec ;; SERVER: 172.16.6.200#53(172.16.6.200) ;; WHEN: Thu Jun 2 23:29:24 2011 ;; MSG SIZE rcvd: 73 五、组件和web接口: mydnscheck 检查语法的一致性Check data syntax and consistency. mydnsexport 导出某个zone的数据 Output zone data in formats understood by other DNS servers. mydnsimport 导入某个zone的数据 Import zone data from external sources. mydns自带了一个admin.php的文件,位于源码包内的contrib目录下 建议使用mydnsconfig来代替admin.php 注意:(1)、ns类型仅对子域名生效。 (2)、类型为'A',DATA为'IP'则记录结尾不以.结束(1.1.1.1)。其它情况全以.结束 (a.com.,1.1.1.1.)。 (3)、类型为'CNAME'只能允许一条记录,其它可允许多条记录。 |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|