Openstack中查看虚拟机console log的几种方法

Openstack中有时候虚拟机启动不正常,这时可以通过查看虚拟机console log能得到一些有用的信息。

有这些方法可以查看或获取虚拟机console log:

1)openstack控制台图形界面(horizon):

进入虚拟机(Instance)列表界面,选中相应虚拟机,点击Log页面即可;或点击右侧的“View Full Log”查看完整的log。

 

2)在虚拟机所在的compute节点上找到log文件:

通过virsh dumpxml指令,找到如下关键段:

<console type='file'>
      <source path='/var/lib/nova/instances/842d5f63-6c0f-4582-8237-076ccc29e759/console.log'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
</console>

再到相应的目录下即可:

root@compute-1:~# cd /var/lib/nova/instances/842d5f63-6c0f-4582-8237-076ccc29e759
root@compute-1:/var/lib/nova/instances/842d5f63-6c0f-4582-8237-076ccc29e759# ls
console.log  disk  disk.config  disk.info  libvirt.xml

 

3)使用指令nova console-log,这是最便捷的方法:

如下所示,能看到通过DHCP成功获取IP的信息:

root@controller:~# nova console-log test_vm68|more

[    0.000000] Initializing cgroup subsys cpuset

[    0.000000] Initializing cgroup subsys cpu

[    0.000000] Initializing cgroup subsys cpuacct

[    0.000000] Linux version 4.4.0-28-generic (buildd@lcy01-13) (gcc version 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2.1) ) #47-Ubuntu S

MP Fri Jun 24 10:09:13 UTC 2016 (Ubuntu 4.4.0-28.47-generic 4.4.13)

[    0.000000] Command line: LABEL=cirros-rootfs ro console=tty1 console=ttyS0

[    0.000000] KERNEL supported cpus:

[    0.000000]   Intel GenuineIntel

[    0.000000]   AMD AuthenticAMD

[    0.000000]   Centaur CentaurHauls

[    0.000000] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256

[    0.000000] x86/fpu: xstate_offset[3]:  960, xstate_sizes[3]:   64

[    0.000000] x86/fpu: xstate_offset[4]: 1024, xstate_sizes[4]:   64

[    0.000000] x86/fpu: xstate_offset[5]: 1088, xstate_sizes[5]:   64

[    0.000000] x86/fpu: xstate_offset[6]: 1152, xstate_sizes[6]:  512

[    0.000000] x86/fpu: xstate_offset[7]: 1664, xstate_sizes[7]: 1024

Starting network...

udhcpc (v1.23.2) started

 Sending discover...

Sending select for 1.3.11.10...

Lease of 1.3.11.10 obtained, lease time 86400 

 

顺便提供通过vnc console用http访问虚拟机的方法:

usage: nova get-vnc-console <server> <console-type>

Get a vnc console to a server.

Positional arguments:  

<server>        Name or ID of server.  

<console-type>  Type of vnc console ("novnc" or "xvpvnc").

1)获取vnc console口的URL:

root@controller:~# nova get-vnc-console test01 novnc
+-------+----------------------------------------------------------------------------------------+
| Type  | Url                                                                                    |
+-------+----------------------------------------------------------------------------------------+
| novnc | https://72.60.60.60:6080/vnc_auto.html?token=9253ac64-bfd1-4ed9-b7b1-35bfd371bd7a |
+-------+----------------------------------------------------------------------------------------+

2)在浏览器中输入上述URL即可。

<Note>新版本中指令是: $ openstack console url show VM1

posted @ 2018-09-01 22:45  bjtime  阅读(4885)  评论(0编辑  收藏  举报