linux6下面 设置rpcbind自启动
时间: 2023-07-04 19:09:26 浏览: 103
在 Linux 6 中,可以使用以下步骤设置 `rpcbind` 自启动:
1. 创建一个启动脚本 `/etc/init.d/rpcbind`,脚本内容如下:
```bash
#!/bin/sh
#
# rpcbind This shell script takes care of starting and stopping
# rpcbind (portmap).
#
# chkconfig: - 64 36
# description: rpcbind is a daemon which converts RPC program numbers into
# universal addresses.
# processname: rpcbind
# config: /etc/sysconfig/portmap
# pidfile: /var/run/rpcbind.pid
# Source function library.
. /etc/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
prog="rpcbind"
start() {
# Start daemons.
echo -n $"Starting $prog: "
daemon rpcbind
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
echo
}
stop() {
# Stop daemons.
echo -n $"Shutting down $prog: "
killproc rpcbind
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
RETVAL=2
esac
exit $RETVAL
```
2. 设置脚本权限:
```bash
chmod +x /etc/init.d/rpcbind
```
3. 将 `rpcbind` 加入系统服务中:
```bash
chkconfig --add rpcbind
```
4. 启动 `rpcbind` 服务:
```bash
service rpcbind start
```
5. 验证服务是否已经自启动:
```bash
chkconfig --list rpcbind
```
输出结果应该类似于:
```bash
rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
```
其中,数字 `0-6` 表示不同的运行级别,`on` 表示服务已经被设置为自启动。
阅读全文
相关推荐

















