Hi all,
I have also trouble in setting up an ONOS Cluster on 3 physical machines having IP Addresses of 192.168.1.117, 192.168.1.108 and 192.168.1.107. The latest ONOS-2.7.0 distribution (X- Wing) cloned from the master branch in Github platform is installed on each one of the machines. I have Ubuntu 20.04 operating system on the separate machines. I recognized a config folder under ONOS directory. I put the cluster.json file into this directory on each machine. I tried to configure the cluster.json for each machine like below.
Cluster.json on 192.168.1.117 machine
{
"name": "onos",
"node": {
"id": "192.168.1.117",
"ip": "192.168.1.117",
"port": 9876
},
"storage": [
{
"id": "atomix-1",
"ip": "192.168.1.117",
"port": 5679
},
{
"id": "atomix-2",
"ip": "192.168.1.108",
"port": 5679
},
{
"id": "atomix-3",
"ip": "192.168.1.107",
"port": 5679
}
]
}
Cluster.json on 192.168.1.108 machine
{
"name": "onos",
"node": {
"id": "192.168.1.108",
"ip": "192.168.1.108",
"port": 9876
},
"storage": [
{
"id": "atomix-1",
"port": 5679
},
{
"id": "atomix-2",
"port": 5679
},
{
"id": "atomix-3",
"ip": "192.168.1.107",
"port": 5679
}
]
}
Cluster.json on 192.168.1.107 machine
{
"name": "onos",
"node": {
"id": "192.168.1.107",
"ip": "192.168.1.107",
"port": 9876
},
"storage": [
{
"id": "atomix-1",
"port": 5679
},
{
"id": "atomix-2",
"port": 5679
},
{
"id": "atomix-3",
"ip": "192.168.1.107",
"port": 5679
}
]
}
In addition to cluster.json file, I cloned atomix-3.1.12 version to the home directory and renamed as atomix. I copied to each machine with the same name. I do not know whether the atomix should be installed on each machine separately. However, I cloned it anyway to the whole machine. There is an atomix.conf file within this directory (/home/emrekarakis/atomix/config). I tried to configure these file as such below:
Atomix.conf on 192.168.1.117
{
"cluster": {
"clusterId": "onos",
"node": {
"id": "atomix-1",
"address": "192.168.1.117:5679"
},
"discovery": {
"type": "bootstrap",
"nodes": [
{
"id": "atomix-1",
"address": "192.168.1.117:5679"
},
{
"id": "atomix-2",
"address": "192.168.1.108:5679"
},
{
"id": "atomix-3",
"address": "192.168.1.107:5679"
}
]
}
},
"managementGroup": {
"type": "raft",
"partitions": 1,
"partitionSize": 3,
"members": [
"atomix-1",
"atomix-2",
"atomix-3"
],
"storage": {
"level": "mapped"
}
},
"partitionGroups": {
"raft": {
"type": "raft",
"partitions": 3,
"partitionSize": 3,
"members": [
"atomix-1",
"atomix-2",
"atomix-3"
],
"storage": {
"level": "mapped"
}
}
}
}
Atomix.conf on 192.168.1.108
cluster {
cluster-id: "onos"
node {
id: "atomix-2"
address: "192.168.1.108:5679"
}
discovery {
type: "bootstrap"
nodes {
node.1 {
id: "atomix-1"
address: "192.168.1.117:5679"
}
node.2 {
id: "atomix-2"
address: "192.168.1.108:5679"
}
node.3 {
id: "atomix-3"
address: "192.168.1.107:5679"
}
}
}
}
management-group {
type: "raft"
partitions: 1
partition-size: 3
members: ["atomix-1", "atomix-2", "atomix-3"]
storage.level: "disk"
}
partition-groups {
raft {
type: "raft"
partitions: 3
partition-size: 3
members: ["atomix-1", "atomix-2", "atomix-3"]
storage.level: "disk"
}
}
Atomix.conf on 192.168.1.107
cluster {
cluster-id: "onos"
node {
id: "atomix-3"
address: "192.168.1.107:5679"
}
discovery {
type: "bootstrap"
nodes {
node.1 {
id: "atomix-1"
address: "192.168.1.117:5679"
}
node.2 {
id: "atomix-2"
address: "192.168.1.108:5679"
}
node.3 {
id: "atomix-3"
address: "192.168.1.107:5679"
}
}
}
}
management-group {
type: "raft"
partitions: 1
partition-size: 3
members: ["atomix-1", "atomix-2", "atomix-3"]
storage.level: "disk"
}
partition-groups {
raft {
type: "raft"
partitions: 3
partition-size: 3
members: ["atomix-1", "atomix-2", "atomix-3"]
storage.level: "disk"
}
}
Additionally, I recognized that after building ONOS, some files called ONOS-SNAPSHOT-3.0.0 folder is created on the tmp directory. Similar to the problem experienced by Chris Ward, even if I configured the cluster.json file and copied it manually to /tmp/ONOS-SNAPSHOT-3.0.0/config/ folder, it gets overwritten by the automatically generated version during runtime. After performing these configurations on the machines, the cluster is not created on one of the instances described above and each node can only recognize itself.
atomix-gen-config 192.168.1.117 ~/atomix.conf 192.168.1.117 192.168.1.108 192.168.1.107
onos-gen-config 192.168.1.117 ~/cluster.json -n 192.168.1.117 192.168.1.108 192.168.1.107
I would like to ask several questions related to the cluster configuration of ONOS instances.
- Does ONOS contain Atomix installation folder within itself? Where should be the position to put atomix.conf files?
- Similary, I do not know where I should put cluster.json exactly? Where am I wrong with this configuration and what additional configurations do I need?
- After a little bit search, I found a cluster.sh file and I reconfigured this file inspired by the Raúl Álvarez according to my environment. However, it does not give any error and it can be able to copy corrensponding files into the specified directory on other machines. After running nodes again, the cluster does not appear again.
- Does ONOS reads these atomix and cluster.json files from which directory of ONOS and how to integrate atomix application residing outside of ONOS application with ONOS?
#!/bin/bash
# Set IP addresses of your machines
ATOMIX_NODES=("192.168.1.117" "192.168.1.108" "192.168.1.107")
ONOS_NODES=("192.168.1.117" "192.168.1.108" "192.168.1.107")
# SSH user
USER="emrekarakis"
PASSWORD="1"
# Path to ONOS and Atomix directories
ONOS_DIR="/home/$USER/onos"
ATOMIX_DIR="/home/$USER/atomix"
# Function to check and kill process using port 5679
check_and_kill_port() {
local node_ip=$1
ssh $USER@$node_ip "if sudo lsof -i :5679; then echo $PASSWORD | sudo -S fuser -k 5679/tcp; fi"
}
# Function to generate Atomix config
generate_atomix_config() {
local node_ip=$1
ssh $USER@$node_ip "cd $ONOS_DIR/tools/test/bin && ./atomix-gen-config $node_ip /tmp/atomix.conf ${ATOMIX_NODES[*]}"
ssh $USER@$node_ip "echo $PASSWORD | sudo -S mv /tmp/atomix.conf $ATOMIX_DIR/conf/atomix.conf"
echo "Atomix config generated on $node_ip"
}
# Function to generate ONOS cluster config
generate_onos_config() {
local node_ip=$1
ssh $USER@$node_ip "cd $ONOS_DIR/tools/test/bin && echo $PASSWORD | sudo -S ./onos-gen-config $node_ip /tmp/cluster.json -n ${ATOMIX_NODES[*]}"
ssh $USER@$node_ip "if [ -f /tmp/cluster.json ]; then echo $PASSWORD | sudo -S mv /tmp/cluster.json $ONOS_DIR/config/cluster.json; else echo 'cluster.json not found on $node_ip'; fi"
ssh $USER@$node_ip "if [ -f /tmp/cluster.json ]; then echo $PASSWORD | sudo -S cp /tmp/cluster.json /tmp/onos-3.0.0-SNAPSHOT/config/cluster.json; fi"
echo "ONOS config generated on $node_ip and copied to necessary directories"
}
# Function to ensure the correct cluster.json is used during ONOS startup
ensure_correct_cluster_config() {
local node_ip=$1
# Copy the correct cluster.json to the ONOS config directory
ssh $USER@$node_ip "echo $PASSWORD | sudo -S cp $ONOS_DIR/config/cluster.json $ONOS_DIR/config/cluster.json"
# Ensure it's also copied to the runtime config directory
ssh $USER@$node_ip "echo $PASSWORD | sudo -S cp $ONOS_DIR/config/cluster.json /tmp/onos-3.0.0-SNAPSHOT/config/cluster.json"
}
# Function to start Atomix and ONOS on each node
start_services() {
local node_ip=$1
# Check and kill any process using port 5679
check_and_kill_port $node_ip
ssh $USER@$node_ip "cd $ATOMIX_DIR && echo $PASSWORD | sudo -S ./bin/atomix-agent -m $(hostname) -a $node_ip:5679"
ssh $USER@$node_ip "cd $ONOS_DIR && echo $PASSWORD | sudo -S ./tools/package/bin/onos-service start"
echo "Services started on $node_ip"
}
# Main function to setup the cluster
setup_cluster() {
for ip in "${ATOMIX_NODES[@]}"; do
generate_atomix_config $ip
done
for ip in "${ONOS_NODES[@]}"; do
generate_onos_config $ip
ensure_correct_cluster_config $ip
done
for ip in "${ATOMIX_NODES[@]}"; do
start_services $ip
done
}
# Run the setup
setup_cluster
What should additionally be implemented for the cluster configuration to see all nodes working properly?
Best Regards,
Emre Karakış
29 Ocak 2023 Pazar tarihinde saat 12:07:08 UTC+3 itibarıyla Johnson0707 şunları yazdı: