我正在设置一个新的虚拟服务器来运行Netbox,这是IP地址管理服务器。我正在安装所有依赖项,并且在PostgreSQL服务器数据库初始化方面遇到麻烦。
我在CentOS 7上安装了PostgreSQL 9.6(在CentOS 7上也尝试了PostgreSQL 9.5,但出现了同样的问题)。
我无法初始化数据库。
我在网上找到的安装指南都说同样的话:
按如下所示初始化数据库:
# /usr/pgsql-9.6/bin/postgresql96-setup initdb
这将产生以下输出:
-bash: /usr/pgsql-9.6/bin/postgresql96-setup: No such file or directory
因此看来文件“ postgresql96-setup”在文件系统上不存在。
我已经使用find命令尝试如下查找文件:
find / -name "postgresql96-setup"
find命令什么也找不到。
下面是文件夹/usr/pgsql-9.6/bin /
的内容[root@prdsw1mgtapp39 bin]# ls -lh
total 9.6M
-rwxr-xr-x 1 root root 52K May 8 10:08 clusterdb
-rwxr-xr-x 1 root root 52K May 8 10:08 createdb
-rwxr-xr-x 1 root root 85K May 8 10:08 createlang
-rwxr-xr-x 1 root root 57K May 8 10:08 createuser
-rwxr-xr-x 1 root root 48K May 8 10:08 dropdb
-rwxr-xr-x 1 root root 85K May 8 10:08 droplang
-rwxr-xr-x 1 root root 48K May 8 10:08 dropuser
-rwxr-xr-x 1 root root 844K May 8 10:08 ecpg
-rwxr-xr-x 1 root root 98K May 8 10:08 initdb
-rwxr-xr-x 1 root root 24K May 8 10:08 oid2name
-rwxr-xr-x 1 root root 15K May 8 10:08 pg_archivecleanup
-rwxr-xr-x 1 root root 72K May 8 10:08 pg_basebackup
-rwxr-xr-x 1 root root 121K May 8 10:08 pgbench
-rwxr-xr-x 1 root root 26K May 8 10:08 pg_config
-rwxr-xr-x 1 root root 36K May 8 10:08 pg_controldata
-rwxr-xr-x 1 root root 41K May 8 10:08 pg_ctl
-rwxr-xr-x 1 root root 379K May 8 10:08 pg_dump
-rwxr-xr-x 1 root root 85K May 8 10:08 pg_dumpall
-rwxr-xr-x 1 root root 48K May 8 10:08 pg_isready
-rwxr-xr-x 1 root root 50K May 8 10:08 pg_receivexlog
-rwxr-xr-x 1 root root 54K May 8 10:08 pg_recvlogical
-rwxr-xr-x 1 root root 44K May 8 10:08 pg_resetxlog
-rwxr-xr-x 1 root root 148K May 8 10:08 pg_restore
-rwxr-xr-x 1 root root 76K May 8 10:08 pg_rewind
-rwxr-xr-x 1 root root 20K May 8 10:08 pg_standby
-rwxr-xr-x 1 root root 18K May 8 10:08 pg_test_fsync
-rwxr-xr-x 1 root root 13K May 8 10:08 pg_test_timing
-rwxr-xr-x 1 root root 112K May 8 10:08 pg_upgrade
-rwxr-xr-x 1 root root 66K May 8 10:08 pg_xlogdump
-rwxr-xr-x 1 root root 6.2M May 8 10:08 postgres
lrwxrwxrwx 1 root root 8 Jun 7 20:23 postmaster -> postgres
-rwxr-xr-x 1 root root 526K May 8 10:08 psql
-rwxr-xr-x 1 root root 56K May 8 10:08 reindexdb
-rwxr-xr-x 1 root root 60K May 8 10:08 vacuumdb
-rwxr-xr-x 1 root root 21K May 8 10:08 vacuumlo
我在这里错过了什么吗? 如果缺少作为安装二进制文件(/usr/pgsql-9.6/bin/postgresql96-setup)的文件,我应该如何运行Initialize数据库命令?
安装二进制文件是否已被弃用,还是需要创建链接或其他脚本? 我什至安装了PostgreSQL 9.5来查看该版本中是否存在该文件,但实际上不存在。
我运行了在CentOS 7上设置PostgreSQL 9.3的指南中给出的“替代”命令:
sudo service postgresql-9.3 initdb
如果上一条命令失败,请直接调用安装程序二进制文件:
sudo /usr/pgsql-9.3/bin/postgresql93-setup initdb
我运行了命令:
service postgresql-9.6 initdb
这有效,并且我能够设置数据库,创建用户,创建表等,但是重新启动后,PostgrSQL-9.6服务无法启动。
这是postgresql 9.6的systemctl的输出
[root@prdsw1mgtapp39 bin]# systemctl | grep postgres*
UNIT LOAD ACTIVE SUB DESCRIPTION
● postgresql-9.6.service loaded failed failed SYSV: PostgreSQL database server.
这是postgresql-9.6服务的systemctl状态
[root@prdsw1mgtapp39 bin]# systemctl status postgresql-9.6.service
● postgresql-9.6.service - SYSV: PostgreSQL database server.
Loaded: loaded (/etc/rc.d/init.d/postgresql-9.6; bad; vendor preset:
disabled)
Active: failed (Result: exit-code) since Sun 2019-06-09 10:50:27 BST;
2h 40min ago
Docs: man:systemd-sysv-generator(8)
Process: 26266 ExecStart=/etc/rc.d/init.d/postgresql-9.6 start
(code=exited, status=1/FAILURE)
Jun 09 10:50:24 prdsw1mgtapp39 systemd[1]: Starting
SYSV: PostgreSQL database server....
Jun 09 10:50:27 prdsw1mgtapp39 postgresql-9.6[26266]:
Starting postgresql-9.6 service: [FAILED]
Jun 09 10:50:27 prdsw1mgtapp39 systemd[1]:
postgresql-9.6.service: control process exited, code=exited status=1
Jun 09 10:50:27 prdsw1mgtapp39 systemd[1]: Failed to
start SYSV: PostgreSQL database server..
Jun 09 10:50:27 prdsw1mgtapp39 systemd[1]: Unit
postgresql-9.6.service entered failed state.
Jun 09 10:50:27 prdsw1mgtapp39 systemd[1]:
postgresql-9.6.service failed.
我正在以root用户身份进行操作,并且遇到某些情况,它抱怨并告诉我以较低特权用户身份运行,在这种情况下,我打开另一个终端并以用户身份登录,并在必要时使用sudo选项。
任何建议都非常感谢。