物理环境:
Hypervisor | qemu |
Memory | 62.7 GB |
Logical CPUs | 24 |
Processor | Intel(R) Xeon(R) CPU X5650 @ 2.67GHz |
Architecture | x86_64 |
一、安装
1、安装kvm Host Server
1 安装工具包
yum install qemu-kvm libvirt libvirt-python libguestfs-tools virt-install bridge-utils novnc -y systemctl start libvirtd systemctl enable libvirtd
1.1 安装libvirt 和KVM
curl http://retspen.github.io/libvirt-bootstrap.sh | sudo sh
或者
wget -O - http://retspen.github.io/libvirt-bootstrap.sh | sudo sh
1.2 打开防火墙
sudo firewall-cmd --get-active-zones sudo firewall-cmd --zone=public --add-port 16509/tcp --permanent sudo firewall-cmd --reload
2、设置认知
可以采用SSH认知或者TCP认证,本次博主使用TCP认证
参考链接:https://github.com/retspen/webvirtmgr/wiki/Setup-TCP-Authorization
2、部署webvirtmgr
参考链接:https://github.com/retspen/webvirtmgr/wiki/Install-WebVirtMgr
2.1 安装依赖软件
$ sudo yum -y install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm $ sudo yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx $ sudo yum -y install gcc python-devel $ sudo pip install numpy
2.1 下载WebVirtMgr
2.1.1 下载并初始化
$ git clone git://github.com/retspen/webvirtmgr.git $ cd webvirtmgr $ sudo pip install -r requirements.txt # or python-pip (RedHat, Fedora, CentOS, OpenSuse) $ ./manage.py syncdb $ ./manage.py collectstatic #填写的用户名与密码用于Web登录
2.1.2 添加Supervisor
本次部署,博主不使用nginx代理,所以直接使用django服务器部署
webVirtMgr supervisor配置
[program:webvirtmgr] command=/usr/bin/python /home/webvirtmgr/manage.py runserver 0:80 directory=/home/webvirtmgr user=root autostart=true autorestart=true logfile=/var/log/supervisor/webvirtmgr.log log_stderr=true
noVNC supervisor配置
[program:webvirtmgr-console] command=/usr/bin/python /home/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
2.1.3 配置防火墙
sudo firewall-cmd --get-active-zones sudo firewall-cmd --zone=public --add-port 80/tcp --permanent sudo firewall-cmd --zone=public --add-port 6080/tcp --permanent sudo firewall-cmd --zone=public --add-port 16509/tcp --permanent sudo firewall-cmd --reload
三、网络配置
3.1 物理机桥接网卡配置
3.1.1 复制物理机网卡配置文件
进入网卡配置文件目录
/etc/sysconfig/network-scripts
复制原物理机网卡到ifcfg-br0
cp ifcfg-em1 ifcfg-br0
编辑ifcfg-br0内容如下:
TYPE="Bridge" BOOTPROTO="static" IPADDR=192.168.2.10 GATEWAY=192.168.2.1 NETMASK=255.255.255.0 DNS1=192.168.1.1 DEFROUTE="yes" PEERDNS="yes" PEERROUTES="yes" IPV4_FAILURE_FATAL="no" NAME="br0" DEVICE="br0" ONBOOT="yes"
编辑原物理机网卡ifcfg-em1
NAME="em1" DEVICE="em1" ONBOOT="yes" BRIDGE="br0"
重启网卡
systemctl restart network
网卡配置如下ip addr:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP qlen 1000 link/ether 00:26:b9:49:4c:73 brd ff:ff:ff:ff:ff:ff 3: em2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000 link/ether 00:26:b9:49:4c:75 brd ff:ff:ff:ff:ff:ff 4: em3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000 link/ether 00:26:b9:49:4c:77 brd ff:ff:ff:ff:ff:ff 5: em4: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000 link/ether 00:26:b9:49:4c:79 brd ff:ff:ff:ff:ff:ff 6: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP link/ether 00:26:b9:49:4c:73 brd ff:ff:ff:ff:ff:ff inet 192.168.2.10/24 brd 192.168.2.255 scope global br0 valid_lft forever preferred_lft forever inet6 fe80::d07f:c9ff:fe40:ee1d/64 scope link valid_lft forever preferred_lft forever
2.1 配置webvirtMgr Networks
二、问题总结
1、qumu+tcp失败
执行virsh -c qemu+tcp://192.168.2.11/system nodeinfo时提示错误。
[root@localhost ~]# virsh -c qemu+tcp://192.168.1.1/system nodeinfo
error: failed to connect to the hypervisor
error: authentication failed: authentication failed
解决方法:暂时关闭权限认证,以后找到原因再解决。
编辑:vim /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
tcp_port = "16509"
listen_addr = "0.0.0.0"
auth_tcp = "none"
重启 libvirtd
systemctl libvirtd restart
隔断
参考链接
- http://www.centoscn.com/image-text/install/2015/0817/6016.html
- https://github.com/retspen/webvirtmgr/wiki
- http://www.cnblogs.com/kevingrace/p/5737724.html
- http://www.cnblogs.com/kevingrace/p/5739009.html
- http://www.cnblogs.com/olinux/articles/4511159.html
- http://www.centoscn.com/image-text/install/2015/0817/6016.html