Chinaunix首页 | 论坛 | 博客
  • 博客访问: 400030
  • 博文数量: 148
  • 博客积分: 3191
  • 博客等级: 中校
  • 技术积分: 1232
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-11 15:25
文章分类

全部博文(148)

文章存档

2011年(148)

我的朋友

分类: LINUX

2011-08-12 13:06:29

NFS 是架構在 RPC Server 上面
一. NFS服务器端配置(Linux):
1. 配置/etc/exports文件
编辑/etc/exports文件,添加如下行:
/mnt/hdc/172.20.1.10    172.20.1.50(rw,nohide,async,root_squash,insecure)
/tmp    *(rw,async)
/data    *.example.com(rw,async)
/data2    172.20.1.133/255.255.255.0(rw,async)
配置这个文件的目的是把服务器上的资源共享出来,使客户机能够把服务器的资源在本地使用。
现针对第一行/mnt/hdc/172.20.1.10    172.20.1.10(rw,nohide,async,root_squash,insecure)进行解释:
/mnt/hdc/172.20.1.10 在服务器端所有共享的资源(目录)
172.20.1.10 可以享用服务器资源的客户端的IP
括号内的内容如下:
rw 可读写
nohide 客户端可以享用服务器的子目录资源,例如/mnt/hdc/172.20.1.10/db
async 非同步模式进行存储,可改善网络和磁盘IO访问性能
root_spuash 权限设置,客户端在服务器上不可以以root用户访问或生成文件
insecure nfs客户端可以用高于1024的端口与服务器进行连接

2. 配置nfs服务器
nfs服务器端由3部分组成:

nfs nfs主程序,提供nfs主功能
nfslock 提供nfs读写方面时的锁定功能
portmap portmap 是一台server , 主要功能 转换 TCP/IP 通讯协定的,port number 变成 RPC program number , 因为这样clinet才能做RPC calls

让/etc/export添加的共享在客户端立即显示,服务端运行
exportfs -r
客户端查看nfs服务器共享那些目录,客户端运行
showmount -e 172.20.1.133

首先检查nfs服务器是否能自动启动:
chkconfig --list nfs

如果显示的结果如下:
[root@localhost etc]# chkconfig --list nfs
nfs            0:off  1:off  2:off    3:off    4:off    5:off    6:off

表明nfs这个程序在运行级0-5都是关闭的,我们要在运行级2-5运行nfs:
chkconfig –level 2345 nfs on

我们再进行一次检查:
[root@localhost etc]# chkconfig --list nfs
nfs            0:off  1:off  2:on    3:on    4:on    5:on    6:off

这表明服务器端重启时,运行级在2345时nfs都会启动
我们还需要检查和配置nfslock和portmap,使nfslock和portmap能够在运行级2345时自动运行

3. 手工运行或停止nfs
通常在第一次启动nfs,nfs服务器出错,修改了配置后都要手工运行或停止nfs:
service [nfs|nfslock|portmap] [start|stop|restart]
其中start为启动,stop为停止,restart是重启动,相当于停止后再启动
其中,开启 nfs相关进程为portmapnfslocknfs,关闭相反


4. 权限配置
为了使目录/mnt/hdc下共享出的目录有被读写的权限,必须执行以下命令:
chmod 777 /mnt/hdc/*

5、测试nfs
範例一:請顯示出剛剛我們所設定好的相關 exports 資訊
[root@linux ~]# showmount -e localhost
[root@linux ~]# showmount -e 172.20.1.60
範例二:重新掛載一次 /etc/exports 的設定
[root@linux ~]# exportfs -arv
範例三:全部都卸載
[root@linux ~]# exportfs -auv

[root@linux ~]# mount -t nfs 172.20.1.60:/home/public /home/nfs/public
# 注意一下掛載的語法!『 -t nfs 』指定檔案系統類型,
# IP:/dir 則是指定某一部主機的某個提供的目錄!
[root@linux ~]# umount /home/nfs/public
#卸載所挂的目录



二. NFS客户端配置:
NFS 開機即掛載
•  [root@linux ~]# vi /etc/fstab
192.168.0.2:/home/public  /home/nfs/public  nfs  nosuid,noexec,nodev,rw,
bg,soft,rsize=32768,wsize=32768  0  0
# 注意!上面的設定是同一行喔!不要搞錯囉! ^_^




(AIX客户端)
1. 自动mount
Linux by default requires any NFS mount to use a so called reserved port
below 1024 and AIX 4.3 does by default use ports above 1024. You can use
the nfso command to restrict AIX to the reserved port range as follows:

nfso -o nfs_use_reserved_ports=1

假如我们在客户机172.20.1.41上,想把服务器172.20.1.60上的资源目录/mnt/hdc/172.20.1.41 mount在客户机/mnt/storage_pz上,我们将采取以下步骤进行:

在文本或图形界面下面执行smitty mknfsmnt或xmit mknfsmnt,在程序界面相应的项目下填写配置信息:
PATHNAME of mount point
填写/mnt/storage_pz,安装点
PATHNAME of remote directory
填写/mnt/hdc/172.20.1.41,服务器资源目录
HOST where remote directory resides
填写172.20.1.60,服务器名称或IP
/etc/filesystems entry will mount the directory on system RESTART
按F4键,选择Yes,表示是否自动在启动是mount
NUMBER of times to attempt mount
填写20,表示如果mount失败时尝试的次数
Buffer SIZE for read
填写16384,读缓冲大小
Buffer SIZE for writes
填写16384,写缓冲大小

填写完按回车执行nfs mount,如果没有出错信息,就表示配置没有错误,按F3回到配置界面,修改“MOUNT now, add entry to /etc/filesystems or boths?”选项为“filesystems”,再按回车执行一次,程序会把配置信息写入:/etc/filesystems ,下次客户端重新启动是就会进行nfs自动mount

2. 手工mount
在172.20.1.41客户端的“#”提示符下执行:
mount –o rw /172.20.1.60:mnt/hdc/172.20.1.41 /mnt/storage_pz
就可以将服务器资源/mnt/hdc/172.20.1.41 mount到/mnt/storage_pz目录


3. 验证
使用mount可以验证哪些资源已经mount:
# mount
  node      mounted        mounted over    vfs      date        options     
-------- ---------------  ---------------  ------ ------------ ---------------
        /dev/hd4        /                jfs    Mar 24 08:45 rw,log=/dev/hd8
        /dev/hd2        /usr            jfs    Mar 24 08:45 rw,log=/dev/hd8
        /dev/hd9var      /var            jfs    Mar 24 08:45 rw,log=/dev/hd8
        /dev/hd3        /tmp            jfs    Mar 24 08:45 rw,log=/dev/hd8
        /dev/hd1        /home            jfs    Mar 24 08:46 rw,log=/dev/hd8
        /dev/lv00        /Tivoli          jfs    Mar 24 08:46 rw,log=/dev/hd8
172.20.1.60 /mnt/hdc/172.20.1.41 /mnt/storage_pz  nfs3  Mar 24 08:46 bg,hard,intr,retry=20,rsize=16384,wsize=16384,rw

可见最后一行显示了nfs mount的信息

4. 为了使目录/mnt/storage_pz的目录有被其它用户(如oracle)读写的权限,必须执行以下命令:
chmod 777 /mnt/hdc/*

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

2011-08-16 18:53:39

我是个新人,请问一下AIX客户端配置是用来干什么的?有什么用?