HA Installation - 2 node setup


Requirements :



Pre-Ha-installation:

We assume that user is performing the below set in infoworks version 2.5.X or below


We also assume that end user has access to all the 2 edge nodes as a infoworks user and has rights to generate ssh key, has a home directory(/home/infoworks/) and also to /opt/  path.


  1. Stop all infoworks services on both machines

    cd $IW_HOME/bin
    source env.sh
    
    ./stop.sh orchestrator all mongo
    #Check all services are stopped
    ./status.sh





  1. Setup Keyless SSH between active and passive machines:

    To check if keyless ssh is working correctly(Imp do not use -i keyfile option):

    ssh infoworksuser@ip_address_of_1st_machine


    If ssh works, all ok, jump to step 3.
    If ssh does not work, follow these instructions:

    On both machines run:

    cd /home/[infoworksuser]/
    Ssh-keygen
    cd /home/[infoworksuser]/.ssh/
    touch authorized_keys
    chmod 600 authorized_keys




    IMP: Copy the contents of Active machine (public key)

    /home/[infoworksuser]/.ssh/id_rsa.pub


    INTO Passive machine

    /home/[infoworksuser]/.ssh/authorized_keys



    Similarly copy the files from passive to active

  2. Update PIP on both machines

    cd  $IW_HOME/bin
    source env.sh
    pip install --upgrade pip




  3. On both machines, create the following file:

    IW_HOME/conf/mongoKey




    Contents of this file should be AlphaNumeric password string about 10 chars and it should be same on both servers (this is like a password for mongo sync)

    chmod 400 IW_HOME/conf/mongoKey





  4. On active machine:

    vi IW_HOME/resources/mongodb/conf/mongodb.conf


    Edit the following:
    Turn off security:

    Change:

# Turn on/off security.  Off is currently the default

#noauth=true

auth=true


to


# Turn on/off security.  Off is currently the default

noauth=true

#auth=true


AND


change:


#keyFile=...  (if key is missing add it)



to


keyFile=IW_HOME/conf/mongoKey





Now proceed and start  the Mongo services


cd IW_HOME/bin



./start.sh mongo

source env.sh

mongo admin    #open mongo admin db

> db.createUser(

{

   user: "iw-ha",

   pwd: "IN11**rk",

   roles: [ "clusterAdmin" ]

})



after the above steps are completed, stop the mongo 



./stop.sh mongo



   6. On Passive machine


vi IW_HOME/resources/mongodb/conf/mongodb.conf


Edit the following:

change:


#keyFile=...  (if key is missing add it)



to


keyFile=IW_HOME/conf/mongoKey


 

 

Install HA:


On Passive Machine:


cd $IW_HOME/bin

wget https://s3.amazonaws.com/infoworks-resources/tmp/scripts/install-ha.sh -O install-ha.sh  



This script will create a HA directory inside $IW_HOME/ directory 


Execute the below command in $IW_HOME/bin/ path


bash install-ha.sh



After the execution gets completed please navigate to the below directory and make copy of the file as shown


cd $IW_HOME/conf/

cp ha.conf.default  ha.conf



We have made duplicate file of ha.conf.default as ha.conf now edit that file


vi ha.conf

Read the comments and fill in all configurations, see below for sample ha.conf file

IMP: For hostname, use hostname -f command

The HA configurations are stored in IW_HOME/conf/ha.conf, please edit ac required to modify the settings as highlighted below:

 

ha.conf:

# hostname of the server, string
# Each server should be accessible by the other using the hostname
host1_hostname=1st_MACHINE’s hostname
# type - local/remote
# Local implies the installation is on the same node as the HA tool
# Remote implies the installation is on a different node but accessible via ssh
host1_type=active
# role of the installation - active/passive
# During failover, the HA tool automatically modifies this value
host1_role=active
# Infoworks services are running on host1 in this case so set the role to active
#SSH login details
host1_ssh_keyless=true
host1_ssh_private_key=
host1_username=infoworks
# IW_HOME value for this host
host1_iw_home=/opt/infoworks
host2_hostname=2nd_machines-hostname
host2_type=remote
host2_role=passive
# Node on which HA is installed in this case.
host2_ssh_keyless=false
host2_ssh_private_key=/home/infoworks/.ssh/id_rsa
host2_iw_home=/opt/infoworks
host2_username=infoworks
# During failover, if all services on the failing active node do not stop,
# The failover is halted and the following script will be executed
# The output the of the script will stored in the configured log folder
failover_error_handler_script=/path/to/script.sh
failover_error_handler_log=/path/to/log
# If any service is not used and is stopped at all times, HA can be configured to ignore this service
# comma separated string of Component Names (as shown in output status.sh), spaces are acceptable
services_error_whitelist=



Start All services

Login to 1st machine(Active machine ) as Infoworks user and perform the below steps


cd $IW_HOME/bin
Source env.sh
./start-active.sh



Login to 2nd machine(Passive Machine) as Infoworks user and perform the below steps

cd $IW_HOME/bin
Source env.sh
./start-passive [1st_machine_hostname]



On the 2nd machine(passive machine):


cd $IW_HOME/bin
vi start.sh




[please comment the below mentioned lines(First 3 Lines and last line)

 

#if [ ${is_process_running} == true ]; then
#  echo "Process like HA Service is already running"
#else
echo -e "Starting HA Service" | tee -a ${LOG_FILE} INFOWORKS_LOGS_BASE_PATH=`grep -v '^#' ${CONF_PROPS}| grep -o 'iw_logs_base_dir=.*' | cut -d '=' -f 2`
      HA_LOGS_DIR=${INFOWORKS_LOGS_BASE_PATH}/ha
  mkdir -p ${HA_LOGS_DIR}
HA_OUT_FILE=${HA_LOGS_DIR}/ha.out
if [ -f "${HA_OUT_FILE}" ]; then
NOW=$(date "+%F-%T")
mv "${HA_OUT_FILE}" "${HA_OUT_FILE}-${NOW}"
Fi
export IW_HA_CONF=${IW_HOME}/conf/ha.conf
export IW_HA_LOG=${HA_LOGS_DIR}/ha.log
 export IW_MONGO_CONF=${IW_HOME}/resources/mongodb/conf/mongodb.conf
export IW_MONGO_HOME=${IW_HOME}/resources/mongodb
pushd ${IW_HOME}/HA >> ${LOG_FILE}
nohup python2.7 main.py &> ${HA_OUT_FILE} & echo $! > ${IW_HOME}/HA/ha.pid
echo $! > ha_pid
popd >> ${LOG_FILE
#fi



After making changes, please save the file and exit from vi editor.


Navigate to $IW_HOME/bin


cd $IW_HOME/bin
Source env.sh
./start.sh ha



After the above settings in 2nd machine(HA machine) only HA should be running.

User can validate the running process by running the below command


cd $IW_HOME/bin
./status.sh



User can see the logs for HA components in $IW_HOME/logs/ha/ha.log and $IW_HOME/logs/ha/ha.out