Openvz和Xen的技術規格分析

Openvz和Xen的技術規格分析

一、Openvz和Xen的技術規格分析
1.Xen與Openvz的區別
Xen和Openvz同樣是虛擬化主機技術,區別在于Xen是半虛擬化技術,它幷不是一個真正的虛擬機,而是相當于自己運行了一個內核的實例,可以自由的加載內核模塊,虛擬的內存和IO,穩定而且可預測。Openvz則是操作系統級別的虛擬化技術,是底層操作系統上的一層應用,這意味著易于理解和低權重開銷,一般來說也意味著更優的性能。
這裏有一個問題,可以看到實際上openvz因爲免去了大量的公共開銷,理論上來說性能會比xen更好。爲什麽大家都會認爲openvz過分壓榨性能呢?我認爲是因爲openvz配置起來比較靈活,給黑心 openvz服務商改低限制的機會。
比如mediatemple,號稱512M內存的dv方案,kmemsize才12M,不瞭解的人看了512M覺得很哈皮啊,可是使用的時候一般這512M能分到你手裏一半就不錯了。此消彼長,所以才會有xen 能更好地利用機器性能的錯覺。
2.Openvz的內核模型
首先當OpenVZ的主機說“256MB的保證”,它實際上意味著約232MB的“privvmpages”,14M的“kmemsize”和其他雜項資源。當應用程序調用 malloc()分配的內存將被添加到“privvmpages”。
當“privvmpages”超過限制,malloc()將失敗幷返回一個NULL。當主機服務器內存用光了,然後虛擬環境下的進程超過 “oomguarpages”的將被終止。
OpenVZ的內存管理方法既有問題也有優勢。最大的問題之一是內存容量的應用程序使用的內存和應用程序實際上分配到的內存是不同的,不同的應用程序他們的差別可能會很大。以Java爲例,它通常分配一大塊的內存,但是,它可能只使用一小部分分配的內存。如果privvmpages受限,java會立即停止運行。調整參數可以解决一部分問題,但它處理得絕對沒有Xen來得乾淨利落。事實上,幾乎所有使用內存分配的應用程序都會受OpenVZ這個問題的影響。
/proc/meminfo 本身也有問題。雖然OpenVZ的已經爲內存進行了虛擬,但是用”free”命令依然會返回主機的內存。這樣就會使小內存的openvz的vps無法運行諸如java或者gcc編譯這樣的程序。
OpenVZ的內存模型的優點是, 它容易理解: 你幾乎就只有privvmpages受限。與專用的服務器或Xen的服務器不一樣的是,你的磁盤高速緩存和頁面緩存幷不計入您的總內存使用情况。因此,在一個沒有過度銷售的openvz主機上,由于擁有較大冗余的公共資源,它實際上可能會比同類規格的Xen的VPS表現更佳。
3.Xen的內存模型
Xen的系統模型更容易解釋。256MB的Xen的VPS是就像一個256MB的專用服務器-該內存段是預留作VPS專用,沒有其他VPS能够使用這部分內存,這就像一個真正的專用服務器。
此外,當內存不足時,VPS會使用Swap。一般每個VPS帶有兩倍大小的交換分區,當您的應用需要更多的內存,不常使用的頁面從內存中被換出到交換分區,從而騰出使更多的房間。因此,256MB的Xen的VPS系統實際上共有768MB內存(256MB內存+ 512MB的交換空間),請相信我,交換空間是非常有用的,特別是處理突發的需求高峰時。
這麽說來,Xen是永遠遠優于OpenVZ?不然,你的256MB的VPS理論可以使用高達768MB內存,而實際上內核,高速緩存,緩衝,他們都占用內存。這部分系統開銷也是可觀的。另外,Swap會嚴重降低性能。
4.穩定性和可預測性
當內存耗盡時,xen和openvz表現大相徑庭。xen會把不常用的內存頁面換入Swap,這將大大降低性能,當Swap也用盡,那麽xen的系統會響應得越來越慢,就像一台真實的服務器一樣。
而openvz一旦內存用盡,則會突然死亡:開不出新的程序,只能等待系統資源可用。更有甚者,本來運行的好好的程序也可能因爲不斷增長而超過限制,然後突然死亡。這就像開車開到70碼,然後突然撞墻上了,一般會死得很慘。
毫無疑問這點上我傾向于xen技術,可預測,穩定。
5.結論
如果xen和openvz一樣貴,我肯定選xen,因爲可預測性,即使openvz打8折,我還是追求穩定。
上面的話總結一下,得出幾個結論:
1、XEN比openvz主機對買家更有利,比如分配給你512M內存後,這一部分內存就從服務器上專門劃給你了,別人將無法使用,而openvz則是共用內存,比如分配給你512M內存是指最大你能使用512M內存,比如你占用了200M內存,那麽就只從物體內存中分配200M給你,所以賣家非常容易在服務器上面超賣!
2、openvz更高效,xen是硬件底層虛擬,更接近真實服務器,而openvz是操作系統虛擬,虛擬服務自身占用內存少,同樣的程序執行效率更高!
3、如果購買openvz應看賣家是否會超賣,應選擇良好聲譽明確申明不會超賣的
4、如果購買xen主機,應同時關注swap大小
5、測試VPS主機性能使用Unixbench(很多人不知道),國外非常流行這個東西!
這是它的一些參數說明
• dhry2reg 內存的register性能
• whetstone-double 雙精度浮點性能
• execl execl call性能
• fstime 文件系統性能
• fsbuffer 文件系統性能
• fsdisk 文件系統性能
• pipe 管道(pipe)的性能
• context1 管道上下文切換的性能
• spawn 創建進程的性能
• shell shell幷發性能
• syscall 系統調用性能
6、VPS用途:服務器、軟交換、代理和反向代理、離綫BT下載等等
7.通常一般的使用條件下,兩者性能應該相差不大。

