Saturday, September 17, 2011

建構 Oracle VM 測試環境

[0] 安裝基本系統
1. 儲存設備設定 NFS.
2. 安裝 n 台 VM server(其中一台會當 server pool master).
3. 安裝一台 CentOS 當 VM manager.
4. 在 3. 的機器或 VM 上安裝 VM manager.
5. 設定每一台機器(ovms1 ~ ovmsn)的 /etc/hosts 及網路設定.
(storage network 沒有 DNS 可用, hostname 必須和 /etc/ocfs2/cluster.conf 中相同, 才會被視為 local)
5.1. hostname ovmsX.DOMAIN.NAME (X: 1 ~ n)
5.2. 編輯 /etc/sysconfig/network
5.3. 編輯 /etc/sysconfig/network-scripts/ifcfg-eth0
編輯 /etc/sysconfig/network-scripts/ifcfg-eth1
5.4. 編輯 /etc/hosts

[1] 為 ovms1 ~ ovmsn 同步機器時間
Sync time, add to each node
# crontab -e
### Generic jobs
0 * * * *      /usr/bin/rdate -s TIME-SERVER-IP
0 3 * * *       /sbin/clock -w

[2] 在 ovms1 ovms2 上編輯 /etc/ocfs2/cluster.conf, 其餘的機器將使用 VM manager 加入, 不需要進行.
# mkdir /etc/ocfs2
# vi /etc/ocfs2/cluster.conf
[root@ovms1 ~]# more /etc/ocfs2/cluster.conf
node:
 ip_port     = 7777
 ip_address  = 192.168.16.71
 number      = 0
 name        = ovms1.DOMAIN.NAME
 cluster     = ocfs2

node:
 ip_port     = 7777
 ip_address  = 192.168.16.72
 number      = 1
 name        = ovms2.DOMAIN.NAME
 cluster     = ocfs2

cluster:
 node_count  = 2
 name        = ocfs2

[3] 在 ovms1 ~ ovmsn 刪除裝機時自動裝上的 /OVS
# /opt/ovs-agent-2.3/utils/repos.py -l
[ * ] 06cb4782-0017-44b1-81f8-45e78984167c => /dev/sda3
# /opt/ovs-agent-2.3/utils/repos.py -d 06cb4782-0017-44b1-81f8-45e78984167c
*** Cluster teared down.
# /opt/ovs-agent-2.3/utils/repos.py -l
# ll /dev/sda3
brw-r----- 1 root disk 8, 3 Mar 5 02:50 /dev/sda3

[4] 在 ovms1 ~ ovms2 啟動 cluster
檢查 o2cb 狀態
# service o2cb status
Driver for "configfs": Loaded
Filesystem "configfs": Not mounted
Driver for "ocfs2_dlmfs": Not loaded
Checking O2CB cluster ocfs2: Offline

載入 o2cb 設定
# service o2cb load
Mounting configfs filesystem at /sys/kernel/config: OK
Loading filesystem "ocfs2_dlmfs": OK
Creating directory '/dlm': OK
Mounting ocfs2_dlmfs filesystem at /dlm: OK

將 o2cb 上線
# service o2cb online
Starting O2CB cluster ocfs2: OK

設定 o2cb heartbeat
# service o2cb configure
Configuring the O2CB driver.

This will configure the on-boot properties of the O2CB driver.
The following questions will determine whether the driver is loaded on
boot. The current values will be shown in brackets ('[]'). Hitting
without typing an answer will keep that current value. Ctrl-C
will abort.

Load O2CB driver on boot (y/n) [n]: y
Cluster stack backing O2CB [o2cb]:
Cluster to start on boot (Enter "none" to clear) [ocfs2]:
Specify heartbeat dead threshold (>=7) [31]:
Specify network idle timeout in ms (>=5000) [30000]:
Specify network keepalive delay in ms (>=1000) [2000]:
Specify network reconnect delay in ms (>=2000) [2000]:
Writing O2CB configuration: OK
Starting O2CB cluster ocfs2: OK

啟動 o2cb
# service o2cb start
Starting O2CB cluster ocfs2: OK

掛載 /OVS
# mount HOSTNAME:/path/to/datastore/ /OVS

檢查 o2cb cluster 狀態
# service o2cb status
Driver for "configfs": Loaded
Filesystem "configfs": Mounted
Driver for "ocfs2_dlmfs": Loaded
Filesystem "ocfs2_dlmfs": Mounted
Checking O2CB cluster ocfs2: Online
Heartbeat dead threshold = 31
Network idle timeout: 30000
Network keepalive delay: 2000
Network reconnect delay: 2000
Checking O2CB heartbeat: Not active

Only server pool master

[5] 只在 ovms1 執行 (特別注意)
# /opt/ovs-agent-2.3/utils/repos.py --new HOSTNAME:/path/to/datastore/
[ NEW ] b40cb283-1a0f-4266-917e-7dcacf64ffbc => /path/to/datastore/
# /opt/ovs-agent-2.3/utils/repos.py --root b40cb283-1a0f-4266-917e-7dcacf64ffbc
[ R ] b40cb283-1a0f-4266-917e-7dcacf64ffbc => /path/to/datastore/

接著可在 ovms2 觀察設定
# /opt/ovs-agent-2.3/utils/repos.py --list
[ R ] b40cb283-1a0f-4266-917e-7dcacf64ffbc => /path/to/datastore/

[6] Remember to reboot ovms1 ~ ovms2, 並且登入手動掛上 /OVS.

[7] 進入 VM manager/Server Pool 新增 server pool
https://ovmm:4443/OVS
在 Create pool 時設定 Server pool name, Enable High Availability Mode, Server Pool Virtual IP,
Server Host/IP, Server Name, Server Agent Password.
ovms1 請選擇 Server Pool Master, Utility Server, Virtual Machine Server
ovms2 請選擇 Utility Server, Virtual Machine Server
輸入 Utility Server 需要的帳密 root / xxxxxx
再將 ovms1 ovms2 加入.

下一步選擇管理人員
再下一步不需要修改任何設定, 直接進行 confirm.

如果狀態是 Error, HA enable. 請直接將 ovms1 ~ 2 重開機.
如果還是 Error, 請將 server pool restore, 靜待幾分鐘.

[8] 安裝 ovms3 ~ ovmsn
請進行 [1] 為 ovms3 ~ ovmsn 同步機器時間
[3] 在 ovms3 ~ ovmsn 刪除裝機時自動裝上的 /OVS
確認可以掛載 HOSTNAME:/path/to/datastore/

[9] 使用 VM manager/Server 加入 VM server
請選擇要加入的 Server Pool
加入 server 時, 請選擇 Utility Server, Virtual Machine Server
輸入 Utility Server 需要的帳密 root / xxxxxx
加入完成後可觀察已加入 server pool ovms1 ~ ovmsp 上的 /etc/ocfs2/cluster.conf, 已自動加入新 server.

移除 server
在 Server Pool 清單中選擇 Servers Total:n 進入 server 清單.
點選要移除的機器先做 power off 後(過程會進行 live migration, 請耐心等候)
再選擇要移除的機器做 Delete.

[10]如何備份/還原 VM manager 設定
# /opt/ovs-manager-2.2/bin/backup.sh
Welcome to Oracle VM Manager

Please enter the choice: [1|2]
1. Back up Oracle VM Manager
2. Restore Oracle VM Manager
1

Back up data now ...
Please enter the password for database account 'OVS':
Please enter the path and filename for the dump file (eg /tmp/ovs.dmp):/BACKUP/PATH/ovs.dmp
Please enter the path and filename for the log file (eg /tmp/ovs.log):/BACKUP/PATH/ovs.log

還原時請選擇 2. Restore Oracle VM Manager

[11] 如何將 server pool master 換台
0. 在 create server pool 時或之後再加上 Server Pool Virtual IP.
1. 停止 server pool master 上的 VM ???(需要測試)
2. 登入 ovms1 (old server pool master) 下 service ovs-agent stop. 沒多久時間(0 ~ 5 mins) ovms1 狀態由 active 改為 unreachable. Server pool master 轉移到 ovms4. 此時再將 ovms1 的 ovs-agent 啟動. ovms1 狀態恢復為 active. Server pool 狀態也由 inactive 轉為 active.

[12] Server pool master 當機時
0. 直接將 server pool master 下 init 0 關機.
1. 所有機器狀態剛開始 1 ~ 2 mins 是 unreachable, 但是 ping Server Pool Virtual IP 正常.
2. 自動選擇一台機器當 server pool master. 此時正常的機器狀態為 active, 當機的機器狀態為
unreachable.
3. 當機的機器恢復正常後, 機器狀態將改為 active, server pool 狀態也將改為 active.

No comments: