AIX 5L上配置NFS Server

主要步骤:

1)在AIX上启动NFS服务,并配置要共享给WINDOWS的目录

2)在WINDOWS上安装SFU客户端,配置与AIX系统的用户映射关系

3)在WINDOWS上运行命令将AIX上目录映射到本地的一个盘符 

 

一、配置NFS Server

首先需要启动NFS Server,可以通过smit nfs–> Network File System (NFS) –>Configure NFS on This System启动或者停止nfs服务组。

注:用smitty来启动有可能出现启动不完整,改用命令行来执行

命令行:

startsrc -g nfs

stopsrc -g nfs

 

可以通过lssrc -g nfs查看nfs的服务情况

#lssrc -g nfs 

Subsystem         Group            PID          Status

biod                nfs              712706       active

nfsd                nfs              635260       active

rpc.mountd       nfs              462932       active

rpc.lockd          nfs              639418       active

rpc.statd          nfs              757914       active

nfsrgyd            nfs                           inoperative

gssd                nfs                           inoperative

当然,以上也可以通过startsrc -g nfsstopsrc -g nfs启动与停止该服务组子系统。每当系统启动时,/etc/rc.nfs运行exportfs命令来读取服务器上的/etc/exports文件,然后 告诉内核要导出哪些目录与对应的权限。然后rpc.mountd和以上守护进程由/etc/rc.nfs启动。

/etc/exports指定了nfs server要导出的目录与权限,该文件内容如下,如

#more /etc/exports

    /u01/logs -sec=sys:krb5p:krb5i:krb5:dh:none,rw,access=host_name

注意:这里的access一定要写机器名,其机器名对应的ip/etc/hosts中体现出来

exportfs可以导出该目录,如:

#/usr/sbin/exportfs -a

#/usr/sbin/exportfs

    /u01/logs -sec=sys:krb5p:krb5i:krb5:dh:none,rw,access=host_name

关于更多的exportfs的用法,可以查看相关帮助,另外,/etc/xtab则与/ext/exports有一样的格式,运行exportfs的时候,/etc/xtab将被更新,这样可以临时导出一个目录而不更新exports文件。

 

说明:如果没有配置NFS共享文件夹的访问权限,则无法查找到/etc/exports文件。

关于/etc/exports的更新,也可以用smit nfs–>Network File System (NFS) –>Add a Directory to Exports List或者是Change / Show Attributes of an Exported Directory来实现,如

#smit chnfsexp

 

* PATHNAME of Directory to Export                     /scanfiles

* MODE to export directory                            read-write                                                             

  HOSTS & NETGROUPS allowed client access             [ZSDA2_bt2,ZSDA2_present,ZSDA_svr2,centos,oa-wjb,db]

  Anonymous UID                                      [-2]

  HOSTS allowed root access                          [ZSDA2_bt2,ZSDA2_present,ZSDA_svr2,centos,oa-wjb,db]

  HOSTNAME list. If exported read-mostly             []

  Use SECURE OPTION?                                  no                                                                     +

  Public filesystem?                                  no                                                                     +

* CHANGE export now, system restart or both           both                                                                   +

  PATHNAME of alternate Exports file                 []

 

////////////////////////////////////////////

    * Pathname of directory to export                     /u01/logs

      Anonymous UID                                      [-2]

      Public filesystem?                                 [no]

    * Change export now, system restart or both           both

      Pathname of alternate exports file                 []

      Allow access by NFS versions                       []

      External name of directory (NFS V4 access only)    []

      Referral locations (NFS V4 access only)            []

      Replica locations                                  []

      Ensure primary hostname in replica list             yes

      Allow delegations?                                 []

      Security method                                    [sys,krb5p,krb5i,krb5,dh,none]

          Mode to export directory                       [read-write]

          Hostname list. If exported read-mostly         []

          Hosts & netgroups allowed client access        [host_name1,host_name2]

          Hosts allowed root access                      []

////////////////////////////////////////

验证服务器中上的 /etc/exports 文件是否列出客户机要安装的文件系统名称以及该文件系统是否已导出。输入以下命令进行操作:

#showmount -e server_name( showmount -e zsda1)

该命令在NFS Server/client上都可以正常运行,列出了由 server_name 当前导出的所有文件系统。

 二、配置 nfs client

nfsclient配置比较简单,需要portmap服务正常即可。

#lssrc -s portmap

    Subsystem         Group            PID          Status

     portmap          portmap          225506       active

关于mount的信息,是写在/etc/filesystems中的,如

#more /etc/filesystems

    ......

    /mydisk:

        dev             = "/disk1"

        vfs             = nfs

        nodename        = dbbak

        mount           = false

        type            = nfs3

        options         = soft,intr,retry=2,rsize=32768,wsize=32768,timeo=300,proto=tcp

        account         = false

    ......

