【NFS】

常见三种存储方案
DAS
NAS
SAN

====NAS之NFS===
NFS:Network File System网络文件系统,Unix系统之间共享文件的一种协议
借助于Linux系统平台来实现NFS存储

一、NFS服务器(存储端)
1. 软件包: nfs-utils
2. 端口:   2049/tcp
3. 配置文件:/etc/exports  使用该文件给客户端共享目录
确保防火墙和SELinux处于关闭
[root@station5 ~]# mkdir -p /share/{dir1,dir2}
[root@station5 ~]# chmod -R 777 /share
[root@station5 ~]# ll /share/
drwxrwxrwx 2 root root 4096 11-09 15:53 dir1
drwxrwxrwx 2 root root 4096 11-09 15:53 dir2
[root@station5 ~]# vim /etc/exports
/share/dir1             *(ro)
/share/dir2             192.168.2.0/24(rw,sync)
[root@station5 ~]# service nfs restart
[root@station5 ~]# chkconfig nfs on

=====================================
示例二:
# mkdir /home/dir1 /home/dir2
# vim /etc/exports
/home/dir1      *(rw,sync)
/home/dir2      192.168.2.0/24(rw,sync,no_root_squash)     不压制root
=====================================


二、NFS客户端
1. 软件包: nfs-utils
[root@station230 ~]# showmount -e 192.168.2.168          //查看存储端共享
Export list for 192.168.2.168:
/share/dir1 *
/share/dir2 192.168.2.0/24
[root@station230 ~]# mkdir /mnt/dir1
[root@station230 ~]# mkdir /mnt/dir2
[root@station230 ~]# mount -t nfs 192.168.2.168:/share/dir1 /mnt/dir1
[root@station230 ~]# mount 192.168.2.168:/share/dir2 /mnt/dir2
[root@station230 ~]# df -Th
文件系统                    类型              容量  已用         可用       已用%      挂载点
192.168.2.168:/share/dir1
               nfs     19G  8.9G  9.1G  50% /mnt/dir1
192.168.2.168:/share/dir2
               nfs     19G  8.9G  9.1G  50% /mnt/dir2
[root@station230 ~]# cp /etc/hosts /mnt/dir1
cp: 无法创建一般文件“/mnt/dir1/hosts”: 只读文件系统
[root@station230 ~]# cp /etc/hosts /mnt/dir2

    
Automount自动挂载NFS:
[root@station230 ~]# vim /etc/auto.master
/nfsmount /etc/auto.nfs                    //定义监控目录和映射文件
[root@station230 ~]# vim /etc/auto.nfs
dir1            -ro             192.168.2.168:/share/dir1
dir2            -rw             192.168.2.168:/share/dir2
[root@station230 ~]# service autofs restart
[root@station230 ~]# chkconfig autofs on
[root@station230 ~]# ls /nfsmount/dir2          //手动触发挂载,一般由应用程序触发

fstab自动挂载:
[root@station230 ~]# vim /etc/fstab
192.168.2.168:/share/dir1 /mnt/dir1 nfs defaults,_netdev 0 0            //网络类型设备
[root@station230 ~]# mount -a
============================================================================
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值