Git地址:https://github.com/retspen/webvirtmgr
环境:
Linux system:CentOS 6.2
libvirt: 0.10.2
webvirtmgr的安装,参考:https://github.com/retspen/webvirtmgr/wiki/Install-WebVirtMgr
1.安装虚拟化环境
2.安装依赖包
$ sudo yum -y install http://dl.Fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm $ sudo yum -y install git Python-pip libvirt-python libxml2-python python-websockify supervisor nginx3.克隆代码
$ git clone git://github.com/retspen/webvirtmgr.git $ cd webvirtmgr $ sudo pip install -r requirements.txt # or python-pip (RedHat, Fedora, CentOS, OpenSUSE)用pip安装django不太顺利,报错:
[root@vm03 ~]# pip install Django==1.5.5
Collecting Django==1.5.5
Could not find a version that satisfies the requirement Django==1.5.5 (from versions: 1.7plus-email-as-username-1.7.0, 4store-0.3, 503-0.1)
No matching distribution found for Django==1.5.5
折腾许久,只能去django官网下载了个Django-1.5.12.tar.gz包来安装
4.Django环境初始化
执行syncdb时,报错,未安装mysqldb
于是下载MySQL-Python-1.2.5.zip,解压安装,又是一个报错:command ‘gcc’ failed with exit status 1
原因是未安装:mysql-devel,python-devel,mysql-python
5.配置nginx
vim /etc/nginx/conf.d/webvirtmgr.conf 内容如下:
注释掉nginx的default内容,vim /etc/nginx/conf.d/default.conf 。然后启动nginx
sudo service nginx restart6.启动django
./manage.py runserver 0.0.0.0:8000访问::8000 (x.x.x.x - your server IP address ),输入创建的django用户和密码,如果没有创建,请用python manager.py createsuperuser,命令创建。登录后如下图所示
webvirtmgr客户端就这样搭建完了,接下来需要配置虚拟机所在宿主机的,参考git地址:https://github.com/retspen/webvirtmgr/wiki/Setup-Host-Server
配置宿主机环境:
system: centos 6.6
libvirt: 0.10.2
1.下载并执行脚本:libvirt-bootstrap.sh
如果虚拟机比较多,该脚本执行时间会比较长,因为会执行service libvirt-guests restart,会将所有运行的虚拟机挂起然后再恢复,感觉这一步不是必须的,因为我有一台只设置ssh认证,也可以正常连接。
2.设置防火墙:
sudo iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 16509 -j ACCEPT3.设置TCP认证Setup TCP authorization
参考:https://github.com/retspen/webvirtmgr/wiki/Setup-TCP-authorization,webvirtmgr新建服务器连接时需要此账号
$ sudo saslpasswd2 -a libvirt fred Password: xxxxxx Again (for verification): xxxxxx查看新加的账号
$ sudo sasldblistusers2 -f /etc/libvirt/passwd.db fred@webvirtmgr.net: userPassword删除新加的账号:
sudo saslpasswd2 -a libvirt -d fred