Adding the Gateway Database (Two Computer Configuration)

In the near future we will be releasing an update that requires operators to add a database on the gateway computer.

Currently, the handbook only covers the setup of the node database. We will be revising the handbook once the update has been released but in the meantime, I wanted to get a head start so operators have time to setup the gateway database and get help if they run into any problems.

There are two hardware configurations listed in the hand handbook:

  • Two Computers: The node and gateway processes are run on different computers.
  • One Computer: The node and gateway processes are run on the same computer.

If you run the node and gateway software on one computer, please refer to Adding the Gateway Database (One Computer)

This post is for operators who run the node and gateway software on separate computers. All of the following will be performed on the the gateway computer.

  1. Install PostgreSQL and its dependencies.
    $ sudo apt install -y postgresql-client postgresql postgresql-contrib

  2. Once the installation is complete, enable the PostgreSQL service.
    $ sudo update-rc.d postgresql enable

  3. Next, start the service.
    $ sudo service postgresql start

  4. Create a database user with the username cmix, which is used to access the database.
    $ sudo -u postgres createuser --createdb --pwprompt cmix

  5. You will be asked to set a password for the cmix user. Create a long and secure password and note, once the update has been released you will need this password for the gateway.yaml file that will be included in the future update.

Enter password for new role:
Enter it again:
  1. Create the required database with the name cmix_gateway .
    $ sudo -u postgres createdb -O cmix cmix_gateway

  2. Login to the user postgres, which was automatically created to run the PostgreSQL database server.
    $ sudo su postgres

  3. Run the command psql to start the interactive PostgreSQL session.
    $ psql

NOTE: The command prompt has changed from $ to # .
Just as you don’t type the $, don’t type the #.

  1. Once at the postgres prompt, enter in \l to get a list of databases.
    # \l

  2. The database has been set up correctly if the newly created database cmix_gateway with the owner cmix exists.

                                  List of databases
     Name     |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
--------------+----------+----------+-------------+-------------+-----------------------
 cmix_gateway | cmix     | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres     | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0    | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
              |          |          |             |             | postgres=CTc/postgres
 template1    | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
              |          |          |             |             | postgres=CTc/postgres
  1. To quit psql, enter \q
    # \q

  2. Exit from the postgres use account
    $ exit

  3. Modify the gateway.yaml file.
    $ nano /opt/xxnetwork/gateway.yaml

  4. Add the following code to the bottom of the gateway.yaml file.

# Database connection information
dbUsername: "cmix"
dbPassword: "PASSWORD"
dbName: "cmix_gateway"
dbAddress: "0.0.0.0:5432"
  1. Save and exit nano by pressing Ctrl+s then Ctrl+x

If you need any help, please feel free to DM me on the xx network Discord channel. My ID is Keith aka LordVetinari#9085 It might take me a few hours to get back to you as I am on Korean Standard Time.

Don’t panic, take a step back from the computer and I’ll be with you ASAP.

Thanks for running a node!
Keith

1 Like