Open afm719 opened 1 month ago
sudo apt update sudo apt upgrade
If you encounter issues, try installing a newer and more stable version.
sudo apt install net-tools gcc make
Once done, shut down the machine:
sudo shutdown -h now
The template machine is now ready to be cloned.
Save the configuration.
To view the available interfaces in the VM, execute the command:
ip link show
You'll see something like:
Where:
enp0s3
enp0s8
You need to configure the enp0s8 interface as static using IP address 192.168.0.1. To do this, edit the following file:
192.168.0.1
sudo vim /etc/netplan/50-cloud-init.yaml
Insert the following content:
network: version: 2 ethernets: enp0s3: dhcp4: true enp0s8: dhcp4: no addresses: [192.168.0.1/24]
If using the VIM editor, the command to save is ESC :w and to exit is ESC :q!. If using the NANO editor, to save use CTRL+X.
ESC :w
ESC :q!
CTRL+X
After saving, always apply the changes using:
sudo netplan apply
To identify the machine more easily, modify the host files with these commands:
sudo vim /etc/hostname
Change template to master.
template
master
Then:
sudo vim /etc/hosts
Add the following lines:
127.0.0.1 localhost 192.168.0.1 master 192.168.0.22 cluster01
This step is important to connect VMs with your host machine:
sudo apt install openssh-server
sudo systemctl status ssh
If not, enable it:
sudo systemctl enable ssh
ssh-keygen
Copy the public key to the master host with the command:
cd .ssh scp -P 2222 id_ed25519.pub vboxuser@127.0.0.1
(Remember, the id_...pub and vboxuser will vary based on the username and key name generated.)
id_...pub
vboxuser
cat id_ed25519.pub >> .ssh/authorized_keys rm id_ed25519.pub
Now, your SSH connection is ready:
ssh -p 2222 vboxuser@127.0.0.1
Execute this command from your WINDOWS/MAC terminal.
Execute the following commands:
sudo apt install dnsmasq -y
Edit the configuration file:
sudo vim /etc/dnsmasq.conf
Add:
port=53 bogus-priv strict-order interface=enp0s8 listen-address=::1,127.0.0.1,192.168.0.1 bind-interfaces log-queries log-dhcp dhcp-range=192.168.0.22,192.168.0.28,255.255.255.0,12h dhcp-option=option:dns-server,192.168.0.1 dhcp-option=3
Link the DNS resolver:
sudo ln -fs /run/systemd/resolve/resolv.conf /etc/resolv.conf
Update the network configuration:
sudo vim /etc/netplan/50-cloud-init.yaml network: ethernets: enp0s3: dhcp4: true enp0s8: dhcp4: false addresses: [192.168.0.1/24] nameservers: addresses: [192.168.0.1] version: 2
Apply changes:
Update DNSMASQ defaults:
sudo vim /etc/default/dnsmasq IGNORE_RESOLVCONF=yes DNSMASQ_EXCEPT="lo"
Restart services:
sudo systemctl restart dnsmasq systemd-resolved sudo systemctl status dnsmasq
Verify DNS:
host cluster01
Install NFS:
sudo apt install nfs-kernel-server sudo mkdir -p /mnt/shared
Mount the NFS share:
sudo mount -t nfs 192.168.0.1:/shared/ /mnt/shared df -h | grep /mnt/shared
Make it persistent:
sudo vim /etc/fstab
192.168.0.1:/shared /mnt/shared nfs defaults 0 0
Test with:
sudo mount -a
Verify with:
df -h | grep /mnt/shared
Reboot:
sudo reboot
Repeat the cloning and network configuration steps for each node.
Once started, edit the network file:
sudo vim /etc/netplan/50-cloud-init.yaml network: ethernets: enp0s3: dhcp4: true dhcp4-overrides: use-dns: no enp0s8: dhcp4: true dhcp-identifier: mac nameservers: addresses: [192.168.0.1] version: 2
Update DNS:
Update the master’s /etc/hosts file:
/etc/hosts
192.168.0.23 cluster01
Test by pinging:
ping cluster01
Finally, from the master machine, connect:
ssh vboxuser@cluster01 # or ssh vboxuser@192.168.0.23
Repeat the same steps to set up the distributed file system on each
node.
Now, your 3-machine cluster is ready to use!
Create a Cluster with One Master Machine and Two Nodes (node01 and node02)
Initial Requirements
Cluster Specifications
Master Machine:
Node Machines (node01, node02, ...):
Creating the template Machine for Post-Creation of Cluster Machines
If you encounter issues, try installing a newer and more stable version.
Once done, shut down the machine:
The template machine is now ready to be cloned.
Creating the Master Machine
Save the configuration.
Network Configuration of the Master Node
To view the available interfaces in the VM, execute the command:
You'll see something like:
Where:
enp0s3
is Adapter1 (NAT).enp0s8
is Adapter2 (Internal Network).You need to configure the
enp0s8
interface as static using IP address192.168.0.1
. To do this, edit the following file:Insert the following content:
If using the VIM editor, the command to save is
ESC :w
and to exit isESC :q!
.If using the NANO editor, to save use
CTRL+X
.After saving, always apply the changes using:
To identify the machine more easily, modify the host files with these commands:
Change
template
tomaster
.Then:
Add the following lines:
SSH Setup
This step is important to connect VMs with your host machine:
If not, enable it:
Copy the public key to the master host with the command:
(Remember, the
id_...pub
andvboxuser
will vary based on the username and key name generated.)Now, your SSH connection is ready:
Execute this command from your WINDOWS/MAC terminal.
DHCP and DNS Configuration
Execute the following commands:
Edit the configuration file:
Add:
Link the DNS resolver:
Update the network configuration:
Apply changes:
Update DNSMASQ defaults:
Restart services:
Verify DNS:
Distributed File System
Install NFS:
Mount the NFS share:
Make it persistent:
Add:
Test with:
Verify with:
Reboot:
Nodes (node01, node02, ...)
Repeat the cloning and network configuration steps for each node.
Once started, edit the network file:
Apply changes:
Update DNS:
Hostname Resolution
Update the master’s
/etc/hosts
file:Test by pinging:
Finally, from the master machine, connect:
Repeat the same steps to set up the distributed file system on each
node.
Now, your 3-machine cluster is ready to use!