How to rename a server

It might sometimes happen that you need to rename a server (when duplicating temporarily a server for instance). If you have to do this, you need to change some parameters in the configuration. This document explains how to do it.

There are some data which are dependent on the current hostname. When the host is renamed, the installation cannot just be used, but some changes must be done before and after renaming. This document describes the steps but only for the Syracuse server (including load balancer) and only what is already possible using the current versions of the code. Some steps may be simplified with future code enhancements.

If the cluster consists of more than 1 host, I strongly advise to stop the cluster before the following steps.

Preparations

Renaming

Rename the server on operating system level

Work after renaming the server

Note that server certificates for all SSL connections should be renewed anyway, because the server name has changed (and the server name usually occurs in the server certificate).

When the X3 server or another server contains a public key which has the name of the old server, you have to copy the .pem file just generated to that server.

Finally delete the old server certificate from MongoDB using the following command within MongoDB prompt (here `OLDNAME` must be replaced with the old server name in lower case letters):
db.Certificate.remove({name: 'OLDNAME'});
The answer to this command should be something like
WriteResult({ "nRemoved" : 1 })

Particular case : Use a different X3 solution

The "Application servers" entity need to be modified.

The following sample should be modified to match your X3 servers (old and new) settings. Copy the javascript code into a file with .js extension.

Write a script that invokes : mongo.exe with the name of the file as parameter. Example on Windows :

"C:\mongodb\bin\mongo.exe" rename.js

CODECODE CODE javascript
db = connect("host:port/syracuse");
db.X3server.update({
    serverHost: "_my_old_hostname_",
    serverPort: _old_port_
}, {
    $set:{
        serverHost: "_new_host_name_",
        serverPort: _new_port_
    }
}, {
    multi: true
});