Message Cloud is a high-performance, scalable system deployed on a 3-node cluster.
Server Configuration: The cluster consists of three nodes, node-1 is installed on server1.
Hardware Requirements:
Operating System: Ubuntu-22.04
IP: 172.21.0.90
Port: 59222
Step-1: Create node-1 using below command.
sudo virt-install \
--name msgcloud-prod-node01 \
--os-variant ubuntu22.04 \
--vcpus 2 \
--memory 8192 \
--location /data1/os-iso/ubuntu-22.04.4-live-server-amd64.iso,kernel=casper/vmlinuz,initrd=casper/initrd \
--network bridge=virbr20,model=virtio,mac=0a:01:e1:20:01:01 \
--network network=virho10,model=virtio,mac=0a:01:e1:10:01:01 \
--disk size=128,pool=adm-images \
--uuid 00000000-0000-0000-0000-0a01e1200008 \
--graphics none \
--extra-args 'console=ttyS0' \
--debug
Step-2: Disk partition for the node.
Step-3: User Setup
<1!Devxxxx>
Note:
visudo
to add the following line at the end of the file:
devopsadmin ALL=(ALL) NOPASSWD: ALL
Execute the following command to clone the repository containing the automation scripts:
git clone https://github.com/DevOps-Model/DevOps-Automation-Scripts.git
Change directory to the cloned repository:
cd DevOps-Automation-Scripts
Copy the message cloud resource files to the temp directory:
cp -r mcConfigurationFiles/mc-resources-conf/ /tmp/mc-resources-conf
Execute the TechStackInstallation.py
script to install the required tech stack:
python3 TechStackInstallation.py mc java maven haproxy tomcat git scylla redpanda mysql
After installing the tech stack, configure the services using the following command:
python3 ConfigureScript.py mc configuration.conf
sudo systemctl start mysql@bootstrap
sudo systemctl start scylla-server
Once the services are configured, run the following command to initialize the base data:
python3 ConfigureScript.py mc databases.conf
Finally, the tech stack is completely installed, configured, and initialized with the base data.
Hardening
folder inside the repository:cd Hardening
bash ubuntu.sh
bash checkScore.sh
Generate additional nodes for the cluster from a base node in server-2.
virsh shutdown msgcloud-prod-node01
scp /data3/adm-images/msgcloud-prod-node01.qcow2 itadmin@172.21.0.32:/tmp
Create and execute the following Python script to generate two additional nodes for the cluster:
Copy the below content save it as generate_nodes.py
file.
import subprocess
def run_command(command):
print(f"Running command: {command}")
subprocess.run(command, shell=True, check=True)
emp_suffix_list = ['02', '03']
ip_prefix = '172.21.'
ip_list = ['0.56', '0.57']
mac_list = ['02', '03']
project_name = 'msgcloud-prod'
source_disk_img = '/tmp/msgcloud-prod-node01.qcow2'
source_xml = '/data2/guest-xml/dev-template.xml'
base_firstboot_script = '/root/scripts/startup-script.sh'
base_uuid = '00000000-0000-0000-'
for i in range(len(emp_suffix_list)):
emp_id = emp_suffix_list[i]
target_name = f'{project_name}-node{emp_id}'
target_disk_img = f'/data2/adm-images/{target_name}.qcow2'
target_xml = f'/data2/guest-xml/{target_name}.xml'
target_firstboot_script = f'/root/scripts/{target_name}.sh'
target_bridge_mac = f'0a:01:e1:30:01:{mac_list[i]}'
target_host_mac = f'0a:01:e0:10:01:{mac_list[i]}'
target_uuid = base_uuid + target_bridge_mac.replace(':', '')
content = ""
with open(source_xml, 'r') as file:
content = file.read()
content = content.replace('dev-ein0034', target_name)
content = content.replace('0a:01:0d:20:de:35', target_bridge_mac)
content = content.replace('0a:01:0d:10:de:35', target_host_mac)
content = content.replace('/data1/guest-images/dev-template.qcow2', target_disk_img)
with open(target_xml, 'w') as file:
file.write(content)
run_command(f"cp {source_disk_img} {target_disk_img}")
script_content = ""
with open(base_firstboot_script, 'r') as script:
script_content = script.read()
script_content = script_content.replace("mac-id", target_uuid)
script_content = script_content.replace("iptobereplaced", ip_prefix + ip_list[i])
with open(target_firstboot_script, "w") as start_script:
start_script.write(script_content)
run_command(f"virt-sysprep -a {target_disk_img}")
run_command(f"virt-sysprep --hostname {target_name} -a {target_disk_img} --firstboot {target_firstboot_script}")
run_command(f"virsh define {target_xml}")
Run the above script.
python3 generate_nodes.py
Once the nodes are generated, start them using the following command:
virsh start <node_name>
Example:
virsh start msgcloud-prod-node02
virsh start msgcloud-prod-node03
Log in to the router through Winbox and assign static IPs for the generated nodes.
Log in to the cluster nodes and update their hostnames in the /etc/hosts
file:
vi /etc/hosts
Add or modify the following entries:
<node_static_ip> msgcloud-prod-node02
<node_static_ip> msgcloud-prod-node03