6.12.1、通过Xmanager - Passive管理kvm虚拟机(首先要安装xmanager):

1、安装虚拟化管理软件:

[root@centos7 ~]# yum install -y virt-manager openssh-askpass

#virt-manager:图形化管理虚拟机工具;openssh-askpass:远程连接KVM主机;

[root@centos7 ~]# yum groupinstall -y "Fonts"

[root@centos7 ~]# yum install -y dejavu-lgc-sans-fonts

#上面两行是解决xmanager-passive乱码的问题;

[root@centos7 ~]# yum install -y xorg-x11-font-utils xorg-x11-server-utils xorg-x11-utils xorg-x11-xauth xorg-x11-xinit

#安装x11图形界面工具;

[root@centos7 ~]# vim /etc/ssh/sshd_config

X11Forwarding yes

[root@centos7 ~]# systemctl restart sshd

#上面两行是开启ssh的X11转发功能;

2、在xshell中设置:

3、运行xmanager-passive:

提示:运行后是不会显示界面的,会在电脑任务栏的右下角出现一个"X"图标;

4、kvm宿主机主动连接xmanager-passive:

[root@centos7 ~]# export DISPLAY=172.16.1.254:0.0

#设定连接的ip端口;

[root@centos7 ~]# virt-manager &

[1] 3369

#执行该命令后xmanager-passive会自动跳出;

[root@centos7 ~]# echo $DISPLAY

172.16.1.254:0.0

[1]+ 完成 virt-manager

说明:当关掉Xmanager - Passive后virt-manager进程也会结束掉;

5、管理虚拟主机:

(1)查看虚拟机连接配置:

1)

2)

3)

4)

(2)查看虚拟机的相关配置项:

1)

2)

3)

4)

5)

6)

7)

8)

9)

10)

(3)克隆:

1)

6.12.2、通过网页方式管理kvm虚拟机:

1、安装WebVirtMgr依赖包:

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

[root@centos7 ~]# pip install numpy

2、下载webvirtmgr包和安装Python的Django环境:

(1)下载webvirtmgr包:

[root@centos7 ~]# git clone git://github.com/retspen/webvirtmgr.git

(2)安装django环境:

[root@centos7 ~]# cd webvirtmgr/

[root@centos7 webvirtmgr]# pip install -r requirements.txt

(3)设置管理用户信息:

[root@centos7 webvirtmgr]# ./manage.py syncdb

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'): #回车

Email address: #回车

Password: 123456 #输入密码

Password (again): 123456 #再次输入密码

Superuser created successfully.

Installing custom SQL ...

Installing indexes ...

Installed 6 object(s) from 1 fixture(s)

(4)生成配置文件:

[root@centos7 webvirtmgr]# ./manage.py collectstatic

(5)补充:添加其它管理用户的方法:

[root@centos7 webvirtmgr]# ./manage.py createsuperuser

3、配置nginx:

(1)拷贝web包到nginx站点目录并授权:

[root@centos7 webvirtmgr]# cd ..

[root@centos7 ~]# mv webvirtmgr /var/www/

[root@centos7 ~]# chown -R nginx:nginx /var/www/webvirtmgr

(2)配置nginx.conf:

主要配置的是server部分;

[root@centos7 ~]# cat /etc/nginx/nginx.conf

user nginx;

worker_processes auto;

error_log /var/log/nginx/error.log;

pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {

worker_connections 1024;

}

