安装依赖包(因最小化安装)
[[email protected] ~]# 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相关的包
[[email protected] ~]# yum install qemu-kvm qemu-kvm-tools libvirt libvirt-client virt-manager virt-install -y
启动libvirt虚拟网卡
[[email protected] ~]# systemctl start libvirtd [[email protected]-master ~]# systemctl enable libvirtd #添加开机自启动
配置网卡绑定
[[email protected] 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[[email protected] network-scripts]# vim ifcfg-br0 #配置br0TYPE=BridgeBOOTPROTO=staticNAME=br0DEVICE=br0ONBOOT=yesIPADDR=172.16.129.102NETMASK=255.255.0.0GATEWAY=172.16.129.1[[email protected] network-scripts]# vim -o ifcfg-eth0 ifcfg-eth1 # 配置eth0和eth1BOOTPROTO=staticNAME=eth0DEVICE=eth0ONBOOT=yesNM_CONTROLLED=noMASTER=bond0USERCTL=noSLAVE=yes~ ~ ~ ~ ifcfg-eth0 [+] 8,10 AllBOOTPROTO=staticNAME=eth1DEVICE=eth1ONBOOT=yesNM_CONTROLLED=noMASTER=bond0USERCTL=noSLAVE=yes [[email protected] network-scripts]# vim -o ifcfg-bond0 ifcfg-bond1 #配置bond1 配置内网BOOTPROTO=staticNAME=bond0DEVICE=bond0ONBOOT=yesBONDING_MASTER=yesBONDING_OPTS="mode=1 miimon=100"BRIDGE=br0~ ~ ~ ~ ~ ifcfg-bond0 7,1 AllBOOTPROTO=staticNAME=bond1DEVICE=bond1ONBOOT=yesBONDING_MASTER=yesBONDING_OPTS="mode=1 miimon=100"BRIDGE=br1 [[email protected] network-scripts]# vim -o ifcfg-br0 ifcfg-br1 TYPE=BridgeBOOTPROTO=staticNAME=br0DEVICE=br0ONBOOT=yesIPADDR=172.16.129.102NETMASK=255.255.0.0GATEWAY=172.16.129.1~ ~ ~ ~ ifcfg-br0 3,1 AllTYPE=BridgeBOOTPROTO=staticNAME=br1DEVICE=br1ONBOOT=yesIPADDR=192.168.37.102NETMASK=255.255.255.0
关闭服务
[[email protected] ~]# systemctl stop NetworManager [[email protected]-master ~]# systemctl disable NetworkManager [[email protected]-master ~]# systemctl disable firewalld [[email protected]-master ~]# vim /etc/sysconfig/selinux SELINUX=disabled
安装组件
[[email protected] ~]# yum install bridge-utils -y
重启网络服务或重启电脑
[[email protected] ~]# systemctl restart network
创建虚拟磁盘
[[email protected] ~]# qemu-img create -f qcow2 /var/lib/libvirt/images/linux_bridge.qcow2 10G
创建虚拟机
[[email protected] ~]# 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
管理虚拟机
[[email protected] ~]# virt-manager
修改参数
安装系统
原文地址:https://www.cnblogs.com/maxuebin/p/11384638.html
时间: 2024-10-09 22:10:35