NFC服务器搭建与autofs自动挂载

NFC服务器搭建与autofs自动挂载

所需安装环境

RPC 

RPC = Remote Procedure Call

#共享主机需要

RPC rpcbind

NFS nfs-server

#访问主机需要

RPC rpcbind

服务端NFS安装

1 yum install nfs-utils -y   #安装nfs

2 systemctl start nfs   #开启nfs服务

3 systemctl enable nfs   #开机自启动

配置NFS服务

1 mkdir /westos

2 echo 'hello,world' > /westos/hello  # 建立目录 /westos, 在其中创建测试文件hello

服务端测试

showmount命令查看指定服务器的nfs共享文件信息,常用选项 -e:显示指定服务器输出的共享目录

1 showmount -e 192.168.1.152

2 Export list for192.168.1.152:

3 /westos *   

挂载共享目录

1 mount 服务器名或IP地址:共享目录 本地挂载目录

2 mount 192.168.1.152:/westos /mnt/ # 将共享目录挂载到本地/mnt     ls /mnt/

3 hello   #有我们的测试文件,说明目录共享成功

4 vim /etc/fstab

5192.168.1.152:/westos /mnt/ nfs defaults 00 # 让共享目录自动挂载

 

设置固定窗口

修改 /etc/sysconfig/nfs 文件  

MOUNTD_PORT="4002"

STATD_PORT="4003"

LOCKD_TCPPORT="4004"

LOCKD_UDPPORT="4004"

 

autofs配置

安装autofs --->yum install autofs在下面的目录下,添加主映射文件

/etc/auto.master.d/share.autofs #一定要加上.autofs后缀,前面的share可以随意改

/share /etc/auto.demo #前面/share为挂载点的目录,服务启动会自动生成,后面的为映射文件,名称随意

创建映射文件/etc/auto.demo

work -rw,sync <host>:/<dirname> #参数和mount相同,work为挂载点,在/share目录下,这两个目录都不需要手动去创建,会自动生成,而work之后在访问的时候,自动挂载之后才会生成,不访问的时候会自动删掉

启动服务

猜你喜欢

转载自www.cnblogs.com/lxz5/p/11876636.html