KVM管理工具 WebVirtMgr

来源:https://www.cnblogs.com/wenrulaogou/archive/2020/01/21/12220977.html
-Advertisement-
Play Games

WEB管理工具 WebVirtMgr WebVirtMgr是一個基於libvirt的Web界面,用於管理虛擬機。它允許您創建和配置新域,並調整域的資源分配。VNC查看器為來賓域提供完整的圖形控制台。KVM是目前唯一支持的虛擬機管理程式。 基礎環境 hosts免密登錄 kvm所用的所有伺服器都需要互相 ...


WEB管理工具 WebVirtMgr

WebVirtMgr是一個基於libvirt的Web界面,用於管理虛擬機。它允許您創建和配置新域,並調整域的資源分配。VNC查看器為來賓域提供完整的圖形控制台。KVM是目前唯一支持的虛擬機管理程式。

基礎環境

[root@BJtest32 ~]# cat /etc/redhat-release 
CentOS release 6.6 (Final)
[root@BJtest32 ~]# uname -r
2.6.32-504.el6.x86_64
[root@BJtest32 ~]# getenforce 
Disabled
查看是否支持虛擬化
cat /proc/cpuinfo | grep -E 'vmx|svm'
查看KVM 驅動是否載入
lsmod | grep kvm
如果沒有載入kvm驅動,利用命令載入驅動
modprobe -a kvm
modprobe -a kvm_intel

hosts免密登錄

kvm所用的所有伺服器都需要互相做免密
如果只有一臺機器,把本機的id_rsa.pub 拷貝到authorized_keys里

[root@BJtest32 ~]# ssh-keygen 
[root@BJtest32 ~]# -copy-id -i .ssh/id_rsa.pub root@$IP

依賴包及管理工具

kvm屬於內核,不需要安裝。但是需要一些管理工具包
yum install -y qemu-kvm libvirt libvirt-python libguestfs-tools virt-install virt-manager python-virtinst libvirt-client virt-viewer qemu-kvm-tool
libvirt 用來管理kvm
yum install -y virt-install
安裝管理KVM命令

WebVirtMgr 安裝

官方地址
WebVirtMgr只在管理端安裝

[root@BJtest32 data]# yum -y install http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
[root@BJtest32 data]# yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx
[root@BJtest32 data]# git clone git://github.com/retspen/webvirtmgr.git
[root@BJtest32 data]# cd webvirtmgr
[root@BJtest32 webvirtmgr]# pip install -r requirements.txt # or python-pip (RedHat, Fedora, CentOS, OpenSuse)
#requirements.txt主要是用於記錄所有依賴包及其精確的版本號。以便新環境部署
[root@BJtest32 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.
這裡需要我們輸入Yes,配置管理員用戶
配置信息如下

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: [email protected]                              #郵箱地址 (可以不填)
Password:                                               #管理員用戶密碼
Password (again):                                       #重覆輸入密碼
Superuser created successfully.                         #創建成功
Installing custom SQL ...
Installing indexes ...
Installed 6 object(s) from 1 fixture(s)

#配置Django 靜態頁面
[root@BJtest32 webvirtmgr]# ./manage.py collectstatic
輸入Yes即可

#如果還需要再添加管理員用戶,執行下麵的命令

#前臺啟動WebVirMgr,預設是Debug模式同時日誌列印在前臺
[root@BJtest32 webvirtmgr]# ./manage.py createsuperuser
以上執行Python腳本必須在webvirtmgr目錄

啟動WebVirMgr

前臺啟動WebVirMgr,預設是Debug模式同時日誌列印在前臺

[root@BJtest32 webvirtmgr]# ./manage.py runserver 0:8000
IP+8000埠訪問

image.png
用戶名和密碼就是剛剛創建的
image.png
登錄成功,沒有報錯。
現在在伺服器端Ctrl+C退出
安裝Nginx使用supervisor進行管理。

配置Nginx

Nginx安裝 安裝完成後修改配置文件

[root@BJtest32 conf.d]# cat webvirtmgr.conf 
server {
    listen       80;
    server_name  webvirtmgr.nfsnobody.com;
    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 $remote_addr;
    proxy_connect_timeout 600;
    proxy_read_timeout 600;
    proxy_send_timeout 600;
    client_max_body_size 5120M;
      }
location /static/ {
    root /data1/webvirtmgr;
    expires max;
  }
}

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

