Linux网络服务——NFS

【centos6.5】

一、使用NFS发布共享资源

二、在客户机中访问NFS共享资源

一、使用NFS发布共享资源

检查rpcbind安装包,关闭防火墙、安全认证

配置文件/etc/exports

[root@localhost ~]# rpm -q rpcbind  【查看rpcbind包是否安装】

rpcbind-0.2.0-11.el6.x86_64

[root@localhost ~]# rpm -q nfs

package nfs is not installed

[root@localhost ~]# /etc/init.d/rpcbind start

[root@localhost ~]# /etc/init.d/nfs start

启动 NFS 服务: [确定]

关掉 NFS 配额:[确定]

启动 NFS mountd:[确定]

启动 NFS 守护进程:[确定]

正在启动 RPC idmapd:[确定]

[root@localhost ~]# chkconfig rpcbind on

[root@localhost ~]# chkconfig rpcbind --list

rpcbind        0:关闭          1:关闭          2:启用          3:启用          4:启用          5:启用          6:关闭

[root@localhost ~]# chkconfig nfs on

[root@localhost ~]# chkconfig nfs --list

nfs            0:关闭          1:关闭          2:启用          3:启用          4:启用          5:启用          6:关闭

[root@localhost ~]# mkdir /www

[root@localhost ~]# echo 'test > /www/test.txt

[root@localhost ~]# vim /etc/exports

www    192.168.157.6(rw,sync,no_root_squash) 192.168.157.*

保存退出

[root@localhost ~]# /etc/init.d/nfs restart

关闭 NFS 守护进程:[确定]

关闭 NFS mountd:[确定]

关闭 NFS quotas:[确定]

Shutting down RPC idmapd: [确定]

启动 NFS 服务: exportfs: No options for /www 192.168.157.*: suggest 192.168.157.*(sync) to avoid warning

[确定]

关掉 NFS 配额:[确定]

启动 NFS mountd:[确定]

启动 NFS 守护进程:[确定]

正在启动 RPC idmapd:[确定]                                                                             

[root@localhost ~]# service iptables stop

iptables:将链设置为政策 ACCEPT:filter [确定]

iptables:清除防火墙规则:[确定]

iptables:正在卸载模块:[确定]

[root@localhost ~]# setenforce 0

二、在客户机中访问NFS共享资源

检查rpcbind安装包,关闭防火墙、安全认证

  挂载、     配置文件/etc/exports

[root@localhost ~]rpm -q rpcbind nfs-utils

rpcbind-0.2.0-11.el6.x86_64

nfs-utils-1.2.3-39.el6.x86_64

[root@localhost ~]# rpm -q httpd

httpd-2.2.15-29.el6.centos.x86_64

[root@localhost ~]#mkdir /qqq

[root@localhost ~]# echo '123 > /qqq/qqq.txt

[root@localhost ~]# /etc/init.d/httpd  start

正在启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName

[确定]

[root@localhost ~]# chkconfig httpd on

[root@localhost ~]# chkconfig httpd --list

httpd                      0:关闭          1:关闭          2:启用          3:启用          4:启用          5:启用          6:关闭

[root@localhost ~]# service iptables stop

iptables:将链设置为政策 ACCEPT:filter [确定]

iptables:清除防火墙规则:[确定]

iptables:正在卸载模块:[确定]

[root@localhost ~]# setenforce 0

[root@localhost ~]# mount 192.168.157.7:/www /qqq

[root@localhost ~]# df -hT

Filesystem                   Type     Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root ext4      37G  3.4G   32G  10% /

tmpfs                        tmpfs    491M   76K  491M   1% /dev/shm

/dev/sda1                    ext4     485M   35M  426M   8% /boot

/dev/sr0                     iso9660  4.2G  4.2G     0 100% /media/CentOS_6.5_Final

192.168.157.7:/www           nfs       37G  3.4G   32G  10% /qqq

[root@localhost ~]# cp -p /etc/fstab /etc/fstab.bak

[root@localhost ~]# vim /etc/fstab

Created by anaconda on Wed Mar  6 00:45:10 2019

#

# 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

#

# 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/VolGroup-lv_root /                       ext4    defaults        1 1

UUID=a85ad1d5-a121-42a5-83e1-a1662002af50 /boot                   ext4    defaults        1 2

/dev/mapper/VolGroup-lv_swap swap                    swap    defaults        0 0

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

192.168.157.7:/www      /qqq                    nfs     defaults,_netdev  0 0

[root@localhost ~]# umount -a

umount: /dev/shm: device is busy.

        (In some cases useful info about processes that use

         the device is found by lsof(8) or fuser(1))

umount: /: device is busy.

        (In some cases useful info about processes that use

         the device is found by lsof(8) or fuser(1))

[root@localhost ~]# df -hT

Filesystem                   Type   Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root ext4    37G  3.4G   32G  10% /

tmpfs                        tmpfs  491M   76K  491M   1% /dev/shm

[root@localhost ~]# mount -a

[root@localhost ~]# df -hT

Filesystem                   Type   Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root ext4    37G  3.4G   32G  10% /

tmpfs                        tmpfs  491M   76K  491M   1% /dev/shm

/dev/sda1                    ext4   485M   35M  426M   8% /boot

192.168.157.7:/www           nfs     37G  3.4G   32G  10% /qqq

[root@localhost ~]# touch /qqq/123{1..10}

[root@localhost ~]# ls /qqq

1231  12310  1232  1233  1234  1235  1236  1237  1238  1239  test.txt

服务端查看,已经同步过来了

[root@localhost ~]# ls /www

1231  12310  1232  1233  1234  1235  1236  1237  1238  1239  test.txt

实验补充:

1、ip配对基本不会出错

   注意有时会因为输入法导致实验失败

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值