溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

Centos6.5中怎么安裝 Xen4.2

發(fā)布時(shí)間:2021-07-12 14:48:33 來(lái)源:億速云 閱讀:156 作者:Leah 欄目:云計(jì)算

本篇文章給大家分享的是有關(guān)Centos6.5中怎么安裝 Xen4.2,小編覺(jué)得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話(huà)不多說(shuō),跟著小編一起來(lái)看看吧。

[root@localhost ~]# cat /etc/redhat-release 
CentOS release 6.5 (Final)

安裝xen

[root@localhost ~]# yum install centos-release-xen.x86_64 配置xen的yum倉(cāng)庫(kù)
[root@localhost ~]# yum install xen -y
[root@localhost ~]# yum install kernel-xen
[root@localhost ~]# yum install bridge-utils

執(zhí)行

[root@localhost yum.repos.d]# /usr/bin/grub-bootxen.sh

查看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/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title 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.img
title 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

設(shè)置xend開(kāi)機(jī)自動(dòng)啟動(dòng)

[root@localhost yum.repos.d]# chkconfig xend on



重啟

重啟系統(tǒng)后,默認(rèn)應(yīng)該進(jìn)入 Xen 內(nèi)核,可以通過(guò) uname -r 和 xm info 確認(rèn)是否安裝成功:

[root@localhost ~]# cd  /proc/xen/
[root@localhost xen]# ls
capabilities  privcmd  xenbus  xsd_kva  xsd_port
[root@localhost xen]# cat capabilities 
control_d                       看有沒(méi)有關(guān)鍵字出現(xiàn)
啟動(dòng)xend
[root@localhost xen]# /etc/init.d/xend start
啟動(dòng) xend 守護(hù)進(jìn)程:                                       [確定]
[root@localhost xen]# chkconfig xend on



#reboot
[root@kcw 桌面]# uname -r
3.10.55-11.el6.centos.alt.x86_64
[root@kcw 桌面]# xm info
host                   : kcw
release                : 3.10.55-11.el6.centos.alt.x86_64
version                : #1 SMP Fri Sep 26 19:08:24 UTC 2014
machine                : x86_64
nr_cpus                : 4
nr_nodes               : 1
cores_per_socket       : 4
threads_per_core       : 1
cpu_mhz                : 3093
hw_caps                : bfebfbff:28100800:00000000:00003f40:17bae3ff:00000000:00000001:00000000
virt_caps              : hvm hvm_directio
total_memory           : 4069
free_memory            : 2983
free_cpus              : 0
xen_major              : 4
xen_minor              : 2
xen_extra              : .5-34.el6
xen_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          : credit
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : unavailable
xen_commandline        : dom0_mem=1024M,max:1024M loglvl=all guest_loglvl=all
cc_compiler            : gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
cc_compile_by          : mockbuild
cc_compile_domain      : centos.org
cc_compile_date        : Fri Sep 26 17:27:55 CDT 2014
xend_config_format     : 4

Xen比較特殊必須有一個(gè)主機(jī)管理硬件Xen里叫Domain-0

[root@kcw 桌面]# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  1024     4     r-----    160.8
                                            ID號(hào) 內(nèi)存    虛擬cpu個(gè)數(shù)  r表示running  運(yùn)行時(shí)間

 
創(chuàng)建虛擬機(jī)先創(chuàng)建虛擬磁盤(pán)鏡像

創(chuàng)建虛擬機(jī)的工具有很多,比如 virt-manager, virt-install, virsh, xen-create-image 等等,不過(guò)這些工具都要每次重頭安裝虛擬機(jī)的操作系統(tǒng),需要人機(jī)交互、速度慢、不自動(dòng),不利于寫(xiě)成腳本。有什么快速的創(chuàng)建/部署/克隆虛擬機(jī)的辦法呢?可 以先做一個(gè)模版,然后通過(guò)拷貝模版的辦法。我們只需要兩個(gè)步驟:1、創(chuàng)建一個(gè)空白文件鏡像;2、然后把一個(gè)打包好的 Linux 系統(tǒng)模版拷貝過(guò)去。通常一個(gè)打包好的最小 Linux 系統(tǒng)只要200MB 左右,在高配置的服務(wù)器上拷貝基本能瞬間完成,比起拷貝整個(gè)虛擬機(jī)鏡像文件(比如 10GB)要快得多。具體步驟:

