如何在 CentOS 6.5 上启动 Postgres?

如何在 CentOS 6.5 上启动 Postgres?

每当我尝试启动 Postgres 时,它都会给出错误。即使我删除它所抱怨的目录,它仍然会失败。

[root@ip-172-31-15-65 init.d]# service postgresql start

/var/lib/pgsql/data is missing. Use "service postgresql initdb" to initialize the cluster first.
                                                           [FAILED]
[root@ip-172-31-15-65 init.d]# service postgresql initdb
Initializing database: mkdir: cannot create directory `/var/lib/pgsql/data/pg_log': File exists
                                                           [FAILED]
[root@ip-172-31-15-65 init.d]# rmdir /var/lib/pgsql/data/pg_log
[root@ip-172-31-15-65 init.d]# service postgresql start

/var/lib/pgsql/data is missing. Use "service postgresql initdb" to initialize the cluster first.
                                                           [FAILED]
[root@ip-172-31-15-65 init.d]# service postgresql initdb
Initializing database:                                     [FAILED]

[root@ip-172-31-15-65 init.d]# service postgresql initdb
Initializing database: mkdir: cannot create directory `/var/lib/pgsql/data/pg_log': File exists
                                                           [FAILED]

版本:postgresql-server-8.4.20-1.el6_5.x86_64

答案1

这有效。

rpm -Uvh http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm

yum install postgresql93-server postgresql93-contrib
service postgresql-9.3 initdb

/etc/init.d/postgresql-9.3 start
chkconfig postgresql-9.3 on

这也许也可以:

yum install pgdg-centos93.noarch # in place of rpm
service postgres-9.3 start # in place of init.d

相关内容