介绍
WebVirtMgr是一个基于libvirt的Web界面,用于管理虚拟机。它允许您创建和配置新域,并调整域的资源分配。VNC查看器向来宾域显示一个完整的图形控制台。KVM是目前唯一支持的虚拟机管理程序。
技术:
应用程序逻辑是用Python和Django编写的。LIBVIRT Python绑定用于与底层虚拟机管理程序交互。
安装
1. 查看系统版本
[root@web ~]# hostnamectl
Static hostname: web.server.com
Icon name: computer-desktop
Chassis: desktop
Machine ID: e57ef32020fa406d9bbee213aba339ed
Boot ID: 5a70728f01fd4402a40d90d47e3f10df
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1160.114.2.el7.x86_64
Architecture: x86-64
2. 安装
]# yum -y install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release
]# yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx gcc python-devel
]# pip3 install numpy
3.安装python要求并设置Django环境
[root@web ~]# git clone https://github.com/retspen/webvirtmgr.git
[root@web ~]# cd webvirtmgr
[root@web webvirtmgr]# pip install -r requirements.txt
4.同步用户数据
[root@web webvirtmgr]# ./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'): root
Email address:
Password:
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 6 object(s) from 1 fixture(s)
5.添加一个超级用户
[root@web webvirtmgr]# ./manage.py createsuperuser
Username: abbott
Email address:
Password:
Password (again):
Superuser created successfully.
运行服务
[root@web webvirtmgr]# ./manage.py runserver &
默认端口:"8000"
6.配置Nginx作为web代理
6.1 将项目文件拷贝到/var/www/
在/etc/nginx/conf.d添加文件webvirtmgr.conf:
[root@web webvirtmgr]# cp webvirtmgr /var/www/ -R
6.2 配置nginx代理
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 ~ .*\.(js|css)$ {
proxy_pass http://127.0.0.1:8000;
}
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 $scheme;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
client_max_body_size 1024M; # Set higher depending on your needs
}
}
6.3 检查nginx配置语法是否正确
[root@web nginx]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
6.4 启动nginx
[root@web nginx]# systemctl start nginx
[root@web nginx]# systemctl enable nginx
评论 (0)