======================
Optional configuration
======================

These optional procedures may or may not be necessary, depending on 
how you want to set up your Anaconda Enterprise Notebooks Data Center.

These procedures assume that you have already performed the 
:doc:`install-server`, :doc:`install-gateway` and :doc:`install-compute` 
procedures.

Optional: Configure common AEN Compute options
==============================================

To make any of the changes described below, please edit the following file:
``/opt/wakari/wakari-compute/etc/wakari/wk-compute-launcher-config.json``

Then restart the AEN Compute service::

    sudo service wakari-compute restart

Increase HTTP timeout between Gateway and Compute Nodes
-------------------------------------------------------

NOTE: This setting works for HTTP timeout only, not HTTPS.

The default timeout is 600 seconds (10 minutes). To adjust this edit the
``httpTimeout`` key::

    "httpTimeout": 600

Note: The ``httpTimeout`` must also be set on the Gateway with the
same key at ``/opt/wakari/wakari-gateway/etc/wakari/wk-gateway-config.json``

Change the project directory
-----------------------------

To make ``aen-compute`` service use a different directory than ``/projects``
for storing the projects, modify 
``/opt/wakari/wakari-compute/etc/wakari/wk-compute-launcher-config.json`` 
as follows::

    "projectRoot" : "/nfs/storage/services/wakari/projects",

The directory ``/nfs/storage/services/wakari/projects`` specified as
``projectRoot`` must exist for this configuration to work.

Create groups with the same ID
------------------------------

Additionally, if the ``/projects`` folder resides on an NFSv3 volume and
you have a setup with several compute nodes, AEN will create local users
with a different uid on each node.

To make the AEN Compute service create groups with the same id, edit the
configuration file referenced above so that it contains the key ``identicalGID``
and the value ``true`` as in the following example. If you don't see the
``identicalGID`` key, add it, and notice that you must add a comma at the
beginning of the line. If you add this line as the last key, remove any 
comma at the end of the line.

::

    , "identicalGID": true

Use numeric usernames
---------------------

To use numeric usernames, you must modify the configuration file
referenced above so that it contains the key ``numericUsernames`` and the value
``true`` as in the following example. If you don't see the ``numericUsernames``
key, add it, and notice that you must add a comma at the beginning of the line.
If you add this line as the last key, remove any comma at the end of the line.

::

    , "numericUsernames": true

Optional: Verify and tune search indexing
=========================================

Verify that the AEN Compute node can communicate with the AEN Server.
This is required for search indexing to work correctly.

::

    curl -m 5 $AEN_SERVER > /dev/null

Ensure that there are sufficient ``inotify`` watches available for the
number of subdirectories within the project root filesystem. Some Linux
distributions default to a low number of watches, which may prevent the
search indexer from monitoring project directories for changes.

::

    cat /proc/sys/fs/inotify/max_user_watches

If necessary, this can be increased with the following command::

    echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Ensure that there are sufficient ``inotify`` user instances available,
at least one per project.

::

    cat /proc/sys/fs/inotify/max_user_instances

If necessary, this can be increased with the following command::

    echo fs.inotify.max_user_instances=1000 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

.. _aen-default-project-env:

Optional: Setting up a default project environment
==================================================

Anaconda Enterprise Notebooks includes a full installation of the
Anaconda python distribution, along with several additional packages,
located in the ``root`` conda environment in the path
``/opt/wakari/anaconda``. A copy of this environment is created for each
new AEN Project.

To configure a different set of packages as the defaults, create a new
conda environment in the directory
``/opt/wakari/anaconda/envs/default``. For example, to do so using a
python 3.4 base environment, run the following command::

    sudo -u $AEN_SRVC_ACCT /opt/wakari/anaconda/bin/conda create -p /opt/wakari/anaconda/envs/default python=3.4

Then use ``conda`` to install any additional packages into the
environment as needed. After creating the environment, clone it once to
ensure that it works correctly::

    sudo -u $AEN_SRVC_ACCT /opt/wakari/anaconda/bin/conda create -p /opt/wakari/testenv --clone /opt/wakari/anaconda/envs/default
    sudo -u $AEN_SRVC_ACCT rm -rf /opt/wakari/testenv

The default project environment will be cloned into the project
workspace the first time the project is started. To convert an existing
project, run the following command to clone the environment, replacing
``/projects/owner/project/envs/<ENV_NAME>`` with the path to the new
environment you would like to create within the project::

    sudo -u $AEN_SRVC_ACCT /opt/wakari/anaconda/bin/conda create -n /projects/owner/project/envs/<ENV_NAME> --clone /opt/wakari/anaconda/envs/default

Then open the Compute Resource Config for the project and set the
project environment path there.

.. _aen-install-mongodb:

Configure a remote Mongo database instance
==========================================

Some AEN users set up a remote Mongo database instance for performance or 
resource reasons.

First stop the AEN Server, AEN Gateway and all AEN Compute Nodes::

    sudo service wakari-server stop
    sudo service wakari-gateway stop
    sudo service wakari-compute stop

In order to configure a remote database to work with
**AEN-Server**, edit ``/opt/wakari/wakari-server/etc/wakari/config.json``, 
create a new key called ``MONGO_URL`` and add the database information. The final file 
should look like::

    {
      "MONGO_URL": "mongodb://MONGO-USER:MONGO-PASSWORD@MONGO-URL:MONGO-PORT",
      "WAKARI_SERVER": "http://YOUR-IP",
      "USE_SES": false,
      "CDN": "http://YOUR-UP/static/",
      "ANON_USER": "anonymous"
    }

The :doc:`../admin/configuration-files` page has more information about these configuration keys.

You can migrate data from the former database into the new one.
There is covered at the `MongoDB documentation
website <https://docs.mongodb.com/manual/tutorial/backup-and-restore-tools/>`_.
After migration you can restart the services with::

    sudo service wakari-server start
    sudo service wakari-gateway start
    sudo service wakari-compute start

Optional: SELinux enforcing mode
================================

In order to run SELinux in Enforcing mode, set ports with  
the ``semanage port`` command.

The semange command relies on ``policycoreutils-python``. To install (if
needed)::

    sudo yum -y install policycoreutils-python

Enable port 5000 for aen-server::

    sudo semanage port -m -t http_port_t -p tcp 5000

The ``-m`` flag is for modifying an existing usage of a port. If you get
an error ``Port tcp/5000 is not defined`` change the flag to ``-a`` to
add the port.

Enable ports 9200 and 9300 for elasticsearch::

    sudo semanage port -a -t http_port_t -p tcp 9200
    sudo semanage port -a -t http_port_t -p tcp 9300

Please see the :doc:`Administrative documentation <../admin/index>` for
additional information.

Wrapping up
===========

Congratulations! You now have a fully installed Anaconda Enterprise
Notebooks!

Should you encounter any issues while installing AEN or have additional
questions, please do not hesitate to contact your enterprise support
representative.

Next steps
==========

Depending on your Data Center setup, you may need to 
perform some of the additional procedures below:

* :doc:`customization`
* :doc:`ldap`
* :doc:`ssl`
* :doc:`sso`
   
Additional post-install information:   
   
* :doc:`installation_update`
* :doc:`uninstall`
* :doc:`release`
