一、部署环境和软件包准备
- 1.1 环要求
龙芯3A4000
- 1.2 软件包清单
qemu-kvm-ev-2.12.0-33.1.lns7.3.loongnix.mips64el
libvirt-4.5.0-23.lns7.3.loongnix.mips64el
virt-install-1.5.0-7.lns7.3.loongnix.noarch
tigervnc-1.3.1-11.fc21.loongson.1.mips64el
二、环境搭建–服务器
- 2.1 软件包安装
因为loongnix的yum源中已经包上述软件,因此直接通过yum安装即可
yum install -y qemu-kvm-ev libvirt virt-install
- 2.2 服务启动
systemctl start libvirtd && systemctl enable libvirtd
- 2.3 本地镜像准备
wget http://ftp.loongnix.org/os/loongnix-server/1.7/isos/mips64el/loongnix-server-1.7.2003.iso
- 2.4 虚拟机配置xml文件准备
[root@node001 zwl]# cat /loongnix_test.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit kvm-7
or other application using the libvirt API.
-->
<domain type="kvm">
<name>loongnix_test</name>
<memory unit="KiB">8388608</memory>
<currentMemory unit="KiB">8388608</currentMemory>
<vcpu placement="static">2</vcpu>
<os>
<type arch="mips64el" machine="loongson3a">hvm</type>
<loader readonly="yes" type="rom">/usr/share/qemu/ls3a_bios.bin</loader>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode="custom" match="exact" check="partial">
<model fallback="allow">Loongson-3A4000-COMP</model>
</cpu>
<clock offset="utc"/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-mips64el</emulator>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2"/>
<source file="/home/zwl/loongnix_test.qcow2"/>
<target dev="vda" bus="virtio"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x06" function="0x0"/>
</disk>
<disk type="file" device="cdrom">
<source file="/home/zwl/loongnix-server-1.7.2003.iso"/>
<target dev="hdc" bus="virtio"/>
</disk>
<controller type="usb" index="0" model="qemu-xhci">
<address type="pci" domain="0x0000" bus="0x00" slot="0x04" function="0x0"/>
</controller>
<controller type="pci" index="0" model="pci-root"/>
<controller type="virtio-serial" index="0">
<address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0"/>
</controller>
<interface type="direct">
<source dev="enp5s0f3" mode="bridge"/>
<model type="virtio"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x0"/>
</interface>
<serial type="pty">
<target port="0"/>
</serial>
<console type="pty">
<target type="serial" port="0"/>
</console>
<channel type="unix">
<target type="virtio" name="org.qemu.guest_agent.0"/>
<address type="virtio-serial" controller="0" bus="0" port="1"/>
</channel>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
<address type="virtio-serial" controller="0" bus="0" port="2"/>
</channel>
<input type="tablet" bus="usb">
<address type="usb" bus="0" port="1"/>
</input>
<input type="keyboard" bus="usb">
<address type="usb" bus="0" port="2"/>
</input>
<graphics type="spice" autoport="yes">
<listen type="address"/>
</graphics>
<video>
<model type="qxl" ram="65536" vram="65536" vgamem="16384" heads="1" primary="yes"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0"/>
</video>
<memballoon model="virtio">
<address type="pci" domain="0x0000" bus="0x00" slot="0x07" function="0x0"/>
</memballoon>
<graphics type="vnc" port="-1" keymap="en-us" listen="0.0.0.0"/>
</devices>
</domain>
三、环境搭建–具有图形界面的客户机
yum install -y tigervnc
四、在服务器中创建虚拟机
- 3.1 生成硬盘镜像文件
[root@node001 zwl]# qemu-img create -f qcow2 loongnix_test.qcow2 30G
Formatting 'loongnix_test.qcow2', fmt=qcow2 size=32212254720 cluster_size=65536 lazy_refcounts=off refcount_bits=16
- 3.2 导入虚拟机配置
[root@node001 zwl]# virsh define loongnix_test.xml
定义域 loongnix_test(从 loongnix_test.xml)
- 3.3 启动虚拟机
[root@node001 zwl]# virsh start loongnix_test
域 loongnix_test 已开始
- 3.4 查看当前虚拟机状态
[root@node001 zwl]# virsh list
Id 名称 状态
----------------------------------------------------
16 loongnix_test running
- 3.5 显虚拟机端口信息
[root@node001 zwl]# virsh vncdisplay loongnix_test
:1
五、通过客户机vnc链接已经启动虚拟
在客户机执行vncviewer,调出vnc客户端
输入服务器ip及虚拟机对应的端口,点击connect即连接,如下
10.130.56.127:1
六、虚拟机安装
连接后虚拟机安装步与正常物理机安装步骤一致,不再单独介绍