LXC Nodes Creation

LXC Node Setup for PSAP Project

Server 01 Setup

1. Create a Storage Image

Create a 128GB disk image for LXC storage:

sudo dd if=/dev/zero of=/data3/lxc/psap1alxc001.img bs=1G count=128

performs the following actions:

  • sudo: Runs the command with superuser privileges.
  • dd: A low-level copying tool used for creating disk images.
  • if=/dev/zero: The input file (if) is /dev/zero, a special file that generates an endless stream of null bytes (0x00). This ensures the created file is zero-filled.
  • of=/data3/lxc/psap1alxc001.img: The output file (of) is a new disk image located at /data3/lxc/psap1alxc001.img.
  • bs=1G: The block size (bs) is set to 1GB, meaning data will be written in chunks of 1GB.
  • count=128: Specifies the number of blocks to be written. Since each block is 1GB, this results in a total file size of 128GB.

Purpose

This command creates a 128GB empty disk image, which is later used to create a ZFS storage pool for LXC containers.

2. Create a ZFS Pool

Create a ZFS storage pool using the disk image:

sudo zpool create psap1alxc001 /data3/lxc/psap1alxc001.img

3. Verify ZFS Pool Status

Check if the ZFS pool was created successfully:

sudo zpool status

4. Create LXC Storage

Create an LXC storage pool using the ZFS pool:

lxc storage create psap1alxc001 zfs source=psap1alxc001

5. Verify LXC Storage

List available LXC storage pools:

lxc storage list

Expected Output:

NAME DRIVER SOURCE DESCRIPTION USED BY STATE
psap1alxc001 zfs psap1alxc001 2 CREATED

6. Create LXC Node Using Canonical LXD UI

  1. Open the Canonical LXD UI at https://172.21.0.20:7443/.
  2. Navigate to the Image section.
  3. Select Ubuntu 22.04 LTS Server (2.1 GiB, Pre-installed Stack).
  4. Fill in the configuration details:
    • Instance Name: psap1alxc001
    • Description: psap1alxc001
  5. In the Resource section, set:
    • CPU Limit: 4
    • RAM: 12 GiB
    • Disk Priority: 0
  6. Click Create and Start to deploy the instance.

7. Modify MAC Address and Assign Static IP

  1. After creating the node, verify it is running and then stop it.
  2. Click on the node psap1alxc001 in the LXD UI.
  3. Navigate to the Configuration section and open the YAML configuration.
  4. Locate the network section and update the MAC address to the allocated value:
    eth0:
      hwaddr: 0a:01:e1:20:00:11
    
  5. Save the configuration and start the node.
  6. Verify that the MAC address has been updated successfully.

8. Assign a Static IP Address

  1. Open Winbox and find the IP allocated to the node via DHCP.
  2. Delete the DHCP-assigned IP.
  3. Bring down the network interface before adding the new IP:
    ip link set eth0 down
    
  4. Assign the new static IP 172.21.0.75 using the MAC address 0a:01:e1:20:00:11.
  5. Bring the network interface back up:
    ip link set eth0 up
    
  6. Verify the new IP configuration.

Server 02 Setup

1. Create LXC Node Using Canonical LXD UI

  1. Open the Canonical LXD UI at https://172.21.0.30:7443/.
  2. Navigate to the Image section.
  3. Select Ubuntu 22.04 LTS Server (3.1 GiB, Pre-installed Stack).
  4. Fill in the configuration details:
    • Instance Name: psap1alxc002
    • Description: psap1alxc002
  5. In the Disk section:
    • Select Default Pool.
    • Set Disk Limit to 128 GiB.
  6. In the Resource section, set:
    • CPU Limit: 4
    • RAM: 12 GiB
    • Disk Priority: 0
  7. Click Create and Start to deploy the instance.

2. Modify MAC Address and Assign Static IP (Server 02)

  1. After creating the node, verify it is running and then stop it.
  2. Click on the node psap1alxc002 in the LXD UI.
  3. Navigate to the Configuration section and open the YAML configuration.
  4. Locate the network section and update the MAC address to the allocated value:
    eth0:
      hwaddr: 0a:01:e1:30:00:12
    
  5. Save the configuration and start the node.
  6. Verify that the MAC address has been updated successfully.

