KVM-centos7 command line deployment
- Environmental preparation
-
- 1. Check the system version
- 2. Verify whether the CPU supports virtualization
- 3. Disable selinux
- 4. Install the service, start
- 5. Create a storage file
- 6. Upload image
- 7. Create the required network card for KVM
- 8. Modify the network card
- 9. Install the virtual machine
- 10. Open vnc connection
- 11. Start KVM Virtual
- 12. Login, modify the network card! [insert picture description here](https://img-blog.csdnimg.cn/20201030150807445.png#pic_center)
- 13. Install basic services and go online with nginx
Environmental preparation
One centos7 [hard disk bit 20G], turn off the firewall and selinux
shutdown configuration requirements
1. Check the system version
cat /etc/centos-release
- 7.4 and above (including 7.4) support deployment
2. Verify whether the CPU supports virtualization
cat /proc/cpuinfo | egrep 'vmx|svm'
- The words vmx and svm indicate support for KVM
3. Disable selinux
vim /etc/sysconfig/selinux
- 7 lines are modified as follows
4. Install the service, start
yum install -y qemu-kvm libvirt virt-install
systemctl start libvirtd
systemctl enable libvirtd
5. Create a storage file
qemu-img create -f raw /opt/CentOS-7-x86_64.raw 10G
6. Upload image
cd /tmp/
7. Create the required network card for KVM
virsh iface-bridge ens33 br0
- If it fails, perform the next step
8. Modify the network card
- Contents of ens33
DEVICE=ens33
ONBOOT=yes
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=ens33
BRIDGE=br0
- Modify the created network card br0
DEVICE="br0"
ONBOOT="yes"
TYPE="Bridge"
BOOTPROTO="dhcp"
PROXY_METHOD=none
BROWSER_ONLY=no
DEFOUTE=yes
IPV4_FAILURE_FATAL=no
NAME=br0
- Renderings show
Restart the network card
systemctl restart network
NIC verification
ifconfig
9. Install the virtual machine
virt-install --virt-type kvm --name CentOS-7-x86_64 --ram 1536 --cdrom=/tmp/CentOS-7-x86_64-Minimal-2003.iso --disk path=/opt/CentOS-7-x86_64.raw --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole
10. Open vnc connection
11. Start KVM Virtual
virsh list
virsh start CentOS-7-x86_64
netstat -nlpt
12. Login, modify the network card
vim /etc/sysconfig/network-scripts/ifcfg-eth0
noboot changed to yes
- After changing the network card, restart to verify the ip, then you can connect to xshell (easy to operate)
13. Install basic services and go online with nginx
- Open the browser to verify