virt-install 创建虚拟机模板

news/2025/1/27 8:57:52/文章来源:https://www.cnblogs.com/wangguishe/p/18689623

上传 iso 到宿主机

ls -l /data1/iso/
total 4422912
-rw-r--r-- 1 root root 1774077952 Jan 22 08:51 ctyunos-2.0.1-210625-x86_64-dvd.iso
-rw-r--r-- 1 root root 2754981888 May  7  2024 ubuntu-24.04-live-server-amd64.iso

创建虚拟磁盘(可选)

创建 qcow2 文件

qemu-img create -f qcow2 /data/ctyunos/ctyun-01_system.qcow2 20G
Formatting '/data/ctyunos/ctyun-01_system.qcow2', fmt=qcow2 size=21474836480 cluster_size=65536 lazy_refcounts=off refcount_bits=16

查看 qcow2 文件大小

ls -lh /data/ctyunos/ctyun-01_system.qcow2
-rw-r--r-- 1 root root 193K Jan 24 15:46 /data/ctyunos/ctyun-01_system.qcow2

查看支持的系统版本

osinfo-query os | grep centos
 centos6.0            | CentOS 6.0                                         | 6.0      | http://centos.org/centos/6.0            centos6.1            | CentOS 6.1                                         | 6.1      | http://centos.org/centos/6.1            centos6.2            | CentOS 6.2                                         | 6.2      | http://centos.org/centos/6.2            centos6.3            | CentOS 6.3                                         | 6.3      | http://centos.org/centos/6.3            centos6.4            | CentOS 6.4                                         | 6.4      | http://centos.org/centos/6.4            centos6.5            | CentOS 6.5                                         | 6.5      | http://centos.org/centos/6.5            centos6.6            | CentOS 6.6                                         | 6.6      | http://centos.org/centos/6.6            centos6.7            | CentOS 6.7                                         | 6.7      | http://centos.org/centos/6.7            centos6.8            | CentOS 6.8                                         | 6.8      | http://centos.org/centos/6.8            centos6.9            | CentOS 6.9                                         | 6.9      | http://centos.org/centos/6.9            centos7.0            | CentOS 7.0                                         | 7.0      | http://centos.org/centos/7.0         

根据 iso 创建虚拟机

事前创建磁盘文件

virt-install \--name ctyun-2.0.1-01 \--ram 2048 \--vcpus 2  \--virt-type kvm  \--os-variant=generic \--description ctyun-2.0.1-01  \--network bridge=CN1,model=virtio  \--network bridge=CN2,model=virtio  \--graphics vnc,listen=0.0.0.0  \--disk path=/data/ctyunos/ctyun-01_system.qcow2,format=qcow2,bus=virtio \--disk path=/data/ctyunos/ctyun-01_data.qcow2,format=qcow2,size=20,bus=virtio \--cdrom=/data/iso/ctyunos-2.0.1-220311-x86_64-dvd.iso \--noautoconsole \--channel unix,path=/var/lib/libvirt/qemu/ctyun-2.0.1-01.agent,mode=bind,target_type=virtio,name=org.qemu.guest_agent.0 \--console pty,target_type=serial \--autostart
Starting install...
Allocating 'ctyun-01_data.qcow2'                                                                     |  20 GB  00:00:00
Domain installation still in progress. You can reconnect to 
the console to complete the installation process.

无需事先创建磁盘文件

virt-install \--name ctyun-2.0.1-01 \--ram 2048 \--vcpus 2  \--virt-type kvm  \--os-variant=generic \--description ctyun-2.0.1-01  \--network bridge=CN1,model=virtio  \--network bridge=CN2,model=virtio  \--graphics vnc,listen=0.0.0.0  \--disk path=/data/ctyunos/ctyun-01_system.qcow2,size=10,format=qcow2,bus=virtio \--disk path=/data/ctyunos/ctyun-01_data.qcow2,size=20,format=qcow2,bus=virtio \--cdrom=/data/iso/ctyunos-2.0.1-220311-x86_64-dvd.iso \--noautoconsole \--channel unix,path=/var/lib/libvirt/qemu/ctyun-2.0.1-01.agent,mode=bind,target_type=virtio,name=org.qemu.guest_agent.0 \--console pty,target_type=serial \--autostart
Starting install...
Allocating 'ctyun-01_system.qcow2'                                                                          |  10 GB  00:00:00     
Allocating 'ctyun-01_data.qcow2'                                                                     |  20 GB  00:00:00
Domain installation still in progress. You can reconnect to 
the console to complete the installation process.