3. Assign a Static IP Address (Server 02)

  1. Open Winbox and find the IP allocated to the node via DHCP.
  2. Delete the DHCP-assigned IP.
  3. Assign the new static IP 172.21.0.76 using the MAC address 0a:01:e1:30:00:12.
  4. Before adding the new IP address, bring down the specific network interface:
    ip link set eth0 down
    
  5. Once updated, bring the interface back up:
    ip link set eth0 up
    
  6. Verify the new IP configuration.

Server 03 Setup

1. Create a Storage Image

Create a 128GB disk image for LXC storage:

sudo dd if=/dev/zero of=/data3/lxc/psap1alxc003.img bs=1G count=128

performs the following actions:

  • sudo: Runs the command with superuser privileges.
  • dd: A low-level copying tool used for creating disk images.
  • if=/dev/zero: The input file (if) is /dev/zero, a special file that generates an endless stream of null bytes (0x00). This ensures the created file is zero-filled.
  • of=/data3/lxc/psap1alxc003.img: The output file (of) is a new disk image located at /data3/lxc/psap1alxc003.img.
  • bs=1G: The block size (bs) is set to 1GB, meaning data will be written in chunks of 1GB.
  • count=128: Specifies the number of blocks to be written. Since each block is 1GB, this results in a total file size of 128GB.

2. Create a ZFS Pool

Create a ZFS storage pool using the disk image:

sudo zpool create psap1alxc003 /data3/lxc/psap1alxc003.img

3. Verify ZFS Pool Status

Check if the ZFS pool was created successfully:

sudo zpool status

4. Create LXC Storage

Create an LXC storage pool using the ZFS pool:

lxc storage create psap1alxc003 zfs source=psap1alxc003

5. Verify LXC Storage

List available LXC storage pools:

lxc storage list

Expected Output:

NAME DRIVER SOURCE DESCRIPTION USED BY STATE
psap1alxc003 zfs psap1alxc003 2 CREATED

6. Create LXC Node Using Canonical LXD UI

  1. Open the Canonical LXD UI at https://172.21.0.36:7443/.
  2. Navigate to the Image section.
  3. Select Ubuntu 22.04 LTS Server (2.1 GiB, Pre-installed Stack).
  4. Fill in the configuration details:
    • Instance Name: psap1alxc003
    • Description: psap1alxc003
  5. In the Resource section, set:
    • CPU Limit: 4
    • RAM: 12 GiB
    • Disk Priority: 0
  6. Click Create and Start to deploy the instance.

7. Modify MAC Address and Assign Static IP

  1. After creating the node, verify it is running and then stop it.
  2. Click on the node psap1alxc003 in the LXD UI.
  3. Navigate to the Configuration section and open the YAML configuration.
  4. Locate the network section and update the MAC address to the allocated value:
    eth0:
      hwaddr: 0a:01:e1:40:00:13
    
  5. Save the configuration and start the node.
  6. Verify that the MAC address has been updated successfully.

8. Assign a Static IP Address

  1. Open Winbox and find the IP allocated to the node via DHCP.
  2. Delete the DHCP-assigned IP.
  3. Bring down the network interface before adding the new IP:
    ip link set eth0 down
    
  4. Assign the new static IP 172.21.0.77 using the MAC address 0a:01:e1:40:00:11.
  5. Bring the network interface back up:
    ip link set eth0 up
    
  6. Verify the new IP configuration.

Tomcat Service Configuration Update on LXC Nodes

Overview

This document outlines the changes made to the Tomcat service on the LXC nodes (psap1alxc001, psap1alxc002, and psap1alxc003). The service name and directory path were updated to reflect the new project structure.

Changes Made

  1. Service Name Change:

    • Previous Service Name: tomcat-portereu.service
    • Updated Service Name: tomcat-psap.service
  2. Tomcat Directory Path Update:

    • Previous Path: /opt/portereu/tomcat
    • Updated Path: /opt/ps/tomcat

Steps to Apply Changes

1. Stop the Existing Tomcat Service

sudo systemctl stop tomcat-portereu.service

2. Rename the Service File and Update the Path

sudo mv /etc/systemd/system/tomcat-portereu.service /etc/systemd/system/tomcat-psap.service
sudo sed -i 's|/opt/portereu/tomcat|/opt/ps/tomcat|g' /etc/systemd/system/tomcat-psap.service

3. Reload Systemd and Start the New Service

sudo systemctl daemon-reload
sudo systemctl start tomcat-psap.service
sudo systemctl enable tomcat-psap.service

4. Verify the Service is Running

sudo systemctl status tomcat-psap.service