===============================

Openvz and Xen technical specifications analysis
The difference 1.Xen with Openvz
Xen and Openvz same mainframe virtualization technology , the difference is that Xen paravirtualization technology that Bing is not a true virtual machine , but the equivalent of running its own instance of a kernel , kernel modules can be loaded free virtual memory and IO, stable and predictable . Openvz is operating system -level virtualization technology, is a layer of applications on the underlying operating system , which means easy to understand and a low weight overhead , generally means better performance .
There is a problem , because you can see that in fact openvz eliminates a lot of public spending , in theory, the performance will be better than xen. Why do we all think too much press openvz performance? I think it is because it is more flexible openvz configuration , change to black heart openvz service providers the opportunity to lower limits .
For example mediatemple, known as 512M of memory dv program , kmemsize only 12M, 512M think people do not understand looked very Happy ah , but it is generally used in this 512M half could be assigned to your hand pretty good . Shift, so will have to make better use xen machine performance illusion.
2.Openvz core model
First, when the OpenVZ host says “256MB of guarantee” , it actually means about 232MB of “privvmpages”, 14M of “kmemsize” and other miscellaneous resources. When an application calls malloc () allocated memory will be added to the “privvmpages”.
When “privvmpages” over the limit , malloc () will fail Bing returns a NULL. When the host server memory runs out , then the process of virtual environments over “oomguarpages” will be terminated.
OpenVZ memory management methods have the advantage of both problems . One of the biggest problems is the memory and application memory capacity actually used by the application is assigned to a different memory , different applications can be significant differences between them . In Java , for example, it usually allocates a chunk of memory, however, it may use only a fraction of the allocated memory. If privvmpages limited , java will immediately stop running. Adjustment parameters can solve part of the problem , but it is absolutely no Xen handled more cleanly . In fact, almost all applications use memory allocation will affect this problem by OpenVZ .
/ proc / meminfo itself a problem. While OpenVZ has been carried out for the virtual memory , but with a “free” command will still be returned to the host memory. This will make the vps openvz small memory can not run as java or gcc compiler such procedures .
Advantages OpenVZ memory model is that it is easy to understand : you can almost only privvmpages limited. With a dedicated server or Xen server is not the same as your disk cache and page cache Bing does not count toward your total memory usage. Therefore, on a no overselling the openvz host , as has a large redundant public resources , it may actually perform better than the Xen VPS similar specifications .
3.Xen memory model
Xen system model is more easily explained. The Xen VPS 256MB 256MB is like a dedicated server – the memory segment is reserved for dedicated VPS , no other VPS to use this part of the memory , it’s like a real dedicated server.
In addition, when there is insufficient memory , VPS will use the Swap. Generally speaking, each VPS has twice the size of the swap partition , if your application requires more memory , infrequently used pages from memory to be swapped out to the swap partition, thus freeing make more room. Therefore , 256MB of Xen VPS system is actually a total of 768MB of RAM (256MB RAM + 512MB swap space ) , believe me , swap space is very useful , especially when you deal with sudden spikes in demand .
So to say , Xen is always much better than OpenVZ? Otherwise , you can use the VPS theory 256MB up to 768MB of memory , but in fact the core , the cache buffer memory for all of them . This part of the overhead is also considerable. Further , Swap seriously degrade performance .
4 . Stability and predictability
When memory is exhausted , xen and openvz performance to differ materially . xen will not commonly used memory pages swapped Swap, which will greatly reduce performance when Swap are exhausted , then the system will respond xen increasingly slowly, like a real server.
And openvz memory exhaustion once , then sudden death : not to open a new program , can only wait for the system resources are available . What is more , had to run the program may also be because of the continuing good growth over the limit , then sudden death. It’s like drove 70 yards, then suddenly hit the wall on the general will die miserable .
There is no doubt on this point I tend xen technology , predictable and stable.
5 Conclusion
If xen and openvz as expensive , I’m sure choose xen, because predictability, even openvz hit 8-fold , I still pursue stable.
To summarize the above , then , leads to several conclusions :
1, XEN host to buyers than openvz more favorable , such as 512M of memory allocated to you after this part of the memory on the server from scratch specifically to you , others will not be able to use , and openvz is shared memory , such as allocated to you 512M RAM is the maximum you can use 512M memory, for example, you take up a 200M memory , then only allocate 200M to you from the object memory, so the seller is very easy on the server above oversold !
2, openvz more efficient , xen underlying virtual hardware , closer to the real server, and virtual openvz operating system , virtual service itself occupies less memory and higher efficiency the same procedure !
3 , if the purchase openvz should see if the seller will oversold , you should choose a good reputation does not expressly stated oversold
4 , if the purchase xen host , should also concern swap size
5, the test VPS host performance using Unixbench ( many people do not know ) , this thing is very popular abroad !
This is a description of some of its parameters
• dhry2reg register memory performance
• whetstone-double double- precision floating-point performance
• execl execl call performance
• fstime file system performance
• fsbuffer file system performance
• fsdisk file system performance
• pipe conduit (pipe) performance
Performance • context1 pipeline context switching
• spawn the process to create performance
• shell shell Bing hair Performance
• syscall system call performance
6, VPS uses: server , softswitch , agents and reverse proxy , offline BT download , etc.
7 usually under normal conditions of use, performance should be little difference between the two .

