本帖最后由 nettman 于 2014-8-18 09:05 编辑
问题导读: 1.OpenStack 虚拟机状态故障处理,虚拟机状态error该如何解决? 2.Icehouse默认生成的libvirt.xml并没有USB重定向的支持,该如何解决? 3.Bios未打开,openstack会报什么错误? 4.Openstack Dashboard如何汉化?
OpenStack 虚拟机状态故障处理,虚拟机状态error等
在日常管理中,经常出现比如物理机故障,Quantum或者Nova服务Down等等各种原因导致虚拟机状态,要么Error。要么处于一直Hard Reboot。或者Softe Reboot的状态,这个时候就要借助于Nova命令来解决了。
1.首先重置虚拟机状态,后面可以使用虚拟机名称或者ID。
nova reset-state06d9d410-bd60-439d-8427-***********
2.停机虚拟机
nova stop 06d9d410-bd60-439d-8427-***********
3.启动虚拟机
nova start06d9d410-bd60-439d-8427-***********
这样虚拟机状态就恢复正常了,但是这个只是临时解决办法,操作的时候还是要分析日志,查找问题的根源,彻底解决。
Openstack Spice USB重定向
目前Openstack最新版本Icehouse默认生成的libvirt.xml并没有USB重定向的支持,对于用Openstack做桌面虚拟化的用户来说很苦恼。不过在网上看到已经有人开始开发了,估计下一个小版本更新会加入。那现在怎么办呢。有两种方法:
方法一:修改源码。为什么要修改源码呢,因为Openstack在创建虚拟机或者软重启或者硬重启虚拟机时,每个虚拟机的libvirt.xml是动态生成的。源码文件为:
/usr/lib/python2.6/site-packages/nova/virt/libvirt/config.py /usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py
如果你不修改源码,无论做什么修改,都是临时的。
方法二:临时修改libvirt.xml
注意虚拟机软重启或者硬重启后都会消失,就看你怎么用别的技巧来保证了。
1.在<device>..</device>之间加入以下内容:
<controllertype='usb' index='0' model='ich9-ehci1'> <alias name='usb0'/> <addresstype='pci' domain='0x0000' bus='0x00'slot='0x09' function='0x7'/> </controller> <controller type='usb' index='0' model='ich9-uhci1'> <alias name='usb0'/> <master startport='0'/> <addresstype='pci' domain='0x0000' bus='0x00'slot='0x09' function='0x0' multifunction='on'/> </controller> <controller type='usb' index='0' model='ich9-uhci2'> <alias name='usb0'/> <master startport='2'/> <addresstype='pci' domain='0x0000' bus='0x00'slot='0x09' function='0x1'/> </controller> <controller type='usb' index='0' model='ich9-uhci3'> <alias name='usb0'/> <master startport='4'/> <addresstype='pci' domain='0x0000' bus='0x00'slot='0x09' function='0x2'/> </controller> <redirdevbus='usb' type='spicevmc'> <alias name='redir0'/> <addresstype='usb' bus='0' port='4'/> </redirdev> <redirdevbus='usb' type='spicevmc'> <alias name='redir1'/> <addresstype='usb' bus='0' port='5'/> </redirdev> <redirdevbus='usb' type='spicevmc'> <alias name='redir2'/> <addresstype='usb' bus='0' port='6'/> </redirdev> <redirdevbus='usb' type='spicevmc'> <alias name='redir3'/> <addresstype='usb' bus='0' port='3'/> </redirdev>
2. virsh undefinevmname
3.virsh define/path/libvirt.xml
4.virsh shutdownvmname
5.virsh startvmname
OK,可以用你的瘦客户机进行测试了。近期已经完成了基于Openstack的桌面虚拟化,使用的Redhat的Spice协议,日常办公是没有问题的哦。
Openstack 报错libvirtError: internal error no supported architecture for os...
Error: ['Traceback (most recent calllast):\n', ' File"/usr/lib/python2.6/site-packages/nova-2013.1.2-py2.6.egg/nova/compute/manager.py",line 848, in _run_instance\n set_access_ip=set_access_ip)\n', ' File "/usr/lib/python2.6/site-packages/nova-2013.1.2-py2.6.egg/nova/compute/manager.py",line 1107, in _spawn\n LOG.exception(_(\'Instance failed to spawn\'), instance=instance)\n',' File"/usr/lib64/python2.6/contextlib.py", line 23, in __exit__\n self.gen.next()\n', ' File"/usr/lib/python2.6/site-packages/nova-2013.1.2-py2.6.egg/nova/compute/manager.py",line 1103, in _spawn\n block_device_info)\n',' File"/usr/lib/python2.6/site-packages/nova-2013.1.2-py2.6.egg/nova/virt/libvirt/driver.py",line 1528, in spawn\n block_device_info)\n', ' File"/usr/lib/python2.6/site-packages/nova-2013.1.2-py2.6.egg/nova/virt/libvirt/driver.py",line 2444, in _create_domain_and_network\n domain = self._create_domain(xml, instance=instance)\n', ' File"/usr/lib/python2.6/site-packages/nova-2013.1.2-py2.6.egg/nova/virt/libvirt/driver.py",line 2404, in _create_domain\n domain= self._conn.defineXML(xml)\n', ' File"/usr/lib/python2.6/site-packages/eventlet/tpool.py", line 179, indoit\n result =proxy_call(self._autowrap, f, *args, **kwargs)\n', ' File"/usr/lib/python2.6/site-packages/eventlet/tpool.py", line 139, inproxy_call\n rv =execute(f,*args,**kwargs)\n', ' File"/usr/lib/python2.6/site-packages/eventlet/tpool.py", line 77, intworker\n rv =meth(*args,**kwargs)\n', ' File"/usr/lib64/python2.6/site-packages/libvirt.py", line 2660, indefineXML\n if ret is None:raiselibvirtError(\'virDomainDefineXML() failed\', conn=self)\n',"libvirtError: internal error no supported architecture for os type'hvm'\n"]
如果创建虚拟机nova.log报以上异常,很可能是物理机CPU虚拟化的支持没有打开,请从Bios打开即可。
Openstack Dashboard自定义汉化
很多朋友看到别人的Dashboard界面和自己的不一样,都想修改。openstack的dashboard在语言设置栏里有多种语言可选,虽然有简体中文选项,但是它的汉化基本没有完成。那就让我们自己来修改吧。
openstack的dashboard采用的是django架构,django 国际化的本质就是开发者对需要翻译的字符串进行标记,并对字符串进行相应的翻译。所以我们自己给自定义一下就完成了翻译了。
第一步:找到语言包。
/var/www/horizon-2013.1.1/openstack_dashboard/locale/zh_CN/LC_MESSAGES
-rw-rw-r-- 1apache apache 1553 May 10 07:08django.mo -rw-rw-r-- 1apache apache 150991 May 10 07:08 django.po
第二步:编辑django.po
Like This:
msgid"Network Topology" msgstr "网络架构"
第三步:生成django.mo文件
msgfmt--statistics --verbose -o django.mo django.po
第四步:重启Apache。
下面就可以欣赏自己的杰作了。
OpenstacklibvirtError: Unable to readfrom monitor: Connection reset by peer ...
Error: ['Traceback(most recent call last):\n', ' File"/usr/lib/python2.6/site-packages/nova-2013.1.2-py2.6.egg/nova/compute/manager.py",line 848, in _run_instance\n set_access_ip=set_access_ip)\n', ' File"/usr/lib/python2.6/site-packages/nova-2013.1.2-py2.6.egg/nova/compute/manager.py",line 1107, in _spawn\n LOG.exception(_(\'Instance failed to spawn\'), instance=instance)\n',' File"/usr/lib64/python2.6/contextlib.py", line 23, in __exit__\n self.gen.next()\n', ' File "/usr/lib/python2.6/site-packages/nova-2013.1.2-py2.6.egg/nova/compute/manager.py",line 1103, in _spawn\n block_device_info)\n', ' File"/usr/lib/python2.6/site-packages/nova-2013.1.2-py2.6.egg/nova/virt/libvirt/driver.py",line 1528, in spawn\n block_device_info)\n', ' File"/usr/lib/python2.6/site-packages/nova-2013.1.2-py2.6.egg/nova/virt/libvirt/driver.py",line 2444, in _create_domain_and_network\n domain = self._create_domain(xml, instance=instance)\n', ' File"/usr/lib/python2.6/site-packages/nova-2013.1.2-py2.6.egg/nova/virt/libvirt/driver.py",line 2405, in _create_domain\n domain.createWithFlags(launch_flags)\n', ' File "/usr/lib/python2.6/site-packages/eventlet/tpool.py",line 179, in doit\n result =proxy_call(self._autowrap, f, *args, **kwargs)\n', ' File "/usr/lib/python2.6/site-packages/eventlet/tpool.py",line 139, in proxy_call\n rv =execute(f,*args,**kwargs)\n', ' File"/usr/lib/python2.6/site-packages/eventlet/tpool.py", line 77, intworker\n rv =meth(*args,**kwargs)\n', ' File"/usr/lib64/python2.6/site-packages/libvirt.py", line 708, increateWithFlags\n if ret == -1: raiselibvirtError (\'virDomainCreateWithFlags() failed\', dom=self)\n','libvirtError: Unable to read from monitor: Connection reset by peer\n']
libvirtError:Unable to read from monitor: Connection reset by peer
出现两种错误,请检查vncserver_listen和vncserver_proxyclient_address 的配置是否正确,正常应该是监听本地的IP地址。
OpenStack Icehouse 创建虚拟机失败Virtual Interfacecreation failed解决
创建instance的virtual interface的时候产生了exception导致create instance的流程失败。
解决办法:
2.修改nova.conf配置文件,将如下两个配置项改为 vif_plugging_timeout = 10 vif_plugging_is_fatal = False
重启Nova和Neutron相关服务即可。
|