2013年6月2日 星期日

Red Hat 虛擬化簡介

近幾年來虛擬化一直都很夯, 在open source 當然也不會缺席, 常見的大概有 xen 與 KVM。

RHEL 5.x 開始內建虛擬化功能, 但為 xen,5.4 之後改為KVM,其實是KVM與 Xen並存。

KVM
KVM 也就是 kernel-base Virtual Machine,在 Linux  的世界中, 把所有功能都模組化, 當要使用到某種功能, 只要把模組載入進來即可使用, KVM 也是相同的方式.
KVM 為 Red Hat 在2008年收購 Qumranet 公司的技術,  Red Hat 收購後, 除了納入自己的RHEL所使用, 也把所有程式碼開放出來。

RHEV   Red Hat Enterprise Virtualization
Red Hat 的虛擬化解決方案統稱 RHEV,底下包含 RHEV-H 與 RHEV-M。

RHEV-H  Red Hat Enterprise Hypervisor
虛擬化運行平台,可把它想成是 VMware 的 ESXi。
這部分可分成兩種,一般使用 RHEL 加入虛擬化的功能即可當 Hypervisor,優點是擁有完全的Linux 功能,缺點是作業系統有損壞的風險
另外 Red Hat 有特製一款作業系統是專門作 Hypervisor 使用,此種作業系統是唯讀,所有設定不會寫到系統上,因此不會有損壞的風險,但也僅能當作 Hypervisor 使用。

RHEV-M  Red Hat Enterprise Virtualization Manager
虛擬化管理程式,由於是收購來的技術,在前兩版中都還是 Windows 的軟體,3 版開始便可在 Linux 下執行。3 版使用 Java 改寫,運行速度會比較慢的感覺。

Ovirt Node On VMware

本文介紹如何在 VMware 上安裝 Ovirt Node

Node 類型
Node 有兩種,一種是一般 Linux 並設定好 VDSM服務,一種為 Ovirt Node 專門當 Node 使用,使用一般 Linux 網路設定我還沒搞懂,因此僅先介紹 Ovirt Node 。

Ovirt Node 專門作為 hypervisor,檔案小,且安裝完之後系統為唯讀,因此系統較不容易掛掉。


Ovirt Node 取得
Ovirt Node 取得也有兩種方式,一種是透過 Ovirt 工具,自己去 build 一個 ISO 出來,我搞了半天還是搞不出來,所以最簡單的,就是去 Ovirt 官網下載吧.....


我抓的是 2.6 beta 版,網址如下
http://resources.ovirt.org/releases/beta/iso/

要抓穩定版的,網址如下
http://resources.ovirt.org/releases/stable/tools/

因為我的 Ovirt 為 3.1,使用 2.5 版的好像會有問題,因此才改抓 2.6。


Ovirt Node On VMware
安裝方式差不多,考慮到有些人是為了要作 Lab ,可能也沒那麼多機器,安裝在 VMware 是不錯的選擇

安裝流程
在 WorkStation 安裝 OS 應該是很簡單的事情,除比較特殊的設定再另外說明,不然僅看圖片應該就能完成:
node-1   


node-2

node-3

node-4

Ovirt Node 可選擇 RHEL 64bit 的類型
node-5
node-6

CPU 請改成 2 cores
node-7

Node 需要最少 4 G 的 RAM
node-8
node-9
node-10
node-11
node-12
node-13
node-14
node-15

啟用CPU的虛擬技術

node-16
node-17

Ovirt Node 光碟開機的畫面,按下 Enter 進入安裝畫面
node-18
node-19
node-20
node-21
node-22
node-23
node-24
node-25
node-26


Ovirt Node 設定
安裝後開機畫面,主要會有 admin 與 root 兩個使用者
root 就不用多說,是超級使用者
admin 登入後可設定 node 的基本設定,底下請以 admin 登入
node-Setup-1



登入後先到 Network 設定相關資訊,設定完選 Save 儲存設定
node-Setup-2
點選 Save 會顯示存檔狀況,點選 Close 回到上一頁
node-Setup-3

接著一樣是 Network 頁面,將光棒移到網路卡後按 Enter 進入網卡設定,如下圖
node-Setup-4

選擇 Static,並輸入 IP 資訊,點選 Save 儲存設定
node-Setup-5

點選 Save 會顯示存檔狀況,點選 Close 回到上一頁
node-Setup-6

移到 Security 設定 SSH 相關設定,將 SSH 啟用並設定密碼
node-Setup-7
node-Setup-8

