How to install Xen4.2 in Centos6.5
This article is to share with you about how to install Xen4.2 in Centos6.5, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
[root@localhost] # cat / etc/redhat-release CentOS release 6.5 (Final)
Install xen
[root@localhost ~] # yum install centos-release-xen.x86_64 configure xen's yum repository [root@localhost ~] # yum install xen-y [root@localhost ~] # yum install kernel-xen [root@localhost ~] # yum install bridge-utils
Execution
[root@localhost yum.repos.d] # / usr/bin/grub-bootxen.sh
View grub.conf
[root@localhost yum.repos.d] # cat / etc/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/mapper/vol0-root# initrd / initrd- [generic-] version.img#boot=/dev/sdadefault=0timeout=5splashimage= (hd0,0) / grub/splash.xpm.gzhiddenmenutitle CentOS (3.10.55-11.el6.centos.alt.x86_64) root (hd0,0) kernel / xen.gz dom0_mem=1024M Max:1024M loglvl=all guest_loglvl=all module / vmlinuz-3.10.55-11.el6.centos.alt.x86_64 ro root=/dev/mapper/vol0-root rd_NO_LUKS rd_LVM_LV=vol0/root rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet module / initramfs-3.10.55-11.el6.centos.alt.x86_64.imgtitle CentOS (2.6.32-431.el6.x86_64) Root (hd0,0) kernel / vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/vol0-root rd_NO_LUKS rd_LVM_LV=vol0/root rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet initrd / initramfs-2.6.32-431.el6.x86_64.img
Set xend to boot automatically
[root@localhost yum.repos.d] # chkconfig xend on
Restart
After rebooting the system, you should enter the Xen kernel by default. You can confirm whether the installation is successful by uname-r and xm info:
[root@localhost ~] # cd / proc/xen/ [root@localhost xen] # lscapabilities privcmd xenbus xsd_kva xsd_ port [root @ localhost xen] # cat capabilities control_d see if there is a keyword to start Xend [root @ localhost xen] # / etc/init.d/xend start to start the xend daemon: [OK] [root] # chkconfig xend on
# reboot [root@kcw Desktop] # uname-r3.10.55-11.el6.centos.alt.x86_64 [root@kcw Desktop] # xm infohost: kcwrelease: 3.10.55-11.el6.centos.alt.x86_64version: # 1 SMP Fri Sep 26 19:08:24 UTC 2014machine: x86_64nr_cpus : 4nr_nodes: 1cores_per_socket: 4threads_per_core: 1cpu_mhz: 3093hw_caps: bfebfbff:28100800:00000000:00003f40:17bae3ff:00000000:00000001:00000000virt_caps: hvm hvm_directiototal_memory: 4069free_memory: 2983free_cpus: 0xen_major : 4xen_minor: 2xen_extra: .5-34.el6xen_caps: xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64 xen_scheduler: creditxen_pagesize: 4096platform_params: virt_start=0xffff800000000000xen_changeset : unavailablexen_commandline: dom0_mem=1024M Max:1024M loglvl=all guest_loglvl=allcc_compiler: gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4) cc_compile_by: mockbuildcc_compile_domain: centos.orgcc_compile_date: Fri Sep 26 17:27:55 CDT 2014xend_config_format: 4
Xen is special. There must be a host management hardware called Domain-0 in Xen.
[root@kcw Desktop] # xm listName ID Mem VCPUs State Time (s) Domain-0 0 1024 4 r-160.8 ID the number of virtual cpu in memory r indicates the running time of running
Create a virtual machine first create a virtual disk image
There are many tools to create a virtual machine, such as virt-manager, virt-install, virsh, xen-create-image and so on, but these tools have to reinstall the operating system of the virtual machine every time, which requires human-computer interaction, slow speed, not automatic, and is not conducive to scripting. Is there any quick way to create / deploy / clone virtual machines? You can make a template first, and then copy the template. We only need two steps: 1, create a blank file image; 2, and then copy a packaged Linux system template. Usually, as long as a packaged minimum Linux system is about 200MB, copying can be done in an instant on a highly configured server, which is much faster than copying the entire virtual machine image file (such as 10GB). Specific steps:
I use virt-install to create a virtual machine here.
Create a virtual disk
Dd if=/dev/zero of=/home/vm01 bs=4096 seek=1024k count=0 mkfs-t ext4 / home/vm01/etc/init.d/iptables stop [root@localhost ~] # mount-o loop CentOS-6.5-x86_64-bin-DVD1.iso / tmp/os/ first copy the CD file to the physical machine and hang it on the [root@localhost ~] # cat / etc/exports nfs output / tmp/os 192.168.1.* (ro) [root@localhost ~] # exportfs -rvexporting 192.168.1.*:/tmp/os
Install a virtual machine
Virt-install-name=domadin01-ram=512-vcpus=2-graphics none-file=/home/vm01-location / tmp/os/-graphics none does not use a graphical interface
Enter as follows
Welcome to CentOS for x86 through 64 ┌─┤ Choose a Language ├─┐ │ What language would you like to use │ │ during the installation process? │ │ │ │ Catalan ↑ │ │ Chinese (Simplified) ▒ │ │ Chinese (Traditional) ▮ │ │ Croatian ▒ │ │ Czech ▒ │ │ Danish ▒ │ │ Dutch ▒ │ │ English ↓ │ ┌────┐ │ OK │ └────┘ │ └──┘
Create a bridged network
[root@kcw ~] # rpm-qf / usr/sbin/brctl bridge-utils-1.2-10.el6.x86_64 [root@kcw network-scripts] # cat ifcfg-br0 # DEVICE=br0TYPE=BridgeBOOTPROTO=dhcpONBOOT=yes#IPADDR=192.168.0.222#PREFIX=24#GATEWAY=192.168.0.1#DNS1=192.168.0.1#DNS2=61.134.1.4#DEFROUTE=yes## # [root@kcw network-scripts] # cat ifcfg-eth0 DEVICE=eth0TYPE=EthernetBOOTPROTO=noneONBOOT=yesBRIDGE=br0### [root@kcw network-scripts] # / etc/init.d/network restar# [root@kcw network-scripts] # ifconfig br0 Link encap: Ethernet HWaddr 78:24:AF:45:1C:7E inet addr:192.168.0.100 Bcast:255.255.255.255 Mask:255.255.255.0 inet6 addr: fe80::7a24:afff:fe45:1c7e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2399 errors:0 dropped:0 overruns:0 frame:0 TX packets:1934 errors:0 dropped:0 overruns:0 carrier : 0 collisions:0 txqueuelen:0 RX bytes:1303859 (1.2 MiB) TX bytes:232667 (227.2 KiB) eth0 Link encap:Ethernet HWaddr 78:24:AF:45:1C:7E inet6 addr: fe80::7a24:afff:fe45:1c7e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8629 errors:0 dropped:3 overruns:0 frame:0 TX packets : 3422 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2094791 (1.9 MiB) TX bytes:336619 (328.7 KiB)
Set up ftp server installation
[root@e3 ~] # yum install vsftpd # install ftp [root @ E3 ~] # / etc/init.d/vsftpd # launch ftp [root@e3 ~] # chkconfig vsftpd on # Boot self-start [root@e3 tmp] # wget http://mirrors.sohu.com/centos/6/isos/x86_64/CentOS-6.6-x86_64-minimal.iso # download Centos6.6 MINI installation disk [root@e3 tmp] # mkdir / mnt/cdrom/ [root@e3 tmp ] # mount CentOS-6.6-x86_64-minimal.iso / mnt/cdrom/ # Mount [root@e3 tmp] # cp-r / mnt/cdrom/ var/ftp/ [root@e3 tmp] # cd / root/centos/cdrom/ [root@e3 cdrom] # vim .treeinfo # modify [general] family = CentOStimestamp = 1414159790.06variant = totaldiscs = 1version = 6.6discnum = 1packagedir = arch = x86room64 [images-xen] kernel = isolinux/vmlinuzinitrd = isolinux/initrd.img [images-x86_ 64] initrd = images/pxeboot/ initrd.IMG [stage 2] mainimage = images/install.img# forced save when finished: wq! Then restart your vftpd. Test: see if you can access
Start installation
Virt-install-n vm01-r 512-vcpus=2-- disk / data/vm01.img,size=10-- nographics-p-l "ftp://192.168.0.244/CentOS6.6/"-w bridge:br0-- extra-args=" text console=com1 utf8 console=hvc0 "
-n represents the guest machine name
-r indicates the amount of memory allocated
-- vcpus represents several virtual CPU
-- disk disk path
-p paravirtualization
-l specify the installation source
-vnc uses vnc
-c specify cdrom
-s-- file-size specifies the disk size in GB
-f-- file specifies that the disk uses file
-- disk= specifies different disk files
For the installation process, refer to this blog post http://my.oschina.net/kcw/blog/369627
[root@kcw] # xm listName ID Mem VCPUs State Time (s) Domain-0 0 2048 4 r-10258.8vm01 9 512 2-b Murmuri-9.3 [root@kcw] # xm console vm01
Virtual machines installed with virt-install-promat need to have vnc-vncview installed
If you can't connect with xm console centos after installation, you need to add a parameter to the kernel-- console=hvc0.
The above is how to install Xen4.2 in Centos6.5. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.