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

时间:2018-10-24 07:20:57

标签: postgresql centos7 postgresql-11

我在CentOS Linux版本7.5.1804(核心)中

当我以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$

然后我跑步

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$

我在GOOGLE中搜索“正在等待服务器启动。.../ bin / sh:日志文件:权限被拒绝”,但是此错误仅在MAC中发生,并且未显示解决方案...

我也跑

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

那我相信PostgreSQL 11可以很好地安装,但是我无法启动服务器。

我用这行安装:

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

我没有添加[postgresql11-llvmjit.x86_64],因为这需要很多依赖。

CentOS Linux版本7.5.1804 + PostgreSQL 11吗?

我需要安装其他软件吗?

3 个答案:

答案 0 :(得分:2)

const discord = require('discord.js'); const bot = new discord.Client(); const cfg = require('./config.json') bot.on('ready', () => {//this works console.log(`Logged in as ${bot.user.tag}(${bot.user.id}) on ${bot.guilds.size} servers`) }); bot.on('message', (msg) => { switch (msg.content) { case '/epicinfo': msg.channel.send('w00t'); //this works } }); console.log(bot.users.get("id", "504658757419270144")) //undefined console.log(bot.channels.get("name", "testbot")) //undefined console.log(bot.users.find("id", "504658757419270144")) //undefined console.log(bot.channels.find("name", "testbot")) //undefined console.log(bot.guilds.get("504658757419270144")); //undefined console.log(bot.channels.get(504658757419270144)) //undefined bot.send((discord.Object(id = '504658757419270144'), 'Hello')) //discord.Object is not a function bot.login(cfg.token); 不能从字面上理解,应替换为PostgreSQL服务器进程具有写许可权的文件。

您通常不会那样做,而是编辑logfile并配置postgresql.conflog_destinationlogging_collectorlog_directory。然后,您可以不使用log_filename选项来启动PostgreSQL。

您尝试使用-l启动PostgreSQL的尝试可能有效;您可以使用

进行检查
systemctl

答案 1 :(得分:2)

因此,我遇到了同样的问题。 首先,我使用以下命令检查了我的计算机上是否以及所有服务器是否都处于活动状态:

brew services list

然后我有一些服务器处于活动状态,所以我停止了它们,因为您需要停止它们才能使posgresql服务器正常工作。

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

然后我创建了一个新数据库

initdb /usr/local/var/postgres2

并使用

启动服务器
 pg_ctl -D /usr/local/var/postgres2 -l logfile start

对我来说很好! enter image description here

答案 2 :(得分:0)

谢谢,现在一切正常¿?:

[root@myhost ~]# systemctl status postgresql-11
â postgresql-11.service - PostgreSQL 11 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-11.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2018-10-24 02:34:19 -05; 1 day 13h ago
     Docs: https://www.postgresql.org/docs/11/static/
  Process: 17927 ExecStartPre=/usr/pgsql-11/bin/postgresql-11-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 17933 (postmaster)
   CGroup: /system.slice/postgresql-11.service
           ââ17933 /usr/pgsql-11/bin/postmaster -D /var/lib/pgsql/11/data/
           ââ17935 postgres: logger
           ââ17937 postgres: checkpointer
           ââ17938 postgres: background writer
           ââ17939 postgres: walwriter
           ââ17940 postgres: autovacuum launcher
           ââ17941 postgres: stats collector
           ââ17942 postgres: logical replication launcher

Oct 24 02:34:19 myhost.myserver.net systemd[1]: Starting PostgreSQL 11 database server...
Oct 24 02:34:19 myhost.myserver.net postmaster[17933]: 2018-10-24 02:34:19.339 -05 [17933] LOG:  listening on IPv6 address "::1", port 5432
Oct 24 02:34:19 myhost.myserver.net postmaster[17933]: 2018-10-24 02:34:19.340 -05 [17933] LOG:  listening on IPv4 address "127.0.0.1", port 5432
Oct 24 02:34:19 myhost.myserver.net postmaster[17933]: 2018-10-24 02:34:19.355 -05 [17933] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
Oct 24 02:34:19 myhost.myserver.net postmaster[17933]: 2018-10-24 02:34:19.396 -05 [17933] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
Oct 24 02:34:19 myhost.myserver.net postmaster[17933]: 2018-10-24 02:34:19.430 -05 [17933] LOG:  redirecting log output to logging collector process
Oct 24 02:34:19 myhost.myserver.net postmaster[17933]: 2018-10-24 02:34:19.430 -05 [17933] HINT:  Future log output will appear in directory "log".
Oct 24 02:34:19 myhost.myserver.net systemd[1]: Started PostgreSQL 11 database server.
[root@myhost ~]#

但是:

[root@myhost ~]# service postgresql status
Redirecting to /bin/systemctl status postgresql.service
Unit postgresql.service could not be found.
[root@myhost ~]#

[root@myhost ~]# /etc/init.d/postgresql status
-bash: /etc/init.d/postgresql: No such file or directory
[root@myhost ~]#

请问:我该如何解决?

致谢