01 xen虚拟化技术基础
配置环境:
node1 192.168.1.61 CentOS6.6
[root@node1 ~]# uname -r
2.6.32-504.el6.x86_64
[root@node1 ~]# cd /etc/yum.repos.d/
[root@node1 yum.repos.d]# vim xen4.repo
[xen4centos]
name=Xen4 for CentOS 6
baseurl=ftp://192.168.56.2/xen4/x86_64/
gpgcheck=0
[root@node1 ~]# yum install xen
[root@node1 ~]# vim /etc/grub.conf
注:xen没有安装成功
02 xen虚拟化技术基础
注:本节测试没有成功
#创建磁盘映像文件
[root@localhost ~]# mkdir -p /p_w_picpaths/xen
[root@localhost ~]# qemu-img create -f raw -o size=2G /p_w_picpaths/xen/busybox.img
或
[root@localhost ~]# qemu-img create -f raw /p_w_picpaths/xen/busybox.img 2G
#对磁盘映像文件格式
[root@localhost ~]# mke2fs -t ext2 busybox.img
挂载磁盘映像
[root@localhost ~]# mount -o loop busybox.img /mnt
#编译busybox
[root@localhost ~]# yum groupinstall "Development Tools" "Server Platform Development"
[root@localhost ~]# yum -y install ncurses.x86_64
[root@localhost ~]# ls busybox-1.22.1.tar.bz2
busybox-1.22.1.tar.bz2
[root@localhost ~]# tar xf busybox-1.22.1.tar.bz2
[root@localhost ~]# cd busybox-1.22.1
[root@localhost busybox-1.22.1]# make menuconfig
[root@localhost busybox-1.22.1]# make
[root@localhost busybox-1.22.1]# make install
[root@localhost busybox-1.22.1]# cp -a install/* /mnt
[root@localhost busybox-1.22.1]# cd /mnt
[root@localhost mnt]# mkdir proc sys dev etc var boot home
[root@localhost mnt]# chroot /mnt /bin/sh
[root@localhost mnt]# cd /boot/
[root@localhost boot]# ln -s vmlinuz-2.6.32-504.el6.x86_64 vmlinuz
[root@localhost boot]# ln -s initramfs-2.6.32-504.el6.x86_64.img initramfs.img
[root@localhost boot]# cd /etc/xen
[root@localhost xen]# cp xlexample.pvlinux busybox
[root@localhost xen]# vim busybox
修改
name = "..."
为
name = "busybox-001"
修改
#ramdisk = "/boot/initrd.gz"
为
ramdisk = "/boot/initramfs.img"
修改
extra = "..."
为
extra = "selinux=0 init=/bin/sh"
修改
memory = 128
为
memory = 256
修改
disk = [ '/dev/vg/guest-volume,raw,xvda,rw' ]
为
disk = [ '/p_w_picpaths/xen/busybox.img,raw,xvda,rw' ]
添加
root = "/dev/xvda ro"
[root@localhost xen]# xl -v create busybox
#打开控制台:
[root@localhost xen]# xl console busybox-001
#设置网络
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-xenbr0
[root@localhost network-scripts]# vim ifcfg-eth0
删除IP、掩码、网关、DNS
修改
NM_CONTROLLED=yes
为
NM_CONTROLLED=no
添加
BRIDGE=xenbr0
[root@localhost network-scripts]# vim ifcfg-xenbr0
修改
DEVICE=eth0
为
DEVICE=xenbr0
修改
NM_CONTROLLED=yes
为
NM_CONTROLLED=no
修改
TYPE=Ethernet
为
TYPE=Bridge
删除UUID行
[root@localhost network-scripts]#service network restart
[root@localhost network-scripts]#service NetworkManager stop
[root@localhost network-scripts]#chkconfig NetworkManager off
[root@localhost ~]# ifconfig eth0 0
[root@localhost ~]# brctl addbr xenbr0
03 xen虚拟化技术进阶
结束至17:59(16357)