查看虚机 ID

virsh list --all
 Id   Name          State
-----------------------------1    ctyun-2.0.1-01   running

查看虚机 VNC 信息

virsh vncdisplay 1
:0

通过 VNC 连接

安装过程 。。。。

虚拟机开启

virsh start ctyun-2.0.1-01
Domain ctyun-2.0.1-01 started

查看虚拟机网卡信息

ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000link/ether 52:54:00:de:1f:fe brd ff:ff:ff:ff:ff:ffinet 192.168.80.138/24 brd 192.168.80.255 scope global dynamic noprefixroute ens3valid_lft 1757sec preferred_lft 1757secinet6 fe80::de9:e2c7:769d:93ed/64 scope link noprefixroute valid_lft forever preferred_lft forever
3: ens4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000link/ether 52:54:00:26:0d:d5 brd ff:ff:ff:ff:ff:ffinet 192.168.174.124/24 brd 192.168.174.255 scope global dynamic noprefixroute ens4valid_lft 1758sec preferred_lft 1758secinet6 fe80::f02a:ae03:bb7d:2e96/64 scope link noprefixroute valid_lft forever preferred_lft forever

查看虚拟机磁盘信息

fdisk -l
Disk /dev/vda: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x31741cc3Device     Boot   Start      End  Sectors Size Id Type
/dev/vda1  *       2048  2099199  2097152   1G 83 Linux
/dev/vda2       2099200 20971519 18872320   9G 8e Linux LVMDisk /dev/vdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/ctyunos-root: 7.102 GiB, 8585740288 bytes, 16769024 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/ctyunos-swap: 1 GiB, 1073741824 bytes, 2097152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

查看宿主机网卡信息

ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master CN2 state UP group default qlen 1000link/ether 00:0c:29:2f:c1:1a brd ff:ff:ff:ff:ff:ff
3: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master CN1 state UP group default qlen 1000link/ether 00:0c:29:2f:c1:24 brd ff:ff:ff:ff:ff:ff
4: CN2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000link/ether 00:0c:29:2f:c1:1a brd ff:ff:ff:ff:ff:ffinet 192.168.174.123/24 brd 192.168.174.255 scope global noprefixroute CN2valid_lft forever preferred_lft foreverinet6 fe80::51c3:93b:274:6372/64 scope link noprefixroute valid_lft forever preferred_lft forever
5: CN1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000link/ether 00:0c:29:2f:c1:24 brd ff:ff:ff:ff:ff:ffinet 192.168.80.137/24 brd 192.168.80.255 scope global noprefixroute CN1valid_lft forever preferred_lft foreverinet6 fe80::2392:17b5:d36:9ae/64 scope link noprefixroute valid_lft forever preferred_lft forever
6: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000link/ether 52:54:00:fe:8d:0f brd ff:ff:ff:ff:ff:ffinet 192.168.124.1/24 brd 192.168.124.255 scope global virbr0valid_lft forever preferred_lft forever
9: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master CN1 state UNKNOWN group default qlen 1000link/ether fe:54:00:de:1f:fe brd ff:ff:ff:ff:ff:ffinet6 fe80::fc54:ff:fede:1ffe/64 scope link valid_lft forever preferred_lft forever
10: vnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master CN2 state UNKNOWN group default qlen 1000link/ether fe:54:00:26:0d:d5 brd ff:ff:ff:ff:ff:ffinet6 fe80::fc54:ff:fe26:dd5/64 scope link valid_lft forever preferred_lft forever

查看网桥信息

brctl show
bridge name	bridge id		STP enabled	interfaces
CN1		8000.000c292fc124	yes		ens192vnet0
CN2		8000.000c292fc11a	yes		ens160vnet1
virbr0		8000.525400fe8d0f	yes	

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/876180.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

理解ABP的领域驱动设计

大家好,我是张飞洪,感谢您的阅读,我会不定期和你分享学习心得,希望我的文章能成为你成长路上的垫脚石,让我们一起精进。关于玩转ABP框架相关的文章,之前在博客园陆续写了《ABP vNext系列文章和视频》,大家可以跳转过去看,后续文章首发主要以CSDN为主。 言归正传,ABP 框…

《HelloGitHub》第 106 期

