| 0 – 基本設定: Download  Openfiler ver. 2.99
 
 用 VirtualBox 設定兩台 VM,每台VM需要兩張 LAN Card。VM設定如下:
 
 CPU – 1 Core
 RAM – 512MB
 Hard Disk 1 (sda)– SATA 12GB
 Hard Disk 2 (sdb)– SATA 32GB
 LAN 1 (eth0)– Bridging在 Host machine 的網卡上。
 LAN 2 (eth1)– 連接 Virtualbox Host-Only Adapter 上。
 
 安裝Openfiler 在各台VM上。請安裝在 sda 上。留下sdb 一會兒安裝好後再人手設定為 cluster 的 data partition。
 
 每台 VM 的 IP 設定如下:
 
 VM1 :
 Hostname: san1.host.local
 eth0: 128.128.0.5/16
 eth1: 192.168.56.1/24
 
 VM2:
 Hostname: san2.host.local
 eth0: 128.128.0.6/16
 eth1: 192.168.56.2/24
 
 Virtual IP: 128.128.0.7 (這是一個 cluster 的 virtual IP,兩台系統將會共用這一 IP address來提供服務。一會兒在設定 corosync 時會看到設定方法)
 
 
 
 1.1 – 設定Host file:
 修改在 san1 上的host file
 root@san1 ~# vi /etc/hosts
 加入:
 192.168.56.2            san2.host.local
 
 修改在 san2上的host file
 root@san1 ~# vi /etc/hosts
 加入:
 192.168.56.1           san1.host.local
 
 1.2 – 設定 SSH Key,使兩台機器經 scp交換檔案不需要輸入密碼,方便一些:
 
 在 san1 上:
 root@san1 ~# ssh-keygen -t dsa
 
 Generating public/private dsa key pair.
 Enter file in which to save the key (/root/.ssh/id_dsa):
 Created directory ‘/root/.ssh’.
 Enter passphrase (empty for no passphrase):
 Enter same passphrase again:
 Your identification has been saved in /root/.ssh/id_dsa.
 Your public key has been saved in /root/.ssh/id_dsa.pub.
 The key fingerprint is:
 
 在 san2 上作同樣的動作:
 root@san2 ~# ssh-keygen -t dsa
 
 Generating public/private dsa key pair.
 Enter file in which to save the key (/root/.ssh/id_dsa):
 Created directory ‘/root/.ssh’.
 Enter passphrase (empty for no passphrase):
 Enter same passphrase again:
 Your identification has been saved in /root/.ssh/id_dsa.
 Your public key has been saved in /root/.ssh/id_dsa.pub.
 The key fingerprint is:
 
 交換 public key
 在 san1 上:
 root@san1 ~# scp ~/.ssh/id_dsa.pub root@san2.host.local:~/.ssh/authorized_keys
 
 在 san2 上:
 root@san2 ~# scp ~/.ssh/id_dsa.pub root@san1.host.local:~/.ssh/authorized_keys
 
 2 – 設定DRBD 和 Meta / Data Partitions
 設定 corosync/pacemaker 前首先需要設定 DRBD 。DRBD 是用作實時同步 Block devices的服務。可視同為透過網路進行即時同步的RAID-1。
 
 2.1 -設定DRBD
 
 我們會設定兩個 partition分別是 sda4 和 sdb1。然後把它記錄在DRDB 的設定檔案內。記住:兩部機也需要設定 partition。
 
 root@san1 ~# fdisk /dev/sda
 Disk /dev/sda: 12.9 GB, 12884901888 bytes
 255 heads, 63 sectors/track, 1566 cylinders, total 25165824 sectors
 Units = sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x000c6d56
 
 Device Boot      Start         End      Blocks   Id  System
 /dev/sda1   *          63      610469      305203+  83  Linux
 /dev/sda2          610470    17382329     8385930   83  Linux
 /dev/sda3        17382330    19486844     1052257+  82  Linux swap / Solaris
 /dev/sda4        19486845    25165823     2839489+  83  Linux
 
 root@san1 ~# fdisk /dev/sdb
 Disk /dev/sdb: 34.4 GB, 34359738368 bytes
 86 heads, 4 sectors/track, 195083 cylinders, total 67108864 sectors
 Units = sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0×00000000
 
 Device Boot      Start         End      Blocks   Id  System
 /dev/sdb1            2048    67108863    33553408   83  Linux
 
 root@san2 ~# fdisk /dev/sda
 Disk /dev/sda: 12.9 GB, 12884901888 bytes
 255 heads, 63 sectors/track, 1566 cylinders, total 25165824 sectors
 Units = sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x000c6d56
 
 Device Boot      Start         End      Blocks   Id  System
 /dev/sda1   *          63      610469      305203+  83  Linux
 /dev/sda2          610470    17382329     8385930   83  Linux
 /dev/sda3        17382330    19486844     1052257+  82  Linux swap / Solaris
 /dev/sda4        19486845    25165823     2839489+  83  Linux
 
 root@san2 ~# fdisk /dev/sdb
 Disk /dev/sdb: 34.4 GB, 34359738368 bytes
 86 heads, 4 sectors/track, 195083 cylinders, total 67108864 sectors
 Units = sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0×00000000
 
 Device Boot      Start         End      Blocks   Id  System
 /dev/sdb1            2048    67108863    33553408   83  Linux
 
 
 
 在 san1 上設定 /etc/drbd.conf。如下:
 複製 san1 上的/etc/drbd.conf 去 san2。複製代碼    # You can find an example in  /usr/share/doc/drbd.../drbd.conf.example
    include "drbd.d/global_common.conf";
    # include "drbd.d/*.res";
     
    resource meta {
        on san1.host.local {
                device /dev/drbd0;
                    disk /dev/sda4;
                    address 192.168.56.1:7788;
                    meta-disk internal;
            }
     
            on san2.host.local {
                    device /dev/drbd0;
                    disk /dev/sda4;
                    address 192.168.56.2:7788;
                    meta-disk internal;
            }
    }
     
    resource data {
            on san1.host.local {
                    device /dev/drbd1;
                    disk /dev/sdb1;
                    address 192.168.56.1:7789;
                    meta-disk internal;
            }
     
            on san2.host.local {
                    device /dev/drbd1;
                    disk /dev/sdb1;
                    address 192.168.56.2:7789;
                    meta-disk internal;
            }
    }
 root@san1 ~# scp /etc/drbd.conf root@san2.host.local: /etc/drbd.conf
 
 在 san1 和 san2 上執行 drbdadm。如下:
 
 root@ san1 ~# drbdadm create-md meta
 root@ san1 ~# drbdadm create-md data
 
 root@ san2 ~# drbdadm create-md meta
 root@ san2 ~# drbdadm create-md data
 
 
 
 如果有問題的話,可以嘗試用 dd 清空 partition 然後再執行上面的命令。例如:
 
 dd if=/dev/zero of=/dev/sda4
 或
 dd if=/dev/zero of=/dev/sdb1
 
 但請不要弄錯 partition。否則…….重新安裝 openfiler 吧。
 
 OK,沒有問題的話可以起動這兩部機的 drbd daemon了。
 
 root@ san1 ~# service drbd start
 
 root@ san2 ~# service drbd start
 
 在 san1 上,執行drbdsetup設定 san1 為 drbd 的primary node。
 
 root@ san1 ~# drbdsetup /dev/drbd0 primary -o
 root@ san1 ~# drbdsetup /dev/drbd1 primary –o
 
 現在請查看drbd 的 status:
 root@ san1 ~# service drbd status
 
 drbd driver loaded OK; device status:
 version: 8.3.10 (api:88/proto:86-96)
 GIT-hash: 5c0b0469666682443d4785d90a2c603378f9017b build by phil@fat-tyre, 2011-01-28 12:17:35
 m:res   cs         ro                 ds                 p  mounted  fstype
 0:meta  Connected  Primary/Secondary  UpToDate/UpToDate  C
 1:data  Connected  Primary/Secondary  UpToDate/UpToDate  C
 
 2.2 –預備系統設定的 partition
 
 所有有關 openfiler 的設定檔會被移送到 DRBD 的 meta resource /dev/drdb0 中。Meta resource 是掛載到 /dev/sda4中。
 
 root@san1 ~# mkfs.ext3 /dev/drbd0
 
 root@san1 ~# service openfiler stop
 
 2.3 –移送 san1 的Openfiler 設定到 meta partition
 root@ san1 ~# mkdir /meta
 root@ san1 ~# mount /dev/drbd0 /meta
 root@ san1 ~# mv /opt/openfiler/ /opt/openfiler.local
 root@ san1 ~# mkdir /meta/opt
 root@ san1 ~# cp -a /opt/openfiler.local /meta/opt/openfiler
 root@ san1 ~# ln -s /meta/opt/openfiler /opt/openfiler
 root@ san1 ~# rm /meta/opt/openfiler/sbin/openfiler
 root@ san1 ~# ln -s /usr/sbin/httpd /meta/opt/openfiler/sbin/openfiler
 root@ san1 ~# rm /meta/opt/openfiler/etc/rsync.xml
 root@ san1 ~# ln -s /opt/openfiler.local/etc/rsync.xml /meta/opt/openfiler/etc/
 root@ san1 ~# mkdir -p /meta/etc/httpd/conf.d
 |