Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6548230
  • 博文数量: 1005
  • 博客积分: 8199
  • 博客等级: 中将
  • 技术积分: 13071
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-25 20:19
个人简介

脚踏实地、勇往直前!

文章分类

全部博文(1005)

文章存档

2020年(2)

2019年(93)

2018年(208)

2017年(81)

2016年(49)

2015年(50)

2014年(170)

2013年(52)

2012年(177)

2011年(93)

2010年(30)

分类: LINUX

2012-08-12 22:16:46

环境:
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 <==全部都卸载了
 
 
-- The End --
阅读(5014) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~