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.1 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.

Install PostgreSQL on CentOS 7

  1. Install PostgreSQL:
    ~$ sudo yum install postgresql-server
  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 postgresql
  5. Start the database:
    ~$ sudo systemctl start postgresql
  6. Set up Arvados credentials and databases for the services that will use this PostgreSQL install.

Install PostgreSQL on Debian or Ubuntu

  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: Prerequisites Next: Install the Single Sign On (SSO) 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.