Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3427283
  • 博文数量: 864
  • 博客积分: 14125
  • 博客等级: 上将
  • 技术积分: 10634
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-27 16:53
个人简介

https://github.com/zytc2009/BigTeam_learning

文章分类

全部博文(864)

文章存档

2023年(1)

2021年(1)

2019年(3)

2018年(1)

2017年(10)

2015年(3)

2014年(8)

2013年(3)

2012年(69)

2011年(103)

2010年(357)

2009年(283)

2008年(22)

分类: LINUX

2010-04-03 07:00:35

1.       linux服务器安装portmap nfs-kernel-server portmap

# apt-get install portmap nfs-kernel-server

Reading package lists... Done

Building dependency tree      

Reading state information... Done

You might want to run `apt-get -f install' to correct these:

The following packages have unmet dependencies:

nfs-kernel-server: Depends: nfs-common (>= 1:1.0.8-1) but it is not going to be installed

                     Depends: libgssapi2 but it is not going to be installed

                     Depends: libnfsidmap2 but it is not going to be installed

                     Depends: librpcsecgss3 but it is not going to be installed

sflphone: Depends: dbus-c++-1 (>= 0.5.0) but it is not installable

            Depends: libccrtp1-1.6-0 but it is not installable

            Depends: libcommoncpp2-1.6-0 but it is not installable

            Depends: libcppunit-1.12-0 but it is not going to be installed

            Depends: libpulse0 (>= 0.9.6) but it is not going to be installed

            Depends: librsvg2-common (>= 2.22.2) but 2.18.2-1 is to be installed

            Depends: libsamplerate0 (>= 0.1.2) but it is not going to be installed

            Depends: sflphone-iax2 but it is not installable

E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

# apt-get -f install

2.       新建共享文件夹

/home/下面建立nfsshare目录,做为nfs的共享目录。

3.       root 身份登陆Linux 服务器,编辑/etc 目录下的共享目录配置文件exports,指定共享目录及权限等。

   # vi /etc/exports or # gedit /etc/exports

   在该文件里添加如下内容:

   /home/nfsshare 192.168.7.0/24rw,sync,no_root_squash

   然后保存退出。

   添加的内容表示:允许ip 地址范围在192.168.7.*的计算机以读写的权限来访问/home/ nfsshare 目录。

   /home/nfsshare 也称为服务器输出共享目录。

  可以设定的参数主要有以下这些:
ro 即为:read only
rw
即为:read write
no_root_squash
信任客户端,对应 UID,登入到NFS主机的用户如果是ROOT用户,他就拥有ROOT的权限,此参数很不安全,建议不要使用。


最好加上sync, 否则 $ exportfs -r 时会给出警告, syncNFS的默认选项.

运行 $ showmount -e 查看NFS serverexport list.

root@jane-desktop:/etc# exportfs -r

exportfs: No options for /home/nfsshare 192.168.7.*rw,sync,no_root_squash: suggest 192.168.7.*rw,sync,no_root_squash(sync) to avoid warning

exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.7.*rw,sync,no_root_squash:/home/nfsshare".

Assuming default behaviour ('no_subtree_check').

NOTE: this default has changed since nfs-utils version 1.0.x

若更改了/etc/exports, 运行 $ sudo exportfs -r 更新
运行 $ sudo /etc/init.d/nfs-kernel-server restart 重启nfs服务)

4.       配置portmap
方法1: 编辑/etc/default/portmap, -i 127.0.0.1 去掉.
方法2: $ dpkg-reconfigure portmap , Should portmap be bound to the loopback address? N.

5.       配置/etc/hosts.deny
(禁止任何host(主机)能和你的NFS服务器进行NFS连接),加入:
### NFS DAEMONS
portmap:ALL
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL

6.       配置/etc/hosts.allow
允许那些你想要的主机和你的NFS服务器建立连接。下列步骤将允许任何IP地址以192.168.1开头的主机(连接到NFS服务器上),也可以指定特定的IP地址。参看man hosts_access(5), hosts_options(5)。加入:
### NFS DAEMONS
portmap: 192.168.7.
lockd: 192.168.7.
rquotad: 192.168.7.
mountd: 192.168.7.
statd: 192.168.7.

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

no_root_squash登入到NFS主机的用户如果是ROOT用户,他就拥有ROOT的权限,此参数很不安全,建议不要使用。
root_squash
在登入 NFS 主机使用分享之目录的使用者如果是 root 时,那么这个使用者的权限将被縮成为匿名使用者,通常他的 UIDGID 都会变成 nobody 那个身份;

all_squash不管登陆NFS主机的用户是什么都会被重新设定为nobody
anonuid
:将登入NFS主机的用户都设定成指定user id,ID必须存在于/etc/passwd中。
anongid
anonuid ,但是变成 group ID 就是了!
sync
资料同步写入存储器中。
async
资料会先暂时存放在内存中,不会直接写入硬盘。
insecure
允许从这台机器过来的非授权访问。
noaccess
客户端不能使用

7.       接着执行如下命令,启动端口映射:

# ./init.d/portmap start   

* Starting portmap daemon...                                                        

* Already running.     

8.         最后执行如下命令启动NFS 服务,此时NFS 会激活守护进程,然后就开始监听 Client 端的请求:

# /etc/rc.d/init.d/nfs-kernel-server restart

9.       Linux 服务器上测试NFS
  
# mount t nfs 192.168.7.15:/home/work /mnt

本地主机IP地址为192.168.7.15,将/home/share挂载到/mnt/nfs

出错:

# mount 192.168.7.15:/home/nfsshare /mnt/nfs/

mount.nfs: 192.168.7.15:/home/nfsshare failed, reason given by server: Permission denied

解决:/etc/exports

/home/nfsshare 192.168.7.0/24(rw,sync, insecure, no_root_squash)

可能权限上还有问题,之后再说。

10.   客户端设置

在配置内核时添加内核对NFS的支持:

选中Networking >> networking options >> IP:kernel level auloconfiguralion

选中file systems>>network file systems>> root file system on nfs nfs file system support重新编译内核下载bootloaderkernel到开发板上

11.   客户端mount NFS 共享目录

# mkdir /mnt/nfs

# mount t nfs 192.168.7.15:/home/nfsshare /mnt/nfs o nolock

# umount /mnt/nfs

12.   挂载NFS根文件系统

将根文件系统拷贝到/home/nfsshare下,然后修改uboot的参数。

bootargs=console=ttyS1,115200n8 root=/dev/nfs rw nfsroot=192.168.7.15:/home/nfsshare ip=dhcp


 

阅读(1972) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~