Install AEN connected to a remote Mongo DB instance (AEN 4.2.0)
===============================================================

.. raw:: html

    <p>To install AEN with a remote database:</p>
    <ol class="arabic">
    <li><p class="first">Connect to the Mongodb instance and create the user for AEN:</p>
    <blockquote>
    <div><div class="highlight-none"><div class="highlight"><pre><span></span>&gt; user = { user: &quot;&lt;username&gt;&quot;,
      pwd: &quot;&lt;super-secure-password&gt;&quot;,
      roles: [
        { role: &quot;dbOwner&quot;, db: &quot;&lt;db_name&gt;&quot; },
        { role: &quot;dbOwner&quot;, db: &quot;&lt;db_name&gt;_mq&quot; }
      ]
    }
    &gt; db.createUser(user)
    Successfully added user: { ... }
    </pre></div>
    </div>
    </div></blockquote>
    </li>
    <li><p class="first">Before installing AEN-server export the database URL and name:</p>
    <blockquote>
    <div><div class="highlight-bash"><div class="highlight"><pre><span></span>$ <span class="nb">export</span> <span class="nv">MONGO_URL</span><span class="o">=</span><span class="s2">&quot;mongodb://&lt;username&gt;:&lt;password&gt;@&lt;host&gt;:&lt;port&gt;/&quot;</span>
    $ <span class="nb">export</span> <span class="nv">MONGO_DB</span><span class="o">=</span><span class="s2">&quot;&lt;database_name&gt;&quot;</span>
    </pre></div>
    </div>
    </div></blockquote>
    </li>
    <li><p class="first">Continue the installation process:  <a class="reference internal" href="../install-server-node.html"><span class="doc">Install the AEN server</span></a>.</p>
    </li>
    </ol>
    <div class="section" id="migrate-from-local-to-remote-mongodb">
    <h2>Migrate from local to remote MongoDB<a class="headerlink" href="#migrate-from-local-to-remote-mongodb" title="Permalink to this headline">¶</a></h2>
    <p>To configure your remote database to work with an already installed AEN server:</p>
    <ol class="arabic">
    <li><p class="first">Stop the server, gateway and compute nodes:</p>
    <div class="highlight-bash"><div class="highlight"><pre><span></span>sudo service wakari-server stop
    sudo service wakari-gateway stop
    sudo service wakari-compute stop
    </pre></div>
    </div>
    </li>
    <li><p class="first">Open the <code class="docutils literal"><span class="pre">/opt/wakari/wakari-server/etc/wakari/config.json</span></code>
    file and create the MONGO_URL key. For the value parameter, add the
    database information.</p>
    <p>The final file should read:</p>
    <div class="highlight-bash"><div class="highlight"><pre><span></span><span class="o">{</span>
      <span class="s2">&quot;MONGO_URL&quot;</span>: <span class="s2">&quot;mongodb://MONGO-USER:MONGO-PASSWORD@MONGO-URL:MONGO-PORT&quot;</span>,
      <span class="s2">&quot;MONGO_DB&quot;</span>: <span class="s2">&quot;MONGO-DB-NAME&quot;</span>,
      <span class="s2">&quot;WAKARI_SERVER&quot;</span>: <span class="s2">&quot;http://YOUR-IP&quot;</span>,
      <span class="s2">&quot;USE_SES&quot;</span>: false,
      <span class="s2">&quot;CDN&quot;</span>: <span class="s2">&quot;http://YOUR-IP/static/&quot;</span>,
      <span class="s2">&quot;ANON_USER&quot;</span>: <span class="s2">&quot;anonymous&quot;</span>
    <span class="o">}</span>
    </pre></div>
    </div>
    <p>For more information about configuration keys, see
    <a class="reference internal" href="use-config-files.html"><span class="doc">Using configuration files</span></a>.</p>
    </li>
    <li><p class="first">Migrate the data from the former database into the new one.
    For more information, see the <a class="reference external" href="https://docs.mongodb.com/manual/tutorial/backup-and-restore-tools/">MongoDB documentation website</a>.</p>
    </li>
    <li><p class="first">After migration, restart the nodes:</p>
    <div class="highlight-bash"><div class="highlight"><pre><span></span>sudo service wakari-server start
    sudo service wakari-gateway start
    sudo service wakari-compute start
    </pre></div>
    </div>
    </li>
    </ol>
    </div>
