kvm虚拟化管理平台WebVirtMgr部署

环境:

Centos7

IP:192.168.179.137

1、yum源的配置及安装所需软件包

#rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

#yum -y install epel-release

#yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx

#yum -y install gcc python-devel

#pip install numpy

2、下载webvirtmgr.git软件

#cd /usr/local/src/

#git clone git://github.com/retspen/webvirtmgr.git

3、数据库安装(一般centos都有安装sqlite,不确定可以输入sqlite命令尝试下)

#cd /usr/local/src/

#wget http://www.sqlite.org/sqlite-3.5.6.tar.gz

#cd sqlite-3.5.6/

#./configure –disable-tcl

#make &&make install

4、webvirtmgr安装

#cd /usr/local/src/webvirtmgr/

#pip install -r requirements.txt

—————————————————————————————————–

注意此处用默认的python执行上面命令,如果报错,如下:
ImportError: No module named django.core.management

这个一般是由于python版本引起的,因为系统自带有好几个版本的python
[root@openstack webvirtmgr]# python       //按Tab键自查找
python python2.6
python2 python2.6-config python-config
[root@openstack webvirtmgr]# python -V
Python 2.6.6

由此可看出,系统默认的Python版本是2.6.6
说明上面命令默认是python2.6执行的

既然使用python2.6执行上面的命令报错,那就换用其他版本python2执行(如果当前是python3.3.0,那么就将下面的/usr/bin/python2换成/usr/bin/python2.6)
/usr/bin/python2 manage.py syncdb     //最终发现使用python2执行这个命令就不报错了

—————————————————————————————————–

#./manage.py syncdb

WARNING:root:No local_settings file found.

Creating tables …

Creating table auth_permission

Creating table auth_group_permissions

Creating table auth_group

Creating table auth_user_groups

Creating table auth_user_user_permissions

Creating table auth_user

Creating table django_content_type

Creating table django_session

Creating table django_site

Creating table servers_compute

Creating table instance_instance

Creating table create_flavor

You just installed Django’s auth system, which means you don’t have any superusers defined.

Would you like to create one now? (yes/no): yes

Username (leave blank to use ‘root’): admin

Email address: 123@qq.com

Password: 123456

Password (again): 123456

Superuser created successfully.

Installing custom SQL …

Installing indexes …

Installed 6 object(s) from 1 fixture(s)

——————————————————————————————————–

#./manage.py collectstatic

WARNING:root:No local_settings file found.

You have requested to collect static files at the destination

location as specified in your settings.

This will overwrite existing files!

Are you sure you want to do this?

Type ‘yes’ to continue, or ‘no’ to cancel: yes

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/css/bootstrap-multiselect.css’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/css/bootstrap.min.css’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/css/signin.css’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/css/table-sort.css’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/css/webvirtmgr.css’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.eot’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.svg’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.ttf’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.woff’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/img/asc.gif’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/img/bg.gif’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/img/desc.gif’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/img/favicon.ico’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/Chart.min.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/bootstrap-multiselect.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/bootstrap.min.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/infrastructure.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/jQuery-1.10.2.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/jquery-migrate-1.2.1.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/jquery.tablesorter.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/Orbitron700.ttf’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/Orbitron700.woff’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/base.css’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/base64.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/black.css’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/blue.css’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/des.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/display.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/input.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/jsunzip.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/logo.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/playback.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/rfb.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/ui.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/util.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/websock.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/webutil.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/chrome-app/tcp-client.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/README.txt’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/WebSocketMain.swf’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/swfobject.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/web_socket.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-HTML5/atKeynames.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-Html5/bitmap.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/cursor.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/display.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/enums.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/filexfer.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/inputs.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/jsbn.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/lz.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/main.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/playback.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/png.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/prng4.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/quic.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/resize.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/rng.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/rsa.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/sha1.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/simulatecursor.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/spicearraybuffer.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/spiceconn.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/spicedataview.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/spicemsg.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/spicetype.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/ticket.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/utils.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/webm.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/wire.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/jsbn.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/prng4.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/rng.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/rsa.js’

Copying ‘/usr/local/src/webvirtmgr/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/sha1.js’

75 static files copied.

————————————————————————————————————-

#./manage.py createsuperuser

WARNING:root:No local_settings file found.

Username (leave blank to use ‘root’): sung

Email address: 123@qq.com

Password: 123456

Password (again): 123456

Superuser created successfully.

5、webvirtmgr配置

#mkdir -pv /var/www

# cp -rf /usr/local/src/webvirtmgr/ /var/www/webvirtmgr

#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 http://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 $remote_addr;

proxy_connect_timeout 600;

proxy_read_timeout 600;

proxy_send_timeout 600;

client_max_body_size 1024M; # Set higher depending on your needs

}

}

#chown -R nginx:nginx /var/www/webvirtmgr

#vim /etc/supervisord.conf (在最后添加)

[program:webvirtmgr]

command=/usr/bin/python2 /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py

directory=/var/www/webvirtmgr

autostart=true

autorestart=true

logfile=/var/log/supervisor/webvirtmgr.log

log_stderr=true

user=nginx

[program:webvirtmgr-console]

command=/usr/bin/python2 /var/www/webvirtmgr/console/webvirtmgr-console

directory=/var/www/webvirtmgr

autostart=true

autorestart=true

stdout_logfile=/var/log/supervisor/webvirtmgr-console.log

redirect_stderr=true

user=nginx

确保下面bind绑定的是本机的8000端口,这个在nginx配置中定义了,被代理的端口

#grep ‘^bind =’ /var/www/webvirtmgr/conf/gunicorn.conf.py

bind = ‘127.0.0.1:8000’

#systemctl restart nginx

#systemctl restart supervisord

#systemctl enable supervisord

#systemctl enable supervisord

6、查看进程

#netstat -lnpt    //即可以看到6080和8000已经启动

# lsof -i:6080


#lsof -i:8000

7、web访问
http://192.168.179.137/login/

这里用超级管理员登陆,只有超级管理员登陆后才能看到“基础构架”窗口

普通用户登陆后,只能看到“WebVirtMgr”一个窗口