移到 oVirt Engine 設定 Ovirt 主機的設定
node-Setup-9
node-Setup-10

此時在 Ovirt 管理介面上已可將 Ovirt Node 加入管理

修改 Node root password
在作 lab 的過程中,root 密碼的設定讓我卡了很久,明明在管理介面上設定了結果還是登不進去,後來找到另一個修改的方法:

在這個畫面按下 e
node-Root-1

如圖所示,輸入 linux single 後 按下 F10
node-Root-2

進入 single mode
node-Root-3

輸入 /usr/libexec/ovirt-config-password 便可修改 root 密碼
node-Root-4

Open Source 中的虛擬平台 Ovirt

前一篇簡單介紹了 Red Hat 的虛擬化產品,其實 Red Hat 的虛擬化產品是以 KVM 為底層並使用 Ovirt 為管理中心,透過 Ovirt 去管理每個使用 KVM 虛擬的機器,這就像是VMware 裡的 vCenter 與 vSphere ESXi 的關係。

Overview-rhev.png       
   


上圖是 RHEV 的架構圖,可從幾個面向來看:

管理中心: 中間為管理中心,也就是 Ovirt 的所在,透過 Ovirt 去設定管理哪些 node 要加入管理、使用那些資源(Storage)、使用者管理,管理介面為網頁介面,並須支援 Java
管理介面: Administrator Portal: 管理者所使用,能使用完整的功能 (目前須使用 IE)
             User Portal: 一般使用者使用,僅能使用指定的功能 (可使用 Firefox)

使用者: 支援 LDAP 與 AD 的使用者
資料庫: 預設使用 Postgresql
Node: 運算節點,可想成是ESXi,在此只要開啟 KVM 功能即可,可使用 Ovirt Node 的安裝光碟,或是使用一般發行的 Linux 並開啟虛擬化功能以及安裝 VDSM 便可當運算節點。


Ovirt 官網
http://www.ovirt.org/Home


Ovirt Node
http://www.ovirt.org/Category:Node

Ovirt On CentOS

本文介紹如何在 CentOS 6 上安裝 Ovirt

參考網址:
http://wiki.centos.org/zh-tw/HowTos/oVirt

版本資訊:
CentOS 6.3 x64 (安裝 Ovirt 請使用 64bit)

系統需求:
硬體:
最少:擁有 4GB 記憶體的雙核伺服器、25 GB 磁碟空間及 1 Gbps 網絡介面。
建議:擁有 16GB 記憶體的雙插座/四核伺服器、橫跨多個轉軸的 50GB 磁碟空間及 1 Gbps 網絡介面。
引擎並不需要 CPU 提供虛擬化延伸。

管理存取:
之後會透過瀏覽器來設定,建議這台就專作 Ovirt 使用,避免其他不必要的問題


網路:
DHCP: 個人覺得可有可無,都設定固定IP即可
DNS: 之後的架構會與 AD 作整合,因此此部分可使用 AD 取代,另外要注意 DNS 需要能正反解,不然有些功能會無法使用。
Ovirt 主機上若有安裝 NetworkManager 請停用,改使用 network



設定步驟

設定 Ovirt yum 套件
[root@OvirtM-1 ~]# cd /etc/yum.repos.d
[root@OvirtM-1 yum.repos.d]# wget -q http://people.centos.org/hughesjr/ovirt31/ovirt.repo


更新 yum 並重開機
[root@OvirtM-1 yum.repos.d]# yum  -y upgrade
[root@OvirtM-1 yum.repos.d]# shutdown -r now


安裝 Ovirt 套件
[root@OvirtM-1 ~]# yum -y install ovirt-engine


Ovirt 初始設定
[root@OvirtM-1 ~]# engine-setup
Welcome to oVirt Engine setup utility

In order to proceed the installer must stop the ovirt-engine service
Would you like to stop the ovirt-engine service? (yes|no): yes
是否要停止 ovirt-engine,請輸入 yes

 oVirt Engine uses httpd to proxy requests to the application server.
It looks like the httpd installed locally is being actively used.
The installer can override current configuration .
Alternatively you can use JBoss directly (on ports higher than 1024)
Do you wish to override current httpd configuration and restart the service? ['yes'| 'no']  [yes] : yes
是否要複寫設定並重啟 httpd ,請輸入 yes

HTTP Port  [80] : 80
請輸入 HTTP 的 Port

HTTPS Port  [443] : 443
請輸入 HTTPS 的 Port

