How to configure NFS file system as OpenNebula data storage

You can download this article in PDF format via the link below to support us.
Download the guide in PDF formatshut down

Welcome to our guide to learn how to configure the NFS file system for use in OpenNebula cloud storage. In OpenNebula, a Storage data store is needed to store disk images of running virtual machines. OpenNebula officially supports three different data storage types:

  • Picture Data Repository: This will store the image repository.
  • System data storage: This will reserve the disk used to run the virtual machine. When deploying or terminating the VM, the disk has been moved to or cloned from the Image data store. Or when connecting or snapshotting the disk.
  • File and kernel data storage: Used to store ordinary files instead of disk images. Plain files can be used as kernels, memory disks or context files.

The disk image is transferred between the image and the system data storage area through the transfer manager (TM) driver. These drivers are dedicated software that performs low-level storage operations.

The following table summarizes the available transfer modes for each data storage area:

Transfer method from DatastoreImage to system Datastore disk
File systemshared, The image will be exported to the shared file systemssh, Copy the image using the ssh protocolqcow2, Like shared but exclusively for qcow2 format
CephalosporinCephalosporin, All images will be exported to the Ceph poolshared, Volatile and context disks are exported in the shared FS.
LVMfs_lvm, The image is exported in shared FS but dumped to LV
Original equipmentDeveloper, The image is the existing block device in the node
iSCSI libvirtIssi, The image is an iSCSI target

Step 1: Install the NFS server

This should be done on the NFS server instance

Ubuntu/Debian

Update APT package index:

sudo apt update

Then install the NFS server software package:

sudo apt -y install nfs-kernel-server

CentOS / RHEL / Fedora

Run the following command to install the NFS server package:

sudo yum -y install nfs-utils

Step 2: Configure NFS export for OpenNebula

I have installed an external storage device in the /mnt directory. I will create the relevant directories in it:

sudo mkdir -p /mnt/opennebula/{images,system,files}

where is it:

  • /mnt/opennebula/images Is the image repository path
  • /mnt/opennebula/system Store the disk used to run the virtual machine
  • /mnt/opennebula/file Store plain files instead of disk images

We will edit /etc/exports and export these paths.

$ sudo vim /etc/exports

# Example configurations to allow mounts from any host
/mnt/opennebula/images *(rw,no_root_squash,no_subtree_check)
/mnt/opennebula/system *(rw,no_root_squash,no_subtree_check)
/mnt/opennebula/files  *(rw,no_root_squash,no_subtree_check)

# Example configurations to allow mounts from known/trusted networks
/mnt/opennebula/images 10.10.20.0/24(rw,no_root_squash,no_subtree_check)
/mnt/opennebula/system 10.10.20.0/24(rw,no_root_squash,no_subtree_check)
/mnt/opennebula/files  10.10.20.0/24(rw,no_root_squash,no_subtree_check)

After updating the changes, restart the nfs-server:

# Ubuntu / Debian
sudo systemctl restart nfs-server

# CentOS / RHEL
sudo systemctl enable --now rpcbind nfs-server
sudo firewall-cmd --add-service=nfs --permanent
sudo firewall-cmd --add-service={nfs3,mountd,rpc-bind} --permanent
sudo firewall-cmd --reload

Verify the NFS export:

$ sudo exportfs -rvv
exporting 10.10.20.0/24:/mnt/opennebula/files
exporting 10.10.20.0/24:/mnt/opennebula/system
exporting 10.10.20.0/24:/mnt/opennebula/images

Step 3: Mount the NFS share on the front-end/KVM node

Install the NFS Client software package on the front-end and virtualized host systems.

# CentOS / RHEL
sudo yum -y install nfs-utils

# Debian / Ubuntu
sudo apt update
sudo apt -y install nfs-common

Mounted on the OpenNebula front end

The front end only needs to mount the image data storage area and Is not System data storage.

The front end needs to prepare the following storage areas:

  • Image data storage area, used to store images.
  • The system data storage area will save the temporary disk and files of the virtual machine stopped with Not deployed.

Get the predefined data storage area ID:Configure NFS data storage opennebula 01

Log in to the front-end node, and then mount the Image Datastore directory in the /var/lib/one/datastores/ directory.

