Short tip: CentOS 7.4, PostgreSQL 9.2.23 and Spacewalk 2.7: Could not install database

When installing Spacewalk 2.7 under CentOS 7.4 along with PostgreSQL 9.2.23, I recently stumbled upon the following error:

1# spacewalk-setup
2* Setting up SELinux..
3** Database: Setting up database connection for PostgreSQL backend.
4** Database: Installing the database:
5** Database: This is a long process that is logged in:
6** Database:   /var/log/rhn/install_db.log
7*** Progress: ####
8Could not install database.

The mentioned log file contained the following errors:

 1# less /var/log/rhn/install_db.log
 2...
 3Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql.service to /usr/lib/systemd/system/postgresql.service.
 4Hint: the preferred way to do this is now "postgresql-setup initdb"
 5Initializing database ... OK
 6
 7/usr/bin/spacewalk-setup-postgresql: Line 165: [: 018446744073692774399: integer expression expected.
 8Redirecting to /bin/systemctl start postgresql.service
 9createdb: database creation failed: ERROR:  new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
10HINT:  Use the same encoding as in the template database, or use template0 as template.

The hint regarding the postgresql-setup command is particularly noticeable. Luckily, I've created a snapshot of the system enabling me to "rewind" in order to check the hint.

Even though the system's localisation configuration was correct, I had to run the following command to successfully initialise the PostgreSQL database:

1# LANG=en_US.utf8 postgresql-setup initdb

Afterwards, installation Spacewalk was possible - even tough a blank terminal was opened during the process. After stopping the process, the installation proceeded:

 1# spacewalk-setup
 2* Setting up SELinux..
 3** Database: Setting up database connection for PostgreSQL backend.
 4** Database: Installing the database:
 5** Database: This is a long process that is logged in:
 6** Database:   /var/log/rhn/install_db.log
 7*** Progress: #
 8** Database: Installation complete.
 9** Database: Populating database.
10...

It seems like this behaviour is a bug that effects Red Hat Enterprise Linux 7 and other Linux distributions based on it - such as CentOS 7.

Translations: