CentOS 7搭建KVM在线管理面板WebVirtMgr

全屏阅读
  • 基本信息
  • 作者:
  • 作者已发布:924篇文章
  • 发布时间:2020年04月30日 9:11:04
  • 所属分类:Linux
  • 阅读次数:2878次阅读
  • 标签:

系统版本:CentOS 7.4

WebVirtMgr版本:master分支的20180720版本,下载链接链接: https://pan.baidu.com/s/1tVyygnGdJualUh3a-aEPEg 提取码: xyaa 

用到的目录:/data/service/nginx,/data/service/nginx_vhost/,/data/service/webvirtmgr

安装成功并成功运行的标志位:/var/log/supervisor/supervisord.log,/var/log/supervisor/webvirtmgr-console.log这两个日志文件会自动生成。

说明:其实网上流传了很多安装的版本,基本都非常乱,要不是这里加一句没用的,就是那里根本不用这么复杂的配置,记住,一切的安装配置以官方文档为准,并且官方这么少的配置都能成功时,自己更应该注意有没有配置错误等问题。

注意:整篇文章未改动过官方的过多配置,如果你运行不起来,那么90%都出在权限以及权限组上!下面安装的步骤都是使用root账号。

一、准备工作

0、准备操作:

##关闭selinux# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config   #修改配置文件则永久生效,但是必须要重启系统。##生效命令# setenforce 0

1、设置目录并安装nginx

复制代码

git clone http://github.com/easonjim/centos-. centos-/. ../../ centos-/.14.0.sh
cd ../../

复制代码

2、安装kvm(这一步不要求按照这个,只需要安装成功即可)

cd centos-shell/kvm
sh install-kvm_centos_7.sh

参考:https://www.cnblogs.com/EasonJim/p/9150733.html

3、安装WebVirtMgr依赖

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

4、正式安装WebVirtMgr并配置超级登录用户

cd /data/service
git clone git://github.com/retspen/webvirtmgr.../manage../manage.py collectstatic

说明:如果上面的版本不能安装,那么建议下载离线版本,随着时间的推移,不保证会不会改变。

配置超级用户,信息类似如下:

复制代码

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 (Put: yes)Username (Leave blank to use 'admin'): admin (Put: your username or login)E-mail address: username@domain.local (Put: your email)Password: xxxxxx (Put: your password)Password (again): xxxxxx (Put: confirm password)Superuser created successfully.

复制代码

如果想再增加多一个超级用户,可以再执行如下命令:

./manage.py createsuperuser

配置信息类似如上所示。

5、设置nginx

vi /data/service/nginx_vhost/webvirtmgr.conf

复制代码

server {
    listen 8001;

    server_name $hostname;
    access_log /data/weblog/nginx/webvirtmgr_access_log;

    location /static/ {
        root /data/service/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;
    }
}

复制代码

service nginx restart

6、配置supervisord服务

设置权限

chown -R nginx:nginx /data/service/webvirtmgr

其实是在supervisord服务增加webvirtmgr进程的启动,依赖这个服务而已。

# 开机自启
systemctl enable supervisord

增加进程启动配置

vi /etc/supervisord.d/webvirtmgr.ini

复制代码

[program:webvirtmgr]command=/usr/bin/python /data/service/webvirtmgr/manage.py run_gunicorn -c /data/service/webvirtmgr/conf/gunicorn.conf.py
directory=/data/service/webvirtmgr
autostart=true
autorestart=true
logfile=/var/log/supervisor/webvirtmgr.log
log_stderr=true
user=nginx

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

复制代码

重启服务

service supervisord restart

7、权限设置(重点),也是设置Local登录的一种方式

增加权限组

groupadd libvirtd

增加用户到权限组

usermod -a -G libvirtd root
usermod -a -G libvirtd nginx

设置kvm服务libvirtd启动权限

vi /etc/libvirt/libvirtd.conf

增加权限启动配置

vi /etc/polkit-1/localauthority/50-local.d/50-org.libvirtd-group-access.pkla
[libvirtd group Management Access]
Identity=unix-group:libvirtdAction=org.libvirt.unix.manage
ResultAny=yes
ResultInactive=yes
ResultActive=yes

最后重启服务

service libvirtd restart
service supervisord start

上面的权限检查:

①、确定是否已libvirtd组启动licvirtd服务

ls -l /var/run/libvirt/libvirt-sock
srwxrwx--- 1 root libvirtd 0 févr. 12 16:03 /var/run/libvirt/libvirt-sock

②、确定WebVirtMgr启动的用户

ps -ef | grep run_gunicorn | awk 'NR==1{ print $1 }'
nginx

③、确定用户已经加入到libvirtd组

groups root
libvirtd groups nginx
libvirtd

8、配置到这里基本全部配置完成,可以直接使用Local添加运行

登录http://x.x.x.x:8001

放心,如果按照以上配置绝对可以运行的起来,已经测试了100+台。

 

 

参考:

https://github.com/retspen/webvirtmgr/wiki/Install-WebVirtMgr(官方配置文档)

顶一下
(0)
100%
订阅 回复
踩一下
(0)
100%
» 郑重声明:本文由mpxq168发布,所有内容仅代表个人观点。版权归恒富网mpxq168共有,欢迎转载, 但未经作者同意必须保留此段声明,并给出文章连接,否则保留追究法律责任的权利! 如果本文侵犯了您的权益,请留言。

目前有 0 条留言 其中:访客:0 条, 博主:0 条

给我留言

您必须 [ 登录 ] 才能发表留言!