kvm相关测试

来源:互联网 发布:汽车防盗芯片编程器 编辑:程序博客网 时间:2024/04/28 18:07
注明:原创内容,转载务必注明出处,否则追究。
 
CPU测试使用的UnixBench、IO测试使用的iozone、网络测试使用iperf,系统需要perl环境。
 
安装UnixBench、iozone
wget http://www.iozone.org/src/current/iozone3_414.tar
wget http://byte-unixbench.googlecode.com/files/UnixBench5.1.3.tgz
tar xvf iozone3_414.tar
tar zxvf UnixBench5.1.3.tgz

cd ./iozone3_414/src/current
make linux

cd ./UnixBench
make

 

安装iperf
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.2-2.el5.rf.*.rpm
rpm -i rpmforge-release-0.5.2-2.el5.rf.*.rpm
yum install iperf

 

遇到的问题:

Centos5.6 运行UnixBench5.1.3 报如下错误
Can't locate Time/HiRes.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./Run line 6.
解决方法:
yum install perl-ExtUtils-MakeMaker.x86_64
yum install perl-Time-HiRes.x86_64
             
 
物理主机信息

CentOS release 6.3 (Final)

Linux localhost.localdomain 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux

QEMU PC emulator version 0.12.1 (qemu-kvm-0.12.1.2), Copyright (c) 2003-2008 Fabrice Bellard

Intel(R) Xeon(R) CPU E5504 @ 2.00GHz

MemTotal: 16319484 kB

Disk /dev/sda: 146.2 GB, 146163105792 bytes

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 26 204800 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 26 3682 29364224 8e Linux LVM

/dev/sda3 3682 17770 113167360 8e Linux LVM


 

一.磁盘IO测试
1.物理机IO
[root@localhost ~]# time dd if=/dev/zero of=/data/test.img bs=1K count=8192000
8388608000 bytes (8.4 GB) copied, 56.9204 s, 147 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/data/test.img bs=1K count=8192000
8388608000 bytes (8.4 GB) copied, 53.0728 s, 158 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/data/test.img bs=8K count=1024000
8388608000 bytes (8.4 GB) copied, 49.6586 s, 169 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/data/test.img bs=8K count=1024000
8388608000 bytes (8.4 GB) copied, 52.2602 s, 161 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/data/test.img bs=8K count=1024000
8388608000 bytes (8.4 GB) copied, 54.7777 s, 153 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/data/test.img bs=256K count=32768
8589934592 bytes (8.6 GB) copied, 52.1963 s, 165 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/data/test.img bs=1MB count=8192
8192000000 bytes (8.2 GB) copied, 46.0236 s, 178 MB/s


