您的位置:首页 > 其它

Ubuntu 9.10 NFS server & client 配置安装

2010-12-10 15:34 429 查看
简单介绍在Ubuntu 9.10 上成功配置NFS 过程。

1
root 下, apt-get install portmap nfs-kernel-server nfs-common

有人说apt-get install nfs-kernel-server 之后 自动安装了portmap 和 nfs-common ,没试过

2 下载成功后,要进行NFS server 配置

首先 配置portmap。输入下面命令:

#dpkg-reconfigure portmap

对出现 “Should portmap be bound to the loopback address?” 选N.

然后是配置/etc/hosts.deny(可以不配置),打开此文件

(禁止任何host(主机)能和你的NFS服务器进行NFS连接),加入:

### NFS DAEMONS

portmap:ALL

lockd:ALL

mountd:ALL

rquotad:ALL

statd:ALL

配 置/etc/hosts.allow文件

允许那些你想要的主机和你的NFS服务器建立连接.下列步骤将允许任何IP地址以

192.168.1开头的主机(连 接到NFS服务器上)。

### NFS DAEMONS

portmap: 192.168.1.

lockd: 192.168.1.

rquotad: 192.168.1.

mountd: 192.168.1.

statd: 192.168.1.

/etc/hosts.deny 和 /etc/hosts.allow 设置对portmap的访问. 采用这两个配置文件有点类似"mask"的意思. 现在/etc/hosts.deny中禁止所有用户对portmap的访问. 再在/etc/hosts.allow 中允许某些用户对portmap的访问.

配置/etc/exports

NFS挂载目录及权限由/etc/exports文件定义。比如我要将将我的home目录中的/home/android目录让192.168.1.*的IP共享, 则在该文件末尾添加下列语句:

/home/android 192.168.1.*(rw,sync,no_root_squash)

或者: /home/android 192.168.1.0/24(rw,sync,no_root_squash)

(最好先用:/home/android *(rw,sync,no_root_squash) 允许所有client mount 方便测试)

3 NFS Server 配置完成 ,下面启动服务

/etc/init.d/portmap restart

/etc/init.d/nfs-common restart(可能没有nfs-common 这个文件,没有就不管它)

/etc/init.d/nfs-kernel-server restart (用命令service nfs-kernel-server status 看是否nfsd running)

追加: 这些命令要以root身份,否则报错

自己测试一下

mount -t nfs localhost:/home/android /mnt (localhost 是主机名或者是IP地址 ,如果不知道自己主机名 用hostname命令看一下)

ls /mnt 看是否已经挂载成功

NFS server 建立成功后找另一台安装了NFS client(也就是portmap和nfs-common)的电脑试一下,

mount -t nfs localhost:/home/android /mnt

ls /mnt

如果是fedroa12 client 要在service 中开启nfs 服务,即可直接mount, fedora13 之后没找到方法,哪位大侠知道可以告诉小弟,先谢了。

这就简单得实现了NFS server 的建立和 client 得连接(如有错误之处请不吝指教)。如何能够使用得更好还要继续学习。比如修改了/etc/exports 文件之后,可以用exportfs -rv 命令更新,而不用/etc/init.d/nfs-kernel-server restart 来重新开启服务。

学习追加:在/etc/exports 文件中



/home/android 192.168.1.*(rw,sync,no_root_squash)

或者: /home/android 192.168.1.0/24(rw,sync,no_root_squash)

这二者似乎是一样得,但是
/home/android 192.168.1.*(rw,sync,no_root_squash)是mount不上自己的(如果自己本机就是server),但是92.168.1.0/24这种方式,自己可以mount自己得文件夹。具体原因由高人指出吧。哈哈
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: