Initializing data directory for postgresql not successful

891 Views Asked by At

I tried to initialize the postgresql data directory, and I get this error :

[postgres@vix-db1-1 ~]$ /usr/pgsql-9.5/bin/initdb --nodename=vix-db1-1 -D /var/lib/pgsql/9.5/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
creating directory /var/lib/pgsql/9.5/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
creating template1 database in /var/lib/pgsql/9.5/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
creating cluster information ... FATAL:  syntax error at or near "-" at character 16
STATEMENT:  CREATE NODE vix-db1-1 WITH (type = 'coordinator');
child process exited with exit code 1
initdb: removing data directory "/var/lib/pgsql/9.5/data"

It says “FATAL: syntax error at or near “-” at character 16”; but the hostname has to have the “-” due to new server version.

I tried doing it without nodename, but for that another problem :

[postgres@vix-db1-1 ~]$ /usr/pgsql-9.5/bin/initdb -D /var/lib/pgsql/9.5/data
initdb: Postgres-XL node name is mandatory
Try "initdb --help" for more information.
[postgres@vix-db1-1 ~]$

How do I resolve this?

2

There are 2 best solutions below

1
On

You must be using some fork of PostgreSQL, since initdb does not have a --nodename parameter.

Whoever wrote that fork didn't do a very good job, since they forgot to properly escape special characters somewhere. You should report that as a bug to the software vendor.

0
On

@anaigini I'll move the comment to answer since it worked:

You may have to pass the name in quotes, so that it substitutes in the query, using --nodename='"vix-db1-1"'. The outer single-quotes will be used by the shell, leaving the inner double-quotes for the query.