Series |
##Common PC/Server Version |
VMware
|
VMware Workstation, vSphere
|
Microsoft
|
VirtualPC, Hyper-V
|
RedHat
|
KVM, RHEV
|
##Oracle | Oracle VM VirtualBox
|
Citrix | Xen |
Install the virtualization server platform (KVM)
1. Main software package
qemu-kvm https ://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b provides low-level simulation support for kvm
libvirt-daemon https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15blibvirtd daemon, manages virtual machines
libvirt-client https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b client software, providing client management commands
libvirt-daemon-driver gemu https://www.php.cn/link /93ac0c50dd620dc7b88e5fe05c70e15blibvirtd Connect gemu driver
virt-manager https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15bGraphic management tool
2. Preparation work
1) Prepare a device (the blogger here prepares a Centos7 server)
2) Turn off SELinux and firewall (may cause communication within the virtual machine to be impossible)
3) Install KVM related packages, the command is as follows
yum -y install kvm bridge-utils virt-v2v libgesttfs-tools libcanberra-gtk2 qemu-kvm.x86_64 qemu-kvm-tools.86_64 libvirt.x86_64 libvirt-cim.x86_64 libvirt-client.x86_64 lsbvirt-java.noarch libvirt-python.x86_64 libiscsidbus-devel virt-clone tunctl virt-manager python-virtinst virt-vieeer virt-top dejavu-lgc-sans-fonts nfs-utils epel-release
3. Start the libvirtd server
libvirtd provides services for managing virtual machines Interface, providing DNS, DHCP and other functions
1) Command
systemctl restart libvirtd
systemctl restart libvirtd
2) Example
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b systemctl restart libvirtd
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b systemctl restart libvirtd
4. Open the management tool
1) Command
virt-manager
2) Instance
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virt-manager
5. Click the icon to create a new virtual machine
6. Choose how to install the operating system
Here select "Local install media (ISO image or CDROM)", click "ForWard"
Note:
1) Local install media (ISO image or CDROM)
Local installation media (ISO image or CDROM)
2) Network Install(HTTPFTPor NFS)
Network Installation (HTTP, FTP or NFS)
3 ) Network Boot (PXE)
Network Boot (PXE)
4) Import existing disk image
Import existing disk image
7. Find the installation media
Select "Use ISO image", click "Browse..." select the ISO image location and click "ForWard"
Note:
1) Use CDROM or DVD
Use CD or DVD
2) Use ISO image
Use ISO image
3)Automatically detect operating system based on install media
自动检测操作系统上的基础安装介质
8、设置内存大小和CPU数量,设置完毕后点击“ForWard”
9、创建虚拟磁盘
勾选“Enable storage for this virtual machine”,创建并设置磁盘容量,点击“ForWard”
注:
1)Enable storage for this virtual machine
为虚拟机启用存储
2)Create a disk image for the virtual machine
为虚拟机创建磁盘映像
3)Select or create custom storage
选择或创建自定义存储
10、准备开始安装,设置好虚拟机名称,点击“Finish”
注:
1)Name:虚拟机名称
2)OS:系统名称
3)Install:安装操作系统方式
4)Memory:内存大小
5)CPUs:处理器数量
6)Storage:存储容量与位置
7)Customize configuration before install:安装前自定义配置
8)Network selection:网络设置
四、操作虚拟机
1、使用virsh命令工具
virsh命令工具提供管理各虚拟机的命令接口,支持交互模式,包括查看、创建、停止、关闭等功能。
1)常用格式
virsh 控制指令 虚拟机名称 参数
2)命令
virsh
3)实例
[root@wangwu~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15bvirsh https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b启动virsh命令工具
欢迎使用virsh,虚拟化的交互式终端
输入:'help'来获得命令的帮助信息
'quit'退出
virsh https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b
2、查看虚拟化信息
查看KVM节点(服务器)信息
1)命令
virsh nodeinfo
2)实例
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virsh nodeinfo https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b查看KVM节点(服务器)信息
CPU 型号: x86_64
CPU: 1
CPU 频率: 2600 MHz
CPU socket: 1
每个 socket 的内核数: 1
每个内核的线程数: 1
NUMA 单元: 1
内存大小: 1,048,576 KiB
列出虚拟机状态
1)命令
virsh list --all
2)实例
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virsh list --all https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b列出所有虚拟机的状态
Id Name State
6 centos7.0 shut off
查看指定虚拟机的信息
1)命令
virsh dominfo 虚拟机名称
2)实例
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virsh dominfo centos7.0 https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b查看centos7.0虚拟机的信息
Id: 6
名称: centos7.0
UUID: 78fa5915-c060-4731-b4c5-bd4aaaea8fee
OS 类型: hvm
状态: running
CPU: 1
CPU 时间: 28.7s
最大内存: 1048576 KiB
使用的内存: 1048576 KiB
持久: 是
自动启动: 禁用
管理的保存: 否
安全性模式: none
安全性 DOI: 0
3、虚拟机开关机操作
启动|重启|关闭 指定的虚拟机
1)命令
virsh start 虚拟机名称
virsh reboot 虚拟机名称
virsh shutdown 虚拟机名称
2)实例
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virsh start centos7.0 https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b启动centos7.0虚拟机
Domain centos7.0 started
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virsh list https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b验证
Id Name State
6 centos7.0 running
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virsh shutdown centos7.0 https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b关闭centos7.0虚拟机
Domain centos7.0 is being shutdown
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virsh list --all https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b验证
Id Name State
- centos7.0 shut off
强制关闭指定的虚拟机
1)命令
virsh destroy 虚拟机名称
2)实例
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virsh destroy centos7.0 https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b强制关闭centos7.0虚拟机
Domain centos7.0 destroyed
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virsh list --all https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b验证
Id Name State
- centos7.0 shut off
将指定的虚拟机设为|取消开机自动运行
1)命令
virsh autostart 虚拟机名称
virsh autostart --disable 虚拟机名称
2)实例
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virsh autostart centos7.0 https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b 设置centos7.0虚拟机自启动
Domain centos7.0 marked as autostarted
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virsh dominfo centos7.0 https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b验证
Id:
Name: centos7.0
... ... ...
Autostart: enable
... ... ...
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virsh autostart --disable centos7.0 https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b 取消centos7.0虚拟机自启动
Domain centos7.0 unmarked as autostarted
[root@wangwu ~]https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b virsh dominfo centos7.0 https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15b验证
Id:
Name: centos7.0
... ... ...
Autostart: disable
... ... ...
相关推荐:《Linux视频教程》