$ sudo vim /etc/fstab
10.10.20.250:/mnt/opennebula/images /var/lib/one/datastores/1 nfs defaults,soft,intr,rsize=32768,wsize=32768 0 0
10.10.20.250:/mnt/opennebula/files /var/lib/one/datastores/2 nfs defaults,soft,intr,rsize=32768,wsize=32768 0 0

10.10.20.250 is the IP address of the NFS server.

Use the mount command to mount the NFS share to confirm that the changes in /etc/fstab are valid.

$ sudo mount -av
/                        : ignored
/boot                    : already mounted
none                     : ignored
/media/cdrom0            : ignored
mount.nfs: timeout set for Tue Mar 23 16:55:04 2021
mount.nfs: trying text-based options 'soft,intr,rsize=32768,wsize=32768,vers=4.2,addr=10.10.20.250,clientaddr=10.10.20.251'
/var/lib/one/datastores/1: successfully mounted
/var/lib/one/datastores/2: successfully mounted

Use the df command to confirm the installation status:

$ df -hT /var/lib/one/datastores/1
Filesystem                          Type  Size  Used Avail Use% Mounted on
10.10.20.250:/mnt/opennebula/images nfs4  915G  1.6G  867G   1% /var/lib/one/datastores/1

$ df -hT /var/lib/one/datastores/2
Filesystem                         Type  Size  Used Avail Use% Mounted on
10.10.20.250:/mnt/opennebula/files nfs4  915G  1.6G  867G   1% /var/lib/one/datastores/2

After the change, the data repository will be listed in the UI.Configure NFS data storage opennebula 02

Mounted on the OpenNebula virtualization node

Log in to the node running VMS and install it in a similar way to the front end.

$ sudo vim /etc/fstab
10.10.20.250:/mnt/opennebula/system /var/lib/one/datastores/0 nfs defaults,soft,intr,rsize=32768,wsize=32768 0 0
10.10.20.250:/mnt/opennebula/images /var/lib/one/datastores/1 nfs defaults,soft,intr,rsize=32768,wsize=32768 0 0
10.10.20.250:/mnt/opennebula/files /var/lib/one/datastores/2 nfs defaults,soft,intr,rsize=32768,wsize=32768 0 0

Create the installation directory:

sudo mkdir /var/lib/one/datastores/{0,1,2}
sudo chown -R oneadmin:oneadmin /var/lib/one/datastores/{0,1,2}

Run the mount command:

$ sudo mount -av
/                        : ignored
/boot                    : already mounted
none                     : ignored
mount.nfs: timeout set for Tue Mar 23 17:12:25 2021
mount.nfs: trying text-based options 'soft,intr,rsize=32768,wsize=32768,vers=4.2,addr=10.10.20.250,clientaddr=10.10.20.252'
/var/lib/one/datastores/0: successfully mounted
mount.nfs: timeout set for Tue Mar 23 17:12:25 2021
mount.nfs: trying text-based options 'soft,intr,rsize=32768,wsize=32768,vers=4.2,addr=10.10.20.250,clientaddr=10.10.20.252'
/var/lib/one/datastores/1: successfully mounted
mount.nfs: timeout set for Tue Mar 23 17:12:25 2021
mount.nfs: trying text-based options 'soft,intr,rsize=32768,wsize=32768,vers=4.2,addr=10.10.20.250,clientaddr=10.10.20.252'
/var/lib/one/datastores/2: successfully mounted

Confirm the installation status:

$ df -hT | grep one
10.10.20.250:/mnt/opennebula/system nfs4      915G  3.6G  865G   1% /var/lib/one/datastores/0
10.10.20.250:/mnt/opennebula/images nfs4      915G  3.6G  865G   1% /var/lib/one/datastores/1
10.10.20.250:/mnt/opennebula/files  nfs4      915G  3.6G  865G   1% /var/lib/one/datastores/2

Create CentOS on OpenNebula | Ubuntu | Debian VM template

Import CentOS 8 | CentOS 7 Qcow2 image on OpenNebula

reference:

You can download this article in PDF format via the link below to support us.
Download the guide in PDF formatshut down

Related Posts