日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

kvmweb管理工具_KVM web管理工具——WebVirtMgr

發(fā)布時間:2024/9/19 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 kvmweb管理工具_KVM web管理工具——WebVirtMgr 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

系統(tǒng)環(huán)境:

[root@kvm-admin ~]# cat /etc/redhat-release

CentOS Linux release7.3.1611(Core)

關閉防火墻、selinux

[root@kvm-admin ~]# systemctl stop firewalld.service

[root@kvm-admin ~]# setenforce 0

一、安裝部署WebVirtMgr

需要有repo源,centos7默認沒有wget:yum install wget

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

1、安裝依賴包

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

[root@localhost ~]# pip install numpy

Collecting numpy

Downloading https://files.pythonhosted.org/packages/6a/a9/c01a2d5f7b045f508c8cefef3b079fe8c413d05498ca0ae877cffa230564/numpy-1.14.5-cp27-cp27mu-manylinux1_x86_64.whl (12.1MB)

100% |████████████████████████████████| 12.1MB 26kB/s

Installing collected packages: numpy

Successfully installed numpy-1.14.5

You are using pip version 8.1.2, however version 18.0 is available.

You should consider upgrading via the 'pip install --upgrade pip' command.

2、安裝python需求并設置Django環(huán)境

[root@localhost ~]# cd /server/tools/[root@localhost tools]# git clone git://github.com/retspen/webvirtmgr.git

Cloning into 'webvirtmgr'...

remote: Counting objects:5730, done.

remote: Compressing objects:100% (6/6), done.

remote: Total5730 (delta 1), reused 0 (delta 0), pack-reused 5724Receiving objects:100% (5730/5730), 3.01 MiB | 341.00 KiB/s, done.

Resolving deltas:100% (3686/3686), done.

[root@localhost tools]# cd webvirtmgr/[root@localhost webvirtmgr]# pipinstall -r requirements.txt

Collecting django==1.5.5 (from -r requirements.txt (line 1))

Downloading https://files.pythonhosted.org/packages/38/49/93511c5d3367b6b21fc2995a0e53399721afc15e4cd6eb57be879ae13ad4/Django-1.5.5.tar.gz (8.1MB)

100% |████████████████████████████████| 8.1MB 42kB/s

Collecting gunicorn==19.5.0 (from -r requirements.txt (line 2))

Downloading https://files.pythonhosted.org/packages/f9/4e/f4076a1a57fc1e75edc0828db365cfa9005f9f6b4a51b489ae39a91eb4be/gunicorn-19.5.0-py2.py3-none-any.whl (113kB)

100% |████████████████████████████████| 122kB 58kB/s

Collectinglockfile>=0.9 (from -r requirements.txt (line 5))

Downloading https://files.pythonhosted.org/packages/c8/22/9460e311f340cb62d26a38c419b1381b8593b0bb6b5d1f056938b086d362/lockfile-0.12.2-py2.py3-none-any.whl

Installing collected packages: django, gunicorn, lockfileRunning setup.pyinstall for django ... doneSuccessfully installed django-1.5.5 gunicorn-19.5.0 lockfile-0.12.2You are using pip version8.1.2, however version 18.0is available.

You should consider upgrading via the'pip install --upgrade pip' command.

2.1 輸入用戶信息:登錄外部頁面的管理用戶

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

WARNING:root:No local_settingsfilefound.

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: test@163.com

Password: 123456

Password (again): 123456

Superuser created successfully.

Installing custom SQL ...

Installing indexes ...

Installed6 object(s) from 1 fixture(s)

2.2 生成配置文件

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

WARNING:root:No local_settingsfilefound.

You have requested to collect static files at the destination

location as specifiedinyour settings.

This will overwrite existing files!Are you sure you want todo this?Type'yes' to continue, or 'no' to cancel:yes

2.3 也可以添加其他管理用戶

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

WARNING:root:No local_settingsfilefound.

Username (leave blank to use'root'): root

Email address: test@163.com

Password:123456

Password (again): 123456

Superuser created successfully.

3、配置nginx

[root@localhost webvirtmgr]# cd ..

[root@localhost tools]#mkdir /var/www

[root@localhost tools]#mv webvirtmgr /var/www/

3.1 在/etc/nginx/conf.d目錄下添加webvirtmgr.conf文件:

[root@localhost conf.d]# cd /etc/nginx/conf.d/

