简体   繁体   English

我无法启动服务器 PostgreSQL 11:“pg_ctl:无法启动服务器”

[英]I can't start server PostgreSQL 11: "pg_ctl: could not start server"

I am in CentOS Linux release 7.5.1804 (Core)我在 CentOS Linux 版本 7.5.1804(核心)

When I login as postgres and run:当我以postgres身份登录并运行时:

bash-4.2$ /usr/pgsql-11/bin/initdb -D /var/lib/pgsql/11/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/11/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
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/pgsql-11/bin/pg_ctl -D /var/lib/pgsql/11/data -l logfile start

bash-4.2$

then I run然后我跑

bash-4.2$ /usr/pgsql-11/bin/pg_ctl start -l logfile -D /var/lib/pgsql/11/data
waiting for server to start..../bin/sh: logfile: Permission denied
 stopped waiting
pg_ctl: could not start server
Examine the log output.
bash-4.2$ date
Wed Oct 24 01:50:44 -05 2018
bash-4.2$

I search in GOOGLE for "waiting for server to start..../bin/sh: logfile: Permission denied" but this error only happened in MAC and no solutions is displayed...我在 GOOGLE 中搜索“等待服务器启动..../bin/sh: logfile: Permission denied”但是这个错误只发生在 MAC 中并且没有显示解决方案...

Also I run我也跑

bash-4.2$ postgres --version;postmaster --version;
postgres (PostgreSQL) 11.0
postgres (PostgreSQL) 11.0
bash-4.2$

then I believe PostgreSQL 11 is fine installed, but I can't start server.然后我相信 PostgreSQL 11 安装得很好,但我无法启动服务器。

I install with this line:我用这条线安装:

yum install postgresql-jdbc.noarch postgresql-jdbc-javadoc.noarch postgresql-unit11.x86_64 postgresql-unit11-debuginfo.x86_64 postgresql11.x86_64 postgresql11-contrib.x86_64 postgresql11-debuginfo.x86_64 postgresql11-devel.x86_64 postgresql11-docs.x86_64 postgresql11-libs.x86_64 postgresql11-odbc.x86_64 postgresql11-plperl.x86_64 postgresql11-plpython.x86_64 postgresql11-pltcl.x86_64 postgresql11-server.x86_64 postgresql11-tcl.x86_64 postgresql11-test.x86_64

I didn't add [postgresql11-llvmjit.x86_64] because this requires many dependences.我没有添加 [postgresql11-llvmjit.x86_64] 因为这需要很多依赖。

CentOS Linux release 7.5.1804 + PostgreSQL 11? CentOS Linux 版本 7.5.1804 + PostgreSQL 11?

Do I need install aditional software?我需要安装其他软件吗?

The logfile is not to be taken literally, it should be replaced with a file where the PostgreSQL server process has write permission. logfile不是字面上的,它应该替换为 PostgreSQL 服务器进程具有写入权限的文件。

You don't do it that way normally, rather you edit postgresql.conf and configure log_destination , logging_collector , log_directory and log_filename .您通常不会那样做,而是编辑postgresql.conf并配置log_destinationlogging_collectorlog_directorylog_filename Then you start PostgreSQL without the -l option.然后你在没有-l选项的情况下启动 PostgreSQL。

Your attempt to start PostgreSQL with systemctl probably did work;您尝试使用systemctl启动 PostgreSQL 可能确实有效; you can check with你可以检查

systemctl status postgresql-11

So, I faced the same issue.所以,我遇到了同样的问题。 First I checked for if and what all servers were active on my machine using :首先,我使用以下命令检查我的机器上是否以及所有服务器都处于活动状态:

brew services list

Then I had some servers active so I stopped them as you need to stop them for posgresql server to work.然后我有一些服务器处于活动状态,所以我停止了它们,因为您需要停止它们以使 posgresql 服务器工作。

brew services stop < name of the server/s active >

Then I created a new database然后我创建了一个新的数据库

initdb /usr/local/var/postgres2

and started the server using并使用启动服务器

 pg_ctl -D /usr/local/var/postgres2 -l logfile start

Worked fine for me !!对我来说很好用!! enter image description here在此处输入图片说明

I think there is a background postgres process running and firstly you need to kill this service.我认为有一个后台 postgres 进程正在运行,首先你需要终止这个服务。 I had same problem and fixed by this command:我有同样的问题并通过这个命令修复:

sudo /etc/init.d/postgresql stop

Then you can start the server as:然后您可以将服务器启动为:

sudo -u <your-username> pg_ctl -D <your-database-file-location> start

An example for this:一个例子:

sudo -u shc /home/shc/postgres-built/bin/pg_ctl -D /home/shc/mydatabase start

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

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