常见三种存储方案
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
============================================================================
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
============================================================================