Ubuntu 10.04 安裝配置 PVFS2 手記

由於項目需要,試用和學習PVFS2,下面記錄安裝過程,以方便其他初用者安裝。

英文指南參見http://www.pvfs.org/cvs/pvfs-2-8-branch-docs/doc/pvfs2-quickstart/pvfs2-quickstart.php 

  • 安裝
  1. 特定針對安裝環境Ubuntu 10.04 Desktop
    首先切換到root權限,以方便後續操作:
    basicthinker@ubuntu:~$ sudo -s  
  2. 安裝SSL的開發庫和頭文件等,可能用於PVFS2的網絡通訊:
    root@ubuntu:~# apt-get install libssl-dev  
  3. 安裝Berkley DB的靜態庫和頭文件等,用於PVFS2的存儲:
    root@ubuntu:~# apt-get install libdb-dev  
  4. 安裝AIO的庫(This library enables userspace to use Linux kernel asynchronous I/O system calls, important for the performance of databases):
    root@ubuntu:~# apt-get install libaio-dev  
  5. 下載PVFS2的源碼http://www.pvfs.org/download/ ,拷貝解壓到/usr/src目錄下:
    root@ubuntu:/home/basicthinker/Downloads# cp pvfs-2.8.2.tar.gz /usr/src
    root@ubuntu:/home/basicthinker/Downloads# cd /usr/src
    root@ubuntu:/usr/src# tar -xzf pvfs-2.8.2.tar.gz  
  6. 編譯源碼:
    root@ubuntu:/usr/src# cd pvfs-2.8.2
    root@ubuntu:/usr/src/pvfs-2.8.2# ./configure

    我的結果是:
    ***** Displaying PVFS Configuration Information *****
    ------------------------------------------------------
    PVFS2 configured to build karma gui               :  no
    PVFS2 configured to perform coverage analysis     :  no
    PVFS2 configured for aio threaded callbacks       : yes
    PVFS2 configured to use FUSE                      :  no
    PVFS2 configured for the 2.6.x kernel module      :  no
    PVFS2 configured for the 2.4.x kernel module      :  no
    PVFS2 configured for using the mmap-ra-cache      :  no
    PVFS2 will use workaround for redhat 2.4 kernels  :  no
    PVFS2 will use workaround for buggy NPTL          :  no
    PVFS2 server will be built                        : yes

    PVFS2 version string: 2.8.2

    再運行:
    root@ubuntu:/usr/src/pvfs-2.8.2# make
    root@ubuntu:/usr/src/pvfs-2.8.2# make install  
           
  • 單機配置 (本機同時扮演metadata server、I/O server和client的角色)
  1. 生成配置文件:
    root@ubuntu:~# pvfs2-genconfig /etc/pvfs2-fs.conf
    這是個交互式腳本,一般選項都默認即可(直接按Enter跳過),只有一個
    * Enter hostnames [Default is localhost]: 
    需要設置爲本機的hostname,可以另開控制檯輸入hostname查看本機的值,我的設置爲"ubuntu"。  
  2. 第一次啓動PVFS2服務要首先分配空間,添加參數-f:
    root@ubuntu:~# pvfs2-server /etc/pvfs2-fs.conf -f
    其後啓動服務則不需加參數,或使用-d使得服務運行於前臺(佔用當前終端窗口,終端窗口關閉後服務終止):
    root@ubuntu:~# pvfs2-server /etc/pvfs2-fs.conf  
  3. 可以設置該服務爲開機自啓動:
    編輯文件/etc/rc.local,在結尾“exit 0”前添加行:
    pvfs2-server /etc/pvfs2-fs.conf
    (不必包含"sudo",啓動階段等同根權限)。   
  4. 因爲是單機,需要同時配置client,首先設置掛載點,創建目錄:
    root@ubuntu:~# mkdir /mnt/pvfs2
    然後在/etc/fstab文件末尾添加行,其中"ubuntu"爲本機的hostname,請讀者注意替換:
    tcp://ubuntu :3334/pvfs2-fs /mnt/pvfs2 pvfs2 defaults,noauto 0 0  
  5. 驗證安裝:
    basicthinker@ubuntu:~$ pvfs2-ping -m /mnt/pvfs2
    會顯示若干驗證信息,最後顯示 "The PVFS2 filesystem at /mnt/pvfs2 appears to be correctly configured." 即爲正常。

    可實驗將任意文件拷貝到PVFS2文件系統中而後查看:
    basicthinker@ubuntu:~$ pvfs2-cp -t ~/Documents/some_file /mnt/pvfs2
    Wrote 19 bytes in 0.003468 seconds. 0.005225 MB/seconds
    basicthinker@ubuntu:~$ pvfs2-ls /mnt/pvfs2
    some_file
    lost+found

    我們使用用戶態的接口,需要pvfs2前綴;最後一行顯示的"lost+found"是系統默認包含的文件夾。  
  6. 【注意】如果想重新安裝PVFS2,需要刪除設置的數據存儲目錄(在本節第1步中,默認爲/pvfs2-storage-space),而後重複上述過程,否則會產生衝突。  
           
  • 集羣配置 (metadata server、I/O server和client分佈在多個節點) 
  1. 個人測試環境推薦VMware Workstation虛擬多個主機,有Team功能,可方便地同時操作多個虛擬機;更重要的是有“克隆”功能,省去很多重複安裝配置。  
  2. 在主界面單機File—New—Team,根據嚮導建立Team,這裏稱作"PVFS2 Team"。完成後,在左側導航欄,右鍵單擊"PVFS2 Team",選擇Settings,在Virtual Machines選項卡下可添加虛擬機。  
  3. 首先添加一個New Virtual Machine,安裝Ubuntu 10.04 Desktop(注意一併安裝常用包如SSH)以及PVFS2(參照上述“安裝”一節);而後添加新的節點,只需選擇New Clone of Virtual Mahine進行克隆,不必重複繁瑣的安裝過程。

    這裏我們開啓3個虛擬節點,其中node1、node2爲I/O server,node2、node3爲metadata server。  
  4. 配置VMware虛擬集羣: 

    我選擇的是NAT網絡,因爲它既可以使用保留地址組建局域網(虛擬機之間通訊),又可以訪問廣域網,使用起來較爲方便。參照本節步驟2打開Team Settings,在Connections選項卡下勾選各個節點爲NAT。

    而後打開VMware配套工具Virtual Network Editor,查看相應NAT網絡的NAT Settings,記錄Gateway IP,本人這裏是192.168.11.2。

    在各個節點,編輯/etc/network/interfaces文件如下(以node1爲例,"eh1"爲其連接名,注意 不同節點可能不同):
    auto eth1 
    iface eth1 inet static
    address 192.168.11.201
    netmask 255.255.255.0
    gateway 192.168.11.2
    其餘node可依次分配IP 192.168.11.202~203(地址任意)。並且重新啓動連接以激活新配置:
    basicthinker@ubuntu:~$ sudo ifdown eth1 
    basicthinker@ubuntu:~$ sudo ifup eth1

    將上述分配的靜態IP依次寫入各個虛擬節點的/etc/hosts文件,以進行主機名的解析:
    192.168.11.201 node1
    192.168.11.202 node2
    192.168.11.203 node3
    注意每個hosts文件都要寫入上面所有行。   
  5. 生成配置文件:
    選擇任意節點運行與“單機配置”第1步相同的命令:
    root@ubuntu:~# pvfs2-genconfig /etc/pvfs2-fs.conf

    不同之處在於選擇I/O server時:
    Next you must list the hostnames of the machines that will act as
    I/O servers.  Acceptable syntax is "node1, node2, ..." or "node{#-#,#,#}".

    * Enter hostnames [Default is localhost]: node1, node2 

    以及選擇metadata server時:
    Now list the hostnames of the machines that will act as Metadata
    servers.  This list may or may not overlap with the I/O server list.

    * Enter hostnames [Default is localhost]: node2, node3  
  6. 將生成後的配置文件pvfs2-fs.conf拷貝到各個節點的/etc目錄下。
    然後依次更改各個節點/etc/hostname文件內容爲本節點名稱(如node1),而不能使用克隆的源虛擬機的hostname;可能需要重啓使更新生效。  
  7. 如果克隆版本已經分配過空間,還需要首先手動刪除/pvfs2-storage-space,其餘同“單機配置”的第2步。如果克隆源未執行“單擊配置”第3步,此時可依次配置各個節點。  
  8. 任意節點可作爲client,配置方法同“單機配置”第4步。注意更改fstab條目中的hostname,克隆源可能爲"ubuntu",現在應改爲node1~3中任意一個。  
  9. 驗證安裝:分別在各個節點運行pvfs2-ping命令可以初步驗證安裝成功。
    另外我們可以嘗試如下幾行命令,實際驗證多機環境:
    在node1節點執行:
    basicthinker@node1:~/Documents$ pvfs-cp some_file /mnt/pvfs2
    而後到node3節點查看:
    basicthinker@node3:~$ pvfs2-ls /mnt/pvfs2
    some_file
    lost+found
    可以看到some_file已經存儲到了pvfs2中。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章