kvmweb管理工具_Centos7.5宿主机安装KVM虚拟化云平台可视化管理工具——WebVirtMgr…

  • Post author:
  • Post category:其他


随着公司业务的增多,服务器上虚拟化机器越来越多,管理起来也不方便,虚拟机一般使用的KVM来做虚拟化,所以对于小型私有云,安装WebVirMgr进行web可视化管理还是很有必要的。简要介绍一下安装方法。

安装KVM

1.首先,对服务器Bios开启虚拟化支持,然后,查看服务器CPU是否支持虚拟化,一般服务器都会支持,可以看到是支持的。

egrep ‘(svm|vmx)’ /proc/cpuinfo

2.关闭Selinux,设置selinux=disabled

vim /etc/selinux/config

3.安装kvm所需依赖包并设置开机自启

yum install qemu-kvm libvirt virt-install bridge-utils -y

systemctl enable libvirtd.service

systemctl start libvirtd.service

4.配置网卡桥接,这样kvm虚拟机就可以使用物理机网段了,编辑物理网卡。

vim ifcfg-em1

BRIDGE=br0        #增加这段br0是桥接网卡名字

BOOTPROTO=none

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

IPV6_FAILURE_FATAL=no

IPV6_ADDR_GEN_MODE=stable-privacy

NAME=em1

UUID=db488d6c-f2bd-4162-91b0-b093da627043

DEVICE=em1

ONBOOT=yes            #设置网卡启用

拷贝一份em1配置文件改名成br0

cp ifcfg-em1 ifcfg-br0

TYPE=Bridge        #增加这段

BOOTPROTO=none

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

IPV6_FAILURE_FATAL=no

IPV6_ADDR_GEN_MODE=stable-privacy

NAME=br0            #名字改成br0

DEVICE=br0            #名字改成br0

ONBOOT=yes            #设置网卡启用

IPADDR=192.168.30.4    #设置IP,这是物理机IP

NETMASK=255.255.255.0

GATEWAY=192.168.30.1

DNS1=8.8.8.8

配置完成重启网卡,配置成功

ifconfig 查看是否正确

下面安装WebVirMgr。

安装WebVirMgr

1.安装所需依赖包

yum -y install git python-pip libvirt-python libxml2-python python-websockify python-devel

pip install numpy

2.git下载安装文件

git clone git://github.com/retspen/webvirtmgr.git        #clone代码

mv webvirtmgr/ /var/www/                                #移动到/var/www目录

cd /var/www/webvirtmgr/

pip install -r requirements.txt                #安装依赖

3.初始化程序并配置管理用户

./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.

Would you like to create one now? (yes/no): yes

Username (leave blank to use ‘root’): root        #管理账号

Email address:

Password:                                         #管理密码

Password (again):

Superuser created successfully.

Installing custom SQL …

Installing indexes …

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

4、配置静态文件收集

./manage.py collectstatic

WARNING:root:No local_settings file found.

You have requested to collect static files at the destination

location as specified in your settings.

This will overwrite existing files!

Are you sure you want to do this?

Type ‘yes’ to continue, or ‘no’ to cancel: yes ###选择yes

Copying ‘/var/www/webvirtmgr/webvirtmgr/static/css/bootstrap-multiselect.css’

Copying ‘/var/www/webvirtmgr/webvirtmgr/static/css/bootstrap.min.css’

Copying ‘/var/www/webvirtmgr/webvirtmgr/static/css/signin.css’

Copying ‘/var/www/webvirtmgr/webvirtmgr/static/css/table-sort.css’

Copying ‘/var/www/webvirtmgr/webvirtmgr/static/css/webvirtmgr.css’

Copying ‘/var/www/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.eot’

Copying ‘/var/www/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.svg’

Copying ‘/var/www/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.ttf’

Copying ‘/var/www/webvirtmgr/webvirtmgr/static/fonts/glyphicons-halflings-regular.woff’

Copying ‘/var/www/webvirtmgr/webvirtmgr/static/img/asc.gif’

5.(可选执行)设置额外管理员

./manage.py createsuperuser

6.配置nginx,如何安装nginx?

修改nginx.conf:

server {

listen 80 default_server;

server_name $hostname;

access_log /var/log/nginx/webvirtmgr_access_log;

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;

}

}

启动nginx服务器。

7.启动webvirtmar

nohup /usr/bin/python /var/www/webvirtmgr/manage.py run_gunicorn 127.0.0.1:8000 &

nohup /usr/bin/python /var/www/webvirtmgr/console/webvirtmgr-console &

8.(可选)防火墙相关操作

firewall-cmd –permanent –add-port=80/tcp

firewall-cmd –permanent –add-port=6080/tcp

firewall-cmd  –permanent  –add-port=5900/tcp

firewall-cmd  –permanent  –add-port=5901/tcp        #控制台端口,可以多

#开放几个5900起

firewall-cmd –reload

9.配置被管宿主机免密登录,以root用户安装webvirtmgr为例,在安装webvirtmgr的服务器执行如下命令即可

ssh-keygen -t rsa

ssh-copy-id 192.168.10.2(更改为需要被管理的服务器ip,如果webvirtmgr和被管服务器是同一主机,也需要对自身做一次免密)

10.打开浏览器,访问ip,输入账号密码即可

点击add connection以ssh方式添加宿主机即可。



版权声明:本文为weixin_39628342原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。