On a single stand alone setup, you can rename your server hostname by following these steps.

WARNING: please contact the support team to have any advice before starting this procedure.

We advise taking a snapshot of the server or performing a backup of the data before doing any of the following actions.

Log in as LTU

All commands should be performed as user ltu:

su - ltu

Export old and new server names:

export OLD_HOSTNAME=old
export NEW_HOSTNAME=new

Stop all services

ltud stop all

Server license

Contact our support team to obtain a new license file. Please send us the following files so we can check the system configuration:

  • /opt/ltuengine/config/license.lic
  • /opt/ltuengine/run/cache/config/ltuengine.full.spec
  • /opt/ltuengine/run/cache/config/weki.cfg
  • /opt/ltuengine/run/cache/config/processor.cfg
  • /opt/ltuengine/run/cache/config/kima.cfg

Copy the new license in /opt/ltuengine/config/license.lic

# Check that the previous hostname is not present:
if [ $(grep $OLD_HOSTNAME -R /opt/ltuengine/config/license.lic --color | wc -l) -eq 0 ]; then echo "OK"; else echo "Error";fi

Rename server

WARNING: The commands in this section must be run by the root user.

Export old and new server names:

export OLD_HOSTNAME=old
export NEW_HOSTNAME=new

To rename a Debian 7 server:

  1. Edit the file “/etc/hosts” to reflect the new server name.
  2. Change the hostname:
     sed -i "s/$OLD_HOSTNAME/$NEW_HOSTNAME/g" /etc/hostname 
  3. Apply the previous change:
     /etc/init.d/hostname.sh 
  4. Log out an in to take the change into account.

To rename a Debian 8/9 server:

  1. Edit the file “/etc/hosts” to reflect the new server name.
  2. Run the following command:
     hostnamectl set-hostname $NEW_HOSTNAME 
  3. Log out an in to take the change into account.

WARNING: make sure you can ping the new hostname

ping $NEW_HOSTNAME

Update LTU Engine specification

All LTU Engine settings are stored into one file and then deployed into multiple configuration files for each service.

Switch user to ltu again and reload hostname variables:

su - ltu
export OLD_HOSTNAME=old
export NEW_HOSTNAME=new

Copy the file containing all specifications:

# backup existing file
cp config/ltuengine.spec config/ltuengine.spec.back

# get full specification file
cp run/cache/config/ltuengine.full.spec config/ltuengine.spec

Update /opt/ltuengine/config/ltuengine.spec to reflect the new server name:

# replace servername in specification file:
sed -i "s/$OLD_HOSTNAME/$NEW_HOSTNAME/g" config/ltuengine.spec

# check that the old hostname is not used anymore:
if [ $(grep $OLD_HOSTNAME -R config/ltuengine.spec --color | wc -l) -eq 0 ]; then echo "OK"; else echo "Error";fi

# check that the new hostname is used:
if [ $(grep $NEW_HOSTNAME -R config/ltuengine.spec --color | wc -l) -eq 0 ]; then echo "Error"; else echo "OK";fi
# regenerate the services configuration files
ltusaas-generate-config-files -i config/ltuengine.spec -o run/cache/config/ -f
sed -i "s/$OLD_HOSTNAME/$NEW_HOSTNAME/g" run/cache/config/weki-repositories.cfg

# clean some cached files
rm -f run/cache/config/*.pyc

# check that the old hostname is not used anymore:
if [ $(grep $OLD_HOSTNAME -R run/cache/config/ --color | wc -l) -eq 0 ]; then echo "OK"; else echo "Error";fi

# check that the new hostname is used:
if [ $(grep $NEW_HOSTNAME -R run/cache/config/ --color | wc -l) -eq 0 ]; then echo "Error"; else echo "OK";fi

Update the SI database

Start only the database service:

ltud start database
# Consult the server list table:
psql saas_si -p 7791 -c "select * from hw_server;"

# Update the server list table:
psql saas_si -p 7791 -c "update hw_server set hostname='$NEW_HOSTNAME' where hostname='$OLD_HOSTNAME';"

# Control the server list table:
psql saas_si -p 7791 -c "select * from hw_server;"
# Consult the application configuration:
psql saas_si -p 7791 -c "select * from application_property where name='database_hostname';"

# Update the application configuration:
psql saas_si -p 7791 -c "update application_property set value='$NEW_HOSTNAME' where name='database_hostname';"

# Control the application configuration:
psql saas_si -p 7791 -c "select * from application_property where name='database_hostname';"

Start all services

ltud start all
ltud status all