CentOS7源码安装最新版本bind9-开机启动服务设置
Posted yangxiaoqian
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7源码安装最新版本bind9-开机启动服务设置相关的知识,希望对你有一定的参考价值。
1、编写一个shell脚本,脚本名称named,内容如下:
#!/bin/bash
#chkconfig: 545 35 75
#description: named DNS service manager
data=" /usr/local/bind9/sbin/named -u named -c /usr/local/bind9/etc/named.conf"
function START()
eval $data && echo -e "BIND9 start\\033[32m ok\\033[0m"
function STOP()
kill `cat /usr/local/bind9/var/run/named.pid` && echo -e "BIND9 stop\\033[32m ok\\033[0m"
case "$1" in
start)
START
;;
stop)
STOP
;;
restart)
STOP
sleep 3
START
;;
*)
echo "Usage: named (start|stop|restart)"
;;
esac
————————————————
版权声明:本文为CSDN博主「张舵主」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u011288801/article/details/106737855
2、相关操作
[root@DNS-XUEXI-xuexiji init.d]# pwd
/etc/rc.d/init.d
[root@DNS-XUEXI-xuexiji init.d]# chmod +x /etc/rc.d/init.d/named
[root@DNS-XUEXI-xuexiji init.d]# chkconfig --add named
[root@DNS-XUEXI-xuexiji init.d]# chkconfig named on
3、添加相关权限
chown -R named:named /usr/local/bind9/var/named
3、启动测试
[root@DNS-XUEXI-xuexiji ~]# ps -ef|grep named
named 106968 1 0 19:04 ? 00:00:00 /usr/local/bind9/sbin/named -u named -c /usr/local/bind9/etc/named.conf
root 107180 105867 0 19:08 pts/2 00:00:00 grep --color=auto named
[root@DNS-XUEXI-xuexiji ~]# service named restart
BIND9 stop ok
BIND9 start ok
[root@DNS-XUEXI-xuexiji ~]# ps -ef|grep named
named 107203 1 0 19:08 ? 00:00:00 /usr/local/bind9/sbin/named -u named -c /usr/local/bind9/etc/named.conf
root 107211 105867 0 19:08 pts/2 00:00:00 grep --color=auto named
[root@DNS-XUEXI-xuexiji ~]#
4、重启操作系统,系统启动后确认named进程已经自动开启
以上是关于CentOS7源码安装最新版本bind9-开机启动服务设置的主要内容,如果未能解决你的问题,请参考以下文章