Host fully qualified domain name. Note: this name should be fully resolvable  [OvirtM-1] : OvirtM-1.example.com
輸入 Ovirt 主機名稱

The IP 192.168.1.221 does not hold a PTR record for the FQDN: OvirtM-1.example.com
User input failed validation, do you still wish to use it? (yes|no): yes
輸入的名稱必須要能正反解,但有時好像會怪怪的,輸入 yes (確定在DNS設定正確)


Enter a password for an internal oVirt Engine administrator user (admin@internal) :
輸入管理介面 admin 的密碼
Warning: Weak Password.
Confirm password :
再輸入一次

Organization Name for the Certificate  [OvirtM-1] : Example
憑證的組織名稱

The default storage type you will be using  ['NFS'| 'FC'| 'ISCSI'| 'POSIXFS']  [NFS] :
預設的 storage 要使用哪一種,預設為 NFS

Enter DB type for installation ['remote'| 'local']  [local] :
使用遠端或本地DB,預設為本地

Enter a password for a local oVirt Engine DB admin user (engine) :
輸入DB的密碼

Warning: Weak Password.
Confirm password :
再輸入一次

Configure NFS share on this server to be used as an ISO Domain? ['yes'| 'no']  [yes] :
是否要設定 ISO Domain

Local ISO domain path  [/var/lib/exports/iso] : /exports/iso
ISO Domain 的路徑

Firewall ports need to be opened.
The installer can configure iptables automatically overriding the current configuration. The old configuration will be backed up.
Alternately you can configure the firewall later using an example iptables file found under /etc/ovirt-engine/iptables.example
Configure iptables ? ['yes'| 'no']: no
是否要設定 iptables,請輸入 no

oVirt Engine will be installed using the following configuration:
=================================================================
override-httpd-config:         yes
http-port:                     80
https-port:                    443
host-fqdn:                     OvirtM-1.example.com
auth-pass:                     ********
org-name:                      Example
default-dc-type:               NFS
db-remote-install:             local
db-local-pass:                 ********
nfs-mp:                        /exports/iso
config-nfs:                    yes
override-iptables:             no
Proceed with the configuration listed above? (yes|no): yes

列出設定值,會問你是否要修改設定,輸入 yes 便開始設定

設定過程
Installing:
Configuring oVirt-engine...                              [ DONE ]
Configuring JVM...                                       [ DONE ]
Creating CA...                                           [ DONE ]
Updating ovirt-engine service...                         [ DONE ]
Setting Database Configuration...                        [ DONE ]
Setting Database Security...                             [ DONE ]
Creating Database...                                     [ DONE ]
Updating the Default Data Center Storage Type...         [ DONE ]
Editing oVirt Engine Configuration...                    [ DONE ]
Editing Postgresql Configuration...                      [ DONE ]
Configuring the Default ISO Domain...                    [ DONE ]
Configuring Firewall (iptables)...                       [ DONE ]
Starting ovirt-engine Service...                         [ DONE ]
Configuring HTTPD...                                     [ DONE ]

 **** Installation completed successfully ******

     (Please allow oVirt Engine a few moments to start up.....)

**** To access oVirt Engine browse to http://OvirtM-1.example.com:80 ****

Additional information:
 * There are less than 4096 MBs of available free memory on this machine.
It is  recommended to have at least 4096 MBs of available memory to run the oVirt Engine.
 * oVirt Engine CA SSL Certificate SHA1 fingerprint: 2C:1A:16:24:C5:E5:E9:16:2C:72:E2:91:6B:3F:02:EA:A8:64:9A:EF
 * SSH Public key fingerprint: bd:db:67:f7:c3:82:e4:f8:f3:1a:ab:3b:f9:25:1b:75
 * A default ISO share has been created on this host.
   If IP based access restrictions are required, please edit /exports/iso entry in /etc/exports
 * oVirt Engine requires the following TCP/IP Incoming ports to be opened on the firewall:
22, 80, 443
 * an example of the required configuration for iptables can be found at: /etc/ovirt-engine/iptables.example
 * The installation log file is available at: /var/log/ovirt-engine/engine-setup_2013_02_14_22_49_46.log
 * Please use the user "admin" and password specified in order to login into oVirt Engine
 * To configure additional users, first configure authentication domains using the 'engine-manage-domains' utility


修正旋轉替換日誌的問題。
sed -i 's/`;/ 2>\/dev\/null`;/' /usr/share/ovirt-engine/scripts/ovirtlogrot.sh


至此,Ovirt 便安裝完成。