XCP-ng: Evolution of Lab V2.0 - Deployment of shared XOSTOR storage and use of Live Migration
- Shared storage is essential for true high availability (HA); NFS is being replaced by XOSTOR.
- XOSTOR relies on DRBD and LINSTOR to replicate disks between the three servers.
- Step-by-step deployment, followed by moving VMs using Live Migration.
- Evaluating the performance of the replicated storage.
Introduction
After taking care of the network, it's time to address the storage.
To benefit from true high availability (HA) features, it is essential to have shared storage for virtual machines (VMs) that can be used by all three servers in the pool.
Several solutions are available. The simplest is to use NFS (Network File System). We could imagine deploying a volume on a NAS, such as my Terramaster F4, mounting it on each node, and creating an SR (Storage Repository) at the pool level.
While this method is perfectly supported, in my case, it requires sufficient NFS performance. However, although performant, my NAS does not have a 10G interface and is used for other purposes.
NFS is already used within the home lab to provide ISOs to VMs, but my NAS does not have sufficient capacity for running VMs.
XOSTOR
The alternative, specific to XCP-ng, is to use XOSTOR.
Click the image to enlarge.
As described on the Vates website, XOSTOR is a hyperconvergence solution for XCP-ng that relies on DRDB technology to aggregate local disks into a high-performance virtual SAN (Storage Area Network).
For those looking for parallels with VMware, it's similar to VSAN in XCP.
However, unlike its competitor, XOSTOR is entirely based on open-source components.
DRBD
Indeed, the product description mentions a DRDB base.
Click the image to enlarge.
DRBD (Distributed Replicated Block Device) is an open-source software solution for Linux that allows real-time data replication between servers.
To put it simply, we could talk about RAID 1 over the network. Instead of transferring data between two disks in the same machine, DRBD transfers data from a disk block on one server to another server across a network (in our case, the 10G network on which we created a VLAN).
DRBD sits in the software stack just above the physical disk (or logical LVM volume) and below the file system.
Its operation is structured in 4 phases:
- The write operation: When an application writes data to the disk of server A (Primary).
- Interception: DRBD intercepts this write operation.
- Replication: DRBD simultaneously sends the data to server B (Secondary) via the network (note that replication can be done to more than one secondary server for greater resilience, at the cost of increased storage space).
- Validation: Once server B has confirmed the write operation, server A validates the operation with the application.
DRBD is a solution that has been around since 2001 and is still actively supported and developed by the Austrian company LINBIT.
LINSTOR
Furthermore, the company also offers another tool, which is also used by XOSTOR: LINSTOR.
Click the image to enlarge.
DRDB is the replication engine, while LINSTOR is the replication manager. One does the work, the other coordinates and manages the configuration.
Indeed, DRDB can be somewhat complex to implement. LINSTOR adds a layer of abstraction that simplifies the management and deployment of DRBD, especially when deploying it on a large number of servers.
We find two components:
- LINSTOR Controller: This is the brain. It contains the database for the entire cluster. You send your configuration and management commands to it.
- LINSTOR Satellite: This is an agent installed on each storage server. It waits for instructions from the Controller to create an LVM volume, activate DRBD replication, or delete a resource.
Note that LINSTOR can be used under Kubernetes via a CSI driver and can also be used with Proxmox or OpenStack, although CEPH is more commonly encountered on these platforms.
However, while CEPH supports various storage types, the combination of LINSTOR/DRDB only handles block storage (like Longhorn), which makes it a very high-performance solution.
Integration with XCP-ng
Under XCP-ng, Vates has gone further in integrating LINSTOR/DRDB, as it offers XOSTOR through a partnership with LINBIT.
This is a complete package designed specifically for XCP-ng to easily and simply deploy LINSTOR/DRDB on an XCP-ng pool.
Rather than reinventing the wheel, Vates chose to rely on a proven and reliable solution to provide simplified integration that is embedded in their hypervisor.
In summary:
- DRBD handles replicating VM data between servers.
- LINSTOR manages the creation and placement of volumes.
- XOSTOR provides the integration of DRDB/LINSTOR under XCP-ng.
Click the image to enlarge.
Our problem is that in the free version, even from source, it's not possible to add the GUI that comes with XOSTOR, at least I haven't found how.
Click the image to enlarge.
But since everything is open source, there is still the possibility of using the entire system through a manual installation, which is certainly more tedious, but perfectly compatible with our pool.
If we cannot use the simplicity of XOSTOR, we can at least use its driver to build a global SR for the pool, taking advantage of the remaining free space on each of the three servers' local disks.
As a reminder, when installing XCP-ng, we intentionally created a locally sized SR with limited size to leave the rest of the disk for creating replicated volumes.
Deployment
Record of the current disk configuration
On each server, you need to connect via SSH to execute fdisk on the NVMe disk and record the current configuration using the p option.
We are not going to create any partitions at this stage, but it is important to know from which location (in GB) we will need to create the next primary partition.
Click the image to enlarge.
In my lab, with the hardware configuration described in the introduction of this cookbook, and after creating the 150 GB local SR on each server, my next partition will start at 206 GB.
The starting point of my next partition at 206 GB is explained by the location of the last sector used on my disk, which is sector 401,606,655. By multiplying this sector number by its size of 512 bytes, we get a total of 205,622,607,360 bytes already occupied or reserved, which corresponds precisely to 205.6 GB. I round up to 206 GB
This is a bit of a workaround, and there's certainly a simpler method. We could actually create the following partition now by simply using what fdisk would suggest by default, but this point will be addressed later.
Preparing the Dom0
Before proceeding, there's one small thing we need to do to avoid problems later: increase the memory of the Dom0 VM.
Remember that in previous articles, we discussed the Dom0 VM, which is deployed during the XCP-ng installation and allows direct communication with the Xen hypervisor for server management and monitoring.
By default, this VM has a limited amount of RAM (2 GB), which is sufficient when you're not trying to deploy other components, but it can become limiting if you start adding additional elements… such as an entire block replication system.
Indeed, DRBD/LINSTOR will run within the Dom0 and may consume more resources (there's Java involved…). If the Dom0 VM becomes saturated with RAM, we could experience instability in the pool and servers.
Click the image to enlarge.
We can check the current status of the VM using the command xl list.
You can see that the dom0 VM has a small amount of RAM.
Click the image to enlarge.
To make these changes, we can directly execute the following command:
/opt/xensource/libexec/xen-cmdline --set-xen dom0_mem=6144M,max:6144M
Click the image to enlarge.
By running this instruction on each server, we increase the VM's memory to 6 GB. We could get away with 4 GB, but I preferred to allocate a bit more… even though, as of the writing of this article, 1 GB of RAM is becoming a rare and expensive resource.
However, for the change to take effect, you need to restart each node.
At this stage, before HA is active and without block replication, we can simply shut down our Xen Orchestra (prdxcpxor501) VM and the test VM created in the previous article.
Click the image to enlarge.
Feel free to check the status of the VMs using the command xe vm-list to ensure that each VM is turned off before rebooting the XCP-ng servers.
Click the image to enlarge.
You must wait for all VMs (except domain0) to be completely shut down. Since XO is no longer available, we will need to reboot the servers via SSH using the command reboot now, restarting the master node last.
Once each XCP-ng server is operational again, XO should restart automatically if auto-start has been enabled.
Otherwise, just to reiterate, XO is not a prerequisite for the proper functioning of the pool.
You can connect to one of the XCP servers via SSH and manually restart the VM using the command xe vm-start (this operation can be performed from any server, as the command will be relayed to the pool master).
Click the image to enlarge.
Once everything is back up, you can continue with the installation of XORSTOR.
Installing packages
We simply deploy the following packages xcp-ng-release-linstor and xcp-ng-linstor on each server:
yum install xcp-ng-release-linstor
yum install xcp-ng-linstor
Click the image to enlarge.
Click the image to enlarge.
Initialization and firewall configuration
As we explained earlier, LINSTOR works using a controller and satellite principle.
For simplicity, we will assume that for our configuration, the controller will be hosted by the pool master. Be aware that this could change permanently, as the controller could be redirected to another server in case of an incident. This is also why you are required to have at least three servers to deploy XOSTOR. As with the HA of the XCP-ng pool, a minimum number of nodes are required to ensure the election of the master (or the controller for XOSTOR).
So, we connect via SSH to the pool master.
We make sure that the newly installed services are active:
systemctl enable --now linstor-controller
systemctl enable --now linstor-satellite
We open the firewall ports that will be necessary for DRBD/LINSTOR, namely ports 3366, 3370 and ports 7000 to 7999:
iptables -I INPUT -p tcp --dport 3366 -j ACCEPT
iptables -I INPUT -p tcp --dport 3370 -j ACCEPT
iptables -I INPUT -p tcp --dport 7000:7999 -j ACCEPT
We back up the iptables configuration:
service iptables save
We restart the satellite service:
systemctl restart linstor-satellite
We leave our SSH connection active on the master server and move on to the other hosts to perform roughly the same steps (without starting the controller) in order to also have the ports open:
systemctl enable --now linstor-satellite
iptables -I INPUT -p tcp --dport 3366 -j ACCEPT
iptables -I INPUT -p tcp --dport 3370 -j ACCEPT
iptables -I INPUT -p tcp --dport 7000:7999 -j ACCEPT
service iptables save
systemctl restart linstor-satellite
Click the image to enlarge.
Click the image to enlarge.
We return to the master and will initially use linstor to create our storage pool, integrating the machines that will participate in it and declaring the XCP pool master as the controller:
linstor node create prdxcpsrv001 192.168.12.1 --node-type Combined
linstor node create prdxcpsrv002 192.168.12.2 --node-type Satellite
linstor node create prdxcpsrv003 192.168.12.3 --node-type Satellite
Click the image to enlarge.
Click the image to enlarge.
Note that we are using the local IPs assigned to our storage VLAN created in the previous article. This is very important, otherwise all replication could go through the 1G network card of the servers, and performance would be disastrous.
You can verify the configuration with the following command:
linstor node list
Click the image to enlarge.
Creating volumes
Now we need to create our partition on each node that we will dedicate to DRBD.
Node by node, we perform the following commands:
parted /dev/nvme0n1 mkpart primary 206GB 1000GB
parted /dev/nvme0n1 print
pvcreate /dev/nvme0n1p7
vgcreate linstor_vg /dev/nvme0n1p7
lvcreate -l 100%FREE -T linstor_vg/thin_pool
Click the image to enlarge.
Click the image to enlarge.
Click the image to enlarge.
The storage capacity and partition parameters are specific to my lab and hardware configuration (to be adapted according to your configurations). We use the 206 GB identified at the beginning of this article. Don't worry, the alignment of the partitions is automatically taken into account by the parted command.
Overall, the goal is to create an LVM partition on each server, utilizing all available disk space on the NVMe drive.
The full name of the logical volume on each node is linstor_vg/thin_pool.
We will use this definition when returning to the first server (the controller) to associate these volumes with our DRDB pool configured with Linstor.
Therefore, we will create this storage pool xostor_pool by combining the local logical volumes linstor_vg/thin_pool of each server:
linstor storage-pool create lvmthin prdxcpsrv001 xostor_pool linstor_vg/thin_pool
linstor storage-pool create lvmthin prdxcpsrv002 xostor_pool linstor_vg/thin_pool
linstor storage-pool create lvmthin prdxcpsrv003 xostor_pool linstor_vg/thin_pool
Click the image to enlarge.
You can verify the configuration using the command linstor storage-pool list
Click the image to enlarge.
To make this new storage source visible to XCP-ng, you need to restart the xe-toolstack service (the xcp-ng console service) on each server:
xe-toolstack-restart
Click the image to enlarge.
Creating the SR (Storage Repository)
Let's go back to the master (the controller), because we are now going to create the SR based on the XORSTOR configuration.
To do this, use the following commands:
# Récupérer l'UUID du pool master
xe host-list params=uuid,hostname
xe sr-create type=linstor name-label="XOSTOR" \
host-uuid=3e0daa17-41a7-45a8-b2fb-bef287aa11e6 \
device-config:group-name=linstor_vg/thin_pool \
device-config:redundancy=2 \
device-config:provisioning=thin
If we break down what we have done, we have created an XOSTOR SR on the master (after retrieving its UUID).
This SR is of type linstor and has a redundancy of 2. This means that, for each VM deployed on this SR, its data will be replicated at least 2 times on two different servers.
This allows us to support the loss of one node out of three. Indeed, with this configuration, a VM can always be restarted on a surviving node and retrieve its data either natively on the new server chosen to start the VM, or through the storage network on the other remaining node.
Immediately, replication will resume to return to two.
However, this means that, unlike hosting a VM on a local SR only, a VM on the XOSTOR SR will consume twice as much data on the total capacity of the pool.
Additional assurance for network interfaces
During deployment, I encountered an error where, without being able to explain it, replication had switched to the IPs associated with the 1G cards of the servers. (I noticed this during performance tests.)
Therefore, I had to force the use of the IPs associated with the storage VLAN, as stated above, in the linstor-client configuration of each server.
For all servers in the pool, it is best to force this configuration:
cat > /etc/linstor/linstor-client.conf << EOF
[global]
controllers=linstor://192.168.12.1,linstor://192.168.12.2,linstor://192.168.12.3
EOF
Click the image to enlarge.
And re-enter the following commands from the master:
linstor node interface modify prdxcpsrv001 default --ip 192.168.12.1
linstor node interface modify prdxcpsrv002 default --ip 192.168.12.2
linstor node interface modify prdxcpsrv003 default --ip 192.168.12.3
linstor node list
Click the image to enlarge.
Click the image to enlarge.
SR configuration and mapping to other nodes
To indicate that the SR is shared at the pool level, you still need to retrieve the label of the XOSTOR SR to assign it the parameter shared to true:
xe sr-list name-label="XOSTOR"
xe sr-param-set uuid=6a7bbd54-6eed-8eb0-ce75-3aa975764eb7 shared=true
Click the image to enlarge.
Click the image to enlarge.
You also need to associate this UUID with the other servers.
On prdxcpsrv002:
xe pbd-create sr-uuid=6a7bbd54-6eed-8eb0-ce75-3aa975764eb7 \
host-uuid=$(xe host-list name-label=prdxcpsrv002 --minimal) \
device-config:group-name=linstor_vg/thin_pool \
device-config:redundancy=2 \
device-config:provisioning=thin
xe pbd-plug uuid=f410da6e-8346-9414-4541-8a8ffe0cb3e4
Click the image to enlarge.
On prdxcpsrv003:
xe pbd-create sr-uuid=6a7bbd54-6eed-8eb0-ce75-3aa975764eb7 \
host-uuid=$(xe host-list name-label=prdxcpsrv003 --minimal) \
device-config:group-name=linstor_vg/thin_pool \
device-config:redundancy=2 \
device-config:provisioning=thin
xe pbd-plug uuid=3dcc1915-9247-10d7-b7aa-33d353c2b024
Click the image to enlarge.
Click the image to enlarge.
With these last commands, the goal is to create a PBD, which is a Physical Block Device. This is a connector that links a host to an SR.
Indeed, if we have initiated the Storage Repository (SR) on prdxcpsrv001, it is necessary to connect it to the other servers. Therefore, remember this command xe pbd-plug uuid, which points to the UUID of the newly created Pooled Backend Device (PBD), and not to the UUID of the SR itself.
To ensure that everything is taken into account on the XCP-ng side, it's best to restart the management stack on each node:
xe-toolstack-restart
We can now check the global status of the final configuration with the following commands:
linstor resource list
linstor node list
linstor storage-pool list
Moving VMs
Displaying in Xen Orchestra
If we connect to the Xen Orchestra GUI, our new SR appears correctly:
Click the image to enlarge.
Upon closer inspection, we see the sum of the space of each logical volume on each server, subtracting the required redundancy, which is approximately 1 TB.
Click the image to enlarge.
We also note the connection to the three servers in the pool. Now it's time to move on to testing.
Click the image to enlarge.
Moving an SR via "Migrate VDI"
To do this, we will start with the test virtual machine running Zorin OS (my new favourite client operating system), which we had already used in the previous article to test the migration of a server virtual machine from one server to another. We then observed that the VM experienced a disconnection and restart.
Let's see what happens now. We had left it on prdxcpsrv002. Currently, its data is located on the local storage repository at prdxcpsrv002:
Click the image to enlarge.
Let's try moving it to our new storage resource (SR). As last time, we will run some ping tests between my workstation and the virtual machine.
Click the image to enlarge.
On the other hand, we will not use the "Warm Migration" option because prdxcpsrv002 has access to both storage repositories (SRs). The source SR, which is only present on prdxcpsrv002, and the destination XOSTOR SR, which is shared across the entire pool.
We can therefore perform an operation equivalent to a storage vMotion by moving only the storage of the virtual machine while keeping the execution context on the server.
To do this, we act directly in the Disk tab of the VM and select the Migrate VDI option.
Click the image to enlarge.
We select the new XOSTOR storage repository, and immediately we can follow the progress of the operations from the Tasks section in Xen Orchestra.
Click the image to enlarge.
Click the image to enlarge.
(Thanks to Camille Lacuve for pointing out this migration capability, which I was not aware of. This allowed me to update my article.)
Unlike the previous attempt, we only observe a loss of two pings during data transfer, and the VM does not restart.
Click the image to enlarge.
The VM is still on prdxcpsrv002, but now it's located on the XOSTOR storage repository:
Click the image to enlarge.
Server migration via Live Migration
Let's try another migration technique, namely the Live Migration option, which is this time found on the main tab of the VM. The goal is to move the VM from one server to another.
Click the image to enlarge.
Let's move it to prdxcpsrv001, keeping the disk on the XOSTOR storage repository and selecting the storage VLAN for the migration:
Click the image to enlarge.
The task completes immediately, but it only takes a few seconds and results in only one lost ping:
Click the image to enlarge.
Click the image to enlarge.
The VM remained running and within its context, while being migrated to the first server:
Click the image to enlarge.
This is just as effective as vMotion in VMware, and the memory context has been successfully moved "hot" from one server to another.
This is the difference with our previous Warm Migration. When a Warm Migration takes a snapshot of the source VM to copy it to the destination and restarts the VM from that snapshot, a Live Migration simply moves the memory context. This is made possible by the presence of the shared XOSTOR storage repository between all servers in the pool.
Both methods have their advantages and meet different needs, but now that we have a shared pool and storage, there's no longer a reason to perform a Warm Migration. Here's a brief summary of the two methods:
| Feature | Live Migration (XenMotion) | Warm Migration |
|---|---|---|
| VM Status | Running | Running during transfer, then briefly shut down |
| Service interruption | A few milliseconds to one second | Several minutes |
| Main Use | Migration between hosts within the same pool | Migration between two different storage repositories or two separate pools |
| Speed | Very fast (transfer of RAM only) | Slower (transfer of entire disks) |
It should be noted that it is now possible to move a VM hosted on the XOSTOR storage repository to a local storage repository on a different server (which is not currently running it) without interrupting services, by simply following these two steps:
- We perform a Live Migration to the server that has the local storage repository.
- Once the memory context has been moved to the target server, we perform a Migrate VDI to the local storage repository of the server, as seen in the previous section (but in the opposite direction).
Performance evaluation
There's one last point to evaluate: performance.
Indeed, I started my article by stating that I couldn't use NFS as a protocol to create a shared storage repository (SR) dedicated to VMs due to performance issues. Let's see if choosing XOSTOR is a more relevant option.
To do this, we will run a simple benchmark of disk performance from the VM. Usually, under Windows 11, for a quick and synthetic test, I use CrystalDiskMark. However, it is not available on Linux. Fortunately, a clone called KdiskMark does the same thing, and it is directly available in the Zorin OS application store.
Click the image to enlarge.
Click the image to enlarge.
We will now install and run it. Here are the results:
Click the image to enlarge.
In terms of read speed, we can see that we are performing within the expected range for an NVMe SSD. However, the maximum write speed achievable is 638.85 MB/s, or 5.1 Gbps.
This already confirms that we are not using a gigabit network, as we are more than 5 times faster than the maximum throughput offered by a standard link. It's clear that 10 Gbit/s is being used for data replication.
By the way, when I mentioned earlier that I encountered an error during failover of replication on the 1G interfaces, here are the results I obtained at that time on a test Windows VM.
Click the image to enlarge.
However, despite using the 10G link, we are operating at approximately 50% of the theoretical bandwidth for such a speed, not to mention the performance of random 4K writes... but this is ultimately normal since we have required double replication for all VMs hosted on the XOSTOR SR.
This means that for each write operation, we must wait for confirmation from two servers in the pool before the data can be considered truly written. And, as a result, even 10G inevitably introduces latency and reduces performance.
It's also important to remember that my lab runs on servers that are actually recycled office machines with entry-level CPUs and reduced performance. In terms of networking, as we mentioned previously during its implementation, the 10G connections are indeed present. I even performed tests using iperf between two servers in the pool, and we achieved the maximum possible throughput. Therefore, the network is perfectly configured.
Click the image to enlarge.
It's worth noting that, as mentioned previously, I also conducted tests with a Windows VM, and I have results in the same order of magnitude, or even better write performance.
Click the image to enlarge.
At this level as well, there can be differences between the amount of RAM in the VM, the disk driver, the driver for the Xen tools installed in the virtual OS, and the benchmark tool itself.
Ultimately, the need to replicate data, combined with the use of minimal server hardware and the potential issues of OS configuration, inevitably leads to limitations in performance. However, this is largely acceptable for a home lab and for common uses. Even a database, which is primarily related to sequential writing, can function on this configuration.
Conclusion
We now have everything we need to create a resilient and performant XCP-ng virtualization platform (in relation to its use). Even though the free version does not offer the ease of implementation of XORSTOR, it is still possible to install it. Relying on DRBD and LINSTOR, it proves perfectly capable of meeting the need for running VMs.
Now, all that remains is to push the solution to its limits and try different incident scenarios to evaluate the relevance of XCP-ng in addressing high availability (HA) issues. This is the goal of the next article, which will conclude this workbook dedicated to the Vates ecosystem.