:orphan:

=============================================================
Installation steps common to online and offline installations
=============================================================

.. S_HEADING_MONGO

1. Install MongoDB 2.6
=======================

.. E_HEADING_MONGO

.. S_MONGO_INSTALL

MongoDB for Redhat and CentOS 7
-------------------------------

#. Install MongoDB::

     sudo yum install -y mongodb-org*

#. Start MongoDB::

     sudo systemctl start mongod

#. Verify that MongoDB is running::

     $ sudo systemctl status mongod
     mongodb (pid 17258) is running...

MongoDB for Redhat and CentOS 6.7+
----------------------------------

#. Install MongoDB::

     sudo yum install -y mongodb-org*

#. Start MongoDB::

     sudo /etc/init.d/mongod start

#. Verify that MongoDB is running::

     $ sudo /etc/init.d/mongod status
     mongodb (pid 17258) is running...

MongoDB for Ubuntu 12.04+
-------------------------

#. Install MongoDB::

     sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

     echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list

     sudo apt-get update

     sudo apt-get install -y mongodb-org=2.6.9 mongodb-org-server=2.6.9 mongodb-org-shell=2.6.9 mongodb-org-mongos=2.6.9 mongodb-org-tools=2.6.9


   NOTE: If you do not specify a version, such as 2.6.9,
   ``apt-get`` installs the latest stable version, which is 3.x.

#. Start MongoDB::

          sudo /etc/init.d/mongod start

   Verify that MongoDB is running::

          $ sudo /etc/init.d/mongod status
          mongodb (pid 17258) is running...


   You receive verification that MongoDB is running::

     start: Job is already running: mongodb


Additional MongoDB resources
-----------------------------

For additional MongoDB installation information see
https://docs.mongodb.org/manual/.

.. E_MONGO_INSTALL

.. S_AER_ADMIN_ACT


2. Create the Repository administrator account
==============================================

#. In a Terminal window, create a new user account for Anaconda
   Repository named "anaconda-server," and switch to this new
   account::

     sudo useradd -m anaconda-server

   NOTE: The anaconda-server user is the default for installing
   Repository. Any username can be used, but using the root user
   is discouraged.

#. Create a Repository package storage directory::

     sudo mkdir -m 0770 -p /opt/anaconda-server/package-storage

#. Assign ownership of this directory to the anaconda-server
   user::

     sudo chown -R anaconda-server:anaconda-server /opt/anaconda-server


#. Switch to the Repository administrator account::

     sudo su - anaconda-server

.. E_AER_ADMIN_ACT

.. S_HEADING_INSTALL

3. Install Repository
=======================

.. E_HEADING_INSTALL

.. S_AER_INSTALL

#. Review and accept the license terms::

     Welcome to Anaconda Repository 2.33 (by Anaconda, Inc.)
     In order to continue the installation process, please review the license agreement.
     Please, press ENTER to continue.


#. Once you have reviewed the license terms, approve them by
   typing ``yes``::

     Do you approve the license terms? [yes|no] yes

#. Accept the default location or specify an alternative::

     anaconda_repository will now be installed into this location:
     /home/anaconda-server/repo  -Press ENTER to confirm the location
     -Press CTRL-C to abort the installation
     -Or specify a different location below
      [/home/anaconda-server/repo] >>> /home/anaconda-server/repo" [Press ENTER]
       PREFIX=/home/anaconda-server/repo
       installing: python-2.7.11-0
       ...
       Python 2.7.11 :: Anaconda, Inc.
       creating default environment... installation finished.



#. At the end of the installation routine, update the
   anaconda-server user's path---prepending
   ``/home/anaconda-server/repo``---by answering "yes" at the
   prompt to add the install location to your path::

     Do you wish the installer to prepend the anaconda_repository install location to PATH in your /home/anaconda-server/.bashrc ? [yes|no]



#. Type ``yes`` and press ENTER.

#. For the new path changes to take effect, source your
   ``.bashrc``::

     source ~/.bashrc


.. E_AER_INSTALL

.. S_AER_SECTIONS_45678

4. Configure Repository
========================

#. Initialize the web server and indicate the filepath for the
   package storage location::

     anaconda-server-config --init
     anaconda-server-config --set fs_storage_root /opt/anaconda-server/package-storage


   NOTE: The location for file storage can be any location owned
   by the anaconda-server user that you created in section 2
   above.

