No pit version - install and deploy kvm virtual machine on centos7 and install nginx on kvm

Kvm installation and deployment connect to KVM through ssh, and deploy nginx in KVM, and can successfully access

Environmental preparation

The release version memory is preferably 3g or more

  • 7.4 above are supported (including 7.4)
[root@localhost tmp]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core) 

Turn off firewall

systemctl stop firewalld

Close selinux

setenforce 0

kvm introduction

Continue to the previous article: What is a kvm virtual machine

Install kvm virtual machine

1. Modify virtual machine settings before turning on VMware

Focus

2. Turn on the virtual machine and check whether the system supports virtualization.
If vmx and svm appear, they support
Insert picture description here


> [root@localhost ~]# cat /proc/cpuinfo | egrep 'vmx|svm' 
 flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat
 pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt pdpe1gb
 rdtscp lm constant_tsc art rep_good nopl tsc_reliable nonstop_tsc
 extd_apicid eagerfpu pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic
  movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm svm extapic
 cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw perfctr_core
 retpoline_amd ssbd ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed
 adx smap clflushopt clwb sha_ni xsaveopt xsavec clzero arat npt
 svm_lock nrip_save vmcb_clean flushbyasid decodeassists overflow_recov
 succor

3. Install and start KVM

yum install -y qemu-kvm libvirt virt-install
systemctl start libvirtd
systemctl enable libvirtd

4. Create a storage file

qemu-img create -f raw /opt/CentOS-7-x86_64.raw 10G

Insert picture description here
5. Upload system files to /tmp/
Insert picture description here
Insert picture description here

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

note! !
If the same error occurs, the bridge is not configured

Insert picture description here
Solution

First: create directly ! Execution failed, execute the next one!

[root@localhost ~]# virsh iface-bridge ens33 br0

Insert picture description here
Second: manual configuration

Configure physical network card

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33 
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=ens33
DEVICE=ens33
ONBOOT=yes
BRIDGE="br0"

Configure bridged network card

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-br0
TYPE=Bridge
PROXY_METHOD=none
BROSWER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=br0
DEVICE=br0
ONBOOT=yes

Restart network

systemctl restart network

Get IP to Insert picture description here
create 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

Insert picture description here
7. Open VNC and use the above IP connection

Insert picture description here

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
8. Start the kvm virtual machine
Insert picture description here
9. Connect to view again through VNC
Insert picture description here
Insert picture description hereInsert picture description here

Now the bridge method is adopted, there is no ip, you need to get ip
Insert picture description here

Insert picture description here

10. Restart the network

systemctl restart network

Check ip again

ip addr

Insert picture description here

12. Connect to this ip through ssh
Insert picture description here
13. Close the firewall

 systemctl stop firewalld 

Install nginx on kvm and
upload nginx.repo to /etc/yum.repos.d/
to connect: nginx yum source nginx.repo

  yum makecache fast
  yum -y install nginx
  nginx -t
  nginx
  yum -y install net-tools
  netstat -lptnu

Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_46174507/article/details/109384167