源码安装libvirt 常见问题
2014-06-10 14:42
387 查看
PS:感谢原作者的文章,解决了我的问题。对linux还是不够精通,很多问题解决还很吃力,毕竟我从windows转过来的。
本来centos5是自带libvirt,但版本计较旧,后来我从libvirt的官网下了0.8的版本,似乎有冲突。于是我把原来的干掉了,重新用yum安装,但不知道为什么,它帮我装了两个版本,一个是x86_64,一个是i386,并且版本号还不一样,导致冲突,是在变态!faint!
索性我就从官网上下了安装包,保守一点,下个0.7的版本。老套路:./configure,make, make install。装完问题也来了!
问题零:
找不到/usr/local/var/lock/subsys/libvirt
ln /usr/local/var/lock/subsys -s /var/lock/subsys
问题一:
启动libvirt时LIBVIERT_VERSION_0.7没找到,才发现原来系统原来有个libvirt.so.0,于是删除原来的,并将新的替换原来的
mv libvirt.so.0.7.0 libvirt.so.0
问题二:
找不到libvirt-sock,说没有这个文件,错误情况:“libvir: Remote error : unable to connect to '/usr/local/var/run/libvirt/libvirt-sock': No such file or directory”再做个链接
ln -s /var/run/libvirt/libvirt-sock /usr/local/var/run/libvirt/libvirt-sock
问题三:
找不到libvirt-sock,说没有这个文件,错误情况:“libvir: Remote error : unable to connect to '/usr/local/var/run/libvirt/libvirt-sock-ro': No such file or directory”再做个链接
ln -s /var/run/libvirt/libvirt-sock-ro /usr/local/var/run/libvirt/libvirt-sock-ro
There are lots of errors that can occur while connecting to the server (when running virsh for example)
[edit]
[edit]
When running a command, the following error (or similar) appears:
[edit]
This can happen when libvirt is compiled from sources. The error means there is no driver to use with the specified URI (e.g. "Xen" for "xen://server/")
[edit]
Check the last part of configure ('./configure' or './autogen') output, you should see something like this:
For example talking about Xen:
If however you see "<driver>: no" (e.g. "Xen:no"), that means configure failed to find all the tools/libraries necessary to implement this support or there was "--without-<driver>" parameter specified on the command line.
[edit]
Do not specify "--without-<driver>" on the command line of the configuration script and make sure there are all development libraries installed as well, then configure the sources again.
[edit]
[edit]
When running a command, the following error (or similar) appears:
[edit]
This error can be caused by various things, for some of them, the error message is little misleading:
specified URI is wrong (missing one '/' -- e.g. 'qemu://system')
connection is not configured
[edit]
specified URI is wrong
In the case of specifying 'qemu://system' or 'qemu://session' as a connection URI, virsh is trying to connect to hostname 'system' or 'session' respectively because when hostname is specified, the transport for qemu defaults to 'tls' and thus the need for a
certificates. Use three slashes in this case.
connection is not configured
You specified correct URI (e.g. 'qemu[+tls]://server/system') but the certificates were not set up properly on your machine. There is a great In
depth guide to configuring TLS. The solution is most probably there.
[edit]
[edit]
When running a command, the following error (or similar) appears:
[edit]
You are trying to connect using unix socket. The connection to "qemu" without any hostname specified is by default using unix sockets. If there is no error running this command as root it's probably just misconfigured.
[edit]
If you want to be able to connect as non-root user using unix sockets, configure following options in '/etc/libvirt/libvirtd.conf' accordingly:
[edit]
These other errors are even simpler to solve than those mentioned before, so here is a list of error/solutions:
unable to connect to server at 'server:port': Connection refused
The daemon is not running on the server or it's configured not to listen (configuration option 'listen_tcp' or 'listen_tls').
End of file while reading data: nc: using stream socket: Input/output error
If you specified 'ssh' transport, the daemon is probably not running on the server.
End of file while reading data: : Input/output error
If you are using ssh transport, for example, by executing
virsh --connect qemu+ssh://username@remove.host.com/system list
Probably the user you are using to access the server does not belong to the proper group, such as 'libvirtd' for Ubuntu servers. Try adding the user to the proper group on server and connect again. For example, below is to be run on Ubuntu servers.
sudo usermod -G libvirtd -a username
Refer to SSHSetup for setup about other distributions.
Retrieved from "http://wiki.libvirt.org/page/Failed_to_connect_to_the_hypervisor"
今天突然使用了rhel6.2系统,之前使用的是rhel6.1。升级过程中遇到的几个问题是这样的。
首先是libvirt启动的问题,开始启动不了的,因为每次restart时它的stopping状态总是failed,
1[root@localhost
~]# service libvirtd restart
2Stopping
libvirtd daemon: [ FAILED ]
3Starting
libvirtd daemon: [ OK ]
执行以下命令就ok了:
01[root@localhost
~]# sudo service messagebus start
02Starting
system message bus:
03
04[root@localhost
~]# sudo service avahi-daemon start
05Starting
Avahi daemon...
06
07[root@localhost
~]# sudo service libvirtd start
08Starting
libvirtd daemon:
09
10[root@localhost
~]# sudo chkconfig messagebus on
11[root@localhost
~]# sudo chkconfig avahi-daemon on
再次重启也ok的:
1[root@localhost
~]# service libvirtd restart
2Stopping
libvirtd daemon: [ OK ]
3Starting
libvirtd daemon: [ OK ]
然后是virsh define xml时遇到如下error:
1[root@localhost
~]# sudo virsh define xml
2error:
Failed to define domain from rhel.test
3error:
unknown OS type hvm
而我自己的os xml是这样的:
1<os>
2 <type>hvm</type>
3</os>
这个时候真的把我搞郁闷了,物理机VT确实开了,KVM模块也装了,依次执行:
1[root@localhost
~]# modprobe kvm
2[root@localhost
~]# modprobe kvm-intel
3[root@localhost
~]# lsmod | grep kvm
4kvm_intel 47822 0
5kvm
300730 1 kvm_intel
那会是什么问题呢,这回真的郁闷了。结果就想去看下virsh的版本,0.9.4是没问题的,但是看得时候看到了一句话:
1[root@localhost
~]# virsh --version
2Compiled
against library: libvir 0.9.4
3Using
library: libvir 0.9.4
4Using
API: QEMU 0.9.4
5error:
failed to get the hypervisor version
6error:
internal error Cannot find suitable emulator for x86_64
嗯,这里问题出来了,原来是没有emulator,那我安装一个好了,yum install qemu-kvm.x86_64.
重启libvirtd,然后再define,ok了。
1[root@localhost
~]# service libvirtd restart
2Stopping
libvirtd daemon: [ OK ]
3Starting
libvirtd daemon: [ OK ]
4[root@localhost
~]# virsh define xml
5Domain
rhel.test defined from rhel.test
然后第三个问题是启动虚拟机的时候,出现这样的错误:
1[root@localhost
~]# sudo virsh start rhel.test
2error:
Failed to start domain rhel.test
3error:
internal error process exited while connecting to monitor: 00:18:12.815: 29825: info : libvirt version: 0.9.4, package: 23.el6 (Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>,
2011-11-08-21:34:51, x86-012.build.bos.redhat.com)
4Could
not access KVM kernel module: Permission denied
5failed
to initialize KVM: Permission denied
6No
accelerator found!
嗯,上面说的很清楚,不能访问KVM内核模块,而这个模块是用一个字符设备来提供服务的:
1[root@localhost
~]# ll /dev/kvm
2crw-rw----
1 root root 10, 232 Apr 10 10:46 /dev/kvm
3[root@localhost
~]# chown root:kvm /dev/kvm
4[root@localhost
~]# sudo virsh start rhel.test
5Domain
rhel.test started
本来centos5是自带libvirt,但版本计较旧,后来我从libvirt的官网下了0.8的版本,似乎有冲突。于是我把原来的干掉了,重新用yum安装,但不知道为什么,它帮我装了两个版本,一个是x86_64,一个是i386,并且版本号还不一样,导致冲突,是在变态!faint!
索性我就从官网上下了安装包,保守一点,下个0.7的版本。老套路:./configure,make, make install。装完问题也来了!
问题零:
找不到/usr/local/var/lock/subsys/libvirt
ln /usr/local/var/lock/subsys -s /var/lock/subsys
问题一:
启动libvirt时LIBVIERT_VERSION_0.7没找到,才发现原来系统原来有个libvirt.so.0,于是删除原来的,并将新的替换原来的
mv libvirt.so.0.7.0 libvirt.so.0
问题二:
找不到libvirt-sock,说没有这个文件,错误情况:“libvir: Remote error : unable to connect to '/usr/local/var/run/libvirt/libvirt-sock': No such file or directory”再做个链接
ln -s /var/run/libvirt/libvirt-sock /usr/local/var/run/libvirt/libvirt-sock
问题三:
找不到libvirt-sock,说没有这个文件,错误情况:“libvir: Remote error : unable to connect to '/usr/local/var/run/libvirt/libvirt-sock-ro': No such file or directory”再做个链接
ln -s /var/run/libvirt/libvirt-sock-ro /usr/local/var/run/libvirt/libvirt-sock-ro
Failed to connect to the hypervisor
There are lots of errors that can occur while connecting to the server (when running virsh for example)[edit]
No connection driver available
[edit]
Symptom
When running a command, the following error (or similar) appears:$ virsh -c <uri> list error: no connection driver available for No connection for URI <uri> error: failed to connect to the hypervisor
[edit]
Cause
This can happen when libvirt is compiled from sources. The error means there is no driver to use with the specified URI (e.g. "Xen" for "xen://server/")[edit]
Investigation
Check the last part of configure ('./configure' or './autogen') output, you should see something like this:configure: Drivers configure: configure: <driver>: yes
For example talking about Xen:
configure: Drivers configure: configure: Xen: yes
If however you see "<driver>: no" (e.g. "Xen:no"), that means configure failed to find all the tools/libraries necessary to implement this support or there was "--without-<driver>" parameter specified on the command line.
[edit]
Solution
Do not specify "--without-<driver>" on the command line of the configuration script and make sure there are all development libraries installed as well, then configure the sources again.[edit]
Cannot read CA certificate
[edit]
Symptom
When running a command, the following error (or similar) appears:$ virsh -c <uri> list error: Cannot read CA certificate '/etc/pki/CA/cacert.pem': No such file or directory error: failed to connect to the hypervisor
[edit]
Investigation
This error can be caused by various things, for some of them, the error message is little misleading:specified URI is wrong (missing one '/' -- e.g. 'qemu://system')
connection is not configured
[edit]
Solution
specified URI is wrongIn the case of specifying 'qemu://system' or 'qemu://session' as a connection URI, virsh is trying to connect to hostname 'system' or 'session' respectively because when hostname is specified, the transport for qemu defaults to 'tls' and thus the need for a
certificates. Use three slashes in this case.
connection is not configured
You specified correct URI (e.g. 'qemu[+tls]://server/system') but the certificates were not set up properly on your machine. There is a great In
depth guide to configuring TLS. The solution is most probably there.
[edit]
Permission denied
[edit]
Symptom
When running a command, the following error (or similar) appears:$ virsh -c qemu:///system list error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied error: failed to connect to the hypervisor
[edit]
Investigation
You are trying to connect using unix socket. The connection to "qemu" without any hostname specified is by default using unix sockets. If there is no error running this command as root it's probably just misconfigured.[edit]
Solution
If you want to be able to connect as non-root user using unix sockets, configure following options in '/etc/libvirt/libvirtd.conf' accordingly:unix_sock_group = <group> unix_sock_ro_perms = <perms> unix_sock_rw_perms = <perms>
[edit]
Other errors
These other errors are even simpler to solve than those mentioned before, so here is a list of error/solutions:unable to connect to server at 'server:port': Connection refused
The daemon is not running on the server or it's configured not to listen (configuration option 'listen_tcp' or 'listen_tls').
End of file while reading data: nc: using stream socket: Input/output error
If you specified 'ssh' transport, the daemon is probably not running on the server.
End of file while reading data: : Input/output error
If you are using ssh transport, for example, by executing
virsh --connect qemu+ssh://username@remove.host.com/system list
Probably the user you are using to access the server does not belong to the proper group, such as 'libvirtd' for Ubuntu servers. Try adding the user to the proper group on server and connect again. For example, below is to be run on Ubuntu servers.
sudo usermod -G libvirtd -a username
Refer to SSHSetup for setup about other distributions.
Retrieved from "http://wiki.libvirt.org/page/Failed_to_connect_to_the_hypervisor"
今天突然使用了rhel6.2系统,之前使用的是rhel6.1。升级过程中遇到的几个问题是这样的。
首先是libvirt启动的问题,开始启动不了的,因为每次restart时它的stopping状态总是failed,
1[root@localhost
~]# service libvirtd restart
2Stopping
libvirtd daemon: [ FAILED ]
3Starting
libvirtd daemon: [ OK ]
执行以下命令就ok了:
01[root@localhost
~]# sudo service messagebus start
02Starting
system message bus:
03
04[root@localhost
~]# sudo service avahi-daemon start
05Starting
Avahi daemon...
06
07[root@localhost
~]# sudo service libvirtd start
08Starting
libvirtd daemon:
09
10[root@localhost
~]# sudo chkconfig messagebus on
11[root@localhost
~]# sudo chkconfig avahi-daemon on
再次重启也ok的:
1[root@localhost
~]# service libvirtd restart
2Stopping
libvirtd daemon: [ OK ]
3Starting
libvirtd daemon: [ OK ]
然后是virsh define xml时遇到如下error:
1[root@localhost
~]# sudo virsh define xml
2error:
Failed to define domain from rhel.test
3error:
unknown OS type hvm
而我自己的os xml是这样的:
1<os>
2 <type>hvm</type>
3</os>
这个时候真的把我搞郁闷了,物理机VT确实开了,KVM模块也装了,依次执行:
1[root@localhost
~]# modprobe kvm
2[root@localhost
~]# modprobe kvm-intel
3[root@localhost
~]# lsmod | grep kvm
4kvm_intel 47822 0
5kvm
300730 1 kvm_intel
那会是什么问题呢,这回真的郁闷了。结果就想去看下virsh的版本,0.9.4是没问题的,但是看得时候看到了一句话:
1[root@localhost
~]# virsh --version
2Compiled
against library: libvir 0.9.4
3Using
library: libvir 0.9.4
4Using
API: QEMU 0.9.4
5error:
failed to get the hypervisor version
6error:
internal error Cannot find suitable emulator for x86_64
嗯,这里问题出来了,原来是没有emulator,那我安装一个好了,yum install qemu-kvm.x86_64.
重启libvirtd,然后再define,ok了。
1[root@localhost
~]# service libvirtd restart
2Stopping
libvirtd daemon: [ OK ]
3Starting
libvirtd daemon: [ OK ]
4[root@localhost
~]# virsh define xml
5Domain
rhel.test defined from rhel.test
然后第三个问题是启动虚拟机的时候,出现这样的错误:
1[root@localhost
~]# sudo virsh start rhel.test
2error:
Failed to start domain rhel.test
3error:
internal error process exited while connecting to monitor: 00:18:12.815: 29825: info : libvirt version: 0.9.4, package: 23.el6 (Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>,
2011-11-08-21:34:51, x86-012.build.bos.redhat.com)
4Could
not access KVM kernel module: Permission denied
5failed
to initialize KVM: Permission denied
6No
accelerator found!
嗯,上面说的很清楚,不能访问KVM内核模块,而这个模块是用一个字符设备来提供服务的:
1[root@localhost
~]# ll /dev/kvm
2crw-rw----
1 root root 10, 232 Apr 10 10:46 /dev/kvm
3[root@localhost
~]# chown root:kvm /dev/kvm
4[root@localhost
~]# sudo virsh start rhel.test
5Domain
rhel.test started
相关文章推荐
- LNMP最新源码包一般安装过程及常见问题
- Centos下源码包安装lamp常见的几个小问题
- Centos下源码包安装lamp常见的几个小问题
- linux下的wireshark最新版安装(源码安装)以及一些常见问题
- Lamp最新源码包一般安装过程及常见问题
- 编译mysql 5.7 源码安装常见问题
- SQL Server补丁安装常见问题(更新)
- 一网打尽 .Net 开发过程中安装、调试的常见问题与错误!
- 详述SQL Server 补丁安装常见问题
- Asp.Net 下安装、调试的常见问题与错误!!!
- 安装,启动与卸载Mysql系统服务(MYSQL常见问题)
- SQL Server补丁安装常见问题
- sql service2000的安装 操作 常见问题
- 常见问题:试图运行项目时出错:无法启动调试 没有正确安装调试器。请运行安装程序安装或修复调试器
- 安装,启动与卸载Mysql系统服务(MYSQL常见问题)
- VS.net 安装、调试的常见问题与错误[转]
- SQL Server补丁安装常见问题 (转)
- NET Framework 安装常见问题解答
- Net 下安装、调试的常见问题与错误!!!
- Loadrunner安装常见问题