KVM配置
安装依赖包(因最小化安装)
[root@slave-master ~]# yum install -y vim wget tree lrzsz gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel openssl openssl-devel iproute net-tools iotop lsof ntpdate telnet bridge-utils -y
安装kvm相关的包
[root@slave-master ~]# yum install qemu-kvm qemu-kvm-tools libvirt libvirt-client virt-manager virt-install -y
启动libvirt虚拟网卡
[root@slave-master ~]# systemctl start libvirtd
[root@slave-master ~]# systemctl enable libvirtd #添加开机自启动
配置网卡绑定
[root@slave-master network-scripts]# vim ifcfg-bond0 #先配置bond0 BOOTPROTO=static NAME=bond0 DEVICE=bond0 ONBOOT=yes BONDING_MASTER=yes BONDING_OPTS="mode=1 miimon=100" BRIDGE=br0
[root@slave-master network-scripts]# vim ifcfg-br0 #配置br0
TYPE=Bridge
BOOTPROTO=static
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=172.16.129.102
NETMASK=255.255.0.0
GATEWAY=172.16.129.1
[root@slave-master network-scripts]# vim -o ifcfg-eth0 ifcfg-eth1 # 配置eth0和eth1
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
NM_CONTROLLED=no
MASTER=bond0
USERCTL=no
SLAVE=yes
~
~
~
~
ifcfg-eth0 [+] 8,10 All
BOOTPROTO=static
NAME=eth1
DEVICE=eth1
ONBOOT=yes
NM_CONTROLLED=no
MASTER=bond1
USERCTL=no
SLAVE=yes
[root@slave-master network-scripts]# vim -o ifcfg-bond0 ifcfg-bond1 #配置bond1 配置内网
BOOTPROTO=static
NAME=bond0
DEVICE=bond0
ONBOOT=yes
BONDING_MASTER=yes
BONDING_OPTS="mode=1 miimon=100"
BRIDGE=br0
~
~
~
~
~
ifcfg-bond0 7,1 All
BOOTPROTO=static
NAME=bond1
DEVICE=bond1
ONBOOT=yes
BONDING_MASTER=yes
BONDING_OPTS="mode=1 miimon=100"
BRIDGE=br1
[root@slave-master network-scripts]# vim -o ifcfg-br0 ifcfg-br1
TYPE=Bridge
BOOTPROTO=static
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=172.16.129.102
NETMASK=255.255.0.0
GATEWAY=172.16.129.1
~
~
~
~
ifcfg-br0 3,1 All
TYPE=Bridge
BOOTPROTO=static
NAME=br1
DEVICE=br1
ONBOOT=yes
IPADDR=192.168.37.102
NETMASK=255.255.255.0
关闭服务
[root@slave-master ~]# systemctl stop NetworManager [root@slave-master ~]# systemctl disable NetworkManager [root@slave-master ~]# systemctl disable firewalld [root@slave-master ~]# vim /etc/sysconfig/selinux SELINUX=disabled
安装组件
[root@slave-master ~]# yum install bridge-utils -y
重启网络服务或重启电脑
[root@slave-master ~]# systemctl restart network
创建虚拟磁盘
[root@slave-master ~]# qemu-img create -f qcow2 /var/lib/libvirt/images/linux_bridge.qcow2 10G
创建虚拟机
[root@slave-master ~]# virt-install --virt-type kvm --name centos7_bridge --ram 1024 --vcpu 2 --cdrom=/usr/local/src/CentOS-7-x86_64-Minimal-1810.iso --disk path=/var/lib/libvirt/images/linux_bridge.qcow2 --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole
管理虚拟机
[root@slave-master ~]# virt-manager
修改参数
安装系统