CentOS安裝OpenVZ和Vtonf控制面板

CentOS安裝OpenVZ和Vtonf控制面板

現在虛擬化技術非常流行,本文介紹基于OpenVZ平臺下的虛擬化配置安裝,以及Vtonf Web界面管理虛擬機應用。
本文爲簡易指導手册,代碼不保證100%準確。本文根據英文教程創作演繹。
一、安裝OpenVZ
1、第一次在CentOS中添加openVZ repository
打開終端複製以下命令
wget http://download.openvz.org/openvz.repo
rpm –import http://download.openvz.org/RPM-GPG-Key-OpenVZ
cp openvz.repo /etc.recpo.d
2、安裝openvz內核
yum install ovzkernel
3、編輯文件 /etc/systcl.conf
打開文件 /etc/systcl.conf
vi /etc/systcl.conf
添加以下內容:
net.ipv4.ip_forward = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.all.rp_filter = 1
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
4、禁止Selinux
禁止Selinux,打開配置文件
vi /etc/selinux/config
找到以下內容,將SELINUX設置成disabled,如下所設:
SELINUX=disabled
5、安裝openvz工具和插件
yum install vzctl vzquota
6、重啓openv服務
service vz restart
二、建立虛擬操作系統
現在,我們已經安裝好了Openvz,馬上去建立一個虛擬操作系統吧。首先下載一下操作系統模板。
本例將使用Slackware模板,其它的操作系統模板你可以查看這裏
1、首先建立和進入cache文件夾,本例如下:
mkdir -p /vz/template/cache
cd /vz/template/cache
2、接下來是下載模板
這個步驟可能會花去你很多時間,視網絡狀况,現在你可以瀏覽一下OSSS.CN開源社區,呵呵:
wget http://download.openvz.org/template/precreated/contrib/slackware-13.0-i386-minimal.tar.gz
下載屏幕如下列所示:
[root@localhost cache]# wget http://download.openvz.org/template/precreated/contrib/slackware-13.0-i386-minimal.tar.gz
–2010-06-27 16:55:33– http://download.openvz.org/template/precreated/contrib/slackware-13.0-i386-minimal.tar.gz
Resolving download.openvz.org… 64.131.90.11
Connecting to download.openvz.org|64.131.90.11|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 39641862 (38M) [application/x-gzip]
Saving to: `slackware-13.0-i386-minimal.tar.gz’
100%[===============================================================>] 39,641,862 4.48M/s in 14s
2010-08-09 16:55:47 (2.71 MB/s) – `slackware-13.0-i386-minimal.tar.gz’ saved [39641862/39641862]
3、建立虛擬機
假如虛擬機名爲:VPS ossscn
vzctl create ossscn –ostemplate slackware-13.0-i386-minimal –config basic
屏幕輸出:
Creating container private area (slackware-13.0-i386-minimal)
Performing postcreate actions
Container private area was created
4、設置虛擬機
[root@localhost cache]# vzctl set ossscn –onboot yes –saveSaved parameters for CT 102make a Hostname for The machien:vzctl set 102 –hostname Hackers.example.com –saveGive Ip adress 192.168.0.130 to the machine:
[root@localhost cache]# vzctl set 102 –ipadd 192.168.0.130 –saveSaved parameters for CT 102
[root@localhost cache]#
5、啓動虛擬機ossscn
vzctl start
屏幕輸出:
ossscn Starting container …Container is mountedAdding IP address(es): 192.168.0.130Setting CPU units: 1000Set hostname: Hackers.example.comContainer start in progress..
6、設置Root密碼
vzctl exec ossscn passwd
New password: 123456
Re-enter new password: 123456
Changing password for root
Enter the new password (minimum of 5, maximum of 127 characters)Please use a combination of upper and lower case letters and numbers.Password changed
7、進入slackware虛擬機ossscn
vzctl enter 102
屏幕輸出:
entered into CT ossscn
root@Hackers:/# cat /etc/slackware-version
Slackware 13.0.0.0.0
Stop of start or Exit
More commands :
To restart use : vzctl restart
To stop use : vzctl stop
to destroy the vm machine user : vzctl destro ossscn
For more commands use :vzctl -help
三、爲OpenVZ安裝Vtonf Web管理界面
VTONF是虛擬機控制面板,專門爲GNU/Linux中運行OpenVZ虛擬機技術設計。VTONF是基于GPL許可證下發布的自由軟件。
1、安裝Vtonf
打開終端,輸入以下命令,不要忘記將vtonf版本vtonfinstaller.x.x-beta1.tar.gz中的x改爲你下載的版本。
cd /tmp
wget http://mesh.dl.sourceforge.net/sourceforge/vtonf/vtonfinstaller.x.x-beta1.tar.gz
tar xvfz vtonfinstaller.1.0-beta1.tar.gz
cd vtonfinstaller.x.x-beta1
./install
當Vtonf控制面板安裝完成,你可以登陸系統:
http://192.168.0.109:8001/
用戶名 : admin
密碼 : admin

VMware incompatible hypervisor 解決方法

VMware incompatible hypervisor 解決方法

最近在一台 Win2003的VPS上,打算在裡面安裝VMware架設Linux,
這樣就可以用一台VPS 同時跑win和Linux.
結果發現在Win上的VMware 啟動虛擬機時會出現這樣的錯誤
「You are running VMware Workstation via an incompatible hypervisor. You may not power on a virtual machine until this hypervisor is disabled.」
上網查了一下,大家都說要在虛擬機器上裝虛擬機是不可行的…
就在我萬念俱灰時,解決了這個問題.

解決敘述如下:
To get this VMware Player VM running inside an Amazon EC2 instance, all I needed to do was edit the instance.vmx file and add the following line to it:
vmx.allowNested = “TRUE”

就是到VM虛擬機的目錄裡面,找到xxxx.vmx 用筆記本打開修改,在最底下加入這行
vmx.allowNested = “TRUE”

之後就能快樂啟動.