简体   繁体   English

为 postgresql 初始化数据目录不成功

[英]Initializing data directory for postgresql not successful

I tried to initialize the postgresql data directory, and I get this error :我尝试初始化 postgresql 数据目录,但出现此错误:

[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”;它说“致命:字符 16 处的“-”处或附近的语法错误; but the hostname has to have the “-” due to new server version.但是由于新的服务器版本,主机名必须带有“-”。

I tried doing it without nodename, but for that another problem :我尝试在没有 nodename 的情况下执行此操作,但对于另一个问题:

[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?我该如何解决?

You must be using some fork of PostgreSQL, since initdb does not have a --nodename parameter.您必须使用 PostgreSQL 的某个分支,因为initdb没有--nodename参数。

Whoever wrote that fork didn't do a very good job, since they forgot to properly escape special characters somewhere.写那个 fork 的人做得不好,因为他们忘记在某处正确地转义特殊字符。 You should report that as a bug to the software vendor.您应该将其作为错误报告给软件供应商。

@anaigini I'll move the comment to answer since it worked: @anaigini 我会移动评论来回答,因为它有效:

You may have to pass the name in quotes, so that it substitutes in the query, using --nodename='"vix-db1-1"'.您可能必须在引号中传递名称,以便它在查询中使用 --nodename='"vix-db1-1"' 进行替换。 The outer single-quotes will be used by the shell, leaving the inner double-quotes for the query.外壳程序将使用外部单引号,为查询保留内部双引号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM