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: [email protected]
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: [email protected]
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 &

 

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/219919.html<

(0)
运维的头像运维
上一篇2025-04-14 08:13
下一篇 2025-04-14 08:14

相关推荐

  • 个人主题怎么制作?

    制作个人主题是一个将个人风格、兴趣或专业领域转化为视觉化或结构化内容的过程,无论是用于个人博客、作品集、社交媒体账号还是品牌形象,核心都是围绕“个人特色”展开,以下从定位、内容规划、视觉设计、技术实现四个维度,详细拆解制作个人主题的完整流程,明确主题定位:找到个人特色的核心主题定位是所有工作的起点,需要先回答……

    2025-11-20
    0
  • 社群营销管理关键是什么?

    社群营销的核心在于通过建立有温度、有价值、有归属感的社群,实现用户留存、转化和品牌传播,其管理需贯穿“目标定位-内容运营-用户互动-数据驱动-风险控制”全流程,以下从五个维度展开详细说明:明确社群定位与目标社群管理的首要任务是精准定位,需明确社群的核心价值(如行业交流、产品使用指导、兴趣分享等)、目标用户画像……

    2025-11-20
    0
  • 香港公司网站备案需要什么材料?

    香港公司进行网站备案是一个涉及多部门协调、流程相对严谨的过程,尤其需兼顾中国内地与香港两地的监管要求,由于香港公司注册地与中国内地不同,其网站若主要服务内地用户或使用内地服务器,需根据服务器位置、网站内容性质等,选择对应的备案路径(如工信部ICP备案或公安备案),以下从备案主体资格、流程步骤、材料准备、注意事项……

    2025-11-20
    0
  • 如何企业上云推广

    企业上云已成为数字化转型的核心战略,但推广过程中需结合行业特性、企业痛点与市场需求,构建系统性、多维度的推广体系,以下从市场定位、策略设计、执行落地及效果优化四个维度,详细拆解企业上云推广的实践路径,精准定位:明确目标企业与核心价值企业上云并非“一刀切”的方案,需先锁定目标客户群体,提炼差异化价值主张,客户分层……

    2025-11-20
    0
  • PS设计搜索框的实用技巧有哪些?

    在PS中设计一个美观且功能性的搜索框需要结合创意构思、视觉设计和用户体验考量,以下从设计思路、制作步骤、细节优化及交互预览等方面详细说明,帮助打造符合需求的搜索框,设计前的规划明确使用场景:根据网站或APP的整体风格确定搜索框的调性,例如极简风适合细线条和纯色,科技感适合渐变和发光效果,电商类则可能需要突出搜索……

    2025-11-20
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注