使用virsh console连接虚拟机
2014-08-26 15:53
701 查看
在网络控制的比较严格的情况下,远程桌面等连接虚拟机的方式可能会受到限制。virsh有一个现有的命令,可以在需要的时候应应急
[root@pc ~]# virsh help console
NAME
console - connect to the guest console
SYNOPSIS
console <domain> [--devname <string>] [--force] [--safe]
DESCRIPTION
Connect the virtual serial console for the guest
OPTIONS
[--domain] <string> domain name, id or uuid
--devname <string> character device name
--force force console connection (disconnect already connected sessions)
--safe only connect if safe console handling is supported
但是默认的情况下,执行virsh console dom_name的时候,会发现hang住,没有任何反应。
原因是kernel在启动的时候并没有打开对ttyS0的支持,console其实是通过这个字符设备进行通信的。只需要简单的在grub对应的选项里面加上启动参数即可:
不管是grub还是grub2,只要在对应处进行设置就可以正常连接了。
[root@pc ~]# virsh console cent65
Connected to domain cent65
Escape character is ^]
root
Password:
Last login: Mon May 19 15:40:28 on ttyS0
[root@pc ~]# virsh help console
NAME
console - connect to the guest console
SYNOPSIS
console <domain> [--devname <string>] [--force] [--safe]
DESCRIPTION
Connect the virtual serial console for the guest
OPTIONS
[--domain] <string> domain name, id or uuid
--devname <string> character device name
--force force console connection (disconnect already connected sessions)
--safe only connect if safe console handling is supported
但是默认的情况下,执行virsh console dom_name的时候,会发现hang住,没有任何反应。
原因是kernel在启动的时候并没有打开对ttyS0的支持,console其实是通过这个字符设备进行通信的。只需要简单的在grub对应的选项里面加上启动参数即可:
[root@cent65 ~]# cat /etc/grub.conf # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/mapper/vg_cent65-lv_root # initrd /initrd-[generic-]version.img #boot=/dev/vda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu 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_cent65-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_cent65/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg_cent65/lv_root rd_NO_DM rhgb quiet <span style="font-size:18px;color:#ff0000;"><strong>console=ttyS0</strong></span>
不管是grub还是grub2,只要在对应处进行设置就可以正常连接了。
[root@pc ~]# virsh console cent65
Connected to domain cent65
Escape character is ^]
root
Password:
Last login: Mon May 19 15:40:28 on ttyS0
相关文章推荐
- KVM的HVM虚拟机使用非串口方式建立virsh console 连接
- KVM的HVM虚拟机使用virsh console 方式连接
- 使用 Putty 连接虚拟机中的Linux
- 虚拟机+ubuntu系统 使用NAT网络连接方式 无网络连接问题
- 如何使用 RDP 或 SSH 连接到 Azure 虚拟机
- Win7中使用Eclipse连接虚拟机中的Ubuntu中的Hadoop2.4<2>
- Win7中使用Eclipse连接虚拟机中的Ubuntu中的Hadoop2.4<1>
- 使用JDBC连接虚拟机数据库时遇到的问题
- Win7中使用Eclipse连接虚拟机中的Ubuntu中的Hadoop2.4<3>
- usb转RS232通用串口与虚拟机连接使用
- 使用putty连接到虚拟机centos被拒绝解决方法
- 在XP下使用putty连接虚拟机中的linux出现主机拒绝的问题解决办法
- 如何在本地计算机连接使用运行在虚拟机上的oracle数据库
- 使用virtualbox安装android 4.0 (ICS)虚拟机,并使用adb连接虚拟机进行应用开发的方法
- VM虚拟机连接Internet,也可以使用SecureCRT连接虚拟机
- 使用ssh无法连接虚拟机linux系统,ubuntu。
- 使用pietty自动连接虚拟机ubuntu 11.10,安装与配置
- 虚拟机使用NAT方式共享主机网络连接上网
- win7-64位使用PLSQL连接虚拟机中ORACLE失败无错误码提示
- 使用SecureCRT连接CentOS虚拟机出现The remote system refused the connection