postgresql服务未在RHEL 7上运行



我们有一个在RHEL6/32位和RHEL6/64位上运行的应用程序。这个应用程序从一开始就使用postgresql8.4。现在,我们希望在RHEL7/64位上为该应用程序提供支持。RHEL7在其百胜列表中提供了默认的postgresql9.2,它正在安装中,其相关服务也在正常运行。但是在RHEL7上安装postgresql8.4之后,这些服务似乎从未运行过。请在日志下面找到:

[root@linpubn218 postgres]# service postgresql status
postgresql.service - SYSV: PostgreSQL database server.
   Loaded: loaded (/etc/rc.d/init.d/postgresql)
      Active: failed (Result: resources) since Mon 2016-07-25 12:40:28 IST; 2h 0min ago
           Docs: man:systemd-sysv-generator(8)
Jul 25 12:40:26 linpubn218.gl.avaya.com systemd[1]: Starting SYSV: PostgreSQL database server....
Jul 25 12:40:28 linpubn218.gl.avaya.com postgresql[26957]: Starting postgresql service: [  OK  ]
Jul 25 12:40:28 linpubn218.gl.avaya.com systemd[1]: PID file /var/run/postmaster-8.4.pid not readable (yet?) after start.
Jul 25 12:40:28 linpubn218.gl.avaya.com systemd[1]: Failed to start SYSV: PostgreSQL database server..
Jul 25 12:40:28 linpubn218.gl.avaya.com systemd[1]: Unit postgresql.service entered failed state.
Jul 25 12:40:28 linpubn218.gl.avaya.com systemd[1]: postgresql.service failed.
Jul 25 14:33:45 linpubn218.gl.avaya.com systemd[1]: Unit postgresql.service cannot be reloaded because it is inactive.
Jul 25 14:33:45 linpubn218.gl.avaya.com systemd[1]: Unit postgresql.service cannot be reloaded because it is inactive.

在查看了journalcl-xe 中的日志之后

[root@linpubn218 postgres]# journalctl -xe
Jul 25 14:39:21 linpubn218.gl.avaya.com yum[29260]: Installed: postgresql84-libs-8.4.17-1PGDG.rhel6.x86_64
Jul 25 14:39:45 linpubn218.gl.avaya.com yum[29275]: Installed: postgresql84-8.4.17-1PGDG.rhel6.x86_64
Jul 25 14:40:01 linpubn218.gl.avaya.com useradd[29316]: failed adding user 'postgres', exit code: 9
Jul 25 14:40:02 linpubn218.gl.avaya.com CROND[29320]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 25 14:40:02 linpubn218.gl.avaya.com systemd[1]: Reloading.
Jul 25 14:40:03 linpubn218.gl.avaya.com systemd[1]: Configuration file /usr/lib/systemd/system/auditd.service is marked world-inaccessible. This has no effect as config
Jul 25 14:40:03 linpubn218.gl.avaya.com yum[29309]: Installed: postgresql84-server-8.4.17-1PGDG.rhel6.x86_64
Jul 25 14:42:05 linpubn218.gl.avaya.com polkitd[819]: Registered Authentication Agent for unix-process:29459:43987285 (system bus name :1.292 [/usr/bin/pkttyagent --not
Jul 25 14:42:05 linpubn218.gl.avaya.com systemd[1]: Starting SYSV: PostgreSQL database server....
Jul 25 14:42:06 linpubn218.gl.avaya.com runuser[29473]: pam_unix(runuser-l:session): session closed for user postgres
Jul 25 14:42:08 linpubn218.gl.avaya.com postgresql[29464]: Starting postgresql service: [  OK  ]
Jul 25 14:42:08 linpubn218.gl.avaya.com systemd[1]: PID file /var/run/postmaster-8.4.pid not readable (yet?) after start.
Jul 25 14:42:08 linpubn218.gl.avaya.com systemd[1]: Failed to start SYSV: PostgreSQL database server..

postgresql8.4可以安装在RHEL7上吗?RHEL7是一个基于systemd的操作系统?如果是,那么我应该怎么做才能消除上述错误?

我注意到在/etc/init.d/postgresql-8.4中有一个声明的变量:

pidfile="/var/run/postmaster-${PGMAJORVERSION}.${PGPORT}.pid"

但在systemctl中,PIDfile不同:

# systemctl show postgresql-8.4.service -p PIDFile PIDFile=/var/run/postmaster-8.4.pid

因此,要解决此问题,请编辑/etc/init.d/postgresql-8.4并替换

pidfile="/var/run/postmaster-${PGMAJORVERSION}.${PGPORT}.pid"

带有

pidfile="/var/run/postmaster-${PGMAJORVERSION}.pid"

然后重新加载systemctl:

# systemctl daemon-reload
#/etc/init.d/postgresql-8.4 start
Starting postgresql-8.4 (via systemctl):                   [  OK  ]

通常权限会导致出现这种类型的错误

su - postgres

之后:

chmod 700 -R <data_directory>

你也应该检查SELinux。

最新更新