Kvm --05 Password protection: WebVirtMgr Kvm management of

Password protection: Kvm management of WebVirtMgr

1 Introduction

As more and more cases Kvm host, the host of the need for the state to regulate, decided to adopt WebVirtMgr as Kvm virtualization web management tools, graphical WEB, people can more easily view Kvm host and operations .

WebVirtMgr the past two years to develop faster, more active, a very fresh Kvm management platform that provides unified management of host and virtual machines, it is different from Kvm comes with a graphical management tools (virtual machine manager), let Kvm management becomes more visual, small and medium Kvm scenario brings more convenient.

WebVirtMgr using nearly pure Python development, which is based on the front end of the Django Python, the rear end of the interface is based on the Python Libvirt will Kvm daily management operations become more visualization.

2. Features

Simple, easy-to-use interface to be on Kvm by libvirt management API provides virtual machine lifecycle management

3. Function

Host CPU utilization management feature supports the following memory utilization, network resource pool management storage resource pool management virtual machine image clone a virtual machine snapshot management log management virtual machine migration

Virtual Machine Manager supports the following features

CPU utilization

Memory Usage

CD Management

Off / On / Pause virtual machine

Install the virtual machine VNC

console connection to create a snapshot

4. Deploy

1), the installation of dependencies

Check the official website: https: //github.com/retspen/webvirtmgr/wiki/Install-WebVirtMgr

You must first install Kvm virtualization environment, and here I will WebVirtMgr Kvm server and server on the same machine deployment, namely stand-alone deployment.

#1.安装epel源
[root@kvm02 ~]# yum install epel-release
#2.安装依赖及环境
[root@kvm02 ~]# yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx
#3.安装编译软件
[root@kvm02 ~]# yum -y install gcc python-devel

#4.安装numpy(Python进行科学计算的基础软件包)
[root@kvm02 webvirtmgr]# pip  install  -r requirements.txt  -i https://pypi.tuna.tsinghua.edu.cn/simple
[root@kvm02 ~]# pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple

2) install Python demand environment

#1.从git-hub中下载相关的webvirtmgr代码
[root@kvm02 ~]# cd /usr/local/src/
[root@kvm02 /usr/local/src]# git clone git://github.com/retspen/webvirtmgr.git

#2.安装WebVirtMgr
[root@kvm02 /usr/local/src]# cd webvirtmgr/
[root@kvm02 /usr/local/src/webvirtmgr]# pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

#3.检查sqlite3 (备注:自带不需要安装,导入模块检查一下。)
[root@kvm02 /usr/local/src/webvirtmgr]# python
Python 2.7.5 (default, Aug 7 2019, 00:51:29)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> exit()

#4.初始化账号
[root@kvm02 /usr/local/src/webvirtmgr]# chmod +x manage.py
[root@kvm02 /usr/local/src/webvirtmgr]# ./manage.py syncdb

#5.生成配置文件
[root@kvm02 /usr/local/src/webvirtmgr]# ./manage.py collectstatic

#6.添加管理员账号,这个是管理员账号,用上面的admin和这个账号都可以登录
[root@kvm02 /usr/local/src/webvirtmgr]# ./manage.py createsuperuser
WARNING:root:No local_settings file found.
Username (leave blank to use 'root'): ops
Email address: [email protected]
Password:
Password (again):
Superuser created successfully.

#7.拷贝web到相关目录
[root@kvm02 /usr/local/src/webvirtmgr]# mkdir -pv /var/www
mkdir: created directory '/var/www'
[root@kvm02 /usr/local/src/webvirtmgr]# cp -rp /usr/local/src/webvirtmgr /var/www/webvirtmgr