兴趣是最好的老师,HelloGitHub 让你对编程感兴趣!简介 HelloGitHub 分享 GitHub 上有趣、入门级的开源项目。github.com/521xueweihan/HelloGitHub这里有实战项目、入门教程、黑科技、开源书籍、大厂开源项目等,涵盖多种编程语言 Python、Java、Go、C/C++、Swift...让你在短…

Cisco Nexus 9000v Switch, NX-OS Release 10.5(2)F - 用于网络原型设计和学习研究的虚拟化数据中心交换机

Cisco Nexus 9000v Switch, NX-OS Release 10.5(2)F - 用于网络原型设计和学习研究的虚拟化数据中心交换机Cisco Nexus 9000v Switch, NX-OS Release 10.5(2)F 用于网络原型设计和学习研究的虚拟化数据中心交换机 请访问原文链接:https://sysin.org/blog/cisco-nexus-9000v/ 查…

数证杯个人

2024数证杯决赛个人赛wp 容器密码:4zL!$WpRkmANv@XFQ#7HdEyU&GpoTb56YZ^Jq83!Wr(tqA%XsPB7f@CY1xRmKH9#Le*WVG9NuvT$kJ2@7b64Tp(FLM#zqRY8Hv%!KU^9C&YXL*powq87Hr 首先还是感谢强大的队友带我进入了决赛,第一天就上强度,直接个人赛八个小时,原地坐牢四五个小时,赛…

VSCode输出中文乱码

VSCode CMake终端日志乱码在使用CMake插件生成项目时,发现VSCode输出窗口输出的是乱码,这让我感觉很头疼,遂写下这篇博客为后人积累经验。一开始我以为是因为编码的问题导致乱码,于是chcp 65001后重新生成CMake项目,但是发现没有解决,那怕是给VSCode设置gbk编码也是没用。…

三创赛商务大数据分析实战赛

数据采集 概念 数据采集就是搜集符合数据挖掘研究要求的原始数据(Raw Data)。原始数据是研究者拿到的一手或者二手资源。数据采集既可以从现有、可用的无尽数据中搜集提取你想要的二手数据,也可以经过问卷调查、采访、沟通等方式获得一手资料。不管用哪种方法得到数据的过程…

索引篇

1.索引如何分类?按照物理结构分类:①聚簇索引 ②二级索引 按数据结构分:①哈希表索引 ②B+树索引 ③Full-text索引 按字段特性分类:① 主键索引 ②唯一索引 ③普通索引 ④前缀索引 按照索引结构分类:①单列索引 ②联合索引2.InnoDB的聚簇索引的默认创建机制如果有主键,默…

2024年度Graph+AI开源探索思考

2024年蚂蚁图计算团队在「Graph+AI」开源技术方向的实践过程和思考,和大家聊一聊这个技术方向带给了我们什么,面向2025年还有哪些有意思的事情可以继续探索。前记 这篇年度总结其实酝酿了许久,却因诸多原因拖至腊月底,此时赶在春节前发出来,也不失为“农历版”年度总结了。…

卷积

参见:Convolutions Over Volume | CourseraBut what is a convolution? | 3Blue1BrownCNN Explainer

Windows安装Mysql-5.7(安装器方式)

1、下载Mysql的安装包下载地址:https://dev.mysql.com/downloads/installer/ 注意:官网的下载速度可能很慢,有任务时间要求的须尽快下载,或者使用其他可靠的下载源2、选择对应的版本注意:选择完MySQL的版本后,可以看到下载列表中有两个可以选择;其中小的那个是在线安装器…

RocketMQ原理—5.高可用+高并发+高性能架构

大纲 1.RocketMQ的整体架构与运行流程 2.基于NameServer管理Broker集群的架构 3.Broker集群的主从复制架构 4.基于Topic和Queue实现的数据分片架构 5.Broker基于Pull模式的主从复制原理 6.Broker层面到底如何做到数据0丢失 7.数据0丢失与写入高并发的取舍 8.RocketMQ读写分离主…

若干文本

4.1.2 基于 CatBoost 的缺失值填充 在数据预处理过程中,为确保模型训练数据的完整性,需对数据集 dataset1 和 dataset3 中的缺失值进行高效填充。针对多维度、多变量的缺失值问题,本研究采用基于梯度提升决策树(Gradient Boosting Decision Tree, GBDT)的 CatBoost 算法,…