远程主机IP:192.168.122.1 远程主机名:server1.example.com
本地主机IP:192.168.122.2 本地主机名:server2.example.com
1、登录到远程主机上,通过virt-install建立虚拟机
[root@server2 ~]$ ssh root@192.168.122.1
[root@server1 ~]# virt-install --prompt --vnc --vncport=6000 --vnclisten=192.168.122.1
注:
--prompt 采用交互式安装(一种询问式的安装,而不是自动的)
--vncport=6000 开启vnc端口
--vnclisten=192.168.122.1 vnc监听的远程主机IP
What is the name of your virtual machine?
koen
How much RAM should be allocated (in megabytes)?
1024
What would like to use as the disk (file path)?
/var/lib/libvirt/images/koen.img
How large would you like the disk (/var/lib/libvirt/images/likai.img) to be (in gigabytes)?
8
What is the install CD-ROM/ISO or URL?
ftp://192.168.122.1/pub/yum
2.在本地主机上安装vnc的客户端,通过以下命令开启安装图形界面,完成虚拟机的安装步骤
[root@server2 ~]# vncviewer 192.168.122.1:6000
相关命令:
virsh list 查看当前正在运行的虚拟机
virsh list --all 查看所有虚拟机
virsh start exam 开启exam虚拟机
virsh shutdown exam 关闭exam虚拟机
virsh destroy exam 直接关闭exam虚拟机
-------end-------