CentOS7.7搭建KVM虚拟化管理工具WebvirtMgr

概述

KVM(Kernel-based Virtual Machine),开源的系统虚拟化模块。出于成本,技术人员力量的原因,很多小型企业都选择她作为自己的虚拟化平台。其自带的图形化管理工具virt_manager,想必很多人都觉得使用起来很别扭。而且随着物理机主机增多的时候,或许我们需要一款可集中管理的工具来管理这些物理机主机。因为,我们引入一款开源web界面管理工具WebvirtMgr。

WebVirtMgr是基于libvirt的Web管理界面,用于管理虚拟机。它允许您创建和配置新域,以及调整域的资源分配。VNC查看器向来宾域提供完整的图形控制台。KVM当前是唯一受支持的虚拟机监控程序。

那么下面我们就在CentOS7.7的环境下搭建这么一款开源web界面管理KVM的工具。

一、Webvirtmgr端的搭建

1、环境准备

操作系统
CentOS7.7
管理节点
webvirtmgr:CPU:4 MEM:4G DISK:60G
资源节点
webvirtmgr-node01: CPU:16 MEM:16G DISK:60G+100G
webvirtmgr-node02: CPU:16 MEM:16G DISK:60G+100G
webvirtmgr-node03: CPU:16 MEM:16G DISK:60G+100G
网络环境
此模拟环境,各虚拟机只有一块网卡eth0,也就是生产环境中的管理网络。如果是在生产环境中,需规划多块网卡。以Dell R730 为例,可以设置NIC0为虚拟机的公网网络,或NIC0 NIC1绑定做公网网络。NIC2作为此处模拟的eth0的管理网络。

各个节点的初始设置:
关闭selinux

sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld

webvirtmgr节点上:

hostnamectl set-hostname webvirtmgr
cat /etc/hosts
192.168.2.30 webvirtmgr
192.168.2.31 webvirtmgr-node01
192.168.2.32 webvirtmgr-node02
192.168.2.33 webvirtmgr-node03
 scp /etc/hosts root@webvirtmgr-node01:/etc/hostsscp /etc/hosts root@webvirtmgr-node02:/etc/hostsscp /etc/hosts root@webvirtmgr-node03:/etc/hosts

1.开始安装

webvirtmgr节点上:

yum -y install vim wget git epel-release
yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx
yum -y install gcc python-devel
pip install --upgrade pip #升级一下pip
pip install --upgrade pip  #报error的话多执行几次
pip install numpy  #报error ?科学方法下载下来

或者这里先下载numpy-1.16.5-cp27-cp27mu-manylinux1_x86_64.whl 到本地
链接:https://pan.baidu.com/s/15hvQqEzWt5_bGUJwqxnG4A 提取码:hjhs
[root@webvirtmgr ~]# ls
numpy-1.16.5-cp27-cp27mu-manylinux1_x86_64.whl [root@webvirtmgr ~]#
pip install numpy-1.16.5-cp27-cp27mu-manylinux1_x86_64.whl

2.安装python requirements和设置Django环境

git clone git://github.com/retspen/webvirtmgr.git #获取源码
cd webvirtmgr
pip install -r requirements.txt #如有报错,请注意看提示信息。

[root@webvirtmgr 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’): admin #填写超级管理员
Email address: admin@localhost #填写邮箱
Password: #输入密码
Password (again): #再次确认密码
Superuser created successfully.
Installing custom SQL …
Installing indexes …
Installed 6 object(s) from 1 fixture(s)

[root@webvirtmgr webvirtmgr]# ./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 ‘/root/webvirtmgr/webvirtmgr/static/css/bootstrap-multiselect.css’
… #省略
Copying ‘/root/webvirtmgr/webvirtmgr/static/js/spice-html5/thirdparty/sha1.js’

75 static files copied.

如需再添加超级管理员,可执行此命令添加

./manage.py createsuperuser

配置nginx
mv /root/webvirtmgr /var/www/
chown -R nginx.nginx /var/www/

cd /var/www
[root@webvirtmgr www]# ls -l
total 72
drwxr-xr-x 6 root root 114 Dec 9 18:56 conf
drwxr-xr-x 2 root root 116 Dec 9 18:56 console
… #省略
drwxr-xr-x 5 root root 177 Dec 9 19:12 webvirtmgr
-rw-r–r-- 1 root root 38912 Dec 9 19:14 webvirtmgr.sqlite3

注释掉 /etc/nginx/conf.d/webvirtmgr.conf 中 server 段
开起 include /etc/nginx/conf.d/*.conf;
vim /etc/nginx/conf.d/webvirtmgr.conf

#    server {
#        listen       8088 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }
server {listen 80 default_server;server_name $hostname;#access_log /var/log/nginx/webvirtmgr_access_log;location /static/ {root /var/www/webvirtmgr;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 $scheme;proxy_connect_timeout 600;proxy_read_timeout 600;proxy_send_timeout 600;client_max_body_size 1024M; # Set higher depending on your needs}
}

vim /etc/nginx/nginx.conf 中开

#    server {
#        listen       80 default_server;
#        listen       [::]:80 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;# Load configuration files for the default server block.include /etc/nginx/default.d/*.conf;#        location / {
#        }#        error_page 404 /404.html;
#            location = /40x.html {
#        }#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#     }

[root@webvirtmgr nginx]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

启动nginx
[root@webvirtmgr ~]# systemctl start nginx
[root@webvirtmgr ~]# systemctl enable nginx
[root@webvirtmgr ~]# ss -ntupl| grep 80
tcp LISTEN 0 128 *:80 : users:

3、启动webvirtmgr程序和webvirtmgr-console

nohup /usr/bin/python /var/www/manage.py run_gunicorn 127.0.0.1:8000 &
nohup /usr/bin/python /var/www/console/webvirtmgr-console &

ss -ntupl 查看相关服务是否正常

4、安装Supervisor

创建文件
vim /etc/supervisord.d/webvirtmgr.ini
注意程序所在的路径

[program:webvirtmgr]
command=/usr/bin/python /var/www/manage.py run_gunicorn -c /var/www/conf/gunicorn.conf.py
directory=/var/www/
autostart=true
autorestart=true
logfile=/var/log/supervisor/webvirtmgr.log
log_stderr=true
user=nginx[program:webvirtmgr-console]
command=/usr/bin/python /var/www/console/webvirtmgr-console
directory=/var/www/
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
redirect_stderr=true
user=nginx

设置开启机启动
[root@webvirtmgr ~]# systemctl start supervisord
[root@webvirtmgr ~]# systemctl enable supervisord
Created symlink from /etc/systemd/system/multi-user.target.wants/supervisord.service to /usr/lib/systemd/system/supervisord.service.

5、登录测试

登录 http://192.168.2.30/login
至此Webvirtmgr端搭建完毕。

二、资源节点的部署

环境准备

各节点新增的磁盘,挂home目录
在webvirtmgr-node01上操作,各资源节点操作一样。

systemctl stop firewalld
systemctl disable firewalld
mkdir -p /home/kvm/iso  #存放ISO镜像文件
mkdir -p /home/kvm/img #存放虚拟机磁盘文件

资源节点安装

脚本一键部署资源节点

curl http://retspen.github.io/libvirt-bootstrap.sh | sudo sh

资源节点认证配置

资源节点有两种认证方式TCP或 SSH认证
此处选择SSH认证

1、在webvirtmgr节点上操作:

因为使用nginx管理
切换到nginx用户操作:

su - nginx -s /bin/bash
ssh-keygen  #一直回车到结束
touch ~/.ssh/config && echo -e "StrictHostKeyChecking=no\nUserKnownHostsFile=/dev/null" >> ~/.ssh/config
chmod 0600 ~/.ssh/config

2、到资源节点webvirtmgr-node02操作:

添加管理用户

adduser webvirtmgr
passwd webvirtmgr
usermod -G libvirt -a webvirtmgr

3、回到webvirtmgr节点

su - nginx -s /bin/bash
ssh-copy-id webvirtmgr@webvirtmgr-node02  #因为有写hosts,如果没写IP地址

4、测试连接

ssh webvirtmgr@webvirtmgr-node02 #成功会ssh到webvirtmgr-node02节点

三、webvirtmgr站点Web UI界面使用

添加资源节点
添加完资源节点以后,点 基础架构 列出资源节点 状态为 已激活

添加存储资源

上传镜像到资源节点 /home/kvm/iso 目录
测试开一台虚拟机
首先为虚拟机创建磁盘镜像
存储池–>img–>添加镜像

虚机实例–>instance -->Custom instance
插入光盘
power 开机
access 启动控制台

系统安装过程省略
PS:控制台30s会断开一次,需要再点控制台打开重连。原因未知,没深入研究。

CentOS7.7搭建KVM虚拟化管理工具WebvirtMgr相关推荐

  1. kvm虚拟化管理工具

    kvm虚拟化管理工具 一.什么是云计算? 二.云计算的基础KVM虚拟化 三.安装kvm虚拟化管理工具 四.virsh虚拟机的日常操作(开关,挂起虚拟机,导配置文件,磁盘增容,转化磁盘格式等) 五.快照 ...

  2. kvm虚拟化管理平台WebVirtMgr部署-完整记录(2)

    继上一篇kvm虚拟化管理平台WebVirtMgr部署-完整记录(1),接下来说说WebVirtMgr的日常配置:添加宿主机,创建虚机,磁盘扩容,快照等 具体操作记录如下: 一.配置宿主机 1.登录We ...

  3. centos7.2 kvm虚拟化管理平台WebVirtMgr部署

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

  4. KVM虚拟化管理工具之virtsh(一)

    一.什么是virsh virsh 是kvm一个管理工具包.virsh提供两种执行模式:"直接模式(Direct Mode)"与"互动模式(Interactive Mode ...

  5. Centos7 下搭建小幺鸡接口管理工具

    小幺鸡,简单好用的接口文档管理工具 访问 www.xiaoyaoji.cn 下载小幺鸡的源码包 小幺鸡版本:v2.1.7 服务环境:jdk8+tomcat9+mysql8.0 IP:192.168.4 ...

  6. KVM虚拟化管理工具之virtsh(三)

    一.virsh常用命令介绍 1.1 domain工作域管理篇 虚拟机磁盘及网卡管理相关操作 virsh attach-disk 挂在磁盘(命令行挂载) 命令参数 说明 必须 –domain 需要操作虚 ...

  7. Centos7搭建KVM虚拟化平台之基于OVS网桥

    Centos7搭建KVM虚拟化平台之基于OVS网桥 文章目录 Centos7搭建KVM虚拟化平台之基于OVS网桥 一.什么是虚拟化技术?为什么要用虚拟化技术? 二.Qemu-KVM基本工作原理分析 三 ...

  8. 搭建kvm虚拟化平台和管理kvm虚拟化平台

    一.搭建kvm虚拟化平台 1,安装前准备:启用虚拟化支持,添加内存和内核 2,安装kvm服务 挂载光盘 2)安装kvm调试工具 3) 安装管理虚拟机命令 4) 安装KVM管理控制台 3.启动虚拟化服务 ...

  9. linux搭建虚拟化平台报告,CentOS 7中搭建KVM虚拟化平台的方法步骤

    什么是虚拟化 虚拟化就是把硬件资源从物理方式转变为逻辑方式,打破原有物理结构,使用户可以灵活管理这些资源,并且允许1台物理机上同时运行多个操作系统,以实现资源利用率最大化和灵活管理的一项技术. 虚拟化 ...

最新文章

  1. 宏基因组报名倒计时!报名线上课还可免费参加线下课
  2. 服务器上安装运行fastqc
  3. ABAP OPEN SQL 模糊查询的方法
  4. ios 中的关联对象
  5. [codevs 1035] 火车停留
  6. 软件工程网络15个人阅读作业1 201521123038 游舒婷
  7. java 平台级模块系统_Java平台模块系统公众审查未能通过
  8. 引导性GCP:带有Google Cloud Pub / Sub的Spring Cloud Stream
  9. linux 查看zookeepr所在路径,Linux系统:Centos7下搭建ZooKeeper3.4中间件,常用命令总结...
  10. feign调用接口参数可以为null吗_FeignClient调用POST请求时查询参数被丢失的情况分析与处理...
  11. Android 五大布局简析
  12. Google 纪念万维网 30 年:没有 HTTP 协议就没有互联网
  13. 《ASP网络编程从入门到精通》
  14. matlab2018a怎么读取nc文件,[转]matlab批量读取nc文件
  15. 将货币转换为大写形式用c语言,C#:小写金额转换为大写
  16. GPS测量误差来源分析
  17. 软考高级/高项/信息系统项目管理师看江山好还是马军好?
  18. Logstash:使用 mutate 过滤器
  19. find commen elements in array 在数组中找到相同的元素 Swift
  20. 【2020-11-26】不扣JS系列之某医保服务平台数据获取

热门文章

  1. RNN模型与NLP应用:Simple RNN模型-3
  2. 【小白篇】从零开始搭建传奇服务器(只做自我娱乐之用)
  3. ArcGIS Maritime Server 开发教程(一)了解 ArcGIS Maritime Server
  4. python中screen用法_screen命令的使用
  5. OKX领投的P2E平台—Klay Dice 打造属于自己的生态!
  6. NBA历史上最长的连胜和连败纪录!
  7. java 8 Collectors.toMap 重复key 值处理、value为null处理
  8. Xilinx fifo研究总结
  9. [转] 身为管理者 会讲的六十八个故事
  10. iis如何发布网站 iis发布网站步骤