:一个NFS实例

来源:百度文库 编辑:九乡新闻网 时间:2024/04/30 03:38:59
一个NFS实例
 2009-04-01 15:17:07   标签:NFS 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://allenyu.blog.51cto.com/193668/144687 目标:1。实现手动挂载             2。实现自动挂载,卸载方法:NFS服务器依靠的几个程序包:portmap,nfs,依次安装,启动。[root@localhost ~]# service portmap status
portmap (pid 4213) is running...
[root@localhost ~]#
[root@localhost ~]# service nfs status
rpc.mountd (pid 4559) is running...
nfsd (pid 4556 4555 4554 4553 4552 4551 4550 4549) is running...
[root@localhost ~]#
NFS的服务器配置/ect/explores,系统默认不一定有,没有就自己新建一个/var/ftp/pub/   192.168.1.0/24(rw)
很简单:共享的目录  共享给谁(可以是IP,主机名,网段,域名) 读写权限 重起portmap和nfsd服务,注意先后顺序,先portmap。 现在我检查一下共享是否已经成功:[root@localhost ~]# showmount -e 192.168.1.200
Export list for 192.168.1.200:
/var/ftp/pub 192.168.1.0/24说明我们服务器端的共享是成功的! 现在配置客户端手动加载比较简单首先,参看一下共享[root@RHEL mnt]# showmount -e 192.168.1.200
Export list for 192.168.1.200:
/var/ftp/pub 192.168.1.0/24
然后使用命令挂载[root@RHEL mnt]# mount -t nfs 192.168.1.200:/var/ftp/pub /temp
[root@RHEL mnt]# cd /temp
[root@RHEL temp]# ls -l /temp
total 340
drwxr-xr-x 2 root      root        4096 Mar 31  2009 1
drwxr-xr-x 2 nfsnobody nfsnobody   4096 Mar 31  2009 2
下面配置自动挂载,卸载。安装autofs服务[root@RHEL temp]# service autofs status
automount (pid 5655) is running...配置/etc/auto.master添加一条记录/mnt    /etc/auto.mnt --timeout=10
挂载点   这个挂载点的具体配置  多少时间没有访问将自动短开连接(秒)配置/etc/auto.mntnfs     -fstype=nfs,rw  192.168.1.200:/var/ftp/pub挂载点下的目录名 挂载的文件类型,读取权限 共享的路径 重新启动autofs服务 [root@RHEL temp]# service autofs restart
Stopping automount:                                        [  OK  ]
Starting automount:                                        [  OK  ]
验证:我们挂载到/mnt下的,先看一下/mnt下有些什么[root@RHEL /]# ls /mnt
[root@RHEL /]#
什么都没有 我们再访问/mnt/nfs[root@RHEL /]# ls /mnt/nfs
1               EULA        isolinux                 RPM-GPG-KEY-redhat-release
2               eula.en_US  README-en                Server
Cluster         GPL         RELEASE-NOTES-en         TRANS.TBL
ClusterStorage  images      RPM-GPG-KEY-redhat-beta  VT
这些正是服务器上的共享文件,说明自动挂载已经成功。同时,我们也可以得出结论,挂载点下的文件(也就是/etc/auto.mnt第一列)是自动建立的,不需要我们手动建立。再看卸载,其实很简单,刚才在配置/etc/auto.master中已经设置了timeout=10秒,所以我们现在在回过去看/mnt下还有没有nfs目录[root@RHEL /]# ls /mnt
[root@RHEL /]# 已经没有了,卸载成功! 其实再往下就可以做异地定时自动备份,只要at和cp命令搭配使用。 
 

本文出自 “allen的学习笔记” 博客,请务必保留此出处http://allenyu.blog.51cto.com/193668/144687