10.3 NFS服务端部署环境准备
10.3.1 NFS服务部署服务器准备
服务器系统 |
角色 |
IP |
Centos6.7 x86_64 |
NFS服务器端(NFS-server) |
192.168.1.14 |
Centos6.7 x86_64 |
NFS客户端(Web-lamp01) |
192.168.1.15 |
Centos6.7 x86_64 |
NFS客户端(Web-lnmp02) |
192.168.1.16 |
10.3.2 NFS服务部署架构图
10.3.3 NFS服务器端操作系统及内核版本
1 [root@NFS-server ~]# cat /etc/redhat-release
2 CentOS release 6.7 (Final)
3 [root@NFS-server ~]# username -r
4 [root@NFS-server ~]# uname -r
5 2.6.32-573.el6.x86_64
6 [root@NFS-server ~]# uname -m
7 x86_64
10.4 NFS服务安装前准备
10.4.1 查询nfs-utils和rpcbind包是否安装
1 [root@NFS-server ~]# rpm -qa nfs-utils rpcbind ##查询结果为两个安装包都未安装
2 [root@NFS-server ~]#
知识扩展:
安装NFS软件安装的3种方法:
检查:rpm -qa nfs-utils rpcbind ←最佳
1)方法1:yum -y install nfs-utils rpcbind
2)方法2:通过系统光盘里的rpm包安装,命令如:rpm -ivh nfs-utils-1.2.3-36.e16.x86_64.rpm
3)方法3:LANG=en
yum grouplist|grep -i nfs
yum groupinstall "NFS file server" -y
10.4.2使用方法1安装所需软件包
10.4.3检查安装包是否安装上
1 [root@NFS-server ~]# rpm -qa nfs-utils rpcbind
2 rpcbind-0.2.0-11.el6_7.x86_64
3 nfs-utils-1.2.3-64.el6.x86_64
10.4.4 接下来启动相应的服务
1 [root@NFS-server ~]# /etc/init.d/rpcbind status <==检查rpcbind服务状态
2 rpcbind is stopped
3 [root@NFS-server ~]# rpcinfo -p localhost <==rpcbind服务未启动检查 rpcinfo信息报错
4 rpcinfo: can't contact portmapper: RPC: Remote system error - Connection refused
5 [root@NFS-server ~]# /etc/init.d/rpcbind start <==启动rpcbind服务
6 Starting rpcbind: [ OK ]
7 [root@NFS-server ~]# /etc/init.d/rpcbind status
8 rpcbind (pid 2083) is running...
9 ?[root@NFS-server ~]# /etc/init.d/nfs status <==查看nfs服务状态
10 rpc.svcgssd is stopped
11 rpc.mountd is stopped
12 nfsd is stopped
13 rpc.rquotad is stopped
14 [root@NFS-server ~]# /etc/init.d/nfs start <==启动nfs服务
15 Starting NFS services: [ OK ]
16 Starting NFS quotas: [ OK ]
17 Starting NFS mountd: [ OK ]
18 Starting NFS daemon: [ OK ]
19 Starting RPC idmapd: [ OK ]
10.4.5 设置开机自启动
1 [root@NFS-server ~]# chkconfig --level 35 nfs on <==设置nfs服务开机自启动
2 [root@NFS-server ~]# chkconfig --list nfs
3 nfs 0:off 1:off 2:off 3:on 4:off 5:on 6:off
4 [root@NFS-server ~]# chkconfig --level 35 rpcbind on
5 [root@NFS-server ~]# chkconfig --list rpcbind <==<==设置rpcbind服务开机自启动
6 rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
10.5 配置NFS服务端
10.5.1 NFS服务端配置文件路径
NFS服务配置文件路径为:/etc/exports,并且默认是为空。
1 [root@NFS-server ~]# ll /etc/exports
2 -rw-r--r--. 1 root root 0 Jan 12 2010 /etc/exports
3 [root@NFS-server ~]# cat /etc/exports
4 [root@NFS-server ~]#
10.5.2 编辑NFS服务端配置文件
1 [root@NFS-server ~]# vim /etc/exports
2 /data 192.168.1.0/24(rw,sync,all_squash) <==添加如下内容,这里要注意加all_squash是将所有的普通用户压缩成匿名用户nobody,如果参数不加,客户端普通用户有可能将没有写的权限。
1 [root@NFS-server ~]# vim /etc/exports
2 /data 192.168.1.0/24(rw,sync,all_squash) <==添加如下内容
3 ?[root@NFS-server ~]# mkdir -p /data <==创建共享目录/data
4 [root@NFS-server ~]# ls -ld /data
5 drwxr-xr-x. 3 root root 4096 Nov 26 15:19 /data <==当前共享目录的属主属组分别为root
6 [root@NFS-server ~]# chown -R nfsnobody.nfsnobody /data <==修改/data及子文件属主属组为nfsnobody
7 [root@NFS-server ~]# ls -ld /data
8 drwxr-xr-x. 3 nfsnobody nfsnobody 4096 Nov 26 15:19 /data
10.5.3 重新加载NFS服务(优雅重启)
1 [root@NFS-server ~]# /etc/init.d/nfs reload ===exportfs -r
2 [root@NFS-server ~]# cat /var/lib/nfs/etab
3 /da