Postgresql启动失败

时间:2016-12-01 01:03:01

标签: postgresql

psql(PostgreSQL)9.5.5 对不起我的英语。

无法连接到DataBase。

postgresql.service - LSB: PostgreSQL RDBMS server
   Loaded: loaded (/etc/init.d/postgresql; bad; vendor preset: enabled)
   Active: active (exited) since Thu 2016-12-01 00:53:23 UTC; 2s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 25257 ExecStop=/etc/init.d/postgresql stop (code=exited, status=0/SUCCESS)
  Process: 24764 ExecReload=/etc/init.d/postgresql reload (code=exited, status=0/SUCCESS)
  Process: 25293 ExecStart=/etc/init.d/postgresql start (code=exited, status=0/SUCCESS)
 Main PID: 1058 (code=exited, status=0/SUCCESS)

Dec 01 00:53:23 Ubuntu-1604-xenial-64-minimal systemd[1]: Starting LSB: PostgreSQL RDBMS server...
Dec 01 00:53:23 Ubuntu-1604-xenial-64-minimal systemd[1]: Started LSB: PostgreSQL RDBMS server.

尝试连接:

psql -h localhost -p 5432 -U postgres -W
Password for user postgres: 
psql: could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?

在我的postgresql.conf中,我听了所有=' *'和5432港口

sudo netstat -pant | grep postgres - 没什么显示

root@Ubuntu-1604-xenial-64-minimal /var/log # tail postgresql/postgresql-9.5-main.log
2016-11-28 23:58:21 UTC [897-3] LOG:  invalid record length at 0/14CC9C90
2016-11-28 23:58:21 UTC [897-4] LOG:  redo is not required
2016-11-28 23:58:21 UTC [897-5] LOG:  MultiXact member wraparound protections are now enabled
2016-11-28 23:58:21 UTC [847-1] LOG:  database system is ready to accept connections
2016-11-28 23:58:21 UTC [909-1] LOG:  autovacuum launcher started
2016-11-28 23:58:21 UTC [915-1] [unknown]@[unknown] LOG:  incomplete startup packet
2016-11-29 22:43:00 UTC [847-2] LOG:  received smart shutdown request
2016-11-29 22:43:00 UTC [909-2] LOG:  autovacuum launcher shutting down
2016-11-29 22:43:00 UTC [906-1] LOG:  shutting down
2016-11-29 22:43:00 UTC [906-2] LOG:  database system is shut down

postgres@Ubuntu-1604-xenial-64-minimal:~/9.5/main$ ls
base  global  pg_clog  pg_commit_ts  pg_dynshmem  pg_logical  pg_multixact  pg_notify  pg_replslot  pg_serial  pg_snapshots  pg_stat  pg_stat_tmp  pg_subtrans  pg_tblspc  pg_twophase  PG_VERSION  pg_xlog  postgresql.auto.conf  postmaster.opts

并且

root@Ubuntu-1604-xenial-64-minimal ~ # sudo systemctl start postgresql
root@Ubuntu-1604-xenial-64-minimal ~ # sudo su - postgres -c psql
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

重启后检查状态

● postgresql.service - LSB: PostgreSQL RDBMS server
   Loaded: loaded (/etc/init.d/postgresql; bad; vendor preset: enabled)
   Active: active (exited) since Thu 2016-12-01 02:21:43 UTC; 13min ago
     Docs: man:systemd-sysv-generator(8)

Dec 01 02:21:43 Ubuntu-1604-xenial-64-minimal systemd[1]: Starting LSB: PostgreSQL RDBMS server...
Dec 01 02:21:43 Ubuntu-1604-xenial-64-minimal systemd[1]: Started LSB: PostgreSQL RDBMS server.
Dec 01 02:25:56 Ubuntu-1604-xenial-64-minimal systemd[1]: Started LSB: PostgreSQL RDBMS server.

1 个答案:

答案 0 :(得分:0)

我会查看/ var / log以查看它是否写了一个日志。

如果没有,我会尝试手动启动数据库:

su - postgres
postgres -d 5 -D /var/db/postgres/data96

-d 5命令将调试设置为级别5. -D命令告诉PostgreSQL数据库文件在哪里。上面的目录是PostgreSQL 9.6在FreeBSD上运行的位置。如果您正在运行Ubuntu,则该目录应为/ var / lib / postgresql / [PostgreSQL版本] / data /。 PostgreSQL默认数据目录是/ usr / local / pgsql / data。

相关问题