虚拟化1—虚拟机的创建
文章目录
需要安装的包
dnf module install virt -y
dnf install virt-install virt-viewer -y
dnf install cockpit -y
dnf install cockpit-machines -y
虚拟机镜像
可以前往官网下载:https://www.redhat.com/zh
产品页面:https://www.redhat.com/zh/technologies/linux-platforms/enterprise-linux
方法一:在文本环境下创建虚拟机
一、启动服务
systemctl start libvirtd
二、关闭客户机
shutdown -h now
三、检查
virt-host-validate
查看是否支持,需要确保没有FAIL的结果,WARN的根据情况决定 。
[root@kittod ~]# virt-host-validate
QEMU: Checking for hardware virtualization :
FAIL (Only emulated CPUs are available, performance will be significantly
limited)
QEMU: Checking if device /dev/vhost-net exists :
PASS
QEMU: Checking if device /dev/net/tun exists :
PASS
QEMU: Checking for cgroup 'cpu' controller support :
PASS
QEMU: Checking for cgroup 'cpuacct' controller support :
PASS
QEMU: Checking for cgroup 'cpuset' controller support :
PASS
QEMU: Checking for cgroup 'memory' controller support :
PASS
QEMU: Checking for cgroup 'devices' controller support :
PASS
QEMU: Checking for cgroup 'blkio' controller support :
PASS
WARN (Unknown if this platform has IOMMU support)
QEMU: Checking for secure guest support :
WARN (Unknown if this platform has Secure Guest support)
出现该图情况表示可以开始下一步,创建虚拟机了
四、文本环境下创建虚拟机
virt-install --name demo-guest1 --memory 1024 --vcpus 2 --disk size=20 --os-variant rhel8.0 --location /iso/rhel-server-8.2-x86_64-dvd.iso --graphics none --extra-args='console=ttyS0'
命令 | 含义 |
---|---|
virt-install | |
–name demo-guest1 | 虚拟机名称 |
–memory 2048 | 虚拟机内存大小 |
–vcpus 2 | 虚拟机cpu个数 |
–disk size=20 | 虚拟机磁盘大小 单位G |
–os-variant rhel8.0 | 虚拟机版本 |
–location /iso/rhel-server-8.2-x86_64-dvd.iso | 需要安装镜像路径 |
–graphics none | 不需要图形化 |
–extra-args=‘console=ttyS0’ | 将虚拟安装的窗口画面传递到当前的画面上来 |
注意事项:
如果 virt-install 失败并显示 cannot find default network 错误:
确定安装了 libvirt-daemon-config-network 软件包:
dnf info libvirt-daemon-config-network
验证 libvirt 默认网络是否活跃,并配置为自动启动:
virsh net-list --all
[root@kittod ~]# virsh net-list --all
Name State Autostart Persistent
--------------------------------------------
default active yes yes
# 如果没有,激活默认网络并将其设置为 auto-start:
[root@kittod ~]# virsh net-autostart default
Network default marked as autostarted
[root@kittod ~]# virsh net-start default
================================================================================
================================================================================
Installation
1) [x] Language settings 2) [x] Time settings
(English (United States)) (America/New_York timezone)
3) [!] Installation source 4) [!] Software selection
(Processing...) (Processing...)
5) [!] Installation Destination 6) [x] Kdump
(No disks selected) (Kdump is enabled)
7) [ ] Network configuration 8) [!] Root password
(Not connected) (Password is not set.)
9) [!] User creation
(No user will be created)
Please make a selection from the above ['b' to begin installation, 'q' to quit,
'r' to refresh]: r
================================================================================
================================================================================
Installation
1) [x] Language settings 2) [x] Time settings
(English (United States)) (America/New_York timezone)
3) [x] Installation source 4) [x] Software selection
(Local media) (Server with GUI)
5) [!] Installation Destination 6) [x] Kdump
(No disks selected) (Kdump is enabled)
7) [ ] Network configuration 8) [!] Root password
(Not connected) (Password is not set.)
9) [!] User creation
(No user will be created)
Please make a selection from the above ['b' to begin installation, 'q' to quit,
'r' to refresh]: 5
Probing storage...
================================================================================
======================================================