使用get-pip安装

1
2
> curl -O https://bootstrap.pypa.io/get-pip.py
> python get-pip.py

使用源安装

1
2
3
4
> sudo apt-get install python-pip
> 
or:
> sudo yum install python-pip

使用

| 从PyPI安装软件包

1
> pip install [package-name]

| 查看软件包信息

1
> pip show [package-name]

| 查看哪些软件包已经有更新版本

1
> pip list --outdated

| 升级软件包

1
> pip install [—U | --upgrade] [package-name]

| 卸载软件包

1
> pip uninstall [package-name]

1. VCPU信息查看

1.1 VCPU与CPU对应关系

1
virsh vcpuinfo [vm_name]

宿主机有一个物理CPU,8个物理核。此处的物理核,是指全部的逻辑CPU核,包括开启了超线程,即/proc/cpuinfo中列表的全部CPU核。如无特殊说明,下同。

center

如图可以看到,VCPU0被调度到物理核4上,VCPU1被调度到物理核5上。 CPU Affinity yyyyyyyy 代表物理核0~7均可以设置绑定,如果不可绑定会显示’-‘。

背景

当前项目的私有云环境中,采用Ceph作为统一的后端存储。由于业务的种类繁多,经常会有部分虚机在某个时间段将宿主网卡吃满的情况。比如用户在VM内做大文件的拷贝,或者环境更新等。所以有必要对VM的I/O进行一定的资源限制,防止单宿主上VM间的网络I/O争抢。

Ceph RBD QoS

Qemu与KVM均提供对网络资源的限制支持,使用libvirt封装的接口可以更方便的实现对rbd设备的资源限制。 libvirt提供如下选项:

  • total_bytes_sec: 混合模式下的带宽限制
  • read_bytes_sec: 顺序读带宽
  • write_bytes_sec: 顺序写带宽
  • total_iops_sec: 混合模式下的IOPS限制
  • read_iops_sec: 随机读IOPS
  • write_iops_sec: 随机写IOPS

使用方法很简单:

1
2
3
4
5
6
7
8
9
10
11
12
13
  
    <disk type='network' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      ...
      <source protocol='rbd' name='[pool_name]/[image_name]'>
      ...
      </source>
      <iotune>
        <read_iops_sec>20</read_iops_sec>
        <write_iops_sec>10</write_iops_sec>
      </iotune>

    ...

在XML文件中添加<iotune>标签,并设置相应的限制值即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
root@cld-osd5-20:/home/henry# virt-install --os-variant list
win2k8               : Microsoft Windows Server 2008 (or later)
win2k3               : Microsoft Windows Server 2003
win7                 : Microsoft Windows 7 (or later)
vista                : Microsoft Windows Vista
winxp64              : Microsoft Windows XP (x86_64)
winxp                : Microsoft Windows XP
win2k                : Microsoft Windows 2000
openbsd4             : OpenBSD 4.x (or later)
freebsd9             : FreeBSD 9.x
freebsd8             : FreeBSD 8.x
freebsd7             : FreeBSD 7.x
freebsd6             : FreeBSD 6.x
freebsd10            : FreeBSD 10.x (or later)
solaris9             : Sun Solaris 9
solaris11            : Sun Solaris 11 (or later)
solaris10            : Sun Solaris 10
opensolaris          : Sun OpenSolaris (or later)
netware6             : Novell Netware 6 (or later)
netware5             : Novell Netware 5
netware4             : Novell Netware 4
msdos                : MS-DOS
generic              : Generic
altlinux             : ALT Linux (or later)
debianwheezy         : Debian Wheezy (or later)
debiansqueeze        : Debian Squeeze
debianlenny          : Debian Lenny
debianetch           : Debian Etch
fedora20             : Fedora 20 (or later)
fedora19             : Fedora 19
fedora18             : Fedora 18
fedora17             : Fedora 17
fedora16             : Fedora 16
fedora15             : Fedora 15
fedora14             : Fedora 14
fedora13             : Fedora 13
fedora12             : Fedora 12
fedora11             : Fedora 11
fedora10             : Fedora 10
fedora9              : Fedora 9
fedora8              : Fedora 8
fedora7              : Fedora 7
fedora6              : Fedora Core 6
fedora5              : Fedora Core 5
mes5.1               : Mandriva Enterprise Server 5.1 (or later)
mes5                 : Mandriva Enterprise Server 5.0
mandriva2010         : Mandriva Linux 2010 (or later)
mandriva2009         : Mandriva Linux 2009 and earlier
mageia1              : Mageia 1 (or later)
rhel7                : Red Hat Enterprise Linux 7 (or later)
rhel6                : Red Hat Enterprise Linux 6
rhel5.4              : Red Hat Enterprise Linux 5.4 or later
rhel5                : Red Hat Enterprise Linux 5
rhel4                : Red Hat Enterprise Linux 4
rhel3                : Red Hat Enterprise Linux 3
rhel2.1              : Red Hat Enterprise Linux 2.1
sles11               : Suse Linux Enterprise Server 11 (or later)
sles10               : Suse Linux Enterprise Server
opensuse12           : openSuse 12 (or later)
opensuse11           : openSuse 11
ubuntusaucy          : Ubuntu 13.10 (Saucy Salamander) (or later)
ubunturaring         : Ubuntu 13.04 (Raring Ringtail)
ubuntuquantal        : Ubuntu 12.10 (Quantal Quetzal)
ubuntuprecise        : Ubuntu 12.04 LTS (Precise Pangolin)
ubuntuoneiric        : Ubuntu 11.10 (Oneiric Ocelot)
ubuntunatty          : Ubuntu 11.04 (Natty Narwhal)
ubuntumaverick       : Ubuntu 10.10 (Maverick Meerkat)
ubuntulucid          : Ubuntu 10.04 LTS (Lucid Lynx)
ubuntukarmic         : Ubuntu 9.10 (Karmic Koala)
ubuntujaunty         : Ubuntu 9.04 (Jaunty Jackalope)
ubuntuintrepid       : Ubuntu 8.10 (Intrepid Ibex)
ubuntuhardy          : Ubuntu 8.04 LTS (Hardy Heron)
mbs1                 : Mandriva Business Server 1 (or later)
virtio26             : Generic 2.6.25 or later kernel with virtio
generic26            : Generic 2.6.x kernel
generic24            : Generic 2.4.x kernel

1. free

linux系统中,查看当前内存的使用情况,简便的方法是free命令,命令行中free -m,列出系统当前的可用内存、cache/buffer、swap相关信息。

free工具是procps项目提供的标准proc文件系统分析工具,通过读取分析/proc/meminfo,实时的反应当前系统的内存使用情况。项目主页:procps.sourceforge.net

free