在Debian的HVM虚拟机上进行Ubuntu的覆盖安装

继定制CentOS 6.x虚拟服务器之后,我们将采用相同的方法来创建基于Debian系操作系统的HVM虚拟机,以尝试性能优化。

Ubuntu 14.04的Unixbench测试结果

由于Ubuntu 14.04作为软件层的虚拟机以PV方式运行,所以下面的基准测试结果并不理想。

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: tkr32: GNU/Linux
   OS: GNU/Linux -- 3.13.0-55-generic -- #94-Ubuntu SMP Thu Jun 18 00:27:10 UTC 2015
   Machine: x86_64 (x86_64)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Xeon(R) CPU E5-2683 v3 @ 2.00GHz (4000.1 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
   06:21:34 up  1:36,  1 user,  load average: 0.45, 0.24, 0.12; runlevel 2

------------------------------------------------------------------------
Benchmark Run: Wed Aug 19 2015 06:21:34 - 06:49:48
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       23205108.3 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     2980.4 MWIPS (9.8 s, 7 samples)
Execl Throughput                               1273.9 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        307910.9 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks           79064.3 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1081678.7 KBps  (30.0 s, 2 samples)
Pipe Throughput                              422892.9 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                  80137.8 lps   (10.0 s, 7 samples)
Process Creation                               2604.3 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   3048.2 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    405.1 lpm   (60.1 s, 2 samples)
System Call Overhead                         386480.8 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   23205108.3   1988.4
Double-Precision Whetstone                       55.0       2980.4    541.9
Execl Throughput                                 43.0       1273.9    296.3
File Copy 1024 bufsize 2000 maxblocks          3960.0     307910.9    777.6
File Copy 256 bufsize 500 maxblocks            1655.0      79064.3    477.7
File Copy 4096 bufsize 8000 maxblocks          5800.0    1081678.7   1865.0
Pipe Throughput                               12440.0     422892.9    339.9
Pipe-based Context Switching                   4000.0      80137.8    200.3
Process Creation                                126.0       2604.3    206.7
Shell Scripts (1 concurrent)                     42.4       3048.2    718.9
Shell Scripts (8 concurrent)                      6.0        405.1    675.2
System Call Overhead                          15000.0     386480.8    257.7
                                                                   ========
System Benchmarks Index Score                                         519.8

Debian 8.1 的结果

对此,Debian 8.1作为一种以HVM模式运行的虚拟机,能够取得与云计算行业其他公司的机器相比仍然良好的基准测试结果。

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: tkr31: GNU/Linux
   OS: GNU/Linux -- 3.16.0-4-amd64 -- #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24)
   Machine: x86_64 (unknown)
   Language: en_US.utf8 (charmap="ANSI_X3.4-1968", collate="ANSI_X3.4-1968")
   CPU 0: Intel(R) Xeon(R) CPU E5-2683 v3 @ 2.00GHz (4000.1 bogomips)
          x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
   06:21:50 up  1:40,  1 user,  load average: 0.15, 0.12, 0.08; runlevel 5

------------------------------------------------------------------------
Benchmark Run: Wed Aug 19 2015 06:21:50 - 06:50:04
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       23688552.4 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     2925.1 MWIPS (9.8 s, 7 samples)
Execl Throughput                               4278.8 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        891102.5 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          239674.0 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       2647651.5 KBps  (30.0 s, 2 samples)
Pipe Throughput                             1655607.1 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 322133.5 lps   (10.0 s, 7 samples)
Process Creation                              12296.2 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   7406.7 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    973.1 lpm   (60.1 s, 2 samples)
System Call Overhead                        3260747.1 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   23688552.4   2029.9
Double-Precision Whetstone                       55.0       2925.1    531.8
Execl Throughput                                 43.0       4278.8    995.1
File Copy 1024 bufsize 2000 maxblocks          3960.0     891102.5   2250.3
File Copy 256 bufsize 500 maxblocks            1655.0     239674.0   1448.2
File Copy 4096 bufsize 8000 maxblocks          5800.0    2647651.5   4564.9
Pipe Throughput                               12440.0    1655607.1   1330.9
Pipe-based Context Switching                   4000.0     322133.5    805.3
Process Creation                                126.0      12296.2    975.9
Shell Scripts (1 concurrent)                     42.4       7406.7   1746.9
Shell Scripts (8 concurrent)                      6.0        973.1   1621.9
System Call Overhead                          15000.0    3260747.1   2173.8
                                                                   ========
System Benchmarks Index Score                                        1471.4

确认虚拟机环境的差异

我会先确认原因。通过内核启动消息,可以看出在Ubuntu中是PV,在Debian中是HVM。

root@tkr32:~# uname -a
Linux tkr32 3.13.0-55-generic #94-Ubuntu SMP Thu Jun 18 00:27:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
root@tkr32:~# dmesg |grep Xen
[    0.000000] Xen: [mem 0x0000000000000000-0x000000000009ffff] usable
[    0.000000] Xen: [mem 0x00000000000a0000-0x00000000000fffff] reserved
[    0.000000] Xen: [mem 0x0000000000100000-0x000000003fffffff] usable
[    0.000000] Booting paravirtualized kernel on Xen
[    0.000000] Xen version: 4.1.5 (preserve-AD)
[    0.000000] Xen: using vcpuop timer interface
[    0.000000] installing Xen timer for CPU 0
[    0.098282] PCI: setting up Xen PCI frontend stub
[    0.166435] xen_netfront: Initialising Xen virtual ethernet driver
root@tkr31:~# uname -a   
Linux tkr31 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64 GNU/Linux
root@tkr31:~# dmesg |grep Xen
[    0.000000] DMI: Xen HVM domU, BIOS 4.1.5 11/28/2013
[    0.000000] Hypervisor detected: Xen HVM
[    0.000000] Xen version 4.1.
[    0.000000] Xen Platform PCI: I/O protocol version 1
[    0.000000] Netfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated NICs.
[    0.000000] Blkfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated disks.

将 Ubuntu 操作系统的映像覆盖到 Debian 操作系统的虚拟机上。

以与上次相同的方式,通过救援内核启动,将Ubuntu 14.04磁盘的RAW镜像覆盖到Debian 8.1虚拟机的引导磁盘中,将Ubuntu 14.04变成HVM虚拟机。以下是启动时的内核消息。可以明确地看到已经成功变成HVM虚拟机。

root@tkr33:~# uname -a
Linux tkr33 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
root@tkr33:~# dmesg |grep Xen
[    0.000000] DMI: Xen HVM domU, BIOS 4.1.5 11/28/2013
[    0.000000] Hypervisor detected: Xen HVM
[    0.000000] Xen version 4.1.
[    0.000000] Xen Platform PCI: I/O protocol version 1
[    0.000000] Netfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated NICs.
[    0.000000] Blkfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated disks.

Ubuntu 是基于 Debian 发行版构建的,因此配置文件具有许多共同部分,没有像 CentOS 6 和 CentOS 7 这样的重大变化。因此,可以在 Debian 上覆盖安装 Ubuntu,在重新启动后获取镜像模板,并从该镜像启动虚拟机。没有出现任何停顿的情况。

Ubuntu 14.04在HVM上的基准测试结果

尽管在PV模式下的性能值接近于基准值的两倍,与Debian 8.1的性能相比并不好。在这里使用的是基于Xen v4.4虚拟环境的Ubuntu 14.04,它是从ISO镜像安装并创建的裸磁盘镜像。考虑到Debian 8.1针对HVM虚拟环境进行了优化。

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: tkr33: GNU/Linux
   OS: GNU/Linux -- 3.13.0-24-generic -- #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014
   Machine: x86_64 (x86_64)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Xeon(R) CPU E5-2683 v3 @ 2.00GHz (4000.1 bogomips)
          x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
   01:39:56 up 8 min,  1 user,  load average: 0.48, 0.51, 0.24; runlevel 2

------------------------------------------------------------------------
Benchmark Run: Thu Aug 20 2015 01:39:56 - 02:08:09
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       23216142.4 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     2982.1 MWIPS (9.8 s, 7 samples)
Execl Throughput                               2941.8 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        444135.2 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          114926.5 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1486421.7 KBps  (30.0 s, 2 samples)
Pipe Throughput                              585781.4 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 155657.6 lps   (10.0 s, 7 samples)
Process Creation                               9615.4 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   5639.0 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    729.0 lpm   (60.0 s, 2 samples)
System Call Overhead                         398018.6 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   23216142.4   1989.4
Double-Precision Whetstone                       55.0       2982.1    542.2
Execl Throughput                                 43.0       2941.8    684.1
File Copy 1024 bufsize 2000 maxblocks          3960.0     444135.2   1121.6
File Copy 256 bufsize 500 maxblocks            1655.0     114926.5    694.4
File Copy 4096 bufsize 8000 maxblocks          5800.0    1486421.7   2562.8
Pipe Throughput                               12440.0     585781.4    470.9
Pipe-based Context Switching                   4000.0     155657.6    389.1
Process Creation                                126.0       9615.4    763.1
Shell Scripts (1 concurrent)                     42.4       5639.0   1329.9
Shell Scripts (8 concurrent)                      6.0        729.0   1214.9
System Call Overhead                          15000.0     398018.6    265.3
                                                                   ========
System Benchmarks Index Score                                         816.9