配置supervisor

supervisorctl所有的操作都需要在webvirtmgr的安裝目錄下,否則會提示找不到文件
WebVirtMgr預設使用supervisor進行管理(啟動停止服務) 所以我們需要配置supervisor

安裝supervisor

[root@BJtest32 ~]# yum remove supervisor -y
[root@BJtest32 ~]# pip install supervisor==3.1.3
[root@BJtest32 ~]# echo_supervisord_conf > /etc/supervisor/supervisord.conf
#修改配置文件
[root@BJtest32 ~]# vim /etc/supervisord.conf
#新增以下內容
[include]
files = /etc/supervisord.d/*.conf

#創建目錄                                                                       
[root@BJtest32 ~]# mkdir /etc/supervisord.d/


#配置service
[root@BJtest32 ~]# vi /etc/init.d/supervisord
#!/bin/bash
#
# supervisord   This scripts turns supervisord on
#
# Author:       Mike McGrath <[email protected]> (based off yumupdatesd)
#
# chkconfig:    - 95 04
#
# description:  supervisor is a process control utility.  It has a web based
#               xmlrpc interface as well as a few other nifty features.
# processname:  supervisord
# config: /etc/supervisor/supervisord.conf
# pidfile: /tmp/supervisord.pid
#
# source function library
. /etc/rc.d/init.d/functions
PIDFILE=/tmp/supervisord.pid

RETVAL=0
start() {
    echo -n $"Starting supervisord: "
    daemon "supervisord --pidfile=$PIDFILE -c /etc/supervisord.conf"
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/supervisord
}
stop() {
    echo -n $"Stopping supervisord: "
    killproc supervisord
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/supervisord
}
restart() {
    stop
    start
}
case "$1" in
  start)
    start
    ;;
  stop) 
    stop
    ;;
  restart|force-reload|reload)
    restart
    ;;
  condrestart)
    [ -f /var/lock/subsys/supervisord ] && restart
    ;;
  status)
    status supervisord
    RETVAL=$?
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
    exit 1
esac
exit $RETVAL
[root@BJtest32 ~]# chmod 755 /etc/init.d/supervisord
[root@BJtest32 ~]# chkconfig supervisord on

supervisord 啟動成功後,可以通過 supervisorctl 客戶端控制進程,啟動、停止、重啟。
運行 supervisorctl 命令,不加參數,會進入 supervisor 客戶端的交互終端,並會列出當前所管理的所有進程。

創建supervisor配置文件

#創建配置文件
[root@BJtest32 ~]# vi /etc/supervisord.d/webvirtmgr.conf
[program:webvirtmgr]
command=/usr/bin/python /data/webvirtmgr/manage.py run_gunicorn -c /data/webvirtmgr/conf/gunicorn.conf.py
directory=/data/webvirtmgr
autostart=true
autorestart=true
logfile=/var/log/supervisor/webvirtmgr.log
log_stderr=true
user=root

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

#重啟supervisor
[root@BJtest32 ~]# /etc/init.d/supervisord status
supervisord (pid  6877) is running...
[root@BJtest32 ~]# /etc/init.d/supervisord restart
[root@BJtest32 ~]# supervisorctl status
webvirtmgr                       RUNNING   pid 8773, uptime 0:01:12
webvirtmgr-console               RUNNING   pid 8772, uptime 0:01:12

Web界面配置webvirtmgr

1.Add Connection 添加宿主機(即KVM主機)
2.點擊SSH連接
3.Label 為主機名,必須為主機名做免密
4.IP 為宿主機IP
5.用戶名為伺服器用戶名
6.點擊添加
image.png
添加完後點擊主機名激活
image.png
虛機實例就是已經存在的虛擬機
image.png
創建存儲KVM鏡像目錄
KVM中的虛擬機都是以鏡像的方式進行存儲

image.png
根據自己伺服器的分區靈活選擇位置
名稱: 這裡的名稱顯示的名稱
路徑: 即存儲KVM虛擬機路徑
image.png
創建完後需要創建鏡像(相當於虛擬硬碟大小)
image.png
創建鏡像

下麵“Metadata”前的小方框一定不能勾選(預設是勾選的,要去掉!)
這裡添加的“鏡像”就是所創建虛擬機的硬碟空間
虛擬機所占用的空間就是這個“鏡像”所在的宿主機下路徑所在的分區空間(也就是/home/kvm/kvmstorage/,即宿主機的home分區)


image.png


創建完畢
image.png

上傳鏡像

創建完虛擬硬碟,我們在創建一個IOS鏡像目錄
點擊>存儲池>NEW_Storage
image.png
點擊上傳鏡像
image.png
選中鏡像選擇上傳
image.png
除了在瀏覽器上傳,還可以直接下載阿裡雲鏡像站鏡像。只要鏡像在/opt下就會被獲取

wget -P /opt/ https://mirrors.aliyun.com/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-DVD-1810.iso

如果使用Web界面上傳鏡像nginx出現413的情況請修改client_max_body_size參數

















您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 要點 導出特性 如何導出Excel表頭 如何導出數據、如何進行數據的切割、如何使用篩選器 導出特性 ExporterAttribute + Name : 名稱(當前Sheet 名稱) + HeaderFontSize :頭部字體大小 + FontSize :正文字體大小 + MaxRowNumber ...
  • 你是否在初學 .net core時,被依賴註入所折磨? 你是否在開發過程中,為了註入依賴而不停的在Startup中增加註入代碼,而感到麻煩? 你是否考慮過或尋找過能輕鬆實現自動註入的組件? 如果有,那請歡迎繼續往下看。 或許你是被我這標題給吸引過來的,請不要懷疑自己的眼睛,如果你真的遇到過以上的問題 ...
  • 序言: 在 UWP 中,常見的存儲數據方式基本上就兩種。第一種方案是 UWP 框架提供的 ApplicationData Settings 這一系列的方法,適用於存放比較輕量的數據,例如存個 Boolean 類型的設置項這種是最適合不過的了。另一種方案是用 Sqlite 這種資料庫,適合存放數據量大 ...
  • 一、前言 在進行 Web 項目開發的過程中,可能會存在一些需要經常訪問的靜態數據,針對這種在程式運行過程中可能幾乎不會發生變化的數據,我們可以嘗試在程式運行前寫入到緩存中,這樣在系統後續使用時就可以直接從緩存中進行獲取,從而減緩因為頻繁讀取這些靜態數據造成的應用資料庫伺服器的巨大承載壓力。 既然需要 ...
  • 這是該系列的第一篇文章:在ASP.NET Core 3.0中使用Serilog.AspNetCore。 1. 第1部分 使用 來簡化ASP.NET Core的日誌輸出(本篇文章) 2. 第2部分 使用Serilog記錄所選的端點名稱[敬請期待] 3. 第3部分 使用Serilog.AspNetCor ...
  • 話不多說,先看運行效果: >./term input flag 0x00000500 BRKINT not in ICRNL IGNBRK not in IGNCR not in IGNPAR not in IMAXBEL not in INLCR not in INPCK not in ISTRI ...
  • 據報道三星已經成功研發出有望替代嵌入式快閃記憶體存儲器(eFlash)的嵌入式磁阻隨機訪問記憶體(eMRAM),容量為1Gb,測試晶元的優良率已達90%。 隨著5G物聯網時代的來臨,存儲器領域發展快速,而在這一領域,韓系廠商擁有著比較明顯的優勢。 MRAM晶元是一種以電阻為存儲方式結合非易失性及隨機訪問兩種 ...
  • 思路:一臺Server 2016用作AD+DNS,一臺Server 2016用作Exchange Server 2016 Exchange Server 2016 CU14 安裝路徑:安裝路徑:https://www.microsoft.com/en-us/download/details.aspx ...
一周排行
    -Advertisement-
    Play Games
  • 概述:在C#中,++i和i++都是自增運算符,其中++i先增加值再返回,而i++先返回值再增加。應用場景根據需求選擇,首碼適合先增後用,尾碼適合先用後增。詳細示例提供清晰的代碼演示這兩者的操作時機和實際應用。 在C#中,++i 和 i++ 都是自增運算符,但它們在操作上有細微的差異,主要體現在操作的 ...
  • 上次發佈了:Taurus.MVC 性能壓力測試(ap 壓測 和 linux 下wrk 壓測):.NET Core 版本,今天計劃準備壓測一下 .NET 版本,來測試並記錄一下 Taurus.MVC 框架在 .NET 版本的性能,以便後續持續優化改進。 為了方便對比,本文章的電腦環境和測試思路,儘量和... ...
  • .NET WebAPI作為一種構建RESTful服務的強大工具,為開發者提供了便捷的方式來定義、處理HTTP請求並返迴響應。在設計API介面時,正確地接收和解析客戶端發送的數據至關重要。.NET WebAPI提供了一系列特性,如[FromRoute]、[FromQuery]和[FromBody],用 ...
  • 原因:我之所以想做這個項目,是因為在之前查找關於C#/WPF相關資料時,我發現講解圖像濾鏡的資源非常稀缺。此外,我註意到許多現有的開源庫主要基於CPU進行圖像渲染。這種方式在處理大量圖像時,會導致CPU的渲染負擔過重。因此,我將在下文中介紹如何通過GPU渲染來有效實現圖像的各種濾鏡效果。 生成的效果 ...
  • 引言 上一章我們介紹了在xUnit單元測試中用xUnit.DependencyInject來使用依賴註入,上一章我們的Sample.Repository倉儲層有一個批量註入的介面沒有做單元測試,今天用這個示例來演示一下如何用Bogus創建模擬數據 ,和 EFCore 的種子數據生成 Bogus 的優 ...
  • 一、前言 在自己的項目中,涉及到實時心率曲線的繪製,項目上的曲線繪製,一般很難找到能直接用的第三方庫,而且有些還是定製化的功能,所以還是自己繪製比較方便。很多人一聽到自己畫就害怕,感覺很難,今天就分享一個完整的實時心率數據繪製心率曲線圖的例子;之前的博客也分享給DrawingVisual繪製曲線的方 ...
  • 如果你在自定義的 Main 方法中直接使用 App 類並啟動應用程式,但發現 App.xaml 中定義的資源沒有被正確載入,那麼問題可能在於如何正確配置 App.xaml 與你的 App 類的交互。 確保 App.xaml 文件中的 x:Class 屬性正確指向你的 App 類。這樣,當你創建 Ap ...
  • 一:背景 1. 講故事 上個月有個朋友在微信上找到我,說他們的軟體在客戶那邊隔幾天就要崩潰一次,一直都沒有找到原因,讓我幫忙看下怎麼回事,確實工控類的軟體環境複雜難搞,朋友手上有一個崩潰的dump,剛好丟給我來分析一下。 二:WinDbg分析 1. 程式為什麼會崩潰 windbg 有一個厲害之處在於 ...
  • 前言 .NET生態中有許多依賴註入容器。在大多數情況下,微軟提供的內置容器在易用性和性能方面都非常優秀。外加ASP.NET Core預設使用內置容器,使用很方便。 但是筆者在使用中一直有一個頭疼的問題:服務工廠無法提供請求的服務類型相關的信息。這在一般情況下並沒有影響,但是內置容器支持註冊開放泛型服 ...
  • 一、前言 在項目開發過程中,DataGrid是經常使用到的一個數據展示控制項,而通常表格的最後一列是作為操作列存在,比如會有編輯、刪除等功能按鈕。但WPF的原始DataGrid中,預設只支持固定左側列,這跟大家習慣性操作列放最後不符,今天就來介紹一種簡單的方式實現固定右側列。(這裡的實現方式參考的大佬 ...