Chapter 33. Prepare the PostgreSQL Database for the Tigase Server

Table of Contents

Basic Setup
Configuring from PostgreSQL Command Line Tool
Configuring From the Linux Shell Command Line

Andrzej Wojcik <andrzejw@tigase.org> v2.0, June 2014: Reformatted for AsciiDoc. :toc: :numbered: :website: http://tigase.net :Date: 2012-06-16 09:38

This guide describes how to prepare the PostgreSQL database for connecting the Tigase server to it.

Basic Setup

The PostgreSQL database can be prepared in many ways. Below are presented two of them. Following assumptions apply to both methods:

  • admin_db_user - database user with admin rights
  • tigase_user - database user for Tigase
  • tigasedb - database for Tigase

Configuring from PostgreSQL Command Line Tool

Run the PostgreSQL command line client and enter following instructions:

  1. Add the tigase_user:

    psql=# create role tigase_user with login password 'tigase123';
  2. Create the database for the Tigase server with tigase_user as owner of database:

    psql=# create database tigasedb owner tigase_user;
  3. Load database schema to initialize the Tigase server from the file that corresponds to the Tigase version you want to use. First you need to switch to tigasedb.

    psql=# \connect tigasedb

    For the Tigase server version 5.0 and later you have to use proper schema version:

    psql=# \i database/postgresql-schema-5.sql

    For the Tigase server version 5.1 and later you have to use proper schema version:

    psql=# \i database/postgresql-schema-5-1.sql

Configuring From the Linux Shell Command Line

Follow steps below to prepare the PostgreSQL database:

  1. Add the tigase_user:

    createuser -U admin_db_user -W -D -R -S -P tigase_user

    You will be asked for credentials for admin_db_user and password for new database user.

  2. Create the database for the Tigase server with tigase_user as owner of database:

    createdb -U admin_db_user -W -O tigase_user tigasedb
  3. Load database schema to initialize the Tigase server from the file that corresponds to the Tigase version you want to use. For the Tigase server version 5.0 and later you have to use proper schema version:

    psql -q -U tigase_user -W tigasedb -f database/postgresql-schema-5.sql

    For the Tigase server version 5.1 and later you have to use proper schema version:

    psql -q -U tigase_user -W tigasedb -f database/postgresql-schema-5-1.sql

    Above commands should be executed from the main Tigase directory. The initialization schema file should be also available locally in database/ directory of your Tigase installation.