其中nodename指定了服务器的名字,其对应的ip/etc/hosts中体现,dev指定了服务器的export出来的目录。

关于更多的options的设置,可以查阅更多的nfs的文档。

其详细信息,也可以在smit中获得,如smit nfs–>Network File System (NFS) –>Add a File System for Mounting或者是Change / Show Attributes of an NFS File System。如

#smit chnfsmnt

    * PATHNAME of mount point                             /mydisk

    * PATHNAME of Remote Directory                       [/disk1]

    * HOST where remote directory resides                [dbbak]

      Mount type NAME                                    [nfs3]

    * Use SECURE mount option?                            no

    * Remount file system now,                            both

       update /etc/filesystems or both?

    * /etc/filesystems entry will mount the directory     no

       on system RESTART.

    * MODE for this NFS file system                       read-write

    * ATTEMPT mount in background or foreground?          foreground

      NUMBER of times to attempt mount                   [2]

      Buffer SIZE for read                               [32768]

      Buffer SIZE for writes                             [32768]

      NFS TIMEOUT. In tenths of a second                 [300]

      NFS version for this NFS file system                any

      Transport protocol to use                           tcp

      Internet port NUMBER for server                    []

    * Allow execution of SUID and sgid programs           yes

       in this file system?

    * Allow DEVICE access via this mount?                 yes

    * Server supports long DEVICE NUMBERS?                yes

    * Mount file system soft or hard                      soft

验证 mountdportmap nfsd 守护程序正在 NFS 服务器上运行,请在客户机 shell 提示符下输入以下命令:

#/usr/bin/rpcinfo -u server_name mount

#/usr/bin/rpcinfo -u server_name portmap

#/usr/bin/rpcinfo -u server_name nfs

如果守护程序在服务器运行,会返回以下响应:

    program  100005  version  1  ready  and  waiting

    program  100000  version  2  ready  and  waiting

    program  100003  version  2  ready  and  waiting

程序号分别与命令对应,如前例中所示。如果没有返回类似的响应,请在服务器控制台上登录服务器并按照获取 NFS 守护程序的当前状态中的指示信息检查守护程序的状态。

#showmount -e server_name

该命令列出了由 server_name 当前导出的所有文件系统。

 

注意:如果在AIXmount linuxnfs文件系统,可能需要特殊执行:

#nfso -o nfs_use_reserved_ports=1

 

三、在WINDOWS 机器上配置 NFS CLIENT

 

Windows 系统挂载 UNIX NFS 分享目录

Linux File Server 除了 Linux + SAMBA 的方案外, 也可以使用 Windows + SFU (Windows Services for UNIX) 的方式连接 Linux NFS Shared Folder.

实测环境

AIX-5.3

Microsoft Windows XP, SP2 + SFU 3.5

下载Microsoft Windows Services for UNIX 3.5 (450MB)

Windows Services for UNIX 3.5 系统需求

下载地址:

http://download.microsoft.com/download/a/1/c/a1ca7af1-a6e3-46e7-874a-4c5d8c0fb3b7/SFU35SEL_EN.exe

解压缩到 C:\SFU35SEL_EN

安装

只安裝 Client for NFS on Windows 的操作指令:

msiexec /I C:\SFU35SEL_EN\sfusetup.msi /qb addlocal="NFSClient"

完整安装 (执行 setup.exe) Windows Services for UNIX 的程式集內容:

默认安装路径: C:\SFU

执行 C Shell Korn Shell 可在 Windows 系统操作 Unix 指令

Services for UNIX Administration 界面如下 (完整安装):

在AIX 5L上配置NFS Server - lefty - lefty

设定 User Name Mapping

NFS Server 上的 /etc/passwd/etc/group 两个文件复制到 Windows 电脑的 C:\

执行 Services for UNIX Administrator

点选 User Name Mapping

Configuration 画面中, 设定:

Password file path and name: c:\passwd

Group file path and name: c:\group

Maps 画面中,设定:

Show User Maps → List Windows UsersList UNIX Users

Windows users清单中点选自己的账号

UNIX users 清单中点选欲映射的账号 (想要以那个 UNIX 身份挂载 NFS Folder)

Add → 确定

按画面右上角 Apply 完成设定

挂载NFS 目录

命令列模式:

cd \SFU\common

mount linux_ip:/path drive_id: (: mount 192.168.0.1:/abc e: → 掛載到 E )

檔案總管模式:

檔案總管工具連線網路磁碟機瀏覽

在AIX 5L上配置NFS Server - lefty - lefty

掛載完成示意圖:

 在AIX 5L上配置NFS Server - lefty - lefty

  

 

 

Services for UNIX使用指南

