linux如何设置rpcbind先于nfs启动
时间: 2024-05-27 14:10:21 浏览: 8
你可以通过修改/etc/systemd/system/nfs-server.service.d/rpcbind.conf文件来实现rpcbind优先于nfs启动。具体步骤如下:
1. 打开终端并用管理员权限打开rpcbind.conf文件:
sudo nano /etc/systemd/system/nfs-server.service.d/rpcbind.conf
2. 在该文件中添加以下内容:
[Unit]
Wants=rpcbind.socket
After=rpcbind.socket
3. 保存并关闭文件,然后重新加载systemctl配置:
sudo systemctl daemon-reload
4. 重新启动nfs-server服务:
sudo systemctl restart nfs-server.service
现在rpcbind将在nfs之前启动,从而确保nfs服务可以访问rpc绑定端口。
相关问题
linux6下面 设置rpcbind自启动
在 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` 表示服务已经被设置为自启动。
启动rpcbind和nfs服务
启动rpcbind服务的命令是:
```
sudo systemctl start rpcbind
```
启动nfs服务的命令是:
```
sudo systemctl start nfs-server
```
如果你的操作系统不是基于systemd的,则可以使用以下命令启动服务:
```
sudo service rpcbind start
sudo service nfs-server start
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)