nfs网络文件系统,学习笔记

  

<强>本次实验的环境是redhat 7.0系统
nfs服务可以将远程linux服务器上的文件共享资源挂载到本地linux主机上,本地的linux主机可以基于TCP/IP协议,像使用本地目录文件一样去操作远程共享的目录文件。

  

1。服务器端

  

1.1安装

  
 <代码> [root@localhost桌面]# yum安装nfs-utils - y
  
  #关闭iptables
  (root@localhost桌面)# iptables - f
  (root@localhost桌面)#系统C ^
  (root@localhost桌面)#服务iptables保存
  iptables防火墙规则保存到/etc/sysconfig/iptables:[好] 
  

1.2创建共享目录

  
 <代码> # mkdir/nfsdir root@localhost桌面
  #确保共享目录有权限,其他人可以读写
  (root@localhost桌面)# chmod 777 rf/nfsdir  
  

1.3配置nfs

  

主配置文件/etc/出口
格式:共享目录的路径允许访问的nfs客户端IP(共享权限参数),nfs客户端IP和权限之间没有空格。
权限的参数:

           参数   作用               罗依   只读         rw   读写         root_squash   当nfs客户端以根管理员访问时,映射为nfs服务器的匿名用户         no_root_squash   芳nfs客户端以根管理员访问时,映射为nfs服务器的根管理员         all_saquash   无论nfs客户端使用什么账户访问,均映射为nfs服务器的匿名用户         同步   同时将数据写入到内存与硬盘中,保证数据不丢         异步   优先将数据保存到内存,然后再写入硬盘,这样效率高,但有可丢失数据            
 <代码> # vim/etc/exports root@localhost桌面/nfsdir 192.168.137。* (rw,同步,root_squash)  
  

1.4启动

  
 <代码> #启动RPC, nfs需要使用RPC服务
  # systemctl重启rpcbind.service root@localhost桌面
  (root@localhost桌面)# systemctl启用rpcbind.service
  #启动nfs
  (root@localhost桌面)# systemctl重新启动nfs服务器
  (root@localhost桌面)# systemctl启用nfs服务器
  ln - s/usr/lib/systemd/系统/nfs服务器。服务“/etc/systemd/系统/nfs.target.wants/nfs-server.service” 
  

2。客户端

  

2.1安装nfs-utils工具

  
 <代码> [root@localhost ~] # yum安装nfs-utils - y  
  

2.2查询服务端共享信息

  

showmount命令的参数

           参数   作用               - e   显示nfs服务器的共享列表         ——一个   显示本机挂载的fn资源            
 <代码> root@localhost ~ # showmount - e 192.168.137.10
  出口192.168.137.10列表:/nfsdir 192.168.137。*  
  

2.3挂载

  
 <代码> root@localhost ~ # mkdir/nfsdir
  [root@localhost ~] nfs 192.168.137.10: # mount - t/nfsdir/nfsdir
  root@localhost ~ # df th
  文件系统类型大小效果使用%安装在使用
  18 g/dev/mapper/rhel-root xfs 3.0 g 15 g/17%
  devtmpfs devtmpfs 985 0 985 0%/dev
  tmpfs tmpfs/dev/shm 994 140 k 994 1%
  tmpfs tmpfs 994 8.9 986/1%运行
  tmpfs tmpfs 994 0 994/sys/fs/cgroup的0%/dev/sda1 xfs 497米112米385米/boot 23%/dev/sr0 iso9660 3.5 g/媒体/cdrom 3.5 g 0 100%
  192.168.137.10:/nfsdir nfs4 18 g 3.0 g 15 g 17%/nfsdir  
  

测试成功

nfs网络文件系统,学习笔记