centos6.4 安装xen
时间:2015-03-09 01:18 来源:linux.it.net.cn 作者:IT
安装xen
yum install -y centos-release-xen xen
安装虚拟化管理工具
yum install libvirt python-virtinst libvirt-daemon-xen bridge-utils -y
重启,xen内核运行
虚拟机安装环境搭建:
1.配置桥接网络
[root@localhost xen]# cat xend-config.sxp |egrep -v '(^#|^\ *$)'
(xend-unix-server yes)
(xend-relocation-server no)
(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$')
(network-script /bin/true)
(vif-script vif-bridge)
(dom0-min-mem 256)
(enable-dom0-ballooning yes)
(total_available_memory 0)
(dom0-cpus 0)
(vncpasswd '')
修改为:
[root@localhost xen]# cat xend-config.sxp |egrep -v '(^#|^\ *$)'
(xend-unix-server yes)
(xend-relocation-server no)
(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$')
(network-script 'network-bridge bridge=xenbr1')
(network-script /bin/true)
(vif-script vif-bridge)
(dom0-min-mem 256)
(enable-dom0-ballooning yes)
(total_available_memory 0)
(dom0-cpus 0)
(vncpasswd '')
[root@localhost xen]#
2.设置服务器启动
chkconfig libvirtd on
chkconfig libvirt-guest on
chkconfig libvirt-guests on
3.重启后:
[root@localhost xen]# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:928 errors:0 dropped:0 overruns:0 frame:0
TX packets:928 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:36599055 (34.9 MiB) TX bytes:36599055 (34.9 MiB)
peth0 Link encap:Ethernet HWaddr 08:00:27:63:01:87
inet6 addr: fe80::a00:27ff:fe63:187/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11196 errors:0 dropped:0 overruns:0 frame:0
TX packets:6741 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9413252 (8.9 MiB) TX bytes:851189 (831.2 KiB)
vif2.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF
inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:25 errors:0 dropped:0 overruns:0 frame:0
TX packets:255 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:32
RX bytes:1028 (1.0 KiB) TX bytes:19605 (19.1 KiB)
virbr0 Link encap:Ethernet HWaddr A2:81:98:EC:A4:44
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
xenbr1 Link encap:Ethernet HWaddr 08:00:27:63:01:87
inet addr:192.168.16.253 Bcast:0.0.0.0 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe63:187/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:25135 errors:0 dropped:0 overruns:0 frame:0
TX packets:26826 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:9837395 (9.3 MiB) TX bytes:305790710 (291.6 MiB)
4.安装httpd,并且把镜像放到html下
yum install httpd
mkdir /var/www/html/iso
mount /dev/cdrom1 /var/www/html/iso/
service iptables stop
service httpd start
mkdir /xen
virt-install -n zyt_vm01 -r 512 --disk path=/xen/zyt_vm01.img,size=6 -l http://192.168.16.253/iso
cp一个虚拟机:
1.创建一个xen虚拟机配置文件
[root@localhost xen]# cat xmexample1|egrep -v '(^#|^\ *$)'
kernel = "/boot/vmlinuz-2.6.10-xenU"
memory = 64
name = "ExampleDomain"
vif = [ '' ]
disk = [ 'phy:hda1,hda1,w' ]
root = "/dev/hda1 ro"
extra = "4"
[root@localhost xen]# cat xmexample1|egrep -v '(^#|^\ *$)'>zyt_vm02
[root@localhost xen]# vi zyt_vm02
[root@localhost xen]# cat zyt_vm02
#kernel = "/boot/vmlinuz-2.6.10-xenU"
memory = 512
name = "zyt_vm02"
vif = [ 'bridge=xenbr1' ]
disk = [ 'file:/xen/zyt_vm02.img,xvda,w' ]
#root = "/dev/hda1 ro"
#extra = "4"
[root@localhost xen]#
2.cp镜像
[root@localhost ~]# cd /xen/
[root@localhost xen]# ll
total 1516148
-rwxr-xr-x. 1 root root 6442450944 Mar 6 05:01 zyt_vm01.img
[root@localhost xen]# cp zyt_vm01.img zyt_vm02.img
[root@localhost xen]#
3.启动新的虚拟机
xm create -c zyt_vm02
4.进入后修改mac地址,主机名
(责任编辑:IT)
安装xen yum install -y centos-release-xen xen 安装虚拟化管理工具 yum install libvirt python-virtinst libvirt-daemon-xen bridge-utils -y 重启,xen内核运行 虚拟机安装环境搭建: 1.配置桥接网络 [root@localhost xen]# cat xend-config.sxp |egrep -v '(^#|^\ *$)' (xend-unix-server yes) (xend-relocation-server no) (xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$') (network-script /bin/true) (vif-script vif-bridge) (dom0-min-mem 256) (enable-dom0-ballooning yes) (total_available_memory 0) (dom0-cpus 0) (vncpasswd '') 修改为: [root@localhost xen]# cat xend-config.sxp |egrep -v '(^#|^\ *$)' (xend-unix-server yes) (xend-relocation-server no) (xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$') (network-script 'network-bridge bridge=xenbr1') (network-script /bin/true) (vif-script vif-bridge) (dom0-min-mem 256) (enable-dom0-ballooning yes) (total_available_memory 0) (dom0-cpus 0) (vncpasswd '') [root@localhost xen]# 2.设置服务器启动 chkconfig libvirtd on chkconfig libvirt-guest on chkconfig libvirt-guests on 3.重启后: [root@localhost xen]# ifconfig lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:928 errors:0 dropped:0 overruns:0 frame:0 TX packets:928 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:36599055 (34.9 MiB) TX bytes:36599055 (34.9 MiB) peth0 Link encap:Ethernet HWaddr 08:00:27:63:01:87 inet6 addr: fe80::a00:27ff:fe63:187/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:11196 errors:0 dropped:0 overruns:0 frame:0 TX packets:6741 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:9413252 (8.9 MiB) TX bytes:851189 (831.2 KiB) vif2.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:25 errors:0 dropped:0 overruns:0 frame:0 TX packets:255 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:32 RX bytes:1028 (1.0 KiB) TX bytes:19605 (19.1 KiB) virbr0 Link encap:Ethernet HWaddr A2:81:98:EC:A4:44 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) xenbr1 Link encap:Ethernet HWaddr 08:00:27:63:01:87 inet addr:192.168.16.253 Bcast:0.0.0.0 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe63:187/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:25135 errors:0 dropped:0 overruns:0 frame:0 TX packets:26826 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:9837395 (9.3 MiB) TX bytes:305790710 (291.6 MiB) 4.安装httpd,并且把镜像放到html下 yum install httpd mkdir /var/www/html/iso mount /dev/cdrom1 /var/www/html/iso/ service iptables stop service httpd start mkdir /xen virt-install -n zyt_vm01 -r 512 --disk path=/xen/zyt_vm01.img,size=6 -l http://192.168.16.253/iso cp一个虚拟机: 1.创建一个xen虚拟机配置文件 [root@localhost xen]# cat xmexample1|egrep -v '(^#|^\ *$)' kernel = "/boot/vmlinuz-2.6.10-xenU" memory = 64 name = "ExampleDomain" vif = [ '' ] disk = [ 'phy:hda1,hda1,w' ] root = "/dev/hda1 ro" extra = "4" [root@localhost xen]# cat xmexample1|egrep -v '(^#|^\ *$)'>zyt_vm02 [root@localhost xen]# vi zyt_vm02 [root@localhost xen]# cat zyt_vm02 #kernel = "/boot/vmlinuz-2.6.10-xenU" memory = 512 name = "zyt_vm02" vif = [ 'bridge=xenbr1' ] disk = [ 'file:/xen/zyt_vm02.img,xvda,w' ] #root = "/dev/hda1 ro" #extra = "4" [root@localhost xen]# 2.cp镜像 [root@localhost ~]# cd /xen/ [root@localhost xen]# ll total 1516148 -rwxr-xr-x. 1 root root 6442450944 Mar 6 05:01 zyt_vm01.img [root@localhost xen]# cp zyt_vm01.img zyt_vm02.img [root@localhost xen]# 3.启动新的虚拟机 xm create -c zyt_vm02 4.进入后修改mac地址,主机名 (责任编辑:IT) |