- Our Server Setup.
After following the guidelines:
- Installation media ISO.
2.1 ISO image
We store our Linux ISO images under the storage pool directory "default" [/vm/images] while our KVM guest images will be stored under the storage pool directory "storage-1TB" [/vm/storage-1TB].
Let's download the latest CentOS 7 Minimal ISO and store it under the storage pool directory "default".
[root@node1 ~]# wget http://ftp.belnet.be/ftp.centos.org/7/isos/x86_64/CentOS-7-x86_64-Minimal-1611.iso -P /vm/images
[root@node1 ~]# wget http://ftp.belnet.be/ftp.centos.org/7/isos/x86_64/sha256sum.txt -P /vm/images
[root@node1 ~]# wget http://ftp.belnet.be/ftp.centos.org/7/isos/x86_64/sha256sum.txt -P /vm/images
Validate the ISO file.
[root@node1 ~]# cd /vm/images
[root@node1 images]# sha256sum -c sha256sum.txt 2>&1 | grep OK
CentOS-7-x86_64-Minimal-1611.iso: OK
[root@node1 images]# cd
[root@node1 images]# sha256sum -c sha256sum.txt 2>&1 | grep OK
CentOS-7-x86_64-Minimal-1611.iso: OK
[root@node1 images]# cd
2.2 Running virt-install to Build the KVM Guest System.
Overview arguments.
--connect | : Connect to a non-default hypervisor. |
--accelerate | : When installing a QEMU guest, make use of the KVM or KQEMU kernel acceleration capabilities if available. Use of this option is recommended unless a guest OS is known to be incompatible with the accelerators. The KVM accelerator is preferred over KQEMU if both are available. |
--arch | : Request a non-native CPU architecture for the guest virtual machine. The option is only currently available with QEMU guests, and will not enable use of acceleration. If omitted, the host CPU architecture will be used in the guest. |
--check-cpu | : Check that the number virtual cpus requested does not exceed physical CPUs and warn if they do. |
--disk | : To specify media, one of the following options is required:
|
--extra-args | : Additional kernel command line arguments to pass to the installer when performing a guest install from "--location". |
--hvm | : Request the use of full virtualization, if both para & full virtualization are available on the host. This parameter may not be available if connecting to a Xen hypervisor on a machine without hardware virtualization support. This parameter is implied if connecting to a QEMU based hypervisor. |
--location | : Installation source for guest virtual machine kernel+initrd pair. The "LOCATION" can take one of the following forms:
|
--memory | : Memory to allocate for guest instance in megabytes. If the hypervisor does not have enough free memory, it is usual for it to automatically take memory away from the host operating system to satisfy this allocation. |
--metadata | : Specify metadata values for the guest. Possible options include name, uuid, title, and description. |
--name | : Name of the new guest virtual machine instance. This must be unique amongst all guests known to the hypervisor on the connection, including those not currently active. |
--network | : Connect the guest to the host network. The value for "NETWORK" can take one of 3 formats:
|
--nographics | : No graphical console will be allocated for the guest. Fully virtualized guests (Xen FV or QEmu/KVM) will need to have a text console configured on the first serial port in the guest (this can be done via the --extra-args option). Xen PV will set this up automatically. The command ’virsh console NAME’ can be used to connect to the serial device. |
--os-type | : Optimize the guest configuration for a type of operating system (ex. ’linux’, ’windows’). This will attempt to pick the most suitable ACPI & APIC settings, optimally supported mouse drivers, virtio, and generally accommodate other operating system quirks. |
--os-variant | : Further optimize the guest configuration for a specific operating system variant (ex. ’fedora8’, ’winxp’). |
--vcpus | : Number of virtual cpus to configure for the guest. Not all hypervisors support SMP guests, in which case this argument will be silently ignored. |
Let’s build the KVM guest machine.
[root@node1 ~]# virt-install --connect qemu:///system --accelerate --arch x86_64 --check-cpu --disk bus=virtio,format=qcow2,pool=storage-1TB,size=5,sparse=false --extra-args='console=tty0 console=ttyS0,115200n8 serial' --hvm --location=/vm/images/CentOS-7-x86_64-Minimal-1611.iso --memory 1024 --metadata title="[CentOS] - test01.server.lab",description="VM Guest" --name test01 --network=bridge:server,model=virtio,mac=52:54:00:4a:a4:44 --nographics --os-type linux --os-variant centos7.0 --vcpus=1
Starting install...
Retrieving file .treeinfo...
Retrieving file vmlinuz...
Retrieving file initrd.img...
Allocating 'test01.qcow2'
Creating domain...
Connected to domain test01
Escape charachter is ^]
....
Starting install...
Retrieving file .treeinfo...
Retrieving file vmlinuz...
Retrieving file initrd.img...
Allocating 'test01.qcow2'
Creating domain...
Connected to domain test01
Escape charachter is ^]
....
Escape character ^] is key combination CTRL + ALT GR + ]
2.3 Remove CD-ROM disk.
After your OS installation, you can remove the attach CDROM disk.
Print information about existing domains (active and inactive).
[root@node1 ~]# virsh list --all
Id | Name | State |
------------------------------------- | ------------------------------------- | ------------------------------------- |
11 | test01 | running |
Print a table showing the brief information of all block devices associated with domain.
[root@node1 ~]# virsh domblklist test01
Target | Source |
------------------------------------- | -------------------------------------------------------------------------- |
vda | /vm/storage-1TB/test01.qcow2 |
hda | - |
Gracefully shuts down our domain "test01".
[root@node1 ~]# virsh shutdown test01
Domain test01 is being shutdown
Domain test01 is being shutdown
Detach a disk device.
[root@node1 ~]# virsh detach-disk test01 hda --persistent
Disk detached successfully
Disk detached successfully
Start domain and check.
[root@node1 ~]# virsh start test01
Domain test01 started
Domain test01 started
# Print a table showing the brief information of all block devices associated with domain.
[root@node1 ~]# virsh domblklist test01
Target
Source
-------------------------------------
--------------------------------------------------------------------------
vda
/vm/storage-1TB/test01.qcow2
- Installation via HTTP.
Compare with the installation media ISO we need to alter two virt-install arguments to initiate the installation via HTTP.
With the argument --extra-args we need to add additional parameters like:
With the argument --extra-args we need to add additional parameters like:
- ksdevice - Define a specific network interface to kickstart.
- ip - Define an IP address with the IP subnet of your VLAN.
- netmask - A netmask is a 32-bit mask used to divide an IP address into subnets and specify the network's available hosts.
- gateway - A networked device which serves as an entry point into another network.
- dns - Helps to point domain names or hostnames to their associated Internet Protocol address.
Let’s build the KVM guest machine.
[root@node1 ~]# virt-install --connect qemu:///system --accelerate --arch x86_64 --check-cpu --disk bus=virtio,format=qcow2,pool=storage-1TB,size=5,sparse=false --extra-args='console=tty0 console=ttyS0,115200n8 serial,ksdevice=eth0 ip=10.0.6.28 netmask=255.255.255.192 dns=8.8.8.8 gateway=10.0.6.1' --hvm --location 'http://ftp.belnet.be/ftp.centos.org/7/os/x86_64/' --memory 1024 --metadata title="[CentOS] -test02.server.lab",description="VM Guest" --name test02 --network=bridge:server,model=virtio,mac=52:54:00:5a:a5:55 --nographics --os-type linux --os-variant centos7.0 --vcpus=1
Starting install...
Retrieving file .treeinfo...
Retrieving file vmlinuz...
Retrieving file initrd.img...
Allocating 'test02.qcow2'
Creating domain...
Connected to domain test02
Escape charachter is ^]
....
Starting install...
Retrieving file .treeinfo...
Retrieving file vmlinuz...
Retrieving file initrd.img...
Allocating 'test02.qcow2'
Creating domain...
Connected to domain test02
Escape charachter is ^]
....
Escape character ^] is key combination CTRL + ALT GR + ]
Geen opmerkingen:
Een reactie posten