2.虚拟机IO缓存使用writeback模式时,写入速度不固定,其写入速度由物理主机的内存缓存决定。
mac=`printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))`
kvm -m 512 -drive file=centos5-15.img,cache=writeback,if=virtio,boot=on -net nic,macaddr=$mac -net tap -nographic -vnc :1
[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=1K count=8192000
8388608000 bytes (8.4 GB) copied, 141.515 seconds, 59.3 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=1K count=8192000
8388608000 bytes (8.4 GB) copied, 74.3178 seconds, 113 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=1K count=8192000
8388608000 bytes (8.4 GB) copied, 133.908 seconds, 62.6 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=8K count=1024000
8388608000 bytes (8.4 GB) copied, 104.59 seconds, 80.2 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=8K count=1024000
8388608000 bytes (8.4 GB) copied, 47.156 seconds, 178 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=8K count=1024000
8388608000 bytes (8.4 GB) copied, 46.4772 seconds, 180 MB/ss

[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=256K count=32768
8589934592 bytes (8.6 GB) copied, 93.3618 seconds, 92.0 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=256K count=32768
8589934592 bytes (8.6 GB) copied, 152.476 seconds, 56.3 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=1MB count=8192
8192000000 bytes (8.2 GB) copied, 84.2115 seconds, 97.3 MB/s


3.虚拟机在缓存模式为none模式下,实际的磁盘写入速度约为物理机速度的50%,写入速度稳定。
uid= `printf ' %08x-%04x-%04x-%04x-%012x\n' $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) `
mac=`printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))`
kvm -m 512 -drive file=centos5-15.img,cache=none,if=virtio,boot=on -net nic,macaddr=$mac -net tap -nographic -vnc :1

[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=1MB count=2000e
1965891584 bytes (2.0 GB) copied, 22.5994 seconds, 87.0 MB/s

[root@localhost ~]# sync
[root@localhost ~]# rm -f /home/test.img 
[root@localhost ~]# sync
\[root@localhost ~]#echo 3 > /proc/sys/vm/drop_caches 
[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=1MB count=2000
1965838336 bytes (2.0 GB) copied, 23.0265 seconds, 85.4 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=1MB count=2000
1969516544 bytes (2.0 GB) copied, 23.0854 seconds, 85.3 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=1K count=2040000
1966112768 bytes (2.0 GB) copied, 23.8183 seconds, 82.5 MB/s

[root@localhost ~]# time dd if=/dev/zero of=/home/test.img bs=256K count=8000
1969266688 bytes (2.0 GB) copied, 23.2247 seconds, 84.8 MB/s


二.网络测试
本测试交换机网速100Mb,因此未能反映实际情况,需进一步测试。

1.虚拟机到本地物理机
[root@localhost ~]# time scp /home/test.img root@192.168.135.124:/home
test.img                                                          100% 1878MB  10.0MB/s   03:07    

real    3m24.464s
user    0m50.679s
sys     2m14.275s

2.虚拟机到本地虚拟机
[root@localhost ~]# time scp /home/test.img root@192.168.135.84:/home
test.img                                                         100% 1878MB  12.7MB/s   02:28    
3.虚拟机到远程虚拟机
[root@localhost ~]# time scp /home/test.img root@192.168.135.108:/opt
test.img                                                          100% 1878MB  11.1MB/s   02:50    

三.CPU性能测试
该测试是使用程序在给定范围内寻找素数,物理主机与虚拟主机的CPU性能相差小于1%

1.物理机CPU测试
[root@localhost test_function]# ./finder 
find prime during 2 - 10000000  using: 42479 ms

2.虚拟机CPU测试
[root@localhost home]# ./finder 
find prime during 2 - 10000000  using: 42246 ms

[root@localhost kvmtest]# cd /data/kvmtest

[root@localhost kvmtest]# uid=`printf ' %08x-%04x-%04x-%04x-%012x\n' $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256))`
[root@localhost kvmtest]# mac=`printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))`
[root@localhost kvmtest]# nohup kvm -m 2048 -drive file=centos15_1.img,cache=none,if=virtio,boot=on -net nic,macaddr=$mac -net tap -uuid $uid -nographic -vnc :0 &

[root@localhost kvmtest]# uid=`printf ' %08x-%04x-%04x-%04x-%012x\n' $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256))`
[root@localhost kvmtest]# mac=`printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))`
[root@localhost kvmtest]# nohup kvm -m 2048 -drive file=centos15_2.img,cache=none,if=virtio,boot=on -net nic,macaddr=$mac -net tap -uuid $uid -nographic -vnc :1 &

[root@localhost kvmtest]# uid=`printf ' %08x-%04x-%04x-%04x-%012x\n' $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256))`
[root@localhost kvmtest]# mac=`printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))`
[root@localhost kvmtest]# nohup kvm -cpu core2duo -smp 2 -m 2048 -drive file=centos15_3.img,cache=none,if=virtio,boot=on -net nic,macaddr=$mac -net tap -uuid $uid -nographic -vnc :2 &

[root@localhost kvmtest]# uid=`printf ' %08x-%04x-%04x-%04x-%012x\n' $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256))`
[root@localhost kvmtest]# mac=`printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))`
[root@localhost kvmtest]# nohup kvm -cpu core2duo -smp 4 -m 2048 -drive file=centos15_4.img,cache=none,if=virtio,boot=on -net nic,macaddr=$mac -net tap -uuid $uid -nographic -vnc :3 &

192.168.135.141  -m 2048 -vnc 0
192.168.135.142  -m 2048 -vnc 1
192.168.135.146  -cpu core2duo -smp 2 -m 2048 -vnc 2
192.168.135.147  -cpu core2duo -smp 4 -m 2048 -vnc 3


一.CPU性能测试

cd ./UnixBench
./Run

测试结果
========================================================================
Benchmark Run: Thu Dec 27 2012 13:58:21 - 14:26:12
8 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       19278152.8 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     2389.7 MWIPS (9.9 s, 7 samples)
Execl Throughput                               2237.1 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        506905.5 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          167039.1 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1169919.4 KBps  (30.0 s, 2 samples)
Pipe Throughput                             1054701.6 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 162959.8 lps   (10.0 s, 7 samples)
Process Creation                               4724.6 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   3211.2 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   1167.8 lpm   (60.0 s, 2 samples)
System Call Overhead                        1351904.9 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   19278152.8   1651.9
Double-Precision Whetstone                       55.0       2389.7    434.5
Execl Throughput                                 43.0       2237.1    520.3
File Copy 1024 bufsize 2000 maxblocks          3960.0     506905.5   1280.1
File Copy 256 bufsize 500 maxblocks            1655.0     167039.1   1009.3
File Copy 4096 bufsize 8000 maxblocks          5800.0    1169919.4   2017.1
Pipe Throughput                               12440.0    1054701.6    847.8
Pipe-based Context Switching                   4000.0     162959.8    407.4
Process Creation                                126.0       4724.6    375.0
Shell Scripts (1 concurrent)                     42.4       3211.2    757.4
Shell Scripts (8 concurrent)                      6.0       1167.8   1946.4
System Call Overhead                          15000.0    1351904.9    901.3
                                                                   ========
System Benchmarks Index Score                                         861.6

------------------------------------------------------------------------
Benchmark Run: Thu Dec 27 2012 14:26:12 - 14:55:58
8 CPUs in system; running 8 parallel copies of tests

Dhrystone 2 using register variables      102175485.5 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                    19042.8 MWIPS (9.9 s, 7 samples)
Execl Throughput                              10702.7 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        501088.8 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          144154.1 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1072613.1 KBps  (30.0 s, 2 samples)
Pipe Throughput                             5462333.5 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                1565018.7 lps   (10.0 s, 7 samples)
Process Creation                              25845.7 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                  12409.1 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   2717.7 lpm   (60.1 s, 2 samples)
System Call Overhead                        4175337.8 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0  102175485.5   8755.4
Double-Precision Whetstone                       55.0      19042.8   3462.3
Execl Throughput                                 43.0      10702.7   2489.0
File Copy 1024 bufsize 2000 maxblocks          3960.0     501088.8   1265.4
File Copy 256 bufsize 500 maxblocks            1655.0     144154.1    871.0
File Copy 4096 bufsize 8000 maxblocks          5800.0    1072613.1   1849.3
Pipe Throughput                               12440.0    5462333.5   4390.9
Pipe-based Context Switching                   4000.0    1565018.7   3912.5
Process Creation                                126.0      25845.7   2051.2
Shell Scripts (1 concurrent)                     42.4      12409.1   2926.7
Shell Scripts (8 concurrent)                      6.0       2717.7   4529.6
System Call Overhead                          15000.0    4175337.8   2783.6
                                                                   ========
System Benchmarks Index Score                                        2765.3



虚拟机---192.168.135.141  -m 2048 -vnc 0
========================================================================
Benchmark Run: Thu Dec 27 2012 15:20:57 - 15:48:55
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       11347938.0 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     1123.8 MWIPS (10.0 s, 7 samples)
Execl Throughput                               2606.2 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        426633.9 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          121600.1 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks        948874.7 KBps  (30.0 s, 2 samples)
Pipe Throughput                              792690.6 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 249596.9 lps   (10.0 s, 7 samples)
Process Creation                              11784.1 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   4433.0 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    613.1 lpm   (60.0 s, 2 samples)
System Call Overhead                         730223.9 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   11347938.0    972.4
Double-Precision Whetstone                       55.0       1123.8    204.3
Execl Throughput                                 43.0       2606.2    606.1
File Copy 1024 bufsize 2000 maxblocks          3960.0     426633.9   1077.4
File Copy 256 bufsize 500 maxblocks            1655.0     121600.1    734.7
File Copy 4096 bufsize 8000 maxblocks          5800.0     948874.7   1636.0
Pipe Throughput                               12440.0     792690.6    637.2
Pipe-based Context Switching                   4000.0     249596.9    624.0
Process Creation                                126.0      11784.1    935.2
Shell Scripts (1 concurrent)                     42.4       4433.0   1045.5
Shell Scripts (8 concurrent)                      6.0        613.1   1021.8
System Call Overhead                          15000.0     730223.9    486.8
                                                                   ========
System Benchmarks Index Score                                         746.9


对虚拟机做IO测试时物理机IO利用率可达到93%~97%,此时虚拟机测试得到的磁盘写入速度为物理主机的50%,既相对于物理主机来说虚拟机的IO约有40%~50%的性能损失。

磁盘IO测试      
./iozone -Mcew -i0 -i1 -i2 -s4g -r256k -f /data/test.img
 writerewritereadrereadreadwrite物理主机12122912221238499453858558378703593721虚拟机89278923061101711156393216939354
原创粉丝点击