#. Configure the connection to your MongoDB database::

     anaconda-server-config --set MONGO_URL mongodb://localhost

   NOTE: You may also :doc:`configure an external MongoDB
   database <config/connect-mongodb>`.

#. If you are not using LDAP or Kerberos authentication, create
   an initial superuser account for Repository::

     anaconda-server-create-user --username "superuser" --password "yourpassword" --email "your@email.com" --superuser



   NOTE: Replace ``superuser`` with a username of your choice,
   ``yourpassword`` with a password of your choice, and
   ``you@youremail.com`` with an email address where you wish to
   receive system email notifications.

   NOTE: To ensure the bash shell does not process any of the
   characters in this password, limit the password to letters and
   numbers, with no punctuation. After setup, you can change the
   password in the web UI.

#. Initialize the Repository database::

     anaconda-server-db-setup --execute

   NOTE: The above command is also run when upgrading Repository.
   Upgrade and then run::

     anaconda-server-db-setup --execute

#. Restart the server.

NOTE: More configuration options can be controlled with one or
more ``.yaml`` configuration files. Repository reads
configuration files in this order:

#. From ``/etc/anaconda-server/*.yaml``.
#. From ``$PREFIX/etc/anaconda-server/*.yaml``.
#. From the path specified in the environment variable
   ANACONDA_SERVER_CONFIG, if it is set and the command line
   argument ``--config-file`` was not used.
#. From the path specified in the command line argument
   ``--config-file``, if it was used.

All configuration is merged, and options from files read earlier
are overwritten by files read later. If there are multiple files
in the same directory, they are read in alphabetical order.


5. Set up automatic restart on reboot, fail or error
====================================================

#. Run the ``anaconda-server-install-supervisord-config.sh``
   script to configure supervisord management of the Anaconda
   server and worker processes::

     anaconda-server-install-supervisord-config.sh

   This will generate the
   ``/home/anaconda-server/repo/etc/supervisord.conf`` file and
   add a crontab rule to restart supervisor after each reboot.

   It will also create the folder
   ``/home/anaconda-server/repo/etc/supervisord/conf.d/`` where you can add
   ``.conf`` files with custom configuration.

   NOTE: If you don't want to include the crontab rule, use the
   ``--no-crontab`` option when running the script.

   If an error message says that the user is disallowed from
   using cron and could not add the crontab rule, you can add it
   manually with sudo. Edit the crontab file::

     sudo crontab -e -u anaconda-server

   When the file is open for editing, add this entry::

        @reboot /home/anaconda-server/repo/bin/supervisord

#. Verify that the server is running::

     supervisorctl status

   If installed correctly, you see::

     binstar-server RUNNING   pid 10831, uptime 0:00:05

#. View the log file at::

     $PREFIX/var/log/anaconda-server/application.log


6. Start and log in to Repository
=================================

#. Open your browser and log into Repository by visiting
   ``http://your.anaconda.repository:8080/`` using the superuser
   account you created in section 4 above.

   NOTE: Replace ``your.anaconda.repository`` with the IP address
   or domain name of your repository.

#. If you are using LDAP or Kerberos authentication, modify your
   user account to be a superuser.

   EXAMPLE: If your user account is "jsmith"::

     anaconda-server-admin set-superuser "jsmith"

NOTE: See :doc:`../troubleshooting` if you have issues starting
the repo server.


7. Client configuration
=======================

Follow the :doc:`config/config-client` instructions so you can
use one or more clients to communicate with the server.


8.  Install the Repository license
==================================

#. In your browser, go to
   ``http://your.anaconda.repository:8080``. Follow the onscreen
   instructions to upload the license file that you received in
   an email from your sales representative.

   NOTE: Replace ``your.anaconda.repository`` with the IP address
   or domain name of your repository.

   Contact your sales representative or support representative if
   you cannot find or have any questions about your license.

#. After uploading the license file, you will see the login page.
   Log in using the superuser user and password that you created
   in section 4 above.

TIP: You can view the current license information and upload a
new license file by visiting the URL
``http://your.anaconda.repository:8080/admin/license``.

NOTE: Replace ``your.anaconda.repository`` with the IP address
or domain name of your repository.

Alternatively, you can install the license by copying the license
file directly into the ``/home/anaconda-server/.continuum``
directory.


.. E_AER_SECTIONS_45678

.. S_HEADING_MIRROR_CONDA

9. OPTIONAL: Mirror installers for Anaconda and Miniconda
===========================================================

Miniconda and Anaconda installers can be served by Repository
via the static directory located at
``/home/anaconda-server/repo/opt/anaconda-server/installers``.
To serve up the latest Miniconda installers for each platform,
download them and copy them to the extras directory. The
following code snippets assume `/tmp` exists.



.. E_HEADING_MIRROR_CONDA

.. S_GET_MINICONDA

The ``Miniconda*latest*.sh`` always point to the latest Miniconda
installers. Either these can be mirrored or the ones with the
latest version number can be mirrored. Define the list of
installers to mirror::

  versions="Miniconda2-4.3.11-Linux-x86_64.sh
            Miniconda2-4.3.11-MacOSX-x86_64.sh
            Miniconda2-4.3.11-Windows-x86.exe
            Miniconda2-4.3.11-Windows-x86_64.exe
            Miniconda3-4.3.11-Linux-x86_64.sh
            Miniconda3-4.3.11-MacOSX-x86_64.sh
            Miniconda3-4.3.11-Windows-x86.exe
            Miniconda3-4.3.11-Windows-x86_64.exe"

  # miniconda installers
  mkdir -p /tmp/extras
  pushd /tmp/extras

  for installer in $versions
  do
      curl -O $URL$installer
  done

.. E_GET_MINICONDA

.. S_GET_ANACONDA

Define the anaconda version to mirror.

EXAMPLE: To mirror version 4.3::

  versions="Anaconda3-4.3.1-Linux-x86_64.sh
            Anaconda3-4.3.1-MacOSX-x86_64.pkg
            Anaconda3-4.3.1-MacOSX-x86_64.sh
            Anaconda3-4.3.1-Windows-x86.exe
            Anaconda3-4.3.1-Windows-x86_64.exe
            Anaconda2-4.3.1-Linux-x86_64.sh
            Anaconda2-4.3.1-MacOSX-x86_64.pkg
            Anaconda2-4.3.1-MacOSX-x86_64.sh
            Anaconda2-4.3.1-Windows-x86.exe
            Anaconda2-4.3.1-Windows-x86_64.exe"

  # miniconda installers
  mkdir -p /tmp/extras
  pushd /tmp/extras

  for installer in $versions
  do
      curl -O $URL$installer
  done

Copy the ``extras`` folder, which contains all installers that
will be mirrored in the repo::

  # Move installers into static directory
  popd
  cp -a /tmp/extras /home/anaconda-server/repo/lib/python2.7/site-packages/binstar/static



Users can download the installers using curl from following URL::

  # Fill in server name, port, and specific installer for your platform
  curl -s -O http://your.anaconda.repository:8080/static/extras/Miniconda-latest-Linux-x86_64.sh



NOTE: Replace ``your.anaconda.repository`` with the IP address or
domain name of your repository.

.. E_GET_ANACONDA


.. S_HEADING_MIRROR_CHANNELS

10. Mirror Anaconda Cloud
=========================

The final step is to mirror the packages from a subset of
channels on Anaconda Cloud to the local Repository. The channels
to mirror are as follows:

+--------------------------+--------------------------------------------------------------------------------+
| Channel                  | Description                                                                    |
+==========================+================================================================================+
| anaconda                 | Default anaconda channel containing all packages built and                     |
|                          | supported by Anaconda, Inc. Also contains custom packages.                     |
+--------------------------+--------------------------------------------------------------------------------+
| r                        | If you would like conda packages for `r`, mirror this channel.                 |
|                          | It is typically done under an `r` account.                                     |
+--------------------------+--------------------------------------------------------------------------------+
| | wakari                 | If the local Repository will be used by Anaconda Enterprise Notebooks          |
| | anaconda-nb-extensions | the recommended method is to mirror these channels under the `wakari` account. |
+--------------------------+--------------------------------------------------------------------------------+
| anaconda-adam            | Anaconda-adam is used to manage the environments on a cluster. If you plan to  |
|                          | use anaconda-scale for cluster management, mirror the anaconda-adam packages.  |
+--------------------------+--------------------------------------------------------------------------------+
| msys2                    | msys2 is required by quite a few windows packages. See http://www.msys2.org/   |
+--------------------------+--------------------------------------------------------------------------------+


The packages will be mirrored to the package store defined by the
fs_storage_root key as described in section 4 above.

Mirror Anaconda
----------------

.. E_HEADING_MIRROR_CHANNELS
