0

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?

anaigini
  • 11
  • 2
  • try inside quote --nodename='vix-db1-1' or --nodename="vix-db1-1 -D" – I S Aug 24 '20 at 03:09
  • 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. – mike.k Aug 24 '20 at 03:14
  • There is no parameter `nodename` for initdb:https://www.postgresql.org/docs/current/app-initdb.html –  Aug 24 '20 at 05:29
  • @mike.k that worked, thx! – anaigini Aug 24 '20 at 05:45

2 Answers2

2

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.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • Thx @Laurenz Albe, will take note of this. This was postgresql-xl - don't know what is the difference, but I think it works with HA (failover) nodes. – anaigini Aug 25 '20 at 07:24
0

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

mike.k
  • 3,277
  • 1
  • 12
  • 18