当前位置:网站首页>小笔记-简单但够用系列_KVM快速入门
小笔记-简单但够用系列_KVM快速入门
2022-06-26 09:45:00 【NYTWTYN】
kvm简介
KVM 全称是 Kernel-Based Virtual Machine。也就是说 KVM 是基于 Linux 内核实现的。
KVM有一个内核模块叫 kvm.ko,只用于管理虚拟 CPU 和内存。
IO 的虚拟化,比如存储和网络设备的实现由 Linux 内核和Qemu来实现。
说白了,作为一个 Hypervisor,KVM 本身只关注虚拟机调度和内存管理这两个方面。IO 外设的任务交给 Linux 内核和 Qemu
kvm安装
- 查看cpu是否支持虚拟化
[[email protected] ~]# grep -E '(vmx|svm)' /proc/cpuinfo **
- 安装qemu-kvm(用户态管理工具),libvirt(命令行管理工具),virt-install(安装kvm工具),bridge-utils(桥接设备管理工具)
[[email protected] ~]# yum install -y qemu-kvm libvirt virt-install bridge-utils
- 确保加载kvm模块
[[email protected] ~]# lsmod |grep kvm
kvm_intel 174841 0
kvm 578518 1 kvm_intel
irqbypass 13503 1 kvm
####如果没有加载,运行一下命令
[[email protected] ~]# modprobe kvm
[[email protected] ~]# modprobe kvm-intel
- 启动libvirtd服务
[[email protected] ~]# systemctl enable libvirtd
[[email protected] ~]# systemctl start libvirtd
[[email protected] ~]# systemctl status libvirtd
- 配置kvm桥接模式
[[email protected] ~]# cd /etc/sysconfig/network-scripts/
[[email protected] network-scripts]# cp ifcfg-ens32 ifcfg-br0
[[email protected] network-scripts]# vim ifcfg-br0
NAME=br0
DEVICE=br0
ONBOOT=yes
NETBOOT=yes
IPV6INIT=no
BOOTPROTO=static
NM_CONTROLLED=no
TYPE=Bridge
IPADDR=192.168.0.127
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
DNS1=8.8.8.8
[[email protected] network-scripts]# vim ifcfg-ens32
NAME=ens32
DEVICE=ens32
BOOTPROTO=none
NM_CONTROLLED=no
ONBOOT=yes
BRIDGE=br0
- 查看网桥
[[email protected] ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29d1267b no ens32
virbr0 8000.52540063d8f4 yes virbr0-nic
- 删除virbr0
[[email protected] ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29d1267b no ens32
virbr0 8000.52540063d8f4 yes virbr0-nic
[[email protected] ~]# virsh net-list
Name State Autostart Persistent
----------------------------------------------------------
default active yes yes
[[email protected] ~]# virsh net-destroy default
Network default destroyed
[[email protected] ~]# virsh net-undefine default
Network default has been undefined
[[email protected] ~]# systemctl restart libvirtd.service
[[email protected] ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29d1267b no ens32
使用virt-manager管理kvm
若要用virt-manager图形化安装虚拟机,所以还需要安装桌面
- 安装桌面软件
[[email protected] ~]# yum grouplist
[[email protected] ~]# yum groupinstall "GNOME Desktop" -y
- 配置中文桌面
grep -E "^[ \t]*export[ \t]+LANG[ \t]*=" /etc/profile&& y="yes" || y="no"
if [[ "$y" = "yes" ]]; then
sed -r -i -e '/^[ \t]*export[ \t]+LANG[ \t]*=/c\export LANG="zh_CN.UTF-8"' /etc/profile
else
echo 'export LANG="zh_CN.UTF-8"' >>/etc/profile
fi
source /etc/profile
- 安装virt-manager
[[email protected] ~]# yum -y install virt-manager
边栏推荐
- MySQL第十一作業-視圖的應用
- 8-图文打造LeeCode算法宝典-最小栈与LRU缓存机制算法题解
- C中字符串基本操作
- Some problems to be considered when designing technical implementation scheme
- MySQL Chapter 4 Summary
- Blog article index summary -- Software Engineering
- The fourteenth MySQL operation - e-mall project
- MySQL 13th job - transaction management
- Under the double reduction, the amount of online education has plummeted. Share 12 interesting uses of webrtc
- Little red book - Summary of internal sales spike project
猜你喜欢
随机推荐
MySQL第四章总结
Poj3682 king arthur's birthday celebration (probability)
String class intern() method and string constant pool
MySQL第十一作業-視圖的應用
Quantitative investment learning - Introduction to classic books
904. fruit baskets
JVM的符号引用和直接引用是什么
What is a botnet
2. merge two ordered arrays
Express (I) - easy to get started
Developers, what is the microservice architecture?
The fourteenth MySQL operation - e-mall project
Global and Chinese market of contemporary lampshade 2022-2028: Research Report on technology, participants, trends, market size and share
Standard implementation of streaming layout: a guide to flexboxlayout
How do technicians send notifications?
MySQL第十四次作业--电子商城项目
瑞萨电子面向物联网应用推出完整的智能传感器解决方案
Retrofit common request methods and comments, post, get heard file upload
Global and Chinese market of electronic pet door 2022-2028: Research Report on technology, participants, trends, market size and share
Appium自动化测试基础 — 移动端测试环境搭建(二)