[root@localhost conf.d]# vim webvirtmgr.conf

server {

listen80default_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_timeout600;

proxy_read_timeout600;

proxy_send_timeout600;

client_max_body_size 1024M; # Set higher depending on your needs

}

}

3.2 編輯/etc/nginx/ngix.conf,注釋server部分

vim /etc/nginx/nginx.conf

# server {

# listen80default_server;

# server_name localhost;

# root/usr/share/nginx/html;

#

# #charset koi8-r;

#

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

#

# # Load configuration filesforthe default server block.

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

#

# location / {

# }

#

# # redirect server error pages to the static page /40x.html

# #

# error_page 404 /404.html;

# location = /40x.html {

# }

#

# # redirect server error pages to the static page /50x.html

# #

# error_page 500 502 503 504 /50x.html;

# location = /50x.html {

# }

# }

3.3 修改屬主屬組,重啟nginx

[root@localhost conf.d]# chown -R nginx:nginx /var/www/webvirtmgr

[root@localhost conf.d]# service nginx restart

4、創(chuàng)建/etc/supervisord.d/webvirtmgr.ini包含以下內容的文件:

[root@localhost conf.d]# 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=trueautorestart=truelogfile=/var/log/supervisor/webvirtmgr.log

log_stderr=trueuser=nginx

[program:webvirtmgr-console]

command=/usr/bin/python /var/www/webvirtmgr/console/webvirtmgr-console

directory=/var/www/webvirtmgr

autostart=trueautorestart=truestdout_logfile=/var/log/supervisor/webvirtmgr-console.log

redirect_stderr=trueuser=nginx

5、重新啟動supervisor守護程序

[root@localhost conf.d]# service supervisord stop

[root@localhost conf.d]# service supervisord start

6、輸入本機IP網頁訪問,用戶名和密碼是上面2.2設置的用戶和密碼。

二、配置KVM宿主機,下載并執(zhí)行腳本:libvirt-bootstrap.sh,如果虛擬機比較多,該腳本執(zhí)行時間會比較長

[root@localhost ~]# curl http://retspen.github.io/libvirt-bootstrap.sh | sudo sh

三、配置SSH連接

ssh和tcp設置一種即可,其實就是設置無密碼登錄,要注意的是從webvirtmgr的什么用戶到宿主機的什么用戶的無密碼登錄,比如我用nginx用戶跑的django webvirtmgr,而宿主機是root跑的virsh,所以需要設置nginx到root的無密碼登錄。而git官網推薦的是用nginx用戶跑django webvirtmgr,webvirtmgr用戶跑的virsh,所以設置的是nginx用戶到宿主機webvirtmgr用戶的無密碼登錄。

創(chuàng)建SSH私鑰和ssh配置選項(在安裝了WebVirtMgr的系統(tǒng)上):

[root@localhost conf.d]# sudo su - nginx -s /bin/bash-bash-4.2$ ssh-keygenGenerating public/private rsa key pair.

Enterfile in which to save the key (/var/lib/nginx/.ssh/id_rsa):

Created directory'/var/lib/nginx/.ssh'.

Enter passphrase (emptyforno passphrase):

Enter same passphrase again:

Your identification has been savedin /var/lib/nginx/.ssh/id_rsa.

Your public key has been savedin /var/lib/nginx/.ssh/id_rsa.pub.

The key fingerprint is:51:4d:c9:0b:24:99:10:45:9a:c5:6b:70:4c:85:e4:3b nginx@localhost.localdomain

The key's randomart image is:

+--[ RSA 2048]----+

| oXB*++.. |

| .=Bo. + |

| ooo. . . |

| oo . |

| .E |

| . |

| |

| |

| |

+-----------------+-bash-4.2$ touch ~/.ssh/config && echo -e "StrictHostKeyChecking=no\nUserKnownHostsFile=/dev/null" >> ~/.ssh/config-bash-4.2$ chmod 0600 ~/.ssh/config-bash-4.2$ cat .ssh/id_rsa.pub

KVM宿主機,將nginx用戶公鑰加到/root/.ssh/authorized_keys文件中。ssh秘鑰連接成功后再網頁添加KVM宿主機。

參考地址:https://github.com/retspen/webvirtmgr/wiki/Install-WebVirtMgr

總結

以上是生活随笔為你收集整理的kvmweb管理工具_KVM web管理工具——WebVirtMgr的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。