在AIX 5L上配置NFS Server/Client

cccgw發表於2008-05-20

在AIX 5L上配置NFS Server/Client

作者: (轉載請註明本文出處:)
永久連結:
[@more@]

一、配置NFS Server

首先需要啟動NFS Server,可以透過smit nfs–> Network File System (NFS) –>Configure NFS on This System啟動或者停止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 nfs與stopsrc -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檔案。

關於/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                     /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

該命令在NFS Server/client上都可以正常執行,列出了由 server_name 當前匯出的所有檔案系統。

二、配置 nfs client

nfs的client配置比較簡單,需要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

驗證 mountd、portmap 和 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 當前匯出的所有檔案系統。

注意:如果在AIX上mount linux的nfs檔案系統,可能需要特殊執行:

#nfso -o nfs_use_reserved_ports=1

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/668365/viewspace-1004303/,如需轉載,請註明出處,否則將追究法律責任。

相關文章