Chinaunix首页 | 论坛 | 博客
  • 博客访问: 379832
  • 博文数量: 120
  • 博客积分: 5051
  • 博客等级: 大校
  • 技术积分: 1255
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-03 01:25
文章分类

全部博文(120)

文章存档

2011年(2)

2010年(11)

2009年(28)

2008年(26)

2007年(53)

我的朋友

分类: LINUX

2008-11-06 15:47:07

NFS 服务器搭建过程简单说明
1)所需要安装的软件:nfs-utils and portmap
 
2)server端的配置:/etc/exports 这个文件是主要设定档,这个文件的格式是:
 
directory machine1(option11,option12) machine2(option21,option22)
directory:分享的本地目录
machine1 and machine2:允许访问该目录的client.(IP or hostname)
options:参数
  • ro: 只读
  • rw: 可读可写
  • no_root_squash: 如果有这个参数,客户端的root用户对server共享的目录具有server root的权限。
  • no_subtree_check:If only part of a volume is exported, a routine called subtree checking verifies that a file that is requested from the client is in the appropriate part of the volume. If the entire volume is exported, disabling this check will speed up transfers.
  • sync: 同步
例如:
[root@master ~]# cat /etc/exports
/home 10.224.254.19(rw)
配置完后启动portmap & nfs 服务:
[root@master ~]# /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
[root@master ~]# showmount -e localhost
Export list for localhost:
/home client.nis
[root@master ~]# /etc/init.d/portmap start
Starting portmap:                                          [  OK  ]
查看启动状况:
[root@master ~]# rpcinfo -p localhost
   program vers proto   port
    100000    2   tcp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp    781  status
    100024    1   tcp    784  status
    100004    2   udp    851  ypserv
    100004    1   udp    851  ypserv
    100004    2   tcp    854  ypserv
    100004    1   tcp    854  ypserv
    100009    1   udp   1011  yppasswdd
    100011    1   udp   1019  rquotad
    100011    2   udp   1019  rquotad
    100011    1   tcp   1022  rquotad
    100011    2   tcp   1022  rquotad
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100021    1   udp  32768  nlockmgr
    100021    3   udp  32768  nlockmgr
    100021    4   udp  32768  nlockmgr
    100021    1   tcp  32780  nlockmgr
    100021    3   tcp  32780  nlockmgr
    100021    4   tcp  32780  nlockmgr
    100005    1   udp    611  mountd
    100005    1   tcp    614  mountd
    100005    2   udp    611  mountd
    100005    2   tcp    614  mountd
    100005    3   udp    611  mountd
    100005    3   tcp    614  mountd
查看exported file:
[root@master ~]# showmount -e localhost
Export list for localhost:
/home client.nis ====>这表明本地的/home已分享给client.nis这台机。
 
如果修改了/etc/exports,想重新挂载或卸载:
[root@master ~]# exportfs -arv
-a mount or unmount all file list in the /etc/exports
-r remount
-v list exported file when use exports
-u unmount all file list in the /etc/exports
 
nfs安全设置
/etc/hosts.allow 或 /etc/hosts.deny
这两个文件的格式是:
进程名 允许或禁止访问的主机名
 
 
4)client:
 
启动portmap & nfs
显示server端所共享的文件:
[root@client ~]# showmount -e 10.224.254.17
Export list for 10.224.254.17:
/tmp  client.nis
/home client.nis
mount 需要的文件
[root@client ~]# mount 10.224.254.17:/home /mnt/
[root@client ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      7.3G  2.1G  4.8G  31% /
/dev/sda1              99M  9.1M   85M  10% /boot
none                  125M     0  125M   0% /dev/shm
10.224.254.17:/home   7.3G  2.1G  4.8G  31% /backup
10.224.254.17:/home   7.3G  2.1G  4.8G  31% /mnt
设置开机自动挂载
[root@client ~]# cat /etc/fstab
# This file is edited by fstab-sync - see 'man fstab-sync' for details
/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
10.224.254.17:/home     /backup                 nfs     defaults        0 0
/dev/hdc                /media/cdrom            auto    pamconsole,exec,noauto,managed 0 0
/dev/fd0                /media/floppy           auto    pamconsole,exec,noauto,managed 0 0
修改/etc/fstab,以后开机会自动mount 10.224.254.17:/home 到本地的/backup。
 
/etc/fstab文件说明:
第一个字段:要挂载的设备或远程目录]
第二个字段:挂载点
第三个字段:挂载的文件系统的格式,如:nfs,ext2, ext3...
第四个字段:挂载参数,defaults一般可以满足要求
第五个字段:是否需要dump file
第六个字段:是否需要检查文件的完整性。
 
Autonfs
(待续)
 
 
 
 
参考文件:

 
 
 
阅读(815) | 评论(0) | 转发(0) |
0

上一篇:NIS 服务器安装与配置

下一篇:AutoHotKey

给主人留下些什么吧!~~