In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use KVM to configure headless virtualization server on Ubuntu 18.04 LTS. It is very detailed and has a certain reference value. Interested friends must read it!
Configure headless virtualized servers using KVM
I tested this guide on the Ubuntu 18.04 LTS server, but it can also be used on other Linux distributions, such as Debian, CentOS, RHEL, and Scientific Linux. This approach is perfect for those who want to configure a simple virtualized environment on a Linux server without any graphical environment.
For the purposes of this guide, I will use two systems.
KVM virtualized servers:
Host operating system-minimize installed Ubuntu 18.04LTS (no GUI)
IP address of the host operating system: 192.168.225.22Universe 24
Guest operating system (which will run on the host machine of Ubuntu 18.04): Ubuntu 16.04 LTS server
Remote Desktop client:
Operating system-Arch Linux
Install KVM
First, let's check whether our system supports hardware virtualization. To do this, you need to run the following command in the terminal:
$egrep-c'(vmx | svm)'/ proc/cpuinfo
If the result is zero (0), the system does not support hardware virtualization, or virtualization is disabled in BIOS. Enter your system BIOS and check the virtualization options, and then enable it.
If the result is 1 or more, the system will support hardware virtualization. However, before you run the above command, you need to always keep the virtualization option enabled in BIOS.
Alternatively, you can use the following command to verify it. But in order to use this command, you need to install KVM first.
$kvm-ok
Sample output:
INFO: / dev/kvm existsKVM acceleration can be used
If you output an error like this, you can still run the guest virtual machine in KVM, but its performance will be very poor.
INFO: Your CPU does not support KVM extensionsINFO: For more detailed results, you should run this as rootHINT: sudo / usr/sbin/kvm-ok
Of course, there are other ways to check if your CPU supports virtualization. Refer to the following guide for more information.
How to know if CPU supports virtual technology (VT)
Next, install KVM and other packages needed to configure the virtualized environment in Linux.
On Ubuntu and other DEB-based systems, run the following command:
$sudo apt-get install qemu-kvm libvirt-bin virtinst bridge-utils cpu-checker
After the KVM installation is complete, start the libvertd service (if it is not started):
$sudo systemctl enable libvirtd$ sudo systemctl start libvirtd create a virtual machine
All virtual machine files and other related files are saved under / var/lib/libvirt/. The default path for ISO mirrors is / var/lib/libvirt/boot/.
First, let's check to see if there is a virtual machine. View the list of available virtual machines and run the following command:
$sudo virsh list-all
Sample output:
Id Name State
As with the screenshot above, there are no virtual machines available.
Now, let's create one.
For example, let's create a Ubuntu 16.04 virtual machine with 512 MB memory, 1 CPU core, and 8 GB hard disk.
$sudo virt-install-name Ubuntu-16.04-ram=512-vcpus=1-cpu host-hvm-disk path=/var/lib/libvirt/images/ubuntu-16.04-vm1,size=8-cdrom / var/lib/libvirt/boot/ubuntu-16.04-server-amd64.iso-graphics vnc
Make sure that there is an ISO image file for Ubuntu 16.04 in the path / var/lib/libvirt/boot/, or a corresponding image file in the other path given in the above command.
Sample output:
WARNING Graphics requested but DISPLAY is not set. Not running virt-viewer.WARNING No console to launch for the guest, defaulting to-- wait-1 Starting install...Creating domain... | 0B 00:00:01Domain installation still in progress. Waiting for installation to complete.Domain has shutdown. Continuing.Domain creation completed.Restarting guest.
Let's explain the above commands and the role of each option you see.
-name: this option defines the virtual machine name. In our case, the name of this virtual machine is Ubuntu-16.04.
-ram=512: allocates 512MB memory to virtual machines.
-vcpus=1: indicates the number of CPU cores in the virtual machine.
-cpu host: optimize the CPU attribute by exposing the configuration of the host CPU to the guest system.
-hvm: complete hardware virtualization is required.
-disk path: the location and size of the virtual machine hard disk. In our example, I assigned 8GB's hard drive.
-cdrom: the location where the ISO image is installed. Please note that you must have a real ISO image at this location.
-graphics vnc: allows VNC to access the virtual machine from a remote client.
Access the virtual machine using the VNC client
Now, we use SSH to log in to the Ubuntu server (virtualized server) on the remote desktop system, as shown below.
$ssh sk@192.168.225.22
Here, sk is the user name of my Ubuntu server, and 192.168.225.22 is its IP address.
Run the following command to find out the port number of VNC. We need it to access the virtual machine from a remote system.
$sudo virsh dumpxml Ubuntu-16.04 | grep vnc
Sample output:
Write down the port number 5900. Install any VNC client application. In this guide, we will use TigerVnc. TigerVNC is the client available in the Arch Linux default repository. Install it on Arch and run the following command:
$sudo pacman-S tigervnc
Enter the following SSH port forwarding command on the remote client system with the VNC client installed.
$ssh sk@192.168.225.22-L 5900 purl 127.0.0.1 purl 5900
Again, 192.168.225.22 is the IP address of my Ubuntu server (virtualized server).
Then, open the VNC client from your Arch Linux.
Enter localhost:5900 in the VNC server box and click the "Connect" button.
Then start installing the Ubuntu virtual machine in the same way that you install the system on the physical machine.
Similarly, you can configure multiple virtual machines according to the hardware of your server.
Alternatively, you can use the virt-viewer utility to install the operating system on the guest machine. Virt-viewer can be found in the default repository of most Linux distributions. After installing virt-viewer, run the following command to establish an access connection to the virtual machine.
$sudo virt-viewer-- connect=qemu+ssh://192.168.225.22/system-- name Ubuntu-16.04 manages virtual machines
It is interesting to use the administrative user interface virsh to manage virtual machines from the command line. Orders are very easy to remember. Let's look at some examples.
View the running virtual machine and run the following command:
$sudo virsh list
Or
$sudo virsh list-all
Sample output:
Id Name State--- 2 Ubuntu-16.04 running
Start a virtual machine and run the following command:
$sudo virsh start Ubuntu-16.04
Alternatively, you can use the virtual machine id to start it.
As you can see in the screenshot above, the Id of the Ubuntu 16.04 virtual machine is 2. Therefore, when you start it, you can also specify only its ID as below.
$sudo virsh start 2
Restart a virtual machine and run the following command:
$sudo virsh reboot Ubuntu-16.04
Sample output:
Domain Ubuntu-16.04 is being rebooted
Pause a running virtual machine and run the following command:
$sudo virsh suspend Ubuntu-16.04
Sample output:
Domain Ubuntu-16.04 suspended
Rerun a paused virtual machine and run the following command:
$sudo virsh resume Ubuntu-16.04
Sample output:
Domain Ubuntu-16.04 resumed
Shut down a virtual machine and run the following command:
$sudo virsh shutdown Ubuntu-16.04
Sample output:
Domain Ubuntu-16.04 is being shutdown
Remove a virtual machine completely and run the following command:
$sudo virsh undefine Ubuntu-16.04$ sudo virsh destroy Ubuntu-16.04
Sample output:
Domain Ubuntu-16.04 destroyed
For more options, it is recommended that you check the man man page:
The above $man virsh is all the contents of the article "how to configure a headless Virtualization Server with KVM on Ubuntu 18.04 LTS". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.