guacamole环境搭建
guacamole 是一个通过web访问vncserver(包括kvm产生的虚拟机的vnc)的开源项目,它是基于html5的,所以只要浏览器支持html5就可以访问。
相关源码:
http://sourceforge.net/projects/guacamole/files/current/source/
帮助文档:http://guac-dev.org/doc/gug/
Api文档:http://guac-dev.org/doc/
开发所需的源码包:http://guac-dev.org/repo/net/sourceforge/guacamole/
搭建服务器端:
http://sourceforge.net/projects/guacamole/files/current/source/
在以上地址下载相关包:
libguac-0.7.0.tar.gz
guacd-0.7.0.tar.gz
libguac-client-vnc-0.7.1.tar.gz
guacamole-0.8.0.tar.gz
安装服务端所需依赖包:
$ tar -xzf libguac-0.7.0.tar.gz
$ cd libguac-0.7.0/
$ ./configure
$ make
$ make install
$ ldconfig
$ tar -xzf guacd-0.7.0.tar.gz
$ cd guacd-0.7.0/
$ ./configure --with-init-dir=/etc/init.d
$ make
$ sudo make install
若有错误如:undefined rpl_malloc,则修改configura注释掉:
$as_echo "#define malloc rpl_malloc" >>confdefs.h
$ tar -xzf libguac-client-vnc-0.7.1.tar.gz
$ cd libguac-client-vnc-0.7.1/
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig
若有错误如:error: rfb/rfbclient.h: No such file or directory
安装libvncserver解决:
rpm -Uvh libvncserver-0.9.7-4.el6.x86_64.rpm
libvncserver-devel-0.9.7-4.el6.x86_64.rpm
安装guacamole的web应用:
$ tar -xzf guacamole-0.8.0.tar.gz
$ cd guacamole-0.8.0/
$ mvn package
将其中的war包放入/apache-tomcat-7.0.30/webapps下将doc中的
guacamole.properties拷贝至
/apache-tomcat-7.0.30/webapps/guacamole-0.8.0/WEB-INF/classes
Guacamole.properties内容:
# Hostname and port of guacamole proxy
guacd-hostname: IP
guacd-port: 4822
# Auth provider class (authenticates user/pass combination, needed if using the provided login screen)
auth-provider: net.sourceforge.guacamole.net.basic.BasicFileAuthenticationProvider
basic-user-mapping: /guacamole/user-mapping.xml
user-mapping.xml内容:
<user-mapping>
<!-- Per-user authentication and config information -->
<authorize username="admin" password="admin">
<protocol>vnc</protocol>
<param name="hostname">IP</param>
<param name="port">5930</param>
<param name="password"></param>
</authorize>
</user-mapping>
启动tomcat:/apache-tomcat-7.0.30/bin/catalina.sh run
访问:http://IP:8080/guacamole-0.8.0
登录:
选择虚拟机:
提示错误,查看服务端日志:
INFO: Successful connection from to "DEFAULT".
May 30, 2013 5:30:56 PM org.slf4j.impl.JCLLoggerAdapter error
SEVERE: Server error in tunnel
net.sourceforge.guacamole.GuacamoleServerException: java.net.ConnectException: Connection refused
...
Caused by: java.net.ConnectException: Connection refused
...
错误排查:
执行命令:guacd
提示:error while loading shared libraries libguac.so.4
这个libguac.so.4文件存在于/usr/local/lib/下,但是却提示找不到。解决方法:在/etc/ld.so.conf中加入/usr/local/lib这一行,保存之后,再运行:/sbin/ldconfig –v更新一下配置即可。
启动guacd
接下来遇到新错误,查看日志:
May 30, 2013 6:05:03 PM org.slf4j.impl.JCLLoggerAdapter error
SEVERE: Server error in tunnel
net.sourceforge.guacamole.GuacamoleServerException: End of stream during initial handshake.
通过查看:http://guac-dev.org/doc/gug/servlet-container-logs.html
得知client连接出错,查看系统日志/var/log/messages发现:
Error loading client plugin: Invalid argument:
/usr/local/lib/libguac-client-vnc.so: undefined symbol: rfbClientErr
大概意思是缺少rfbClientErr,怀疑是libvncserver版本过低,或者libguac-client的版本过高,与之不匹配。重新下载libvncserver的rpm包,地址:
http://bo.mirror.garr.it/pub/1/centos/6.4/os/x86_64/Packages/libvncserver-0.9.7-4.el6.x86_64.rpm
之前用的centos6.3的版本,现在用6.4的,重新安装这两个rpm包。之后重新安装libguac-client-vnc客户端:
记得清除之前安装的:make clean
rm -f /usr/local/lib/libguac-client-vnc*
重新http启动服务,一切OK:
最后,由于该项目是开源的,你可以根据自己的需要灵活应用与自己的项目中。
转载于:https://blog.51cto.com/aiven86/1290396