CentOS 6.2下KVM管理平台WebVirtMgr的部署

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.安装虚拟化环境

yum -y groupinstall 'Virtualization Tools' yum -y groupinstall 'Virtualization' yum -y groupinstall 'Virtulization Client' yum -y groupinstall 'Virtulization Platform'

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 nginx

3.克隆代码

$ 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

$ ./manage.py syncdb $ ./manage.py collectstatic

5.配置nginx
vim /etc/nginx/conf.d/webvirtmgr.conf 内容如下:

server { listen 80 default_server; server_name $hostname; #access_log /var/log/nginx/webvirtmgr_access_log; location /static/ { root /var/www/webvirtmgr/webvirtmgr; # or /srv instead of /var expires max; } location / { proxy_pass 127.0.0.1:8000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for; proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-Proto $scheme; proxy_connect_timeout 600; proxy_read_timeout 600; proxy_send_timeout 600; client_max_body_size 1024M; # Set higher depending on your needs } }

注释掉nginx的default内容,vim /etc/nginx/conf.d/default.conf 。然后启动nginx

sudo service nginx restart

6.启动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认证,也可以正常连接。

curl .github.io/libvirt-bootstrap.sh | sudo sh

2.设置防火墙:

sudo iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 16509 -j ACCEPT

3.设置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

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/14324.html