您的位置:首页 > 运维架构 > Linux

linux企业常用服务---nfs

2016-05-15 16:48 453 查看
NFS是一种基于TCP/IP传输的网络文件系统协议,最初由SUN公司开发。
通过NFS协议,客户机可以像访问本地目录一样访问远程服务器中的共享资源。
NFS得到了如NAS等网络存储的设备极好支持。也是LVS共享存储的首选。

nfs相关服务
软件包:nfs-utils,rpcbind
配置文件:/etc/exports
相关命令:
exportfs
showmount
rpcinfo
mount

基本配置文件;
/etc/exports
/ master(rw) trusty(rw,no_root_squash)
/projects proj*.local.domain(rw)
/usr *.local.domain(ro)@trusted(rw)
/home/joe pc001(rw,all_squash,anonuid=150,anongid=100)
/build buildhost[0-9].local.domain(rw)

部署前准备
配置系统镜像为本地yum源,配置yum文件
环境介绍:
使用母盘克隆虚拟机,IP设置为:192.168.100.250并将虚拟机命名为存储服务器,使用192.168.100.100作为客户端。

1.安装nfs-utils、rcpbind软件包
[root@localhost ~]# yum -y install nfs-utils rpcbind
[root@localhost ~]# for i in rpcbind nfs;do chkconfig $i on; done ##设置为开机启动

2.设置共享目录
[root@localhost ~]# mkdir /opt/wwwroot
[root@localhost ~]# mkdir -p /var/ftp/pub
[root@localhost ~]# chmod 777 /opt/wwwroot ##设置权限
vi /etc/exports
/opt/wwwroot 192.168.100.0/24(rw,sync,no_root_squash)
/var/ftp/pub 192.168.0.10(ro) 192.168.0.200(rw)

3.启动nfs服务程序
[root@localhost ~]# /etc/init.d/rpcbind start
[root@localhost ~]# /etc/init.d/nfs start
[root@localhost ~]# netstat -utpnl |grep rpcbind
[root@localhost ~]# showmount -e ##查看本机共享的目录

4.客户机设置
[root@localhost ~]# yum -y install nfs-utils rpcbind
chkconfig rpcbind on
[root@localhost ~]# showmount -e 192.168.100.250
[root@localhost ~]# echo 3 >/proc/sys/vm/drop_caches ##当nfs因为缓存没有及时而导致错,可以使用该命令
5.客户机挂载使用nfs共享
[root@localhost ~]# mkdir -p /var/www/html
[root@localhost ~]# mount 192.168.100.250:/opt/wwwroot /var/www/html/
[root@localhost ~]# mount |grep nfs
[root@localhost ~]# vi /etc/fstab
192.168.100.250:/opt/wwwroot /var/www/html nfs defaults,_netdev 0 0
:wq
[root@localhost ~]# mount -a
[root@localhost ~]# mount |grep nfs
验证:
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# touch a.file
[root@localhost html]# ll
切换到100.250上验证:
[root@localhost ~]# ls /opt/wwwroot/
a.file
本文出自 “LP-linux” 博客,请务必保留此出处http://linuxlp.blog.51cto.com/11463376/1773633
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: