在 AIX 系统中, 我们如何开启 NFS 呢? 这个问题本文来帮助大家解决一下首先让我们看看都需要哪些准备工作具体过程如下:
1 准备 AIX 服务器
默认安装完 AIX5.3 后, 先停止 nfs 和 portmap 两个进程, 然后删掉一些和 NFS 有关的文件
- # stopsrc -g nfs
- 0513-044 The biod Subsystem was requested to stop.
- 0513-044 The nfsd Subsystem was requested to stop.
- 0513-044 The rpc.mountd Subsystem was requested to stop.
- 0513-044 The rpc.lockd Subsystem was requested to stop.
- 0513-044 The rpc.statd Subsystem was requested to stop.
- #
-g 表示停止一组 nfs 相关的进程
- # stopsrc -s portmap
- 0513-044 The portmap Subsystem was requested to stop.
- #
- # cd /etc
- # rm -rf sm sm.bak state xtab rmtab
2 配置 AIX 的 NFS 服务器
可以直接手动配置 / etc/exports 或使用 smit 工具配置, 因为 AIX 的 NFS 和 Linux 的配置文件内容不同, 所以建议使用 smit 工具来配
这是我通过 smit 配置好的 / etc/exports 文件内容:
- # cat /etc/exports
- /mnt -sec=sys:krb5p:krb5i:krb5:dh:none,rw,root=192.168.3.160,access=192.168.3.161:192.168.3.160
- #
我将 / mnt 目录共享出去, 设置只允许 192.168.3.160 可以对共享目录写操作, 能够访问的服务器有 192.168.3.161 和 192.168.3.160,sec 是数据加密方法. 配置完后, 使用 exportfs 命令将 / etc/exports 的内容更新至 / etc/xtab 文件中,/etc/xtab 文件是 NFS 读取的内容, 所以这步很关键, 如果不用这个命令, 其它的节点是无法正确挂载 NFS 共享目录的:
# exportfs -a
这里要注意一下: NFS 客户端的 IP 地址要写到 / etc/hosts 文中, 并要指定机器名, 否则是无法挂载 AIX 上的 NFS 共享目录
3 启动 NFS 并测试
- # startsrc -s portmap
- 0513-059 The portmap Subsystem has been started. Subsystem PID is 233644.
- # startsrc -g nfs
- 0513-059 The biod Subsystem has been started. Subsystem PID is 245894.
- 0513-059 The nfsd Subsystem has been started. Subsystem PID is 213136.
- 0513-059 The rpc.mountd Subsystem has been started. Subsystem PID is 172270.
- 0513-059 The nfsrgyd Subsystem has been started. Subsystem PID is 217294.
- 0513-059 The gssd Subsystem has been started. Subsystem PID is 221400.
- 0513-059 The rpc.lockd Subsystem has been started. Subsystem PID is 217296.
- 0513-059 The rpc.statd Subsystem has been started. Subsystem PID is 221402.
- #
在 AIX 上查看 NFS 的共享目录
- # showmount -e localhost
- export list for localhost:
- /mnt (everyone)
- #
在 Linux 上查看 AIX 的 NFS 共享目录:
- test01:~ # showmount -e 192.168.3.162
- Export list for 192.168.3.162:
- /mnt (everyone)
- test01:~ #
Linux 系统挂载 NFS 目录
- test01:~ # mount 192.168.3.162:/mnt /mnt.
- ---------------------------------------------------------------------------------
使用 exportfs 命令来重新加载 / etc/exports 文件
当修改 / etc/exports 文件后, 文件是不会立即生效的
需要使用如下命令来重新加载 exports 文件:
- [root@localhost huage]# exportfs -a
- [root@localhost huage]# vi /etc/exports
- [root@localhost huage]# showmount -e
- Export list for localhost.localdomain:
- /home/huage *
- [root@localhost huage]# exportfs -a
- [root@localhost huage]# showmount -e
- Export list for localhost.localdomain:
- /opt */home/huage *
- [root@localhost huage]# man exportfs
- [root@localhost huage]# cat /var/lib/nfs/etab
- /opt *(ro,sync,wdelay,hide,nocrossmnt,secure,root_squash,no_all_squash,no_subtree_check,secure_locks,acl,anonuid=65534,anongid=65534)
- /home/huage *(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,no_all_squash,no_subtree_check,secure_locks,acl,a
- -------------------------------------------------------------
Linuxnfs 服务的 exportfs 命令的简介
如果修改了 / etc/exports 文件后不需要重新激活 nfs, 只要重新扫描一次 / etc/exports 文件, 并且重新将设定加载即可:
# exportfs [-aruv]
参数说明如下
1)-a: 全部挂载 (或卸载)/etc/exports 文件内的设定
2)-r: 重新挂载 / etc/exports 中的设置, 此外同步更新 / etc/exports 及 / var/lib/nfs/xtab 中的内容
3)-u: 卸载某一目录
4)-v: 在 export 时将共享的目录显示在屏幕上
下面是一些 NFS 共享的常用参数:
ro 只读访问
rw 读写访问
sync 所有数据在请求时写入共享
async NFS 在写入数据前可以相应请求
secure NFS 通过 1024 以下的安全 TCP/IP 端口发送
insecure NFS 通过 1024 以上的端口发送
wdelay 如果多个用户要写入 NFS 目录, 则归组写入 (默认)
no_wdelay 如果多个用户要写入 NFS 目录, 则立即写入, 当使用 async 时, 无需此设置
hide 在 NFS 共享目录中不共享其子目录
no_hide 共享 NFS 目录的子目录
subtree_check 如果共享 / usr/bin 之类的子目录时, 强制 NFS 检查父目录的权限 (默认)
no_subtree_check 和上面相对, 不检查父目录权限
all_squash 共享文件的 UID 和 GID 映射匿名用户 anonymous, 适合公用目录
no_all_squash 保留共享文件的 UID 和 GID(默认)
root_squash root 用户的所有请求映射成如 anonymous 用户一样的权限 (默认)
no_root_squash root 用户具有根目录的完全管理访问权限
anonuid=xxx 指定 NFS 服务器 / etc/passwd 文件中匿名用户的 UID
anongid=xxx 指定 NFS 服务器 / etc/passwd 文件中匿名用户的 GID
来源: http://www.bubuko.com/infodetail-2528192.html