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

从网站建设到定制行业解决方案,为提供成都网站设计、做网站服务体系,各种行业企业客户提供网站建设解决方案,助力业务快速发展。成都创新互联将不断加快创新步伐,提供优质的建站服务。
1. 服务器端
1.1 安装
[root@localhost Desktop]# yum install nfs-utils -y
# 关闭iptables
[root@localhost Desktop]# iptables -F
[root@localhost Desktop]# system^C
[root@localhost Desktop]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]1.2 创建共享目录
[root@localhost Desktop]# mkdir /nfsdir
# 确保共享目录有权限,其他人可以读写
[root@localhost Desktop]# chmod -Rf 777 /nfsdir1.3 配置nfs
主配置文件/etc/exports
格式:共享目录的路径 允许访问的nfs客户端IP(共享权限参数),nfs客户端IP和权限之间没有空格。
权限的参数:
| 参数 | 作用 | 
|---|---|
| ro | 只读 | 
| rw | 读写 | 
| root_squash | 当nfs客户端以root管理员访问时,映射为nfs服务器的匿名用户 | 
| no_root_squash | 芳nfs客户端以root管理员访问时,映射为nfs服务器的root管理员 | 
| all_saquash | 无论nfs客户端使用什么账户访问,均映射为nfs服务器的匿名用户 | 
| sync | 同时将数据写入到内存与硬盘中,保证数据不丢 | 
| async | 优先将数据保存到内存,然后再写入硬盘;这样效率高,但有可丢失数据 | 
[root@localhost Desktop]# vim /etc/exports
/nfsdir 192.168.137.*(rw,sync,root_squash)1.4 启动
# 启动RPC,nfs需要使用RPC服务
[root@localhost Desktop]# systemctl restart rpcbind.service 
[root@localhost Desktop]# systemctl enable rpcbind.service 
# 启动nfs
[root@localhost Desktop]# systemctl restart nfs-server
[root@localhost Desktop]# systemctl enable nfs-server
ln -s '/usr/lib/systemd/system/nfs-server.service' '/etc/systemd/system/nfs.target.wants/nfs-server.service'2. 客户端
2.1 安装nfs-utils工具
[root@localhost ~]# yum install nfs-utils -y2.2 查询服务端共享信息
showmount 命令的参数
| 参数 | 作用 | 
|---|---|
| -e | 显示nfs服务器的共享列表 | 
| -a | 显示本机挂载的fns资源 | 
[root@localhost ~]# showmount -e 192.168.137.10
Export list for 192.168.137.10:
/nfsdir 192.168.137.*2.3 挂载
[root@localhost ~]# mkdir /nfsdir
[root@localhost ~]# mount -t nfs 192.168.137.10:/nfsdir /nfsdir
[root@localhost ~]# df -Th
Filesystem             Type      Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root  xfs        18G  3.0G   15G  17% /
devtmpfs               devtmpfs  985M     0  985M   0% /dev
tmpfs                  tmpfs     994M  140K  994M   1% /dev/shm
tmpfs                  tmpfs     994M  8.9M  986M   1% /run
tmpfs                  tmpfs     994M     0  994M   0% /sys/fs/cgroup
/dev/sda1              xfs       497M  112M  385M  23% /boot
/dev/sr0               iso9660   3.5G  3.5G     0 100% /media/cdrom
192.168.137.10:/nfsdir nfs4       18G  3.0G   15G  17% /nfsdir测试成功
分享名称:nfs网络文件系统--学习笔记
标题网址:http://www.scyingshan.cn/article/ijdpch.html

 建站
建站
 咨询
咨询 售后
售后
 建站咨询
建站咨询 
 