我這里用virt-install 創(chuàng)建一個(gè)虛擬機(jī)

創(chuàng)建虛擬磁盤(pán)

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/  首先要把光盤(pán)文件復(fù)制到物理機(jī)上在掛在
[root@localhost ~]# cat /etc/exports  nfs輸出
/tmp/os     192.168.1.*(ro)
[root@localhost ~]# exportfs -rv
exporting 192.168.1.*:/tmp/os

安裝虛擬機(jī)

virt-install  --name=domadin01 --ram=512 --vcpus=2 --graphics none  --file=/home/vm01  --location /tmp/os/
 --graphics none不使用圖形界面

回車(chē)后如下

Welcome to CentOS for x86_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 │                │
                    │               └────┘                │
                    │                                     │
                    │                                     │
                    └─────────────────────────────────────┘

創(chuàng)建橋接網(wǎng)絡(luò)

[root@kcw ~]# rpm -qf /usr/sbin/brctl 
bridge-utils-1.2-10.el6.x86_64
[root@kcw network-scripts]# cat ifcfg-br0  ####
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=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=eth0
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
BRIDGE=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)


搭建ftp服務(wù)器安裝

[root@e3 ~]# yum install vsftpd #安裝ftp
[root@e3 ~]# /etc/init.d/vsftpd #啟動(dòng)ftp
 [root@e3 ~]# chkconfig vsftpd  on #開(kāi)機(jī)自啟動(dòng)
[root@e3 tmp]#wget http://mirrors.sohu.com/centos/6/isos/x86_64/CentOS-6.6-x86_64-minimal.iso  #下載Centos6.6 MINI安裝盤(pán)
[root@e3 tmp]# mkdir /mnt/cdrom/
[root@e3 tmp]# mount CentOS-6.6-x86_64-minimal.iso /mnt/cdrom/ #掛載
[root@e3 tmp]# cp -r /mnt/cdrom /var/ftp/ 
[root@e3 tmp]# cd /root/centos/cdrom/
[root@e3 cdrom]# vim .treeinfo
#修改如下
[general]
family = CentOS
timestamp = 1414159790.06
variant =
totaldiscs = 1
version = 6.6
discnum = 1
packagedir =
arch = x86_64

[images-xen]
kernel = isolinux/vmlinuz
initrd = isolinux/initrd.img


[images-x86_64]
initrd = images/pxeboot/initrd.img

[stage2]
mainimage = images/install.img
#完了保存的時(shí)候強(qiáng)制保存 :wq!
然后重啟你的vftpd。
測(cè)試:看能不能訪(fǎng)問(wèn)

Centos6.5中怎么安裝 Xen4.2

開(kāi)始安裝

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 表示guest機(jī)器名字

-r 表示分配內(nèi)存大小

--vcpus 表示虛擬幾顆CPU

--disk 磁盤(pán)路徑

-p 半虛擬化

-l 指定安裝源

-vnc 使用vnc

-c 指定cdrom

-s --file-size 指定磁盤(pán)大小,單位GB

-f  --file 指定磁盤(pán)使用file

--disk=  指定不同的磁盤(pán)文件

安裝過(guò)程參考這篇博文http://my.oschina.net/kcw/blog/369627

[root@kcw ~]# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  2048     4     r-----  10258.8
vm01                                         9   512     2     -b----      9.3
[root@kcw ~]# xm console vm01

用virt-install --promat 安裝的虛擬機(jī)需要安裝 vnc-vncview

裝完后用xm console centos 不能連接需要在內(nèi)核加參數(shù) --console=hvc0

以上就是Centos6.5中怎么安裝 Xen4.2,小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見(jiàn)到或用到的。希望你能通過(guò)這篇文章學(xué)到更多知識(shí)。更多詳情敬請(qǐng)關(guān)注億速云行業(yè)資訊頻道。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI