一、webvirtmgr介绍及环境说明

温馨提示:安装KVM是需要2台都操作的,因为我们是打算将2台都设置为宿主机所有都需要安装KVM相关组件

github地址https://github.com/retspen/webvirtmgr

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

查看服务器版本号

[root@webc ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

内核版本

[root@webc ~]# uname -r
3.10.0-1160.42.2.el7.x86_64

关闭Selinux & 防火墙

[root@webc ~]# systemctl stop firewalld
[root@webc ~]# systemctl disable firewalld
[root@webc ~]# setenforce 0
setenforce: SELinux is disabled
[root@webc ~]# sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config

更新软件包并安装epel扩展源

[root@webc ~]# yum update
[root@webc ~]# yum install epel*

查看python版本

[root@webc ~]# python -V
Python 2.7.5
[root@webc ~]#

查看KVM 驱动是否加载

[root@webc ~]# lsmod | grep kvm
kvm_intel 188740 0
kvm 637515 1 kvm_intel
irqbypass 13503 1 kvm
[root@webc ~]#
[root@webc ~]#
[root@webc ~]# modprobe -a kvm
[root@webc ~]# modprobe -a kvm_intel
[root@webc ~]#

免密配置

[root@webc ~]# ssh-keygen
[root@webc ~]# ssh-copy-id -i .ssh/id_rsa.pub root@192.168.1.104

二、安装KVM

安装KVM依赖包及管理工具

kvm属于内核态,不需要安装。但是需要一些管理工具包

[root@webc ~]# yum install qemu-img qemu-kvm qemu-kvm-tools virt-manager virt-viewer virt-v2v virt-top libvirt libvirt-Python libvirt-client python-virtinst bridge-utils tunctl
[root@webc ~]# yum install -y virt-install
[root@webc ~]#
[root@webc ~]# systemctl start libvirtd.service
[root@webc ~]# systemctl enable libvirtd.service
[root@webc ~]#
[root@webc ~]# cd cby/kvm/
[root@webc kvm]#
[root@webc kvm]#
[root@webc kvm]# git clone https://github.com/palli/python-virtinst.git
[root@webc kvm]# cd python-virtinst/
[root@webc python-virtinst]# python setup.py install
[root@webc python-virtinst]# virt-install
[root@webc python-virtinst]# yum install bridge-utils
[root@webc python-virtinst]#
[root@webc python-virtinst]# vim /etc/sysconfig/network-scripts/ifcfg-br0
[root@webc python-virtinst]#
[root@webc python-virtinst]#
[root@webc python-virtinst]#
[root@webc python-virtinst]#
[root@webc python-virtinst]#
[root@webc python-virtinst]# cat /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.1.49
NETMASK=255.225.255.0
GATEWAY=192.168.1.1
DNS1=192.168.1.1
[root@webc python-virtinst]# brctl show
bridge name bridge id STP enabled interfaces
br-0d093958d245 8000.0242d5824d14 no
br-2e2d3c481379 8000.0242884030e2 no
br-36a6ad3375a8 8000.0242d7d7f1ef no
br-66a9675a6dd5 8000.024248a61c72 no
br-b7daf4844ff7 8000.024263dd4715 no
br-deba197eb09e 8000.0242b290e104 no
br0 8000.000000000000 no
docker0 8000.0242858c017c no vethe14f7ac
docker_gwbridge 8000.0242588c6db0 no
virbr0 8000.5254009ba65a yes virbr0-nic
[root@webc python-virtinst]# ln -s /usr/libexec/qemu-kvm /usr/sbin/

三、WebVirtMgr 安装

安装pip、git及supervisor && Nginx

WebVirtMgr只在管理端安装

[root@webc ~]# yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor gcc python-devel

使用pip安装Python扩展程序库

[root@webc ~]# pip install numpy

git克隆配置并运行WebVirMgr

[root@webc ~]# cd cby/
[root@webc cby]# mkdir kvm
[root@webc cby]# cd kvm
[root@webc kvm]# pwd
/root/cby/kvm
[root@webc kvm]#
[root@webc kvm]# git clone git://github.com/retspen/webvirtmgr.git
正克隆到 'webvirtmgr'...
remote: Enumerating objects: 5614, done.
remote: Total 5614 (delta 0), reused 0 (delta 0), pack-reused 5614
接收对象中: 100% (5614/5614), 2.97 MiB | 748.00 KiB/s, done.
处理 delta 中: 100% (3606/3606), done.
[root@webc kvm]#
[root@webc kvm]#
[root@webc kvm]# cd webvirtmgr
[root@webc webvirtmgr]# pip install -r requirements.txt
#初始化环境
[root@webc webvirtmgr]# ./manage.py syncdb #配置Django 静态页面
[root@webc webvirtmgr]# ./manage.py collectstatic

启动WebVirMgr

前台启动WebVirMgr,默认是Debug模式同时日志打印在前台

用户名和密码是我们刚刚创建的

下载Nginx

[root@webc webvirtmgr]# cd ..
[root@webc kvm]# ls
webvirtmgr
[root@webc kvm]#
[root@webc kvm]# mkdir nginx
[root@webc kvm]# cd nginx
[root@webc nginx]# wget https://nginx.org/download/nginx-1.20.1.tar.gz
[root@webc nginx]# tar xf nginx-1.20.1.tar.gz
[root@webc nginx]# cd nginx-1.20.1/
[root@webc nginx-1.20.1]#

修改nginx配置文件

[root@webc conf]# vim nginx.conf
[root@webc conf]#
[root@webc conf]# cat nginx.conf
user  root;
worker_processes 1; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
listen 90;
server_name 192.168.1.104;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
#root html;
#index index.html index.htm;
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 5120M;
}
        location /static/ {
root /root/cby/kvm/webvirtmgr;
expires max;
}
        error_page   500 502 503 504  /50x.html;
location = /50x.html {
root html;
}
    }
}
[root@webc conf]#

安装Nginx

[root@webc nginx-1.20.1]# yum install -y gcc glibc gcc-c++ prce-devel openssl-devel pcre-devel
[root@webc nginx-1.20.1]# useradd -s /sbin/nologin nginx -M
[root@webc nginx-1.20.1]# ./configure --prefix=/root/cby/kvm/nginx/ --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module
[root@webc nginx-1.20.1]# make && make install

启动Nginx

[root@webc nginx-1.20.1]# cd /root/cby/kvm/nginx/sbin/
[root@webc sbin]# /root/cby/kvm/nginx/sbin/nginx -t
nginx: the configuration file /root/cby/kvm/nginx//conf/nginx.conf syntax is ok
nginx: configuration file /root/cby/kvm/nginx//conf/nginx.conf test is successful
[root@webc sbin]# /root/cby/kvm/nginx/sbin/nginx

使用systemctl启停服务

[root@webc sbin]# cat > /etc/supervisord.d/webvirtmgr.ini << EOF
[program:webvirtmgr]
command=/usr/bin/python /root/cby/kvm/webvirtmgr/manage.py run_gunicorn -c /root/cby/kvm/webvirtmgr/conf/gunicorn.conf.py
directory=/root/cby/kvm/webvirtmgr
autostart=true
autorestart=true
logfile=/var/log/supervisor/webvirtmgr.log
log_stderr=true
user=root [program:webvirtmgr-console]
command=/usr/bin/python /root/cby/kvm/webvirtmgr/console/webvirtmgr-console
directory=/root/cby/kvm/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
redirect_stderr=true
user=root
EOF

启动supervisor

[root@webc webvirtmgr]# systemctl daemon-reload
[root@webc webvirtmgr]# systemctl stop supervisord
[root@webc webvirtmgr]# systemctl start supervisord

查看是否启动成功

[root@webc webvirtmgr]# supervisorctl status
webvirtmgr RUNNING pid 23783, uptime 0:00:11
webvirtmgr-console RUNNING pid 23782, uptime 0:00:11
[root@webc webvirtmgr]#

四、Web界面配置webvirtmgr

4.1 添加主机设置存储

1.Add Connection 添加宿主机(即KVM主机)

2.点击SSH连接

3.Label 为主机名,必须为主机名做免密

4.IP 为宿主机IP

5.用户名为服务器用户名

6.点击添加

KVM WEB管理工具 WebVirtMgr的更多相关文章

  1. KVM web管理工具——WebVirtMgr(一)

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

  2. 快速搭建 kvm web 管理工具 WebVirtMgr

    作者:SRE运维博客 博客地址: https://www.cnsre.cn/ 文章地址:https://www.cnsre.cn/posts/211117937177/ 相关话题:https://ww ...

  3. KVM WEB管理工具webvirtmgr安装和使用

    生产环境的KVM宿主机越来越多,需要对宿主机的状态进行调控.这里用webvirtmgr进行管理.图形化的WEB,让人能更方便的查看kvm 宿主机的情况和操作 1 安装支持的软件源 yum -y ins ...

  4. KVM WEB管理工具——WebVirtMgr(二)日常配置

    配置宿主机 1.登录WebVirtMgr管理平台 2.添加宿主机 选择首页的WebVirtMgr -->Addd Connection 选择“SSH链接“,设置Label,IP,用户 注意:La ...

  5. KVM web管理工具——WebVirtMgr

    系统环境: [root@kvm-admin ~]# cat /etc/redhat-release CentOS Linux release (Core) 关闭防火墙.selinux [root@kv ...

  6. KVM Web管理平台 WebVirtMgr

    WebVirtMgr介绍 WebVirtMgr是一个KVM管理平台,让kvm管理变得更为可视化,对中小型kvm应用场景带来了更多方便.WebVirtMgr采用几乎纯Python开发,其前端是基于Pyt ...

  7. 虚拟化技术之kvm WEB管理工具kimchi

    在前面的博客中,我们介绍了kvm的各种工具,有基于图形管理的virt-manager.有基于命令行管理的virt-install .qemu-kvm.virsh等等:今天我们来介绍一款基于web界面的 ...

  8. KVM网页管理工具WebVirtMgr部署

    KVM-WebVirtMgr 0ther https://github.com/retspen/webvirtmgr/wiki System Optimization(Only CentOS6.X) ...

  9. kvm-web管理工具webvirtmgr

    前言: 使用开源的虚拟化技术,对公司自有的少数服务器进行虚拟化,在满足业务需求的同时,并未增加投入,同时也避免了使用云主机的不便,技术层面,kvm是开源的虚拟化产品,虚拟化性能出众,更重要的是免费!! ...

  10. KVM管理工具 WebVirtMgr

    WEB管理工具 WebVirtMgr WebVirtMgr是一个基于libvirt的Web界面,用于管理虚拟机.它允许您创建和配置新域,并调整域的资源分配.VNC查看器为来宾域提供完整的图形控制台.K ...

随机推荐

  1. redis面试题汇总

    1redis持久化机制 redis是一个支持持久化的内存数据库,通过持久化机制把内存中的数据同步到硬盘文件来保证数据持久化,当redis重启后通过把硬盘文件重新加载到内存,就能达到恢复数据的目的 2缓 ...

  2. vue 数组对象去重

    unique(arr) {     const res = new Map();     return arr.filter((arr) => !res.has(arr.id) &&am ...

  3. vue 组件之间事件触发($emit)与event Bus($on)的用法说明

    组件之间事件触发 新增按钮组件: 操作按钮组合组件: 此时有个需求就是,无论是哪个按钮,如果改变了列表中的数据,列表需要实时更新数据. 此时就需要用到组件间的事件触发. 父子组件之间事件触发可以使用$ ...

  4. centos7 系统运行中做raid磁盘阵列

    插入磁盘 lsblk查看磁盘总体情况 对sdb1等需要做的硬盘进行制作 fdisk /dev/sdb 开始 n 创建 p 给资源回车 重选代码 t 确认磁盘阵列代码 fd 保存w 首先安装工具 mda ...

  5. echarts图表自适应屏幕/浏览器窗口大小

    昨天完成echarts柱状图的生成,突然发现在项目中还有个小缺陷,当柱状图完成渲染之后,放大缩小浏览器窗口echarts柱状图宽度没有随之改变. 接昨天的代码做了小调整: setTimeout(fun ...

  6. 【PostgreSql】more than one owned sequence found

    do --check seq not in sync $$ declare _r record; _i bigint; _m bigint; begin for _r in ( Select DIST ...

  7. SpringMvc配置和原理

    运行原理 DispatcherServlet通过HandlerMapping在MVC的容器中找到处理请求的Controller,将请求提交给Controller,Controller对象调用业务层接口 ...

  8. CentOS7 安裝DHCP服務並啟用DHCP failover

    1. 安裝dhcp服務 yum install -y dhcp 2. host1 vi /etc/dhcp/dhcpd.failover failover peer "dhcpfailove ...

  9. ASP.NET的MVC模式中分布页和布局页的使用

    大概描述一下,分布页是布局页的一部分,分布页就相当于小图标,布局页就相当于PPT模板,PPT模板可以加入一些小图标(分布页),你只需要改改内容就好,视图创建的时候要选择包含布局页的 首先,去Contr ...

  10. CAS无锁机制

    1. 背景 传统Synchronized锁:悲观,如果没有获取到锁的情况下,会让当前线程变为阻塞的状态,释放CPU执行权,效率非常低. 乐观锁(自旋):本质上没有锁,没有死锁现象,而且效率比较高,不会 ...