本文是操作过程稍微整理而成。。。
注意:共享文件目录,关闭seliunx iptables
客户端:192.168.1.141
服务端:192.168.1.145
在服务端安装配置操作:
[root@xie2 ~]# yum install nfs* -y
[root@xie2 ~]# rpm -ql nfs-utils|more
[root@xie2 etc]# rpm -qa | egrep "nfs|rpcbind"
nfs-utils-lib-1.1.5-13.el6.x86_64
rpcbind-0.2.0-16.el6.x86_64
nfs-utils-1.2.3-78.el6_10.1.x86_64
nfs4-acl-tools-0.3.3-8.el6.x86_64
nfs-utils-lib-devel-1.1.5-13.el6.x86_64
[root@xie2 etc]# rpm -ql nfs-utils
保存默认配置文件
[root@xie2 ~]# vim /etc/nfsmount.conf
共享配置文件
[root@xie2 ~]# mkdir -p /data/mydata
[root@xie2 ~]# ll /data/
总用量 4
drwxr-xr-x. 2 root root 4096 12月 4 00:32 mydata
[root@xie2 ~]# chmod 666 /data/mydata/
[root@xie2 etc]# chown -R nfsnobody:nfsnobody /data/
NFS 主要配置文件:添加共享目录
[root@xie2 etc]# vim exports
/data/ *(rw,no_root_squash,no_all_squash,sync)
#/data/ 需要共享的目录ro 只读访问
#rw 读写访问
#sync 所有数据在请求时写入共享
#all_squash 共享文件的UID和GID映射匿名用户anonymous,适合公用目录。
#no_all_squash 保留共享文件的UID和GID(默认)
#root_squash root用户的所有请求映射成如anonymous用户一样的权
#限(默认)
#no_root_squash root用户具有根目录的完全管理访问权限
#Linux客户端,如何想使用这个NFS文件系统,需要在客户端挂载,挂载命令为:
[root@xie2 mydata]# mkdir 20181203
[root@xie2 mydata]# touch test_jfedu.txt
[root@xie2 mydata]# ls
20181203 test_jfedu.txt
[root@xie2 mydata]#
[root@xie2 mydata]#
[root@xie2 mydata]# cd
[root@xie2 etc]# /etc/init.d/rpcbind start
[root@xie2 etc]# /etc/init.d/nfs start
[root@xie2 etc]# chkconfig nfs on
[root@xie2 etc]# chkconfig --list nfs
nfs 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@xie2 etc]# chkconfig --list rpcbind
rpcbind 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@xie2 ~]# netstat -tnl
[root@xie2 ~]# yum install telnet -y
[root@xie2 ~]# telnet 192.168.1.141
Trying 192.168.1.141...
telnet: connect to address 192.168.1.141: No route to host
[root@xie2 ~]# telnet 192.168.1.141 111
Trying 192.168.1.141...
telnet: connect to address 192.168.1.141: No route to host
不通;;;、
关闭防火墙,selinux iptable
[root@xie2 ~]# /etc/init.d/iptables stop
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:清除防火墙规则: [确定]
iptables:正在卸载模块: [确定]
[root@xie2 ~]# cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@xie2 ~]# telnet 192.168.1.141 111
Trying 192.168.1.141...
Connected to 192.168.1.141.
Escape character is '^]'.
客户端:192.168.1.141
[root@xie1 ~]# yum install nfs-utils -y
s: 无法访问/mnt/data/mydata/: 没有那个文件或目录
[root@xie1 ~]# ll /mnt/mydata/
总用量 4
drwxr-xr-x 2 root root 4096 12月 4 02:36 20181203
-rw-r--r-- 1 root root 0 12月 4 02:36 test_jfedu.txt
[root@xie1 ~]# touch /mnt/mydata/20181203/test123.txt
[root@xie1 ~]#
[root@xie1 ~]# cd /mnt/mydata/20181203/
[root@xie1 20181203]# ll
总用量 0
-rw-r--r-- 1 root root 0 12月 4 03:27 test123.txt
[root@xie1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 92G 2.1G 85G 3% /
tmpfs 490M 0 490M 0% /dev/shm
/dev/sda1 190M 47M 134M 26% /boot
/dev/sda2 4.7G 9.8M 4.5G 1% /home
/dev/sda3 1.9G 3.0M 1.8G 1% /swap
192.168.1.145:/data/ 77G 1.9G 72G 3% /mnt
NFS
重点注意:共享文件目录,关闭seliunx iptables