Skip to content

Deployment

Samantha Leung edited this page Aug 17, 2021 · 6 revisions

This page describes how to deploy Alhena with a three node Elasticsearch cluster on https://domainname.com/alhena, with Elasticsearch being accessible through https://domainname.com/alhena/db

Specs

There are three separate setups involved, so below we will describe our specifications for each setup. You can combine this into one setup.

Loading Setup

  • 16GB RAM, 8 CPUs
  • python 3, venv, pip

ElasticSearch Setup

  • 16GB RAM, 4 CPUs
  • 1 mounted disk per node (~1TB each)
  • docker and docker-compose

Webserver Setup

  • 16GB RAM, 4 CPUs
  • docker and docker-compose
  • nginx

Elasticsearch

This setup describes a 3 node Elasticsearch instance (named es01, es02, es03). Adjust this setup as needed.

In the /db folder, edit the following files:

  • In .env, change the password ELASTIC_PASSWORD - this is the password needed to query the Elasticsearch API
ELASTIC_PASSWORD=PleaseChangeMe
  • In docker-compose.yml, update the filepaths in the volumes of each node (marked with !!!) to where the data will be stored on your system
volumes:
      - /mnt/data3:/usr/share/elasticsearch/data
      - /mnt/data4:/usr/share/elasticsearch/backup

Now we generate the certificates

docker-compose -f create-certs.yml run --rm create_certs

Increase max_map_count

sysctl -w vm.max_map_count=262144

Start the Elasticsearch instance

docker-compose up -d

Curling the localhost URL with your credentials should return an introductory response:

curl -k -u elastic:PleaseChangeMe -XGET https://localhost:9200

Response:

{
  "name" : "es01",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "7KG9Po4hRQ-5GglViidmnQ",
  "version" : {
    "number" : "7.13.3",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "a479a2a7fce0389512d6a9361301708b92dff667",
    "build_date" : "2020-08-11T21:36:48.204330Z",
    "build_snapshot" : false,
    "lucene_version" : "8.6.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Loading Data

Setup virtual environment in the loader server

python3 -m venv <!!! /path/to/new/virtual/environment>

source <!!! /path/to/new/virtual/environment>/bin/activate

Install the loading code

pip install -e git://github.com/shahcompbio/alhenaloader.git#egg=alhenaloader

Add these variables into your bash_profile - the password comes from your db/.env file

export ALHENA_ES_USER=elastic
export ALHENA_ES_PASSWORD=PleaseChangeMe

Run the initialization call - this will set up the default project (DLP) and any initial indices

alhenaloader initialize

Now you should be able to load the test data (in data)

alhenaloader --id TEST_123 load  --library testLibrary --sample testSample --description test --qc data

App

These instructions will run the application locally, connected to port 80.

First, edit the following files in the app folder:

  • In .env, edit the REACT_APP_BASENAME and PUBLIC_URL to reflect the domain name where you want Alhena to be deployed.
REACT_APP_BASENAME="/alhena"
PUBLIC_URL="https://www.google.ca/alhena"
  • In .graphql.env, edit ES_PASSWORD with the password you specified in db/.env, and ELASTICSEARCH_NODE with the domain name
ELASTICSEARCH_NODE=https://google.ca/alhena/db
  • In docker-compose.yml, edit HOST with the same URL you have in ELASTICSEARCH_NODE
 environment:
      - HOST=https://www.google.ca/alhena/db

Then run the Dockerfile to build your specific React layer

docker build . -t alhena

Then you can run the app:

docker-compose up -d

nginx

Lastly, in order to expose both the application and Elasticsearch pubically, we will need to make some adjustments to the nginx layer on the webserver.

Please note that we assume that this is already installed and setup with https. If you have not already done that, here are some resources we used to install nginx on our ubuntu systems:

https://ubuntu.com/tutorials/install-and-configure-nginx#2-installing-nginx

https://certbot.eff.org/lets-encrypt/ubuntuxenial-nginx.html

In nginx/nginx.conf, we provided a file that sets up the server blocks needed for Alhena - this can be placed in /etc/nginx/conf.d/. This may clash if other server blocks exist.

You may need to edit these parts:

  1. Update the server location for the Elasticsearch node if it is not located in the same place as your webserver:
upstream alhena-db {
        server  localhost:9200;
        keepalive 15;
}
  1. Update the server_name with your proper domain name:
   server_name    www.google.ca;
  1. Update the ssl_certificate and ssl_certificate_key, depending on how the SSLs were installed:
        ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
        ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;

After changes, make sure you restart nginx accordingly:

sudo service nginx restart

Troubleshooting

Server errors

  • Are your http/https ports are open?
  • Are you the root user? Many of these commands need the user to be able to sudo.

Nginx issues

  • Have you checked the error logs? (tail -30 /var/log/nginx/error.log)
  • Have you tried checking the status of nginx to pinpoint an issue in the nginx conf file? (service ningx status)

Docker issues

  • Are all containers started?
  • Are all containers running?
  • Have you tried pulling in new images?
  • Is the graphql password set correctly in your graphql.env file?
  • Are all the variables set correctly in the env files?
  • Have you checked the docker logs?
  • Are the es containers still starting up?
  • Have you tried re-starting containers?
  • Do your ES docker containers have access to your persistent data folders?
Clone this wiki locally