Redhat下如何搭建NFS

本文详细介绍如何在RedHat Linux AS5环境下配置NFS服务,包括创建共享目录、编辑exports文件、启动NFS服务及客户端挂载等步骤,并提供了一些实用的NFS命令。
环境:
OS:Red Hat Linux As 5

服务器ip:192.168.50.199
客户端ip:192.168.50.200

 
1.服务器上创建共享目录同时修改权限
mkdir /bak1/nfs_archivelog01
chmod -R 777 /bak1/nfs_archivelog01/

2.编辑exports文件
vim /etc/exports
写入
/bak1/nfs_archivelog01 192.168.50.200/255.255.255.0(rw,sync)
格式是:
要共享的目录 对方的IP及掩码或者域名(权限,同步更新)
 
3.启动服务
/etc/init.d/portmap restart
/etc/init.d/nfs restart
chkconfig nfs on
chkconfig portmap on
然后关闭防火墙以及更改Selinux关于NIS的选项
/etc/init.d/iptables stop (防护墙服务关闭)
chkconfig iptables off
system-config-selinux (设置selinux)

查看共享的东西
[root@node1 nfs_archivelog01]# exportfs -rv
exporting 192.168.50.200/255.255.255.0:/bak1/nfs_archivelog01
 
 
4.客户端
手工mount:
mount -t nfs 192.168.50.199:/bak1/nfs_archivelog01 /bak2/nfs_archivelog02
192.168.50.199 是服务器的ip
/bak1/nfs_archivelog01 是服务器上的目录
/bak2/nfs_archivelog02 是本机客户端上的目录

自动mount:
编辑fstab文件,实现开机自动挂载
mount -t nfs IP:/目录 挂载到的目录 (此为临时挂载)

vim /etc/fstab 添加如下内容
192.168.50.199:/bak1/nfs_archivelog01     /bak2/nfs_archivelog02   nfs     defaults        0 0
 
 
相关的一些命令:
showmout命令对于NFS的操作和查错有很大的帮助.
showmout 
-a:这个参数是一般在NFS SERVER上使用,是用来显示已经mount上本机nfs目录的cline机器.
-e:显示指定的NFS SERVER上export出来的目录.
例如: 
[root@node1 nfs_archivelog01]# showmount -e 192.168.50.199
Export list for 192.168.50.199:
/bak1/nfs_archivelog01 192.168.50.200/255.255.255.0
 
exportfs命令:
如果我们在启动了NFS之后又修改了/etc/exports,是不是还要重新启动nfs呢?这个时候我们就可以用exportfs命令来使改动立刻生效,该命令格式如下:
exportfs [-aruv] 
-a :全部mount或者unmount /etc/exports中的内容 
-r :重新mount /etc/exports中分享出来的目录 
-u :umount 目录 
-v :在 export 的时候,将详细的信息输出到屏幕上.
具体例子:
[root @test root]# exportfs -rv <==全部重新 export 一次! 
exporting 192.168.0.100:/home/test 
exporting 192.168.0.*:/home/public 
exporting *.the9.com:/home/linux 
exporting *:/home/public 
exporting *:/tmp 
reexporting 192.168.0.100:/home/test to kernel
exportfs -au <==全部都卸载了

转载于:https://www.cnblogs.com/ariclee/p/4726684.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值