IT 专业人员与开发人员所面临的难题之一是如何集成各种不同平台上的应用程序和数据,尤其是企业同时拥有UNIXWINDOWS平台,如何共享数据,方便不同的用户使用,就摆在IT管理人员的面前。

这里介绍微软公司的Services for UNIX(以下简称SFU),将提供简便的解决方案。

前期准备工作:

1、确认两个服务是否正确运行(Server for NFS User Name Mapping).

2、将passwd group 文件从linux主机拷贝到NAS主机的某个目录下。目录位置没有限定。如:systemroot\system32\drivers\etc

3、在Windows设定一个专用用户来作为UNIX用户,并设定相应的权限。

注:本文仅说明简单的映射关系,关于NISAD的集成,以后有机会在说明。

安装Services for UNIX

微软公司提供免费的SFU3.5下载,点击如下地址注册下载:

http://www.microsoft.com/windowsserversystem/sfu/downloads/default.mspx

点击安装文件:

 

在AIX 5L上配置NFS Server - lefty - lefty

输入用户名和组织名称,并接受协议。

在AIX 5L上配置NFS Server - lefty - lefty在AIX 5L上配置NFS Server - lefty - lefty


选择标准安装还是自定义安装,由于我们这里是做简单映射,所以选择标准安装。安装文件会安装在C:\SFU。下表会列出标准和自定义的不同的功能:

Component

Windows ;;2000 Professional, or Windows ;;XP Professional

Windows ;;2000 Server or Windows Server ;;2003, except domain controllers

Windows ;;2000 Server or Windows Server ;;2003 domain controllers

Base utilities, including Interix subsystem

Standard

Standard

Standard

UNIX Perl

Standard

Standard

Standard

Interix GNU utilities

Standard

Standard

Standard

Interix GNU SDK

Custom

Custom

Custom

Client for NFS

Standard

Standard

Standard

Server for NFS

Custom

Standard

Standard

Gateway for NFS

N/A

Custom

Custom

Server for NIS

N/A

N/A

Standard

Password synchronization

Custom

Custom

Standard

Telnet Server (available Windows ;;2000 only)

Standard

Standard

Standard

Windows-based Remote Shell and Cron services

Custom

Standard

Standard

User Name Mapping

Custom

Custom

Standard

Server for NFS Authentication

Custom

Standard

Standard

Server for PCNFS

Custom

Custom

Custom

Interix SDK

Custom

Custom

Custom

ActiveState Perl

Custom

Custom

Custom

下面是内建的安全设定,如:SUID等设定,在这里不加解释。一般可以不选,如果有特殊的要求可以选择。

在AIX 5L上配置NFS Server - lefty - lefty在AIX 5L上配置NFS Server - lefty - lefty

 


用户名映射:这里选Local User Name Mapping ServerPassword and group files。并选择域名,这里选本机的服务器名。NIS服务器不选。

在AIX 5L上配置NFS Server - lefty - lefty在AIX 5L上配置NFS Server - lefty - lefty


安装,完成。


设定SFU

在运行输入:services.msc

启动服务:client for NFS,server for NFS, User Name Mapping三个服务。

选择Start → Programs → Administrative Tools → Windows Services for UNIX


点击User Name Mapping:选择Use Password and Group files,并将路径指向前面拷贝的目录里,我这里是C:\nfsuser\passwordgroup。选择Maps。点击Simple maps

在AIX 5L上配置NFS Server - lefty - lefty

 

点击Show User Maps。并分别点击List Windows Users,和List Unix Users

在AIX 5L上配置NFS Server - lefty - lefty

在AIX 5L上配置NFS Server - lefty - lefty

分别输入Windows user name,和Unix user name。按Add。已经设定好的映射将在Mapped users表中列出。

在AIX 5L上配置NFS Server - lefty - lefty

点击Apply就可以完成用户名映射。同样用户组也是这样设定。

 

说明:如果是作为客户端使用,可以不需要下面的操作:

设定完成后就可以设定共享的目录:右键点击共享的目录,选择属性>NFS Sharing.

在AIX 5L上配置NFS Server - lefty - lefty

点击Share this folder。设定共享名称,注意如果你需要匿名访问就要点击Allow ….

在AIX 5L上配置NFS Server - lefty - lefty

如果你是使用root用户,则点击Permissions,选择Allow root access

在AIX 5L上配置NFS Server - lefty - lefty

OK。结束共享设置。

 

四、盘符映射

重启两个服务client for NFS ,Server for NFS

Linux 主机上用root 用户登录,然后键入如下命令:

mount -t nfs IP_address: Share folder  /mnt

 

AIX命令:

mount 服务器名(IP):/share floder /mnt

 

windows命令:

Mount 服务器名(IP)/共享文件夹 盘符

如:mount zsda1:/scanfiles X:

 

然后你可以进入 /mnt 目录用 ls 来确认你的共享文件夹已经ok