NFS

网络文件系统

 1  2  3  4  5  6  7  8  9 10 11 12 13 14
yum install nfs-utils Loaded plugins: langpacks, product-id, subscription-manager (1/2): rhel7/group_gz | 134 kB 00:00 (2/2): rhel7/primary_db | 3.4 MB 00:00 Package 1:nfs-utils-1.3.0-0.el7.x86_64 already installed and latest version Nothing to do iptables -F service iptables save iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ] mkdir /nfsfile chmod -Rf 777 /nfsfile echo "welcome to linuxprobe.com" > /nfsfile/readme

NFS配置文件

参数作用
ro只读
rw读写
root_squash当NFS客户端以root管理员访问时,映射为NFS服务器的匿名用户
no_root_squash当NFS客户端以root管理员访问时,映射为NFS服务器的root管理员
all_squash无论NFS客户端使用什么账户访问,均映射为NFS服务器的匿名用户
sync同时将数据写入到内存与硬盘中,保证不丢失数据
async优先将数据保存到内存,然后再写入硬盘;这样效率更高,但可能会丢失数据

1 2 3 4 5 6 7 8
vim /etc/exports /nfsfile 192.168.10.*(rw,sync,root_squash) systemctl restart rpcbind systemctl enable rpcbind systemctl start nfs-server systemctl enable nfs-server ln -s '/usr/lib/systemd/system/nfs-server.service' '/etc/systemd/system/nfs.target.wants/nfs-server.service'

showmount命令参数

参数作用
-e显示NFS服务器的共享列表
-a显示本机挂载的文件资源的情况
-v显示版本号

 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
showmount -e 192.168.10.10 Export list for 192.168.10.10: /nfsfile 192.168.10.* mkdir /nfsfile mount -t nfs 192.168.10.10:/nfsfile /nfsfile cat /nfsfile/readme welcome to linuxprobe.com vim /etc/fstab # # /etc/fstab # Created by anaconda on Wed May 4 19:26:23 2017 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/rhel-root / xfs defaults 1 1 UUID=812b1f7c-8b5b-43da-8c06-b9999e0fe48b /boot xfs defaults 1 2 /dev/mapper /rhel-swap swap swap defaults 0 0 /dev/cdrom /media/cdrom iso9660 defaults 0 0 192.168.10.10:/nfsfile /nfsfile nfs defaults 0 0

浙ICP备11005866号-12