centos6.7环境半虚拟化软件xen及xm配置工具使用详解
1、xen软件的安装及配置
环境准备:
①操作系统:centos6.7(注意最好使用centos6.7,centos6.5无法使用xen的图形化界面创建操作系统)
②调整虚拟机配置,内存4G(推荐2G以上)
③增加xen安装yum源(系统自带的源没有包括xen软件)
# cd /etc/yum.repos.d/
# vim xen4.repo
[xen4]
name=Xen4 Project
baseurl=http://mirrors.aliyun.com/centos/6.7/xen4/x86_64
enabled=1
gpgcheck=0
cost=300
# yum repolist
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
xen4 | 3.4 kB 00:00
xen4/primary_db | 166 kB 00:00
base | 2.9 kB 00:00
updates | 2.9 kB 00:00
repo id repo name status
xen4 Xen4 Project 263
base localyum 3,995
updates localyum 3,995
repolist: 8,253
安装xen虚拟机服务
# yum install -y xen
# vim /boot/grub/grub.conf
加入kernel /xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=2 dom0_vcpus_pin
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.18.21-16.el6.x86_64)
root (hd0,0)
kernel /xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=2 dom0_vcpus_pin
module /vmlinuz-3.18.21-16.el6.x86_64 ro root=/dev/mapper/vg_node4-root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_node4/root rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_node4/swap KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb
module /initramfs-3.18.21-16.el6.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/vg_node4-root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_node4/root rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_node4/swap KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-431.el6.x86_64.img
重新启动系统,启动xend服务,并验证服务是否正常启动
# service xend start
Starting xend daemon: [ OK ]
[root@node4 ~]# xm list
WARNING: xend/xm is deprecated.
Name ID Mem VCPUs State Time(s)
Domain-0 0 1024 2 r----- 58.5
[root@node4 ~]# xl list
Name ID Mem VCPUs State Time(s)
Domain-0 0 1024 2 r----- 58.7
[root@node4 ~]# xl info
host : node4.chinasoft.com
release : 3.18.21-16.el6.x86_64
version : #1 SMP Sat Sep 26 01:24:19 UTC 2015
machine : x86_64
nr_cpus : 4
max_cpu_id : 63
nr_nodes : 1
cores_per_socket : 2
threads_per_core : 1
cpu_mhz : 2099
hw_caps : 1fabfbff:28100800:00000000:00007f00:f6ba2223:00000000:00000001:00000281
virt_caps : hvm
total_memory : 4095
free_memory : 3022
sharing_freed_memory : 0
sharing_used_memory : 0
outstanding_claims : 0
free_cpus : 0
xen_major : 4
xen_minor : 4
xen_extra : .3-3.el6
xen_version : 4.4.3-3.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 : Wed Oct 21 16:18:30 2015 +0100 git:5418e02-dirty
xen_commandline : dom0_mem=1024M cpufreq=xen dom0_max_vcpus=2 dom0_vcpus_pin
cc_compiler : gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16)
cc_compile_by : mockbuild
cc_compile_domain : centos.org
cc_compile_date : Thu Oct 29 12:18:52 UTC 2015
xend_config_format : 4
[root@node4 ~]# xm info
WARNING: xend/xm is deprecated.
host : node4.chinasoft.com
release : 3.18.21-16.el6.x86_64
version : #1 SMP Sat Sep 26 01:24:19 UTC 2015
machine : x86_64
nr_cpus : 4
nr_nodes : 1
cores_per_socket : 2
threads_per_core : 1
cpu_mhz : 2099
hw_caps : 1fabfbff:28100800:00000000:00007f00:f6ba2223:00000000:00000001:00000281
virt_caps : hvm
total_memory : 4095
free_memory : 3022
free_cpus : 0
xen_major : 4
xen_minor : 4
xen_extra : .3-3.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 : Wed Oct 21 16:18:30 2015 +0100 git:5418e02-dirty
xen_commandline : dom0_mem=1024M cpufreq=xen dom0_max_vcpus=2 dom0_vcpus_pin
cc_compiler : gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16)
cc_compile_by : mockbuild
cc_compile_domain : centos.org
cc_compile_date : Thu Oct 29 12:18:52 UTC 2015
xend_config_format : 4
2、配置网络
安装桥接工具
# yum install -y bridge-utils
# cd /etc/sysconfig/network-scripts/
# cp ifcfg-eth0 ifcfg-br0
配置网桥设备
# cat ifcfg-br0
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPADDR=192.168.8.44
NETMASK=255.255.255.0
GATEWAY=192.168.8.254
DNS1=192.168.8.251
IPV6INIT=no
USERCTL=no
# cat ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
BRIDGE=br0
IPV6INIT=no
USERCTL=no
重启生效
# service network restart
# ifconfig
br0 Link encap:Ethernet HWaddr 00:0C:29:D7:3A:10
inet addr:192.168.8.44 Bcast:192.168.8.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fed7:3a10/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:520 errors:0 dropped:0 overruns:0 frame:0
TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:32011 (31.2 KiB) TX bytes:5460 (5.3 KiB) eth0 Link encap:Ethernet HWaddr 00:0C:29:D7:3A:10
inet6 addr: fe80::20c:29ff:fed7:3a10/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2198 errors:0 dropped:2 overruns:0 frame:0
TX packets:60 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:249888 (244.0 KiB) TX bytes:6922 (6.7 KiB) 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: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)
# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29d73a10 no eth0
# brctl stp br0 on
# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29d73a10 yes eth0
可以生成自动化脚本
#!/bin/bash
#
brctl addbr br0
ifconfig eth0 0 up
brctl addif br0 eth0
ifconfig br0 192.168.8.45/24 up
brctl stp br0 on
3、使用xm命令行工具配置添加虚拟机
获取linux启动文件
# lftp http://192.168.8.42/cobbler/ks_mirror/centos6.5-x86_64/isolinux/
> mget vmlinuz initrd.img
准备启动文件
# cd /etc/xen/
将xm样例1作为模板
# cp xmexample1 centos6
# vim centos6
kernel = "/root/vmlinuz"
ramdisk = "/root/initrd.img"
memory = 1024
name = "centos6"
vif = [ 'bridge=br0' ]
disk = [ 'file:/xen/vm1/centos6.img,xvda,w' ]
on_reboot = 'destroy'
on_crash = 'restart'
# mkdir /xen/vm1 -pv
# cd /xen/vm1 # dd if=/dev/zero of=centos6.img oflag=direct seek=102399 bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.00446458 s, 235 MB/s # ls -lh
total 1.0M
-rw-r--r-- 1 root root 100G May 1 00:46 centos6.img # cd /etc/xen
# xm create -c centos6
等安装完成后,在系统重启之前,将虚拟机配置/etc/xen/centos6修改为如下:
#kernel = "/root/vmlinuz"
#ramdisk = "/root/initrd.img"
bootloader = "/usr/bin/pygrub" # 使用pygrub引导系统启动:
memory = 1024
name = "centos6"
vif = [ 'bridge=br0' ]
disk = [ 'file:/xen/vm1/centos6.img,xvda,w' ]
on_reboot = 'destroy'
通过命令连接到虚拟机centos6:
# xm console centos6
# ifconfig查看IP
修改IP,重启网络服务报错:Bringing up interface eth0: Device eth0 has different MAC address than expected, ignoring.
# ifconfig eth0查看的硬件地址和ifcfg-eth0里面的硬件地址不一致,修改为一致即可
ctrl+]可以退出当前虚拟机,通过终端可以连接进入8.47
安装vnc软件
# yum install -y tigervnc-server
使用命令创建vnc链接,并设置密码
# vncserver :1
可以看到
# ss -tnlp
windows安装vnc客户端可以连接到Linux主机中
# vim centos67
kernel = "/root/vmlinuz"
ramdisk = "/root/initrd.img"
vcpus=2
memory = 512
name = "centos6.7"
vif = [ 'bridge=br0' ]
disk = [ 'file:/xen/vm2/centos67.img,xvda,w' ]
on_reboot = 'destroy'
kernel="/root/vmlinuz"
ramdisk="/root/initrd.img"
vcpus=2
memory=512
name="centos6.7"
vif=['bridge=br0']
disk = ['file:/xen/vm2/centos67.qcow2,xvda,w']
vfb=['vnc=1,vnclisten=0.0.0.0']
on_reboot = 'destroy'
#on_crash = 'restart'
# mkdir -pv /xen/vm2
# qemu-img create -f qcow2 -o ? /xen/vm2/centos67.qcow2
Supported options:
size Virtual disk size
backing_file File name of a base image
backing_fmt Image format of the base image
encryption Encrypt the image
cluster_size qcow2 cluster size
preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
# qemu-img create -f qcow2 -o size=80G,preallocation=metadata /xen/vm2/centos6.qcow2
Formatting '/xen/vm2/centos67.qcow2', fmt=qcow2 size=128849018880 encryption=off cluster_size=65536 preallocation='metadata'
[root@localhost xen]# ll -h /xen/vm2
total 19M
-rw-r--r-- 1 root root 121G May 17 10:23 centos67.qcow2
libvirt工具的使用
# yum install -y libvirt
# yum install -y virt-manager
# virt-manager &
报错:暂时无法找到解决方案
Unable to initialize GTK: could not open display
后面发现是xshell和xmanager环境的问题,重新安装即可
继续安装报错,估计是红帽对xen的支持不好,关于xen的研究和学习就告一段落:
Unable to complete install: 'internal error: unable to execute QEMU command 'qom-list': The command qom-list has not been found'
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 44, in cb_wrapper
callback(asyncjob, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/create.py", line 1928, in do_install
guest.start_install(False, meter=meter)
File "/usr/lib/python2.6/site-packages/virtinst/Guest.py", line 1229, in start_install
noboot)
File "/usr/lib/python2.6/site-packages/virtinst/Guest.py", line 1297, in _create_guest
dom = self.conn.createLinux(start_xml or final_xml, 0)
File "/usr/lib64/python2.6/site-packages/libvirt.py", line 3488, in createLinux
if ret is None:raise libvirtError('virDomainCreateLinux() failed', conn=self)
libvirtError: internal error: unable to execute QEMU command 'qom-list': The command qom-list has not been found
centos6.7环境半虚拟化软件xen及xm配置工具使用详解的更多相关文章
- java环境配置及原理详解
java环境配置及原理详解 1.java跨平台的本质 我们谈到java,总是提到跨平台这个词.那么java语言是怎么实现跨平台的呢? 我们编写的java代码不是直接让windows系统读取解析,而是在 ...
- centos6.7环境之kvm虚拟化quem工具配置及使用详解
环境准备 需要勾选CPU的虚拟化支持,支持cpu虚拟化的CPU列表: intel支持虚拟化技术CPU列表: Intel 6 Cores / 12 Threads CPU Number: Code Na ...
- rhel7配置tiger vnc详解 centos6配置安装vnc-server
参考网站:http://blog.51cto.com/xjsunjie/1963463 结合 https://blog.csdn.net/wamath/article/details/760 ...
- 【软件构造】(转)Git详解、常用操作与版本图
版本控制与Git 转自:http://www.cnblogs.com/angeldevil/p/3238470.html 版本控制 版本控制是什么已不用在说了,就是记录我们对文件.目录或工程等的修改历 ...
- 【转】apue《UNIX环境高级编程第三版》第一章答案详解
原文网址:http://blog.csdn.net/hubbybob1/article/details/40859835 大家好,从这周开始学习apue<UNIX环境高级编程第三版>,在此 ...
- FastDFS分布式文件系统&Nginx负载均衡最小环境安装配置[超级详解]
1.背景 FastDFS 是一款开源的.分布式文件系统(Distributed File System),由淘宝开发平台部资深架构师余庆开发.该开源项目的主页是 http://code.google. ...
- UNIX高级环境编程(14)文件IO - O_DIRECT和O_SYNC详解 < 海棠花溪 >
春天来了,除了工作学习,大家也要注意锻炼身体,多出去运动运动. 上周末在元大都遗址公园海棠花溪拍的海棠花. 进入正题. O_DIRECT和O_SYNC是系统调用open的flag参数.通过指定o ...
- 全网最详细的实用的搜索工具【堪称比Everything要好】Listary软件的下载与安装(图文详解)
不多说,直接上干货! 但是呢,作为博主的我而言,一般不用免费版,喜欢用专业版,具体原因,你懂得. 下载,得到 需要破解安装包的,进 对应本平台的讨论和答疑QQ群:大数据和人工智能躺过的坑(总群)(16 ...
- Android + Appium 自动化测试完整的环境配置及代码详解
环境的的搭建 参考大神博客:https://www.cnblogs.com/fnng/p/4540731.html 该博客有一套详细的入门教程,奈何时间有点久远有些东西不能用了,但是参考价值还是有滴. ...
随机推荐
- node.js安装后出现环境变量错误找不到node
安装node.js和bower之后,运行bower出现/usr/bin/env: 'node': No such file or directory错误 这个错误是由于安装完node.js环境变量并没 ...
- A1082. Read Number in Chinese
Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese ...
- 【模板】Trie
代码如下 int trie[maxn][26],tot=1,ed[maxn]; void insert(char *s){ int len=strlen(s+1),now=1; for(int i=1 ...
- qbxt的题:找一个三元环
有向图中找一个三元环 题意: 考虑 N 个人玩一个游戏, 任意两个人之间进行一场游戏 (共 N*(N-1)/2 场),且每场一定能分出胜负.现在,你需要在其中找到三个人构成的这样的局面:A战胜B,B战 ...
- C++11并发——多线程std::mutex (二)
https://www.cnblogs.com/haippy/p/3237213.html Mutex 又称互斥量,C++ 11中与 Mutex 相关的类(包括锁类型)和函数都声明在 <mute ...
- sizeof 与 字节对齐
转:http://baike.baidu.com/view/1356720.htm sizeof是运算符,可用于任何变量名.类型名或常量值,当用于变量名(不是数组名)或常量时,它不需要用圆括号. ...
- python爬虫 beutifulsoup4_1官网介绍
http://www.crummy.com/software/BeautifulSoup/bs4/doc/ Beautiful Soup Documentation Beautiful Soup is ...
- Web Scraping with Python
Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门 https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6E ...
- 关于连接linux被拒
一.scp被拒 在服务器A命令行使用scp往服务器B传输,如: scp -i id_rsa_125 file1 user01@IP:/home #ssh_exchange_identification ...
- python---RabbitMQ(4)exchange中模糊匹配topic
和关键字相似 生产者: # coding:utf8 # __author: Administrator # date: // # /usr/bin/env python import pika con ...