http {

log_format main '$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;

tcp_nopush on;

tcp_nodelay on;

keepalive_timeout 65;

types_hash_max_size 2048;

include /etc/nginx/mime.types;

default_type application/octet-stream;

include /etc/nginx/conf.d/*.conf;

server {

listen 80 default_server;

server_name $hostname;

location /static/ {

root /var/www/webvirtmgr/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;

}

}

}

(3)检查nginx的配置文件:

[root@centos7 nginx]# nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

(4)启动nginx并加入到开机自启动:

[root@centos7 ~]# systemctl start nginx

[root@centos7 ~]# systemctl enable nginx

4、创建文件/etc/supervisord.d/webvirtmgr.ini如下内容:

[root@centos7 ~]# vim /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

logfile=/var/log/supervisor/webvirtmgr.log

log_stderr=true

user=nginx

[program:webvirtmgr-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

5、启动supervisord并加入开机自启动:

[root@centos7 ~]# systemctl start supervisord.service

[root@centos7 ~]# systemctl enable supervisord.service

6、配置ssh认证:

(1)说明:

ssh和tcp设置一种即可,其实就是设置无密码登录,要注意的是从webvirtmgr的什么用户到宿主机的什么用户的无密码登录,

比如我用nginx用户跑的django webvirtmgr,而宿主机是root跑的virsh,所以需要设置nginx到root的无密码登录,git官网推

荐的是用nginx用户跑django webvirtmgr,webvirtmgr用户跑的virsh,所以设置的是nginx用户到宿主机webvirtmgr用户的

无密码登录。

(2)发送认证公钥:

[root@centos7 ~]# su - nginx -s /bin/bash

-bash-4.2$ ssh-keygen

-bash-4.2$ touch ~/.ssh/config

-bash-4.2$ echo -e "StrictHostKeyChecking=no\nUserKnownHostsFile=/dev/null" >> ~/.ssh/config

-bash-4.2$ chmod 0600 ~/.ssh/config

-bash-4.2$ ssh-copy-id root@localhost

#如果有其它的kvm宿主机,也需要将公钥发送到其它的宿主机上;

7、在网页端管理虚拟机:

1、登录:

2、连接宿主机:

(1)

(2)

(3)

3、管理宿主机:

(1)添加存储池(存放虚拟机的虚拟磁盘用):

(2)添加桥接网络:

(3)虚拟机配置:

6.12.3、小结:

1、使用可视化工具连接kvm宿主机后能够在管理工具上查看虚拟机的界面,主要用的是vnc,默认的vnc监听是"0.0.0.0:0";

2、以上内容没有写如何在kvm可视化管理工具中如何安装操作系统,因为安装较为简单,这里只写出了一些重要参数的设置

项,在生产中建议使用命令安装虚拟机,然后使用kvm可视化管理工具进行克隆即可;

3、使用manager-passvie管理kvm虚拟机需要在每台宿主机上安装"virt-manager"等管理工具,且每次用时都需要在宿主机

上执行"virt-manager &"命令,非常的不方便;WebVirtMgr管理平台可以单独装一台服务器,然后通过ssh免密连接到其它

的kvm宿主机,实现对多台kvm宿主机的管理;

4、以上kvm可视化管理工具用于小规模的服务器kvm虚拟化管理,如果是大规模的kvm虚拟化管理,需要使用openstack;

6.12、通过kvm可视化管理虚拟机的更多相关文章

  1. kvm命令管理虚拟机

    virsh 既有命令行模式,也有交互模式,在命令行直接输入 virsh 就进入交互模式, virsh 后面跟命令参数,则是命令行模式: KVM 工具集合 libvirt:操作和管理KVM虚机的虚拟化 ...

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

    一.背景说明  在之前的篇章中,提到在webvirtmgr里安装linux系统的vm,下面说下安装windows系统虚拟机的操作记录: 由于KVM管理虚拟机的硬盘和网卡需要virtio驱动,linux ...

  3. CloudStack+KVM环境搭建(步骤很详细,说明ClockStack是用来管理虚拟机的)

    文章目录环境准备配置本地域名解析关闭selinux安装ntp服务安装管理端安装Mysql数据库安装服务端RPM:初始化CloudStack数据库:初始化cloudstack管理服务器安装系统虚拟机安装 ...

  4. KVM虚拟机管理——虚拟机创建和操作系统安装

    1. 概述2. 交互式安装2.1 图形化-本地安装2.1.1 图形化本地CDROM安装2.2.2 图形化本地镜像安装2.2 命令行-本地安装2.2.1 命令行CDROM安装2.3 图形化-网络安装2. ...

  5. CentOS7.1 KVM虚拟化之经常使用管理虚拟机命令(3)

    一.查看虚拟机列表及状态 [root@kvm01 ~]# virsh list --all Id Name State ---------------------------------------- ...

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

    公司机房有一台2U的服务器(64G内存,32核),由于近期新增业务比较多,测试机也要新增,服务器资源十分有限.所以打算在这台2U服务器上部署kvm虚拟化,虚出多台VM出来,以应对新的测试需求.当KVM ...

  7. KVM Web管理平台 WebVirtMgr

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

  8. KVM虚拟化管理平台WebVirtMgr部署及使用

    KVM虚拟化管理平台WebVirtMgr部署及使用   需求: 公司机房有一台2U的服务器(64G内存,32核),由于近期新增业务比较多,测试机也要新增,服务器资源十分有限.所以打算在这台2U服务器上 ...

  9. [原创]KVM虚拟化管理平台的实现

    KVM虚拟化管理平台的实现 源码链接:https://github.com/wsjhk/IaaS_admin.git 根据KVM虚拟化管理的要求,设计并实现网页操作管理KVM虚拟机.设计原理架构如下图 ...

随机推荐

  1. markerdown基础

    标题 用#+空格 字体 加粗两边两个** 斜体两边* 斜体加粗三个* 引用 '>' 分割线 三个---或者三个*** 图片 ![截图]() 超链接 点击跳转到文章 []+() 列表 1 + 点+ ...

  2. Docker------Idea连接远程并生成和上传镜像

    1.Docker开启远程访问连接 备注: 1)Linux是CentOS7版本 2)安装Docker可参考: https://www.cnblogs.com/tianhengblogs/p/125202 ...

  3. ]# dmesg | grep ATAcentos下查看网卡,主板,CPU,显卡,硬盘型号等硬件信息

    centos下查看网卡,主板,CPU,显卡,硬盘型号等硬件信息 osc_4o5tc4xq 2019/10/11 15:03 阅读数 253 centos下查看网卡,主板,CPU,显卡,硬盘型号等硬件信 ...

  4. 一、python入门练习题

    题目: 练习1:华氏温度转摄氏温度. 练习2:输入圆的半径计算计算周长和面积. 练习3:输入年份判断是不是闰年. 答案: 练习1: """ 将华氏温度转换为摄氏温度 F ...

  5. Modbus RTU CRC校验码计算方法

    在CRC计算时只用8个数据位,起始位及停止位,如有奇偶校验位也包括奇偶校验位,都不参与CRC计算. CRC计算方法是: 1.  加载一值为0XFFFF的16位寄存器,此寄存器为CRC寄存器. 2.   ...

  6. 11.20 yum:自动化RPM包管理工具

    yum(Yellow dog Updater Modified)是多个Linux发行版的软件包管理器,例如Redhat RHEL.CentOS和Fedora.yum主要用于自动安装.升级rpm软件包, ...

  7. vue项目使用百度地图API获取经纬度

    一.首先在百度api注册获得ak密钥 二.进行引入 (1).第一种方式: 直接在vue中index.html中用script标签引入. //你的ak密钥需要替换真实的你的ak码 <script ...

  8. Azure Synapse Link for Dataverse

    MyBuild - Scale, analyze and serve Microsoft Dynamics 365 application data with Azure 本周的微软Bulid大会上发 ...

  9. 第7讲 | ICMP与ping:投石问路的侦察兵

    第7讲 | ICMP与ping:投石问路的侦察兵 ping 是基于 ICMP 协议工作的.ICMP 全称 Internet Control Message Protocol,就是互联网控制报文协议. ...

  10. win系统下如何安装xgboost,开发环境是anaconda,以及这中间需要注意的问题

    最近学到了xgboost,但是anaconda并没有这个环境只好自己安装了... 注: (1)并没有测试anaconda在2.x的版本下是如何安装的, 基本上应该是大同小类的,我的anaconda版本 ...