啥也没写
分类: LINUX
2010-09-16 12:31:25
MYDNS没有自动检测主机是否存活的功能,随手写了一个SHELL来实现这个功能
首先,给mysql中的rr表加一个active的字段,emun 1 或 0 1表示启动,0表示禁用
再修改/etc/mydns.conf
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 = 10 # Number of seconds after which cached replies expire
尽量缓存的时间小点,这样修改过的域名,很会快生效,可能也会对MYSQL有一定的影响!
脚本如下:
--------check.sh--------------------------------
#!/bin/bash
#auther:akin520
#blog: http://badb0y.cublog.cn and http://badb0y.blog.51cto.com
#set mysql config
MYSQL_BIN=/usr/local/mysql/bin
MYSQL_HOST=localhost
MYSQL_USER=root
MYSQL_PWD=root
stty erase ^h
mysql_ip=`$MYSQL_BIN/mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PWD -e "select * from mydns.rr where type='A';"|awk 'NR>1 {print $5}'`
for x in $mysql_ip
do
ping -c1 -W1 $x
result=$?
if [[ $result -eq 0 ]]
then
echo "server $x active!"
$MYSQL_BIN/mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PWD -e "UPDATE mydns.rr SET active=\"1\" WHERE DATA=\""$x"\";"
else
echo "server $x down!"
$MYSQL_BIN/mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PWD -e "UPDATE mydns.rr SET active=\"0\" WHERE DATA=\""$x"\";"
fi
done
只是一个简单的PING做检测,速度太慢!如果谁有更快的方便,,一定要告诉我噢,和和!
chinaunix网友2010-09-16 15:27:46
很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com