Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
186 views
in Technique[技术] by (71.8m points)

Postgresql Start failed

psql (PostgreSQL) 9.5.5 sorry for my eng lang.

can't connect to 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.

Try to connect:

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?

In my postgresql.conf i have listen all = '*' and port 5432

sudo netstat -pant | grep postgres - nothing show

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

And

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"?

After reboot check status

● 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.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I would look at /var/log to see if it wrote a log.

If it did not, I would attempt to start it manually to the database:

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

The -d 5 command sets debugging to level 5. The -D command tells PostgreSQL where the database files are. The above directory is the location where PostgreSQL 9.6 runs on FreeBSD. If you are running Ubuntu, the directory should be /var/lib/postgresql/[PostgreSQL version]/data/. The PostgreSQL default data directory is /usr/local/pgsql/data.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...