感谢支持
我们一直在努力

CentOS 7.2下KVM虚拟化管理平台WebVirtMgr部署

WebVirtMgr采用几乎纯Python开发,其前端是基于Python的Django,后端是基于Libvirt的Python接口,将日常kvm的管理操作变的更加的可视化。

WebVirtMgr特点:
操作简单,易于使用
通过libvirt的API接口对kvm进行管理
提供对虚拟机生命周期管理
WebVirtMgr 功能

宿主机管理支持以下功能
CPU利用率
内存利用率
网络资源池管理
存储资源池管理
虚拟机镜像
虚拟机克隆
快照管理
日志管理
虚机迁移

虚拟机管理支持以下功能
CPU利用率
内存利用率
光盘管理
关/开/暂停虚拟机
安装虚拟机
VNC console连接
创建快照

系统环境:
CentOS Linux release 7.2.1511 (Core)

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

yum -y install http://dl.Fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
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软件
mkdir /application/
cd /application/
git clone git://github.com/retspen/webvirtmgr.git 
git clone https://github.com/retspen/webvirtmgr.git                                   
 
3、数据库安装
cd /application/
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 /application/webvirtmgr
pip install -r requirements.txt
—————————————————————————————————–
./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: 10880347@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 ‘/application/webvirtmgr/webvirtmgr/static/css/bootstrap-multiselect.css’
Copying ‘/application/webvirtmgr/webvirtmgr/static/css/bootstrap.min.css’
Copying ‘/application/webvirtmgr/webvirtmgr/static/css/signin.css’
Copying ‘/application/webvirtmgr/webvirtmgr/static/css/table-sort.css’
Copying ‘/application/webvirtmgr/webvirtmgr/static/css/webvirtmgr.css’
Copying ‘/application/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.eot’
Copying ‘/application/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.svg’
Copying ‘/application/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.ttf’
Copying ‘/application/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.woff’
Copying ‘/application/webvirtmgr/webvirtmgr/static/img/asc.gif’
Copying ‘/application/webvirtmgr/webvirtmgr/static/img/bg.gif’
Copying ‘/application/webvirtmgr/webvirtmgr/static/img/desc.gif’
Copying ‘/application/webvirtmgr/webvirtmgr/static/img/favicon.ico’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/Chart.min.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/bootstrap-multiselect.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/bootstrap.min.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/infrastructure.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/jQuery-1.10.2.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/jquery-migrate-1.2.1.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/jquery.tablesorter.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/Orbitron700.ttf’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/Orbitron700.woff’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/base.css’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/base64.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/black.css’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/blue.css’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/des.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/display.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/input.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/jsunzip.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/logo.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/playback.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/rfb.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/ui.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/util.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/websock.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/webutil.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/chrome-app/tcp-client.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/README.txt’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/WebSocketMain.swf’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/swfobject.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/novnc/web-socket-js/web_socket.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-HTML5/atKeynames.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-Html5/bitmap.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/cursor.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/display.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/enums.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/filexfer.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/inputs.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/jsbn.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/lz.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/main.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/playback.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/png.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/prng4.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/quic.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/resize.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/rng.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/rsa.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/sha1.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/simulatecursor.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/spicearraybuffer.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/spiceconn.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/spicedataview.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/spicemsg.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/spicetype.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/ticket.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/utils.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/webm.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/wire.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/jsbn.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/prng4.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/rng.js’
Copying ‘/application/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/rsa.js’
Copying ‘/application/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’): mgruser
Email address: 10880347@qq.com
Password: 123456
Password (again): 123456
Superuser created successfully.
—————————————————————————————————————
5、webvirtmgr配置
mkdir -pv /var/www
cp -Rv /application/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                    #启动8000端口
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                              #启动6080端口(这是控制台vnc端口)
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.service
Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.
vi /etc/nginx/nginx.conf
注释掉39行
39    #    listen      80 default_server;

systemctl restart nginx.service
systemctl start supervisord.service 

后台执行
nohup /usr/bin/python2 /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py &

 

6、KVM被管理端配置
vi /etc/sysconfig/libvirtd
LLIBVIRTD_CONFIG=/etc/libvirt/libvirtd.conf
LIBVIRTD_ARGS=”–listen”

vi /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
tcp_port = “16509”
listen_addr = “0.0.0.0”
auth_tcp = “none”
systemctl restart  libvirtd.service                                                                 

登录

http://172.16.8.30/login/

1

CentOS 7.2下KVM虚拟化管理平台WebVirtMgr部署

2

CentOS 7.2下KVM虚拟化管理平台WebVirtMgr部署

3

CentOS 7.2下KVM虚拟化管理平台WebVirtMgr部署

4

CentOS 7.2下KVM虚拟化管理平台WebVirtMgr部署

5

CentOS 7.2下KVM虚拟化管理平台WebVirtMgr部署

6

CentOS 7.2下KVM虚拟化管理平台WebVirtMgr部署

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-02/140382.htm

赞(0) 打赏
转载请注明出处:服务器评测 » CentOS 7.2下KVM虚拟化管理平台WebVirtMgr部署
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