#8.设置ssh
[root@kvm02 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:CAIi5mok4liJ/kdhHu45iknOPhfla3rG+NLyNVSPwCk root@kvm02
The key's randomart image is:
+---[RSA 2048]----+
|+. |
|=o . . . |
|+o+ .E + . |
|O. .+o+.o o |
|o+ o+..S. . |
|. ..o.o |
| . .==.o |
|+.o=oBo . |
|.*ooXo |
+----[SHA256]-----+
#传密钥给当前主机
[root@kvm02 ~]# ssh-copy-id  -i  .ssh/id_rsa.pub   10.0.0.162

#设置加密连接
[root@kvm02 ~]# ssh 10.0.0.162 -L localhost:8000:localhost:8000 -L localhost:6080:localhost:60

3), arranged Nginx

#1.打开/etc/nginx/nginx.conf文件,注释server段

#2.编辑配置文件
[root@kvm02 ~]# cat /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 $scheme;
    proxy_connect_timeout 600;
    proxy_read_timeout 600;
    proxy_send_timeout 600;
    client_max_body_size 1024M; # Set higher depending on your needs
    }
}


#3.重新启动nginx服务
[root@kvm02 ~]# systemctl restart nginx

#4.设置权限
[root@kvm02 ~]# chown -R nginx:nginx /var/www/webvirtmgr
#5.创建/etc/supervisord.d/webvirtmgr.ini具有以下内容的文件
[root@kvm02 ~]# cat /etc/supervisord.d/webvirtmgr.ini
[program:webvirtmgr]
command=/usr/bin/python /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr.log
redirect_stderr=true
user=nginx

[program:webvirtmgri-console]
command=/usr/bin/python /var/www/webvirtmgr/console/webvirtmgr-console
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
redirect_stderr=true
user=nginx

#6.启动守护进程supervisord
[root@kvm02 ~]# systemctl start supervisord.service
[root@kvm02 ~]# systemctl enable supervisord.service

#7.查看端口
[root@kvm02 ~]# netstat -lntp |grep -E '6080|8000'
tcp 0 0 127.0.0.1:6080 0.0.0.0:* LISTEN 14866/ssh
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 14866/ssh
tcp6 0 0 ::1:6080 :::* LISTEN 14866/ssh
tcp6 0 0 ::1:8000 :::* LISTEN 14866/ssh

8. browser IP address to access http://10.0.0.182/login/

Only the super administrator login to see the "infrastructure" window [img]

4), remote connections

#使用tcp进行对远程libvirtd进行连接访问的配置如下:
#1.修改文件/etc/sysconfig/libvirtd,用来启用tcp的端口(修改内容如下过滤出来的所示)
[root@kvm02 ~]# grep -Ev "^$|#" /etc/sysconfig/libvirtd
LIBVIRTD_CONFIG=/etc/libvirt/libvirtd.conf
LIBVIRTD_ARGS="--listen"

#2.修改文件/etc/libvirt/libvirtd.conf,(修改过滤出来的内容)
[root@kvm02 ~]# grep -Ev "^$|#" /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
tcp_port = "16509"
listen_addr = "0.0.0.0"
auth_tcp = "none"

#3.重启libvirtd
[root@kvm02 ~]# systemctl restart libvirtd.service

#4.查看端口16509是否启动
[root@kvm02 ~]# netstat -lntp|grep 16509
tcp 0 0 0.0.0.0:16509 0.0.0.0:* LISTEN 15344/libvirtd

#5.在source host连接dest host远程libvirtd查看信息

[root@kvm02 ~]# virsh -c qemu+tcp://10.0.0.182/system
Welcome to virsh, the virtualization interactive terminal.

Type: 'help' for help with commands
'quit' to quit

[root@kvm02 ~]# echo " * - nofile 65534"  >> /etc/security/limits.conf
virsh #         #表示成功

5), update

[root@kvm02 conf.d]# cd /var/www/webvirtmgr
[root@kvm02 webvirtmgr]# git pull
[root@kvm02 webvirtmgr]# ./manage.py collectstatic
[root@kvm02 webvirtmgr]# service supervisord restart

6), web end for connection tcp

7), add multiple managed

Guess you like

Origin www.cnblogs.com/gongjingyun123--/p/12010197.html