没有安装的PostgreSQL在Windows中运行但服务器未在CentOS Linux中启动

问题描述:

我已经从此处下载了Windows版本的PostgreSQL: https:// www。 enterprisedb.com/products-services-training/pgbindownload

I have downloaded the windows version of PostgreSQL from here: https://www.enterprisedb.com/products-services-training/pgbindownload

我解压缩了该文件,并执行了以下命令来运行服务器,该服务器在Windows 10中可以正常工作:

I unzipped it and I executed the commands below to run the server, and it worked in Windows 10:

D:\postmaster_standalone\postgresql-11.0-2-windows-x64-binaries\pgsql\bin>initdb -D C:/Users/myuser/pgdataTest -U postgres -E UTF8

D:\postmaster_standalone\postgresql-11.0-2-windows-x64-binaries\pgsql\bin>pg_ctl -D C:/Users/myuser/pgdataTest start
waiting for server to start....2018-11-20 23:06:37.912 IST [14540] LOG:  listening on IPv6 address "::1", port 5432
2018-11-20 23:06:37.912 IST [14540] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2018-11-20 23:06:38.231 IST [11352] LOG:  database system was shut down at 2018-11-20 23:05:02 IST
2018-11-20 23:06:38.385 IST [14540] LOG:  database system is ready to accept connections
 done
server started

D:\postmaster_standalone\postgresql-11.0-2-windows-x64-binaries\pgsql\bin>psql -U postgres
psql (11.0)
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.

postgres=# 

在我的CentOS中,我检查了 uname -m命令,它将返回x86_64。
从上面的链接中,我下载了Linux x86-64的10.6版二进制文件。

In my CentOS , I checked with uname -m command and it returns x86_64. From the above link I downloaded the binaries for version 10.6 of Linux x86-64.

然后,我按照以下顺序在Windows中执行了类似的步骤,但服务器未启动:

Then, I executed similar steps as in Windows in the below order, but the server is not starting:

[cloudera@quickstart bin]$ initdb -D /home/cloudera/pgdata -U postgres -E UTF8 
The files belonging to this database system will be owned by user "cloudera".
This user must also own the server process.
-----
-----
The database cluster will be initialized with locale en_US.UTF-8.
Success. You can now start the database server using:

    postgres -D /home/cloudera/pgdata
or
    pg_ctl -D /home/cloudera/pgdata -l logfile start

[cloudera@quickstart bin]$ pg_ctl -D /home/cloudera/pgdata/ start
server starting
[cloudera@quickstart bin]$ psql 
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
[cloudera@quickstart bin]$ psql -U postgres
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

我犯了什么错误吗?

您使用的PostgreSQL二进制文件必须对 unix_socket_directories使用更改后的默认值 code>,并且启动服务器的用户无权在此处写入。

The PostgreSQL binary you are using must use a changed default value for unix_socket_directories, and the user that starts the server doesn't have permissions to write there.

要么编辑 / home / cloudera / pgdata / postgresql.conf 并设置

unix_socket_directories = /tmp

或使用

pg_ctl -D /home/cloudera/pgdata/ -o '-k /tmp' start

,使用

psql -h /tmp -U postgres -d postgres