In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to install and deploy KVM virtual machine on Ubuntu system". The explanation in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian and study and learn "how to install and deploy KVM virtual machine on Ubuntu system" together!
I. Install the required software package
The code is as follows:
#apt-get install kvm
#apt-get install qemu
#apt-get install libvirt-bin libvirt
management
The code is as follows:
#apt-get install bridge-utils
network bridging
If you need to support kvm VM boot from NIC, you also need to install kvm-pxe package
The code is as follows:
#apt-get install kvm-pxe
Second, create a virtual machine
You can refer to the libvirt official website and create your own xml domain file.
The domain name, UUID and startup options of virtual machine can be defined.
Memory size, cpu number, hard disk and optical drive mirror path, network card correlation, etc.
VM disk format is qcow2
Here's an example: Building a Centos system
###ubuntu recommends vim with vim-gnome###
Remove the vim that comes with it.
The code is as follows:
#apt-get remove vim-tiny
Install vim-gnome
The code is as follows:
#apt-get install vim-gnome
1. Create a directory to store virtual machine related files
The code is as follows:
#mkdir /datastore
2, first to create a network bridge device
#ifconfig eth0 Get the IP of eth0 first, assuming it is 192.168.1.22
The code is as follows:
#/sbin/ifconfig eth0 0.0.0.0 promisc up
#/usr/sbin/brctl addbr vSwitch0
#/usr/sbin/brctl addif vSwitch0 eth0
#/sbin/ifconfig vSwitch0 192.168.1.22 netmask 255.255.255.0 up
#/sbin/route add default gw 192.168.1.1 dev vSwitch0
The above command restart failure, you can write a script, and then add the execution path in/etc/rc.local
The code is as follows:
#!/ bin/sh
if /sbin/ifconfig vSwitch0 down > /etc/null 2>&1 &
then
/usr/sbin/brctl delbr vSwitch0 > /etc/null 2>&1 &
/sbin/ifconfig eth0 0.0.0.0 promisc up
/usr/sbin/brctl addbr vSwitch0
/usr/sbin/brctl addif vSwitch0 eth0
/sbin/ifconfig vSwitch0 192.168.1.22 netmask 255.255.255.0 up
/sbin/route add default gw 192.168.1.1 dev vSwitch0
else
/sbin/ifconfig eth0 0.0.0.0 promisc up
/usr/sbin/brctl addbr vSwitch0
/usr/sbin/brctl addif vSwitch0 eth0
/sbin/ifconfig vSwitch0 192.168.1.22 netmask 255.255.255.0 up
/sbin/route add default gw 192.168.1.1 dev vSwitch0
fi
3. Create an xml definition file. Below is my xml file.
XML/HTML Code Copy content to clipboard
templates-1 ##Domain Name
0112310a-ff1a-bfb5-7cd8-5b2b22ad8de1 ##UUID
262144 ##Maximum Memory
262144 ##Current Memory
1 ##Number of CPUs
hvm
##Start mode
destroy
restart
restart
/usr/bin/kvm
##Disk file path for this VM
##Drive
##Virtual optical drive image path
##MAC Address
##Bridge equipment
##Virtual devices
The disk and CD mirror paths in the definition file must actually exist
4. Create virtual machine disks
The code is as follows:
# qemu-img create -f qcow2 templates-1.qcow2 20G
Formatting 'templates.qcow2', fmt=qcow2 size=21474836480 encryption=off cluster_size=0
refers to creating a virtual disk named templates.qcow2 with the format qcow2 and a size of 20 gigabytes
The code is as follows:
# du -sh templates.qcow2
136K templates.qcow2
This size will vary with system changes, but should not exceed 20G maximum
5. Start installation
The code is as follows:
#virsh define templates-1.xml
Define a virtual machine
The code is as follows:
#virsh start templstes-1
Start a virtual machine
The code is as follows:
#virsh vncdisplay templates-1
View vnc ports for windowed management of the installation process
The code is as follows:
#vncviewer :0
Open vnc window
This command requires one of these to be installed
The code is as follows:
# vncviewer
The program "vncviewer" is included in the following packages:
* xtightvncviewer
* xvnc4viewer
* tightvnc-java
* vnc-java
Please try:
The code is as follows:
apt-get install
###If there are multiple VMs, their vnc ports should be different ##
The code is as follows:
#virsh destoy DOMAINNAME
Shut down a virtual machine
More command details
The code is as follows:
#virsh --help
6. If graphical management is needed, you can install packages such as virt-manager.
Thank you for reading, the above is "how to install and deploy KVM virtual machine on Ubuntu system" content, after the study of this article, I believe everyone on how to install and deploy KVM virtual machine on Ubuntu system this problem has a deeper understanding, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.