手机版
你好,游客 登录 注册
背景:
阅读新闻

CentOS 6.3 NFS的安装配置、启动及mount挂载方法

[日期:2014-06-11] 来源:oschina.net  作者:Linux [字体: ]

一、环境介绍:
  服务器:CentOS 192.168.1.225
  客户端:centos 192.168.1.226

二、安装:
NFS的安装配置:
centos 5 :
yum -y install nfs-utils portmapcentos 6(在CentOS 6.3当中,portmap服务由rpcbind负责) :
yum -y install nfs-utils rpcbind

三、服务器端配置:
1、创建共享目录:
[root@centos2 /]# mkdir /usr/local/test

2、NFS文件配置:
[root@centos2 /]# vi /etc/exports
#增加一行:
/usr/local/test/ 192.168.1.226(rw,no_root_squash,no_all_squash,sync):x保存退出;
使配置生效:
[root@centos2 /]# exportfs -r注:配置文件说明:
/usr/local/test/ 为共享的目录,使用绝对路径。
192.168.1.226(rw,no_root_squash,no_all_squash,sync) 为客户端的地址及权限,地址可以是一个网段,一个IP地址或者是一个域名,域名支持通配符,如:*.youxia.com,地址与权限中间没有空格,权限说明:
rw:read-write,可读写;
ro:read-only,只读;
sync:文件同时写入硬盘和内存;
async:文件暂存于内存,而不是直接写入内存;
no_root_squash:NFS客户端连接服务端时如果使用的是root的话,那么对服务端分享的目录来说,也拥有root权限。显然开启这项是不安全的。
root_squash:NFS客户端连接服务端时如果使用的是root的话,那么对服务端分享的目录来说,拥有匿名用户权限,通常他将使用nobody或nfsnobody身份;
all_squash:不论NFS客户端连接服务端时使用什么用户,对服务端分享的目录来说都是拥有匿名用户权限;
anonuid:匿名用户的UID值,通常是nobody或nfsnobody,可以在此处自行设定;
anongid:匿名用户的GID值。
3、启动:
centos6:
[root@centos2 /]# service rpcbind start
Starting rpcbind:                                          [  OK  ]
[root@centos2 /]# service nfs start
Starting NFS services:                                    [  OK  ]
Starting NFS quotas:                                      [  OK  ]
Starting NFS mountd:                                      [  OK  ]
Stopping RPC idmapd:                                      [  OK  ]
Starting RPC idmapd:                                      [  OK  ]
Starting NFS daemon:                                      [  OK  ]
[root@centos2 /]#centos 5
[root@centos2 /]# service portmap start
[root@centos2 /]# service nfs start
[root@centos2 /]#

--------------------------------------分割线 --------------------------------------

Ubuntu 12.04安装NFS server http://www.linuxidc.com/Linux/2012-09/70728.htm

NFS服务器安装配置实现Ubuntu 12.04与ARM文件共享 http://www.linuxidc.com/Linux/2012-10/73159.htm

Ubuntu搭建nfs服务器 http://www.linuxidc.com/Linux/2012-10/71930.htm

文件服务器NFS配置详解 http://www.linuxidc.com/Linux/2013-06/86542.htm

Ubuntu下搭建NFS网络文件系统服务器 http://www.linuxidc.com/Linux/2013-07/87367.htm

Heartbeat_ldirector+LB+NFS实现HA及LB、文件共享 http://www.linuxidc.com/Linux/2013-06/85292.htm

CentOS 5.5配置NFS服务器教程 http://www.linuxidc.com/Linux/2013-03/81737.htm

Ubuntu 12.10下NFS的安装使用 http://www.linuxidc.com/Linux/2013-03/80478.htm

--------------------------------------分割线 --------------------------------------

四、客户端挂载:
1、创建需要挂载的目录:
[root@localhost ~]# mkdir /usr/local/test
[root@localhost ~]#

2、测试挂载:
[root@localhost ~]# showmount -e 192.168.1.225
Export list for 192.168.1.225:
/usr/local/test 192.168.1.226
[root@localhost ~]#如果显示:rpc mount export: RPC: Unable to receive; errno = No route to host,则需要在服务端关闭防火墙(稍候会详细说)。

3、挂载:
[root@localhost ~]# mount -t nfs 192.168.1.225:/usr/local/test /usr/local/test
[root@localhost ~]# mount
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
192.168.1.225:/usr/local/test on /usr/local/test type nfs (rw,vers=4,addr=192.168.1.225,clientaddr=192.168.1.226)
[root@localhost ~]#如果信息如上显示则挂载成功!
4、测试:
客户端生成一个文件:
[root@centos2 /]# cd /usr/local/test/
[root@centos2 test]# echo "hello nfs test">>test
[root@centos2 test]# ll
total 4
-rw-r--r-- 1 root root 15 Apr  9 13:24 test
[root@centos2 test]#服务端检查:
[root@centos2 /]# cd /usr/local/test/
[root@centos2 test]# ll
total 4
-rw-r--r-- 1 root root 15 Apr  9 13:24 test
[root@centos2 test]#挂载成功!

更多详情见请继续阅读下一页的精彩内容http://www.linuxidc.com/Linux/2014-06/102987p2.htm

linux
相关资讯       NFS 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款