使用yum安装Xen
Xen 虚拟机初级安装
目录
一、 使用yum安装Xen. 3
1. yum install xen* (安装Xen的基本程序)… 3
2. yum install virt-manager (安装Xen的虚拟管理程序)… 6
3. yum install kernel-xen*(安装Xen内核)… 11
二、 配置Xen环境… 13
1. ls –lh /boot (查看/boot下的文件). 13
2. vi /boot/grub/grub.conf更改启动内核… 13
3. 检查xen功能… 14
a) xm list(检查虚拟域的状况)… 14
b) ls –lh /var/log/xen (查看日志路径). 14
c) cat /var/log/xen/xend-debug.log (查看日志状况). 14
三、 建立虚拟机… 15
1. 建立虚拟机安装目录… 15
a) mkdir /opt/xen (在opt目录下建立xen目录). 15
b) cd /opt/xen/ (进入/opt/xen目录). 15
c) mkdir test1 test2 test3 (建立3个目录,分别装3个虚拟机). 15
2. 创建虚拟机并安装CentOS 5.2. 15
a) 创建虚拟机… 15
b) virt-install命令参数… 21
四、 Xen虚拟机的操作… 22
1. 虚拟机的配置文件… 22
2. 查看状态… 22
3. 启动虚拟机… 23
4. 关闭虚拟机… 23
5. 其他常用命令… 23
一、 使用yum安装Xen
1. yum install xen* (安装Xen的基本程序)
[root@localhost /]# yum install xen* Setting up Install Process Parsing package install arguments Resolving Dependencies –> Running transaction check —> Package xen.i386 0:3.0.3-64.el5 set to be updated –> Processing Dependency: xen-hypervisor-abi = 3.1 for package: xen –> Processing Dependency: libSDL-1.2.so.0 for package: xen –> Processing Dependency: python-virtinst for package: xen –> Processing Dependency: bridge-utils for package: xen —> Package xen-devel.i386 0:3.0.3-64.el5 set to be updated —> Package xen-libs.i386 0:3.0.3-64.el5 set to be updated –> Running transaction check —> Package python-virtinst.noarch 0:0.300.2-8.el5 set to be updated –> Processing Dependency: libvirt-python >= 0.2.1 for package: python-virtinst –> Processing Dependency: virt-viewer for package: python-virtinst —> Package bridge-utils.i386 0:1.1-2 set to be updated —> Package kernel-xen.i686 0:2.6.18-92.el5 set to be installed —> Package SDL.i386 0:1.2.10-8.el5 set to be updated–> Processing Dependency: libaudiofile.so.0 for package: SDL –> Processing Dependency: libesd.so.0 for package: SDL –> Running transaction check —> Package libvirt-python.i386 0:0.3.3-7.el5 set to be updated –> Processing Dependency: libvirt.so.0 for package: libvirt-python –> Processing Dependency: libvirt = 0.3.3 for package: libvirt-python —> Package audiofile.i386 1:0.2.6-5 set to be updated —> Package esound.i386 1:0.2.36-3 set to be updated –> Processing Dependency: libasound.so.2(ALSA_0.9.0rc4) for package: esound –> Processing Dependency: libasound.so.2(ALSA_0.9) for package: esound –> Processing Dependency: libasound.so.2 for package: esound —> Package virt-viewer.i386 0:0.0.2-2.el5 set to be updated –> Processing Dependency: libgtk-vnc-1.0.so.0 for package: virt-viewer –> Running transaction check —> Package alsa-lib.i386 0:1.0.14-1.rc4.el5 set to be updated —> Package libvirt.i386 0:0.3.3-7.el5 set to be updated –> Processing Dependency: libavahi-common.so.3 for package: libvirt
|
–> Processing Dependency: libavahi-client.so.3 for package: libvirt –> Processing Dependency: dnsmasq for package: libvirt —> Package gtk-vnc.i386 0:0.3.2-3.el5 set to be updated –> Running transaction check —> Package avahi.i386 0:0.6.16-1.el5 set to be updated –> Processing Dependency: libdaemon for package: avahi –> Processing Dependency: libdaemon.so.0 for package: avahi —> Package dnsmasq.i386 0:2.39-2.el5 set to be updated –> Running transaction check —> Package libdaemon.i386 0:0.10-5.el5 set to be updated –> Finished Dependency Resolution Dependencies Resolved =================================================================== Package Arch Version Repository Size =================================================================== Installing: Xen i386 3.0.3-64.el5 base 1.8 M xen-deve i386 3.0.3-64.el5 base 214 k Installing for dependencies: SDL i386 1.2.10-8.el5 base 233 k alsa-lib i386 1.0.14-1.rc4.el5 base 406 k audiofile i386 1:0.2.6-5 base 107 k avahi i386 0.6.16-1.el5 base 249 k bridge-utils i386 1.1-2 base 27 k dnsmasq i386 2.39-2.el5 base 150 k esound i386 1:0.2.36-3 base 129 k gtk-vnc i386 0.3.2-3.el5 base 51 k kernel-xen i686 2.6.18-92.el5 base 15 M libdaemon i386 0.10-5.el5 base 24 k libvirt i386 0.3.3-7.el5 base 918 k libvirt-python i386 0.3.3-7.el5 base 74 k python-virtinst noarch 0.300.2-8.el5 base 161 k virt-viewer i386 0.0.2-2.el5 base 24 k xen-libs i386 3.0.3-64.el5 base 141 k Transaction Summary ================================================================ Install 17 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 20 M Is this ok [y/N]: y Downloading Packages: (1/17): gtk-vnc-0.3.2-3.e 100% |=========================| 51 kB 00:00 (2/17): virt-viewer-0.0.2 100% |=========================| 24 kB 00:00 |
(3/17): SDL-1.2.10-8.el5. 100% |=========================| 233 kB 00:00 (4/17): libvirt-0.3.3-7.e 100% |=========================| 918 kB 00:00 (5/17): alsa-lib-1.0.14-1 100% |=====================| 406 kB 00:00 (6/17): dnsmasq-2.39-2.el 100% |=====================| 150 kB 00:00 (7/17): xen-libs-3.0.3-64 100%|=====================| 141 kB 00:00 (8/17): esound-0.2.36-3.i 100%|=====================| 129 kB 00:00 (9/17): avahi-0.6.16-1.el 100%|=====================| 249 kB 00:00 (10/17): libdaemon-0.10-5 100% |=====================| 24 kB 00:00 (11/17): kernel-xen-2.6.1 100% |======================| 15 MB 00:01 (12/17): bridge-utils-1.1 100% |=========================| 27 kB 00:00 (13/17): python-virtinst- 100% |=========================| 161 kB 00:00 (14/17): xen-devel-3.0.3- 100% |=========================| 214 kB 00:00 (15/17): xen-3.0.3-64.el5 100% |=========================| 1.8 MB 00:00 (16/17): audiofile-0.2.6- 100% |=========================| 107 kB 00:00 (17/17): libvirt-python-0 100% |=========================| 74 kB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: xen-libs ####################### [ 1/17] Installing: bridge-utils ####################### [ 2/17] Installing: audiofile ####################### [ 3/17] Installing: gtk-vnc ####################### [ 4/17] Installing: alsa-lib ####################### [ 5/17] Installing: esound ####################### [ 6/17] Installing: SDL ####################### [ 7/17] Installing: dnsmasq ####################### [ 8/17] Installing: libdaemon ####################### [ 9/17] Installing: avahi ####################### [10/17] Installing: libvirt ####################### [11/17] Installing: libvirt-python ####################### [12/17] Installing: virt-viewer ####################### [13/17] Installing: python-virtinst ####################### [14/17] Installing: kernel-xen ####################### [15/17] Installing: xen ####################### [16/17] Installing: xen-devel ####################### [17/17] Installed: xen.i386 0:3.0.3-64.el5 xen-devel.i386 0:3.0.3-64.el5 Dependency Installed: SDL.i386 0:1.2.10-8.el5 alsa-lib.i386 0:1.0.14-1.rc4.el5 audiofile.i386 1:0.2.6-5 avahi.i386 0:0.6.16-1.el5 bridge-utils.i386 0:1.1-2 dnsmasq.i386 0:2.39-2.el5 esound.i386 1:0.2.36-3 gtk-vnc.i386 0:0.3.2-3.el5 kernel-xen.i686 0:2.6.18-92.el5 libdaemon.i386 0:0.10-5.el5 libvirt.i386 0:0.3.3-7.el5 libvirt-python.i386 0:0.3.3-7.el5 python-virtinst.noarch 0:0.300.2-8.el5 virt-viewer.i386 0:0.0.2-2.el5 xen-libs.i386 0:3.0.3-64.el5 Complete! |
2. yum install virt-manager (安装Xen的虚拟管理程序)
[root@localhost /]# yum install virt-manager Setting up Install Process Parsing package install arguments Resolving Dependencies –> Running transaction check —> Package virt-manager.i386 0:0.5.3-8.el5 set to be updated –> Processing Dependency: scrollkeeper for package: virt-manager –> Processing Dependency: pygtk2 >= 1.99.12-6 for package: virt-manager –> Processing Dependency: pygtk2-libglade for package: virt-manager –> Processing Dependency: gtk-vnc-python for package: virt-manager –> Processing Dependency: gnome-keyring >= 0.4.9 for package: virt-manager –> Processing Dependency: librsvg2 for package: virt-manager –> Processing Dependency: gnome-python2-gconf >= 1.99.11-7 for package: virt-manager –> Processing Dependency: vte >= 0.12.2 for package: virt-manager –> Processing Dependency: gnome-python2-gnomekeyring >= 2.15.4 for package: virt-manager –> Running transaction check —> Package pygtk2-libglade.i386 0:2.10.1-12.el5 set to be updated –> Processing Dependency: libglade-2.0.so.0 for package: pygtk2-libglade —> Package librsvg2.i386 0:2.16.1-1.el5 set to be updated –> Processing Dependency: libgsf-1.so.114 for package: librsvg2 –> Processing Dependency: libgnomevfs-2.so.0 for package: librsvg2 –> Processing Dependency: gnome-vfs2 >= 1.9.16 for package: librsvg2 –> Processing Dependency: libcroco >= 0.6.1 for package: librsvg2 –> Processing Dependency: libgsf >= 1.6.0 for package: librsvg2 –> Processing Dependency: libcroco-0.6.so.3 for package: librsvg2 —> Package vte.i386 0:0.14.0-2.el5 set to be updated –> Processing Dependency: bitmap-fonts for package: vte —> Package gnome-python2-gnomekeyring.i386 0:2.16.0-2.el5 set to be updated –> Processing Dependency: gnome-python2-desktop = 2.16.0-2.el5 for package: gnome-python2-gnomekeyring —> Package scrollkeeper.i386 0:0.3.14-9.el5 set to be updated –> Processing Dependency: docbook-dtds for package: scrollkeeper –> Processing Dependency: libxslt for package: scrollkeeper –> Processing Dependency: libxslt.so.1 for package: scrollkeeper —> Package gtk-vnc-python.i386 0:0.3.2-3.el5 set to be updated —> Package gnome-python2-gconf.i386 0:2.16.0-1.fc6 set to be updated –> Processing Dependency: gnome-python2 = 2.16.0-1.fc6 for package: gnome-python2-gconf —> Package pygtk2.i386 0:2.10.1-12.el5 set to be updated –> Processing Dependency: python-numeric for package: pygtk2 –> Processing Dependency: pycairo for package: pygtk2 —> Package gnome-keyring.i386 0:0.6.0-1.fc6 set to be updated
|
–> Running transaction check —> Package libgsf.i386 0:1.14.1-6.1 set to be updated –> Processing Dependency: libbonobo-2.so.0 for package: libgsf –> Processing Dependency: libbonobo-activation.so.4 for package: libgsf —> Package gnome-python2.i386 0:2.16.0-1.fc6 set to be updated –> Processing Dependency: gnome-python2-bonobo for package: gnome-python2 –> Processing Dependency: libgnomecanvas-2.so.0 for package: gnome-python2 –> Processing Dependency: libbonoboui-2.so.0 for package: gnome-python2 –> Processing Dependency: gnome-python2-gnomevfs for package: gnome-python2 –> Processing Dependency: libgnome-2.so.0 for package: gnome-python2 –> Processing Dependency: libart_lgpl_2.so.2 for package: gnome-python2 –> Processing Dependency: libgnomeui-2.so.0 for package: gnome-python2 —> Package gnome-python2-desktop.i386 0:2.16.0-2.el5 set to be updated —> Package docbook-dtds.noarch 0:1.0-30.1 set to be updated –> Processing Dependency: xml-common for package: docbook-dtds –> Processing Dependency: xml-common >= 0.6.3-8 for package: docbook-dtds –> Processing Dependency: openjade = 1.3.2 for package: docbook-dtds –> Processing Dependency: sgml-common >= 0.6.3-4 for package: docbook-dtds —> Package pycairo.i386 0:1.2.0-1.1 set to be updated —> Package libglade2.i386 0:2.6.0-2 set to be updated —> Package libcroco.i386 0:0.6.1-2.1 set to be updated —> Package python-numeric.i386 0:23.7-2.2.2 set to be updated —> Package gnome-vfs2.i386 0:2.16.2-4.el5 set to be updated –> Processing Dependency: libavahi-glib.so.1 for package: gnome-vfs2 –> Processing Dependency: shared-mime-info for package: gnome-vfs2 –> Processing Dependency: gnome-mount >= 0.4 for package: gnome-vfs2 –> Processing Dependency: gnome-mime-data >= 2.0.0-11 for package: gnome-vfs2 —> Package libxslt.i386 0:1.1.17-2 set to be updated —> Package bitmap-fonts.noarch 0:0.3-5.1.1 set to be updated –> Running transaction check —> Package libgnomeui.i386 0:2.16.0-5.el5 set to be updated —> Package shared-mime-info.i386 0:0.19-5.el5 set to be updated —> Package libbonoboui.i386 0:2.16.0-1.fc6 set to be updated —> Package gnome-python2-bonobo.i386 0:2.16.0-1.fc6 set to be updated –> Processing Dependency: pyorbit >= 2.0.l for package: gnome-python2-bonobo —> Package libgnome.i386 0:2.16.0-6.el5 set to be updated —> Package openjade.i386 0:1.3.2-27 set to be updated –> Processing Dependency: libosp.so.5 for package: openjade —> Package libart_lgpl.i386 0:2.3.17-4 set to be updated —> Package sgml-common.noarch 0:0.6.3-18 set to be updated —> Package libbonobo.i386 0:2.16.0-1.fc6 set to be updated —> Package gnome-mount.i386 0:0.5-3.el5 set to be updated —> Package xml-common.noarch 0:0.6.3-18 set to be updated —> Package libgnomecanvas.i386 0:2.14.0-4.1 set to be updated |
—> Package gnome-python2-gnomevfs.i386 0:2.16.0-1.fc6 set to be updated —> Package avahi-glib.i386 0:0.6.16-1.el5 set to be updated —> Package gnome-mime-data.i386 0:2.4.2-3.1 set to be updated –> Running transaction check —> Package opensp.i386 0:1.5.2-4 set to be updated —> Package pyorbit.i386 0:2.14.1-1.1 set to be updated –> Finished Dependency Resolution Dependencies Resolved =================================================================== Package Arch Version Repository Size =================================================================== Installing: virt-manager i386 0.5.3-8.el5 base 1.2 M Installing for dependencies: avahi-glib i386 0.6.16-1.el5 base 14 k bitmap-fonts noarch 0.3-5.1.1 base 906 k docbook-dtds noarch 1.0-30.1 base 677 k gnome-keyring i386 0.6.0-1.fc6 base 170 k gnome-mime-data i386 2.4.2-3.1 base 690 k gnome-mount i386 0.5-3.el5 base 70 k gnome-python2 i386 2.16.0-1.fc6 base 126 k gnome-python2-bonobo i386 2.16.0-1.fc6 base 63 k gnome-python2-desktop i386 2.16.0-2.el5 base 43 k gnome-python2-gconf i386 2.16.0-1.fc6 base 31 k gnome-python2-gnomekeyring i386 2.16.0-2.el5 base 15 k gnome-python2-gnomevfs i386 2.16.0-1.fc6 base 65 k gnome-vfs2 i386 2.16.2-4.el5 base 1.3 M gtk-vnc-python i386 0.3.2-3.el5 base 9.7 k libart_lgpl i386 2.3.17-4 base 76 k libbonobo i386 2.16.0-1.fc6 base 501 k libbonoboui i386 2.16.0-1.fc6 base 389 k libcroco i386 0.6.1-2.1 base 127 k libglade2 i386 2.6.0-2 base 96 k libgnome i386 2.16.0-6.el5 base 858 k libgnomecanvas i386 2.14.0-4.1 base 222 k libgnomeui i386 2.16.0-5.el5 base 978 k libgsf i386 1.14.1-6.1 base 116 k librsvg2 i386 2.16.1-1.el5 base 178 k libxslt i386 1.1.17-2 base 483 k openjade i386 1.3.2-27 base 980 k opensp i386 1.5.2-4 base 1.1 M pycairo i386 1.2.0-1.1 base 27 k pygtk2 i386 2.10.1-12.el5 base 1.1 M pygtk2-libglade i386 2.10.1-12.el5 base 18 k |
pyorbit i386 2.14.1-1.1 base 47 k python-numeric i386 23.7-2.2.2 base 751 k scrollkeeper i386 0.3.14-9.el5 base 294 k sgml-common noarch 0.6.3-18 base 40 k shared-mime-info i386 0.19-5.el5 base 148 k vte i386 0.14.0-2.el5 base 459 k xml-common noarch 0.6.3-18 base 5.8 k Transaction Summary ============================================================================= Install 38 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 14 M Is this ok [y/N]: y Downloading Packages: (1/38): virt-manager-0.5. 100% |=========================| 1.2 MB 00:00 (2/38): python-numeric-23 100% |=========================| 751 kB 00:00 (3/38): pyorbit-2.14.1-1. 100% |=========================| 47 kB 00:00 (4/38): gnome-mime-data-2 100% |=========================| 690 kB 00:00 (5/38): avahi-glib-0.6.16 100% |=========================| 14 kB 00:00 (6/38): bitmap-fonts-0.3- 100% |=========================| 906 kB 00:00 (7/38): vte-0.14.0-2.el5. 100% |=========================| 459 kB 00:00 (8/38): pygtk2-libglade-2 100% |=========================| 18 kB 00:00 (9/38): gnome-python2-gno 100% |=========================| 65 kB 00:00 (10/38): libgnomecanvas-2 100% |=========================| 222 kB 00:00 (11/38): gnome-python2-2. 100% |=========================| 126 kB 00:00 (12/38): xml-common-0.6.3 100% |=========================| 5.8 kB 00:00 (13/38): libcroco-0.6.1-2 100% |=========================| 127 kB 00:00 (14/38): gnome-python2-gc 100% |=========================| 31 kB 00:00 (15/38): gnome-mount-0.5- 100% |=========================| 70 kB 00:00 (16/38): scrollkeeper-0.3 100% |=========================| 294 kB 00:00 (17/38): gnome-python2-gn 100% |=========================| 15 kB 00:00 (18/38): libxslt-1.1.17-2 100% |=========================| 483 kB 00:00 (19/38): libbonobo-2.16.0 100% |=========================| 501 kB 00:00 (20/38): gnome-keyring-0. 100% |=========================| 170 kB 00:00 (21/38): pygtk2-2.10.1-12 100% |=========================| 1.1 MB 00:00 (22/38): gtk-vnc-python-0 100% |=========================| 9.7 kB 00:00 (23/38): librsvg2-2.16.1- 100% |=========================| 178 kB 00:00 (24/38): sgml-common-0.6. 100% |=========================| 40 kB 00:00 (25/38): libart_lgpl-2.3. 100% |=========================| 76 kB 00:00 (26/38): gnome-python2-de 100% |=========================| 43 kB 00:00 (27/38): openjade-1.3.2-2 100% |=========================| 980 kB 00:00 (28/38): libgnome-2.16.0- 100% |=========================| 858 kB 00:00 (29/38): gnome-python2-bo 100% |=========================| 63 kB 00:00 |
(30/38): opensp-1.5.2-4.i 100% |=========================| 1.1 MB 00:00 (31/38): gnome-vfs2-2.16. 100% |=========================| 1.3 MB 00:00 (32/38): pycairo-1.2.0-1. 100% |=========================| 27 kB 00:00 (33/38): libglade2-2.6.0- 100% |=========================| 96 kB 00:00 (34/38): docbook-dtds-1.0 100% |=========================| 677 kB 00:00 (35/38): libbonoboui-2.16 100% |=========================| 389 kB 00:00 (36/38): shared-mime-info 100% |=========================| 148 kB 00:00 (37/38): libgnomeui-2.16. 100% |=========================| 978 kB 00:00 (38/38): libgsf-1.14.1-6. 100% |=========================| 116 kB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: libbonobo ####################### [ 1/38] Installing: libart_lgpl ####################### [ 2/38] Installing: gnome-keyring ####################### [ 3/38] Installing: libglade2 ####################### [ 4/38] Installing: libgnomecanvas ####################### [ 5/38] Installing: sgml-common ####################### [ 6/38] Installing: libxslt ####################### [ 7/38] Installing: opensp ####################### [ 8/38] Installing: openjade ####################### [ 9/38] Installing: python-numeric ####################### [10/38] Installing: pyorbit ####################### [11/38] Installing: gnome-mime-data ####################### [12/38] Installing: avahi-glib ####################### [13/38] Installing: bitmap-fonts ####################### [14/38] Installing: vte ####################### [15/38] Installing: xml-common ####################### [16/38] Installing: docbook-dtds ####################### [17/38] Installing: scrollkeeper ####################### [18/38] Installing: libcroco ####################### [19/38] Installing: gtk-vnc-python ####################### [20/38] Installing: pycairo ####################### [21/38] Installing: pygtk2 ####################### [22/38] Installing: pygtk2-libglade ####################### [23/38] Installing: shared-mime-info ####################### [24/38] Installing: gnome-vfs2 ####################### [25/38] Installing: libgnome ####################### [26/38] Installing: libbonoboui ####################### [27/38] Installing: libgnomeui ####################### [28/38] Installing: gnome-mount ####################### [29/38] Installing: libgsf ####################### [30/38] |
Installing: librsvg2 ####################### [31/38] Installing: gnome-python2 ####################### [32/38] Installing: gnome-python2-desktop ####################### [33/38] Installing: gnome-python2-gnomekeyring ####################### [34/38] Installing: gnome-python2-gconf ####################### [35/38] Installing: gnome-python2-bonobo ####################### [36/38] Installing: gnome-python2-gnomevfs ####################### [37/38] Installing: virt-manager ####################### [38/38] Installed: virt-manager.i386 0:0.5.3-8.el5 Dependency Installed: avahi-glib.i386 0:0.6.16-1.el5 bitmap-fonts.noarch 0:0.3-5.1.1 docbook-dtds.noarch 0:1.0-30.1 gnome-keyring.i386 0:0.6.0-1.fc6 gnome-mime-data.i386 0:2.4.2-3.1 gnome-mount.i386 0:0.5-3.el5 gnome-python2.i386 0:2.16.0-1.fc6 gnome-python2-bonobo.i386 0:2.16.0-1.fc6 gnome-python2-desktop.i386 0:2.16.0-2.el5 gnome-python2-gconf.i386 0:2.16.0-1.fc6 gnome-python2-gnomekeyring.i386 0:2.16.0-2.el5 gnome-python2-gnomevfs.i386 0:2.16.0-1.fc6 gnome-vfs2.i386 0:2.16.2-4.el5 gtk-vnc-python.i386 0:0.3.2-3.el5 libart_lgpl.i386 0:2.3.17-4 libbonobo.i386 0:2.16.0-1.fc6 libbonoboui.i386 0:2.16.0-1.fc6 libcroco.i386 0:0.6.1-2.1 libglade2.i386 0:2.6.0-2 libgnome.i386 0:2.16.0-6.el5 libgnomecanvas.i386 0:2.14.0-4.1 libgnomeui.i386 0:2.16.0-5.el5 libgsf.i386 0:1.14.1-6.1 librsvg2.i386 0:2.16.1-1.el5 libxslt.i386 0:1.1.17-2 openjade.i386 0:1.3.2-27 opensp.i386 0:1.5.2-4 pycairo.i386 0:1.2.0-1.1 pygtk2.i386 0:2.10.1-12.el5 pygtk2-libglade.i386 0:2.10.1-12.el5 pyorbit.i386 0:2.14.1-1.1 python-numeric.i386 0:23.7-2.2.2 scrollkeeper.i386 0:0.3.14-9.el5 sgml-common.noarch 0:0.6.3-18 shared-mime-info.i386 0:0.19-5.el5 vte.i386 0:0.14.0-2.el5 xml-common.noarch 0:0.6.3-18 Complete! |
3. yum install kernel-xen*(安装Xen内核)
[root@localhost ~]# yum install kernel-xen* Setting up Install Process Parsing package install arguments Resolving Dependencies –> Running transaction check —> Package kernel-xen.i686 0:2.6.18-92.el5 set to be installed —> Package kernel-xen-devel.i686 0:2.6.18-92.el5 set to be installed –> Finished Dependency Resolution Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: kernel-xen i686 2.6.18-92.el5 base 15 M kernel-xen-devel i686 2.6.18-92.el5 base 4.8 M Transaction Summary |
============================================================================= Install 2 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 20 M Is this ok [y/N]: y Downloading Packages: (1/2): kernel-xen-devel-2 100% |=========================| 4.8 MB 00:03 (2/2): kernel-xen-2.6.18- 100% |=========================| 15 MB 00:06 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: kernel-xen-devel ######################### [1/2] Installing: kernel-xen ######################### [2/2] /sbin/ldconfig: /lib/libradiusclient-ng.so.2 is not a symbolic link Installed: kernel-xen.i686 0:2.6.18-92.el5 kernel-xen-devel.i686 0:2.6.18-92.el5 Complete! |
二、 配置Xen环境
1. ls –lh /boot (查看/boot下的文件)
[root@localhost ~]# ls -lh /boot total 14M -rw-r–r– 1 root root 64K Jun 11 2008 config-2.6.18-92.el5 -rw-r–r– 1 root root 64K Jun 11 2008 config-2.6.18-92.el5xen drwxr-xr-x 2 root root 1.0K Apr 21 14:05 grub -rw——- 1 root root 3.1M Apr 16 17:45 initrd-2.6.18-92.el5.img -rw——- 1 root root 3.1M Apr 21 14:05 initrd-2.6.18-92.el5xen.img drwx—— 2 root root 12K Apr 16 17:41 lost+found -rw-r–r– 1 root root 79K Nov 23 2007 message -rw-r–r– 1 root root 90K Jun 11 2008 symvers-2.6.18-92.el5.gz -rw-r–r– 1 root root 92K Jun 11 2008 symvers-2.6.18-92.el5xen.gz -rw-r–r– 1 root root 892K Jun 11 2008 System.map-2.6.18-92.el5 -rw-r–r– 1 root root 888K Jun 11 2008 System.map-2.6.18-92.el5xen -rw-r–r– 1 root root 1.8M Jun 11 2008 vmlinuz-2.6.18-92.el5 -rw-r–r– 1 root root 2.1M Jun 11 2008 vmlinuz-2.6.18-92.el5xen (带xen内核的启动文件) -rw-r–r– 1 root root 322K Jun 11 2008 xen.gz-2.6.18-92.el5 -rwxr-xr-x 1 root root 698K Jun 11 2008 xen-syms-2.6.18-92.el5 |
2. vi /boot/grub/grub.conf更改启动内核
# grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00 # initrd /initrd-version.img #boot=/dev/sda default=1 #将此处的1改为0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS (2.6.18-92.el5xen) root (hd0,0) kernel /xen.gz-2.6.18-92.el5 |
module /vmlinuz-2.6.18-92.el5xen ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.18-92.el5xen.img title CentOS (2.6.18-92.el5) #这个是具有xen功能的系统内核,更改用这个启动项启动系统 root (hd0,0) kernel /vmlinuz-2.6.18-92.el5 ro root=/dev/VolGroup00/LogVol00 initrd /initrd-2.6.18-92.el5.img
“/boot/grub/grub.conf” 22L, 771C |
修改完毕后保存退出,并重新启动系统。
3. 检查xen功能
a) xm list(检查虚拟域的状况)
[root@localhost ~]# xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 1896 4 r—– 30.0 (根虚拟域) (域ID) (虚拟机内存) (虚拟机CPU数量) (状态) (运行时间) |
注释:Domain-0是最高的根虚拟域,管理控制虚拟域。以后建立的虚拟机都会有一个各自的虚拟域。
b) ls –lh /var/log/xen (查看日志路径)
[root@localhost ~]# ls -lh /var/log/xen/ total 24K drwx—— 2 root root 4.0K May 25 2008 console -rw-r–r– 1 root root 36 Apr 21 14:34 xend-debug.log -rw-r–r– 1 root root 1.8K Apr 21 14:34 xend.log |
c) cat /var/log/xen/xend-debug.log (查看日志状况)
[root@localhost ~]# cat /var/log/xen/xend-debug.log Nothing to flush. Nothing to flush. |
到此Xen虚拟机安装完毕
三、 建立虚拟机
1. 建立虚拟机安装目录
a) mkdir /opt/xen (在opt目录下建立xen目录)
[root@localhost /]# mkdir /opt/xen [root@localhost /]# |
b) cd /opt/xen/ (进入/opt/xen目录)
[root@localhost /]#cd /opt/xen [root@localhost xen]# |
c) mkdir test1 test2 test3 (建立3个目录,分别装3个虚拟机)
[root@localhost xen]# mkdir test1 test2 test3 #建立3个目录 [root@localhost xen]# ls #查看是否建立成功 test1 test2 test3 #我们已经看见刚才建的3个目录了 [root@localhost xen]#cd test1 #进入test1目录 |
2. 创建虚拟机并安装CentOS 5.2
a) 创建虚拟机
执行命令:virt-install -n billing -r 1024 –vcpus=2 –file=master.img –nographic -l ftp://10.20.6.2/centos52/
root@localhost test1]# virt-install -n billing -r 1024 –vcpus=2 –file=master.img –nographic -l ftp://10.20.6.2/centos52/ How large would you like the disk (master.img) to be (in gigabytes)? 20 #询问磁盘需要多少空间,单位是G Starting install… #开始安装 Retrieving file .treeinfo 100% |=========================| 413 B 00:00 Retrieving file vmlinuz.. 100% |=========================| 2.1 MB 00:00 Retrieving file initrd.im 100% |=========================| 5.4 MB 00:00 |
Creating storage file… 100% |=========================| 20 GB 00:00 Creating domain… 0 B 00:03 Linux version 2.6.18-92.el5xen (mockbuild@builder16.centos.org) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Jun 10 19:55:54 EDT 2008 BIOS-provided physical RAM map: Xen: 0000000000000000 – 0000000040800000 (usable) 304MB HIGHMEM available. 727MB LOWMEM available. NX (Execute Disable) protection: active ACPI in unprivileged domain disabled Built 1 zonelists. Total pages: 264192 Kernel command line: method=ftp://10.20.6.2/centos52/ Enabling fast FPU save and restore… done. Enabling unmasked SIMD FPU exception support… done. Initializing CPU#0 CPU 0 irqstacks, hard=c073b000 soft=c071b000 PID hash table entries: 4096 (order: 12, 16384 bytes) Xen reported: 3000.106 MHz processor. Console: colour dummy device 80×25 Dentry cache hash table entries: 131072 (order: 7, 524288 bytes) Inode-cache hash table entries: 65536 (order: 6, 262144 bytes) Software IO TLB disabled vmalloc area: ee000000-f4ffe000, maxmem 2d7fe000 Memory: 1024936k/1056768k available (2098k kernel code, 22792k reserved, 867k data, 176k init, 311304k highmem) Checking if this processor honours the WP bit even in supervisor mode… Ok. Calibrating delay using timer specific routine.. 7503.83 BogoMIPS (lpj=15007676) Security Framework v1.0.0 initialized SELinux: Initializing. selinux_register_security: Registering secondary module capability Capability LSM initialized as secondary Mount-cache hash table entries: 512 CPU: Trace cache: 12K uops, L1 D cache: 16K CPU: L2 cache: 2048K Checking ‘hlt’ instruction… OK. SMP alternatives: switching to UP code CPU 1 irqstacks, hard=c073c000 soft=c071c000 Brought up 1 CPUs checking if image is initramfs… it is Freeing initrd memory: 7224k freed Grant table initialized NET: Registered protocol family 16 ACPI Exception (utmutex-0262): AE_BAD_PARAMETER, Thread C18F4AA0 could not acquire Mutex [2] [20060707] |
No dock devices found. ACPI Exception (utmutex-0262): AE_BAD_PARAMETER, Thread C18F4AA0 could not acquire Mutex [2] [20060707] SMP alternatives: switching to SMP code Initializing CPU#1 migration_cost=1942 Brought up 2 CPUs PCI: Fatal: No PCI config space access function found PCI: setting up Xen PCI frontend stub ACPI: Interpreter disabled. Linux Plug and Play Support v0.97 (c) Adam Belay pnp: PnP ACPI: disabled xen_mem: Initialising balloon driver. usbcore: registered new driver usbfs usbcore: registered new driver hub PCI: System does not support PCI PCI: System does not support PCI NetLabel: Initializing NetLabel: domain hash size = 128 NetLabel: protocols = UNLABELED CIPSOv4 NetLabel: unlabeled traffic allowed by default NET: Registered protocol family 2 IP route cache hash table entries: 32768 (order: 5, 131072 bytes) TCP established hash table entries: 131072 (order: 8, 1048576 bytes) TCP bind hash table entries: 65536 (order: 7, 524288 bytes) TCP: Hash tables configured (established 131072 bind 65536) TCP reno registered audit: initializing netlink socket (disabled) audit(1240316875.802:1): initialized highmem bounce pool size: 64 pages VFS: Disk quotas dquot_6.5.1 Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) Initializing Cryptographic API ksign: Installing public key data Loading keyring – Added public key D1F27370ACBC602E – User ID: CentOS (Kernel Module GPG key) io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered (default) pci_hotplug: PCI Hot Plug PCI Core version: 0.5 rtc: IRQ 8 is not free. Non-volatile memory driver v1.2 |
Linux agpgart interface v0.101 (c) Dave Jones RAMDISK driver initialized: 16 RAM disks of 16384K size 4096 blocksize Xen virtual console successfully installed as xvc0 Linux version 2.6.18-92.el5xen (mockbuild@builder16.centos.org) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Jun 10 19:55:54 EDT 2008 BIOS-provided physical RAM map: Xen: 0000000000000000 – 0000000040800000 (usable) 304MB HIGHMEM available. 727MB LOWMEM available. NX (Execute Disable) protection: active ACPI in unprivileged domain disabled Built 1 zonelists. Total pages: 264192 Kernel command line: method=ftp://10.20.6.2/centos52/ Enabling fast FPU save and restore… done. Enabling unmasked SIMD FPU exception support… done. Initializing CPU#0 CPU 0 irqstacks, hard=c073b000 soft=c071b000 PID hash table entries: 4096 (order: 12, 16384 bytes) Xen reported: 3000.106 MHz processor. Console: colour dummy device 80×25 Dentry cache hash table entries: 131072 (order: 7, 524288 bytes) Inode-cache hash table entries: 65536 (order: 6, 262144 bytes) Software IO TLB disabled vmalloc area: ee000000-f4ffe000, maxmem 2d7fe000 Memory: 1024936k/1056768k available (2098k kernel code, 22792k reserved, 867k data, 176k init, 311304k highmem) Checking if this processor honours the WP bit even in supervisor mode… Ok. Calibrating delay using timer specific routine.. 7503.83 BogoMIPS (lpj=15007676) Security Framework v1.0.0 initialized SELinux: Initializing. selinux_register_security: Registering secondary module capability Capability LSM initialized as secondary Mount-cache hash table entries: 512 CPU: Trace cache: 12K uops, L1 D cache: 16K CPU: L2 cache: 2048K Checking ‘hlt’ instruction… OK. SMP alternatives: switching to UP code CPU 1 irqstacks, hard=c073c000 soft=c071c000 Brought up 1 CPUs checking if image is initramfs… it is Freeing initrd memory: 7224k freed Grant table initialized NET: Registered protocol family 16 ACPI Exception (utmutex-0262): AE_BAD_PARAMETER, Thread C18F4AA0 could not acquire Mutex |
[2] [20060707] No dock devices found. ACPI Exception (utmutex-0262): AE_BAD_PARAMETER, Thread C18F4AA0 could not acquire Mutex [2] [20060707] No dock devices found. ACPI Exception (utmutex-0262): AE_BAD_PARAMETER, Thread C18F4AA0 could not acquire Mutex [2] [20060707] SMP alternatives: switching to SMP code Initializing CPU#1 migration_cost=1942 Brought up 2 CPUs PCI: Fatal: No PCI config space access function found PCI: setting up Xen PCI frontend stub ACPI: Interpreter disabled. Linux Plug and Play Support v0.97 (c) Adam Belay pnp: PnP ACPI: disabled xen_mem: Initialising balloon driver. usbcore: registered new driver usbfs usbcore: registered new driver hub PCI: System does not support PCI PCI: System does not support PCI NetLabel: Initializing NetLabel: domain hash size = 128 NetLabel: protocols = UNLABELED CIPSOv4 NetLabel: unlabeled traffic allowed by default NET: Registered protocol family 2 IP route cache hash table entries: 32768 (order: 5, 131072 bytes) TCP established hash table entries: 131072 (order: 8, 1048576 bytes) TCP bind hash table entries: 65536 (order: 7, 524288 bytes) TCP: Hash tables configured (established 131072 bind 65536) TCP reno registered audit: initializing netlink socket (disabled) audit(1240316875.802:1): initialized highmem bounce pool size: 64 pages VFS: Disk quotas dquot_6.5.1 Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) Initializing Cryptographic API ksign: Installing public key data Loading keyring – Added public key D1F27370ACBC602E – User ID: CentOS (Kernel Module GPG key) io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered |
io scheduler cfq registered (default) pci_hotplug: PCI Hot Plug PCI Core version: 0.5 rtc: IRQ 8 is not free. Non-volatile memory driver v1.2 Linux agpgart interface v0.101 (c) Dave Jones RAMDISK driver initialized: 16 RAM disks of 16384K size 4096 blocksize Xen virtual console successfully installed as xvc0 Event-channel device installed. Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2 ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx ide-floppy driver 0.99.newide usbcore: registered new driver hiddev usbcore: registered new driver usbhid drivers/usb/input/hid-core.c: v2.6:USB HID core driver PNP: No PS/2 controller found. Probing ports directly. i8042.c: No controller found. mice: PS/2 mouse device common for all mice md: md driver 0.90.3 MAX_MD_DEVS=256, MD_SB_DISKS=27 md: bitmap version 4.39 TCP bic registered Initializing IPsec netlink socket NET: Registered protocol family 1 NET: Registered protocol family 17 Using IPI No-Shortcut mode XENBUS: Device with no driver: device/vbd/51712 XENBUS: Device with no driver: device/vif/0 Freeing unused kernel memory: 176k freed Write protecting the kernel read-only data: 379k
Greetings. anaconda installer init version 11.1.2.113 starting mounting /proc filesystem… done creating /dev filesystem… done mounting /dev/pts (unix98 pty) filesystem… done mounting /sys filesystem… done anaconda installer init version 11.1.2.113 using /dev/xvc0 as console trying to remount root filesystem read write… done mounting /tmp as ramfs… done Welcome to CentOS |
+———+ Choose a Language +—————————+ | | | What language would you like to use | | during the installation process? | | | | Catalan ^ | | Chinese(Simplified) : | | Chinese(Traditional) # | | Croatian : | | Czech : | | Danish : | | Dutch : | | English v | | | | +—-+ | | | OK | | | +—-+ | | | | | +——————————————————————+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen #看见这个画面是否很熟悉?对了,我们已经开始安装CentOS了 running install… running /sbin/loader |
b) virt-install命令参数
出现上述画面,系统已经开始安装CentOS了,只需按照正常方式安装完毕就OK了。在安装的过程中我们来讲讲virt-install命令中的参数
-n billing #虚拟机的名称,这里我们的名称是billing
-r 1024 #虚拟机的内存,单位MB。这里我们的内存是1G
–vcpus=2 #虚拟机的CPU数量,这里我们的数量是2个
–file=master.img #虚拟机虚拟硬盘的名称,我们这里用master.img
–nographic #不适用图形界面。
-l ftp://10.20.6.2/centos52/ #系统的安装路径。Xen只支持FTP/HTTP/NFS,我们选择了FTP方式
四、 Xen虚拟机的操作
1. 虚拟机的配置文件
虚拟机配置文件在 vi /etc/xen/billing #billing为虚拟机域名,同时也是此虚拟机的配置文件
[root@localhost ~]# vi /etc/xen/billing
name = “billing” #虚拟机域名 uuid = “2e9c9c60-916e-3ff1-6000-06bfe56ae136” #序列号 maxmem = 1024 #虚拟机最大内存 memory = 1024 #虚拟机内存 vcpus = 2 #CPU数量 bootloader = “/usr/bin/pygrub” #虚拟机引导文件 on_poweroff = “destroy” on_reboot = “restart” on_crash = “restart” vfb = [ ] disk = [ “tap:aio:/opt/xen/test1/master.img,xvda,w” ] vif = [ “mac=00:16:3e:02:59:77,bridge=xenbr0” ] #虚拟网卡的参数
Type :quit<Enter> to exit Vim |
2. 查看状态
执行命令:xm list
[root@localhost ~]# xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 997 4 r—– 169.8 billing 4 1023 2 -b—- 14.6 [root@localhost ~]# |
我们可以看见有一个根域以及一个叫做billing的虚拟机正在运行
3. 启动虚拟机
执行命令:xm create billing #billing为虚拟机名
[root@localhost test1]# xm create billing Using config file “/etc/xen/billing”. Started domain billing [root@localhost test1]# |
4. 关闭虚拟机
执行命令:xm shutdown billing #billing为虚拟机名
[root@localhost test1]# xm shutdown billing [root@localhost test1]# |
5. 其他常用命令
xm console #使用文方式连接虚拟机
xm reboot #重新启动虚拟机
xm pause #暂停虚拟机
xm resume #恢复被暂停的虚拟机
文章来源:http://wenku.baidu.com/view/fc3c4b0e52ea551810a68727.html