.. _nats-server-migration-to-supported-howto:

How To migrate NATS Server to a supported configuration
-------------------------------------------------------

In this chapter we are going to explain how to migrate a NATS Server
to be compliant with the supported NetEye 4 configuration.

Prerequisites:
~~~~~~~~~~~~~~

.. warning:: Before proceeding with the NATS Server migration procedure,
    if you are in a NetEye cluster environment, remember to put all nodes
    into standby except the one on which the configuration steps are
    executed (the Master).

To put a node in standby, run the following command on the current node:

.. code-block::

   # pcs node standby --wait=300
   # echo $?

The output of the last command (which is the exit code of the previous
command) must be 0.
If the exit code is different from 0, the current node is not yet in
standby, so please be sure that **the current node is in standby** before
proceeding.


Procedure
~~~~~~~~~

.. warning:: NetEye Clusters only: the following procedure must be
    run on the active node.


#. Navigate to the NATS Server config folder:

   .. code-block::

      # cd /neteye/shared/nats-server/


#. Backup the running configuration folder:

   .. code-block::

      # cp -a conf conf.backup

#. Disable the NATS Server service:

   - NetEye Single Instances and Satellites:

   .. code-block::

      # systemctl stop nats-server

   - NetEye Clusters:

   .. code-block::

      # pcs resource disable nats-server

#. Delete the NATS Server unsupported configuration:

   .. code-block::

      # rm -rf conf/*

#. Restore the NATS Server configuration with the supported one:

   .. code-block::

      # yum reinstall nats-server --enablerepo=neteye

   .. note:: Configurations folders `/neteye/shared/nats-server/conf.backup/users.d` and
      `/neteye/shared/nats-server/conf.backup/permissions.d` under `/neteye/shared/nats-server/conf.backup`
      can contain configuration files from other software, or custom configuration files.
      For example, **tornado-nats-json-collector.conf** must be manually migrated from
      `/neteye/shared/nats-server/conf.backup/users.d` to `/neteye/shared/nats-server/conf/users.d`

#. Run the NetEye Secure Install (skip this step in NetEye Satellites):

   .. code-block::

      # neteye_secure_install

#. Start the NATS Server service:

   - NetEye Single Instances and Satellites:

   .. code-block::

      # systemctl start nats-server

   - NetEye Clusters:

   .. code-block::

      # pcs resource restart nats-server

#. Only in cluster environments, you need to restore
   the high availability operation. To do this you have to follow
   :ref:`this procedure<cluster-reactivation>`.