Oracle Virtual Machine OVM

Oracle VM為甲骨文公司所發行的企業級開放原始碼虛擬機監視器,其建基於Xen。其免費供應於大眾下載、使用與發布,並為用戶提供有償支援。

Troubleshooting

Log Files

檔案目錄: /u01/app/oracle/ovm-manager-3/domains/ovm_domain/servers/AdminServer/logs/

Log Parsing Tool: OvmLogTool.py

檔案目錄: /u01/app/oracle/ovm-manager-3/ovm_tools/ , 由於 AdminServer.log 的內容不易讀取,使用這指令格式化 log 內容。

cd /u01/app/oracle/ovm-manager-3/ovm_tools/
python OvmLogTool.py -s -o ~/ovm_logs/summary.`date +%y%m%d_%H%M`

格式化後的結果會儲存在 ~/ovm_logs/summary.<todaty_now>

TIP:

-s , 只會顯示 Error 相關的 Log; 不加則會顯示所有 Log。

Q: 執行手動備份 OVMM 資料庫失敗

執行 /u01/app/oracle/ovm-manager-3/ovm_tools/bin/BackupDatabase -w

mysqlbackup: WARNING: The value of 'innodb_checksum_algorithm' option provided to mysqlbackup might be incompatible with server config.
mysqlbackup: ERROR: Page at offset 5242880 in /u01/app/oracle/mysql/data/appfw/APPFW_EVENTS.ibd seems corrupt!

解決方案:

  1. 檢查資料表 APPFW_EVENTS 是否已損壞
  2. 如果已損壞,嘗試執行修復資料表
  3. 如果顯示正常,嘗試手動重建資料表
  4. 再執行備份一次

檢查資料表狀態

mysqlcheck -uroot -p -S /u01/app/oracle/mysql/data/mysqld.sock --databases appfw

mysql -u appfw -p -S /u01/app/oracle/mysql/data/mysqld.sock appfw
mysql> select count(*) from APPFW_EVENTS;
+----------+
| count(*) |
+----------+
|    18650 |
+----------+
1 row in set (0.01 sec)

重建 table APPFW_EVENTS

service ovmm stop
mysqldump -uappfw -p -S /u01/app/oracle/mysql/data/mysqld.sock --databases appfw --tables APPFW_EVENTS > table_dump.appfw_events.sql

mysql -u appfw -p -S /u01/app/oracle/mysql/data/mysqld.sock appfw
mysql> create table APPFW_EVENTS_NEW like APPFW_EVENTS;
mysql> rename table APPFW_EVENTS to APPFW_EVENTS_OLD;
mysql> rename table APPFW_EVENTS_NEW to APPFW_EVENTS;

# Import the table
mysql -uappfw -p -S /u01/app/oracle/mysql/data/mysqld.sock appfw < table_dump.appfw_events.sql

# Drop the old table
mysql -u appfw -p -S /u01/app/oracle/mysql/data/mysqld.sock appfw
mysql> drop table APPFW_EVENTS_OLD;
Q: OVMM 主機的 MySQL DB 耗盡所有磁碟空間

檢查 MySQL 的資料表使用空間
# du -chs /u01/app/oracle/mysql/data/ovs/OVM_STATISTIC*
16K /u01/app/oracle/mysql/data/ovs/OVM_STATISTIC.frm
121G /u01/app/oracle/mysql/data/ovs/OVM_STATISTIC.ibd <===

解決:

  1. 先釋出一些其他的可用空間,使 MySQL 可正常運作。
  2. 關閉 ovmm 服務,避免更多資料的寫入。
  3. 清除資料表 OVM_STATISTIC 的內容。

關閉 ovmm

service ovmm stop

檢查資料表 OVM_STATISTIC 的筆數

mysql -u ovs -p -S /u01/app/oracle/mysql/data/mysqld.sock ovs
Enter password: <網頁登入密碼>
mysql> select count(*) from OVM_STATISTIC;
+-----------+
| count(*)  |
+-----------+
| 184795278 |
+-----------+
1 row in set (6 min 35.98 sec)

清除資料表 OVM_STATISTIC

mysql> truncate table OVM_STATISTIC;

TIP:
truncate 基本上是先執行 drop 再 create,就算有 1 億多筆資料在幾秒鐘就會完成清除。

另一個方式取代 truncate

mysql> create table NEW_OVM_STATISTIC like OVM_STATISTIC;
mysql> rename table OVM_STATISTIC to OLD_OVM_STATISTIC, NEW_OVM_STATISTIC to OVM_STATISTIC;
mysql> drop table OLD_OVM_STATISTIC;
Q: VM 無法結束,使用 Kill 也沒用

VM 狀態一直顯示 Stopping,執行 Kill 失敗,出現錯誤:
tpeoddovm-db01 <1108> is locked. job info: job id(time):1525839275699 name:Stop VM: tpeoddovm-db01 description:Stop VM: tpeoddovm-db01

解決:試試重啟該 VM 所在的 OVS 主機裡的 ovs-agent 服務

service ovs-agent stop
service ovs-agent start
Q: 無法建立 Server Pool

重裝完 OVS 與 OVM Manager 主機後,無法使用原有的 LUNs 建立 Server Pool 與 Repository。

解決:SSH 登入 OVS 主機,清空 LUNs 的資料

# 找出 LUN 路徑
multipath -ll

dd if=/dev/zero of=/dev/mapper/360a980004434375a385d4747374b5155 bs=1M count=256
Q: [OVM 3.3.x] 管理介面網頁突然無法登入

錯誤訊息:
Unexpected error during login (java.lang.NullPointerException)

解決:二擇一

Updated by 2022/7/6

管理介面輸入帳密後無法成功登入,且沒有任何錯誤訊息。

解決:

# 檢查 ovmm 服務狀態
service ovmm status

# 如果沒有顯示: 服務執行中
# 再次嘗試關閉 ovmm 服務
service ovmm stop
service ovmm start

# 如果重啟服務不成功,將與 java 有關的 process 手動 Kill
ps -ef | grep java

# 確定 MySQL 服務正常
# 如果沒有,先啟動 MySQL 服務
service ovmm_mysql start

# 再次啟動 ovmm 服務
service ovmm start
service ovmm status


Q: Server Pool 的 Master Server 硬體故障並意外關機,隨後將 VM 遷移(Migrate) 至另一部 OVS 後,啟動 VM 時發生錯誤

錯誤訊息
Caught during invoke method: com.oracle.ovm.mgr.api.exception.IllegalOperationException....

解決:在遷移 VM 之前,請先將它的 Event Serverity 狀態從 Critical 變更成 Informational。步驟如下:

  1. 確認主機故障原因
  2. 確認第二部主機服務正常,與所有 Repositories Storage 正常
  3. 將 VM 從故障主機遷移(Migrate) 至另一部主機
  4. OVMM > Servers and VMs > 選擇第二部OVS主機 > 選擇要啟動的 VM > 按右鍵 Display Events
    將每個 Critical Event 做完 Acknowledge,完成後這 VM 的 Event Serverity 狀態應該會顯是正常 Informational。
  5. 啟動 VM 試試
Q: Repositories 總是顯示 Error 圖示

先前由於硬體維護工作,造成 Storage 短暫的連接異常,但解決異常後,Error 圖示 仍保持顯示

解決:OVMM Admin > Repositories > 選擇 Storage Repository > Perspective: 選擇 Events > 選擇尚未處理的舊事件,按 Acknowledge,完成。

Q: [OVM 3.3.x]無法從 Clustered Server Pool 移除既有 Oracle VM Server(OVS)

有一個 OVS 需要重新安裝,但無法從已經加入的 Clustered Server Pool 中移除,出現以下錯誤:
OVMRU_000036E Cannot remove server: tycoddovs01.winfoundry.com, from pool: oddfdc_db. There are still OCFS2 file systems

解決:要移除從 Clustered Server Pool 裡移除其中一台 OVS 主機,必須符合下列條件

假使這個 OVS 是 Server Pool 裡唯一的主機,可以使用下述步驟,強制將它從 Server Pool 內移除。

1. SSH 登入至該 OVS 主機,執行以下指令:

service ovs-agent stop
rm -rf /etc/ovs-agent/db
cat /dev/null > /etc/ocfs2/cluster.conf
service ovs-agent start 

2. 登入 OVMM 後,從控制台的視窗,應該就會顯示該 OVS 主機是在 Unassigned Servers 狀態。

TIPs:

Q: 如何加大 VM 既有磁碟的可用空間

問題描述:
使用 VM template 新增的 VM 後,發現預設的系統磁碟容量太小,要如何才能加大容量?

1. 使用 OVMM 將 VM 的 System 磁碟增大

OVMM > Servers and VMs > 選擇 VM > 編輯 VM > Disks > 編輯 Slot 0 的磁碟

2. 登入 VM 後,執行以下操作

記下 SWAP 的大小

# 記下 SWAP 的大小
free -m
例如是 2048M

# 關閉 SWAP
swapoff /dev/xvda3
  1. 刪除 xvda3 & xvda2 磁區
  2. 重建 xvda2 (+48G) & xvda3 (剩餘空間)
  3. 寫入後離開
fdisk /dev/xvda

重啟主機

reboot

格式化 SWAP

mkswap /dev/xvda3
swapon /dev/xvda3 

Resize 根目錄

resize2fs /dev/xvda2
Q: 如何取得 Oracle VM 的擁有權
Q: 如何做校時設定

建議做法是將 OVMM 設定為 NTP Server,所有的 OVS 主機與 VM 自動向 OVMM 做校時。

OVMM 設定 NTP)

1. 設定系統時區

編輯 /etc/sysconfig/clock 或指令 setup。

2. 編輯 ntp.conf

# 這裡要設定 OVS 的網段,如果有其他網段的主機也要做校時,也可以加上。
# Hosts on local network are less restricted.
restrict 192.168.7.0 mask 255.255.255.0 nomodify notrap

# 註解這兩行
#server 127.127.1.0     # local clock
#fudge  127.127.1.0 stratum 10

# 這裡是上層的 NTP 校時主機位址
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org

啟動 ntpd 服務

OVS 設定 NTP)

OVMM 3.3.x 不需要在 OVS 上做設定,當使用 VM Manager 第一次加入 OVS 時,系統會自動修改 OVS 的 ntp.conf。

VM 設定 NTP)

VM(guest OS) 如果是用 OEL template,而且 Linux kernel 是 UEK based。當 VM 重啟時,系統時間會與 OVS 主機相同,不過,直到下次重啟前,系統運行過程並不會與 OVS 主機做校時,如果 VM 長時間不做重啟,必須手動設定 NTPD 或 ntpdate 校時功能。

編輯 /etc/ntp.conf

# 註解這兩行
#server 127.127.1.0     # local clock
#fudge  127.127.1.0 stratum 10

# 最後一行加上
# OVM Manager
server 10.23.0.203

重啟 ntpd 服務

Installation

Introduction