Set up PostgreSQL databases

Two Arvados Rails servers store data in a PostgreSQL database: the SSO server, and the API server. The API server requires at least version 9.4 of PostgreSQL. Beyond that, you have the flexibility to deploy PostgreSQL any way that the Rails servers will be able to connect to it. Our recommended deployment strategy is:

  • Install PostgreSQL on the the same host as the SSO server, and dedicate that install to hosting the SSO database. This provides the best security for the SSO server, because the database does not have to accept any client connections over the network. Typical load on the SSO server is light enough that deploying both it and its database on the same host does not compromise performance.
  • If you want to provide the most scalability for your Arvados cluster, install PostgreSQL for the API server on a dedicated host. This gives you the most flexibility to avoid resource contention, and tune performance separately for the API server and its database. If performance is less of a concern for your installation, you can install PostgreSQL on the API server host directly, as with the SSO server.

Find the section for your distribution below, and follow it to install PostgreSQL on each host where you will deploy it. Then follow the steps in the later section(s) to set up PostgreSQL for the Arvados service(s) that need it.

It is important to make sure that autovacuum is enabled for the PostgreSQL database that backs the API server. Autovacuum is enabled by default since PostgreSQL 8.3.

Install PostgreSQL 9.4+

The API server requires at least version 9.4 of PostgreSQL.

CentOS 7

Note:

On CentOS 7 and RHEL 7, these packages require a more recent version from Software Collections. The Software Collection will be installed automatically as long as Software Collections are enabled on your system.

To enable Software Collections on CentOS, run:

~$ sudo yum install centos-release-scl scl-utils

To enable Software Collections on RHEL:

~$ sudo yum-config-manager --enable rhel-server-rhscl-7-rpms

See also section 2.1 of Red Hat’s Installation chapter .

  1. Install PostgreSQL:
    ~$ sudo yum install rh-postgresql95
    ~$ scl enable rh-postgresql95 bash
  2. Initialize the database:
    ~$ sudo postgresql-setup initdb
  3. Configure the database to accept password connections:
    ~$ sudo sed -ri -e 's/^(host +all +all +(127\.0\.0\.1\/32|::1\/128) +)ident$/\1md5/' /var/lib/pgsql/data/pg_hba.conf
  4. Configure the database to launch at boot:
    ~$ sudo systemctl enable rh-postgresql95-postgresql
  5. Start the database:
    ~$ sudo systemctl start rh-postgresql95-postgresql
  6. Set up Arvados credentials and databases for the services that will use this PostgreSQL install.

Debian or Ubuntu

Debian 8 (Jessie) and Ubuntu 16.04 (Xenial) and later versions include a sufficiently recent version of Postgres.

Ubuntu 14.04 (Trusty) requires an updated PostgreSQL version, see the PostgreSQL ubuntu repository

  1. Install PostgreSQL:
    ~$ sudo apt-get install postgresql
  2. Set up Arvados credentials and databases for the services that will use this PostgreSQL install.

Set up SSO server credentials and database

  1. Start a shell for the postgres user:
    ~$ sudo -u postgres bash
  2. Generate a new database password:
    $ ruby -e 'puts rand(2**128).to_s(36)'
    yourgeneratedpassword
    
    Record this. You’ll need it when you set up the Rails server later.
  3. Create a database user with the password you generated:
    $ createuser --encrypted -R -S --pwprompt arvados_sso
    Enter password for new role: yourgeneratedpassword
    Enter it again: yourgeneratedpassword
    
  4. Create a database owned by the new user:
    $ createdb arvados_sso_production -T template0 -E UTF8 -O arvados_sso
  5. Exit the postgres user shell:
    $ exit

Set up API server credentials and database

  1. Start a shell for the postgres user:
    ~$ sudo -u postgres bash
  2. Generate a new database password:
    $ ruby -e 'puts rand(2**128).to_s(36)'
    yourgeneratedpassword
    
    Record this. You’ll need it when you set up the Rails server later.
  3. Create a database user with the password you generated:
    $ createuser --encrypted -R -S --pwprompt arvados
    Enter password for new role: yourgeneratedpassword
    Enter it again: yourgeneratedpassword
    
  4. Create a database owned by the new user:
    $ createdb arvados_production -T template0 -E UTF8 -O arvados
  5. Exit the postgres user shell:
    $ exit

Previous: Choosing which components to install Next: Install the API server

The content of this documentation is licensed under the Creative Commons Attribution-Share Alike 3.0 United States licence.
Code samples in this documentation are licensed under the Apache License, Version 2.0.