5

How to restart postgresql 8.4 on Debian Squeeze?

/etc/init.d/postgresql stop/start/restart does nothing (no output given).

Daniil Ryzhkov
  • 171
  • 1
  • 1
  • 10
  • 1
    This is the right command, but it may do nothing if, for example, there is no cluster defined. Could you add the output of `pg_lsclusters` ? Also you can invoke `sh -x /etc/init.d/postgresql start` to see the sequence of commands executed inside the script. – Daniel Vérité Aug 22 '12 at 11:24
  • `pg_lsclusters` outputs empty table. Looks like this is what I am looking for. How can I define cluster and will it cause problems with existing postgesql tables? – Daniil Ryzhkov Aug 22 '12 at 11:36
  • No cluster normally means no existing data. A new cluster can be defined with `pg_createcluster` but it will be empty. If you had a cluster previously, you need to understand what happened to it. Is there data under `/var/lib/postgresql/8.4` ? (try `du` there) – Daniel Vérité Aug 22 '12 at 12:35
  • No, `/var/lib/postgresql/8.4` does not exsist. But for some reason my postgresql server works for 3 months. – Daniil Ryzhkov Aug 22 '12 at 12:40
  • Assuming the data is not lost, you need to locate it. Look for directories named `pg_*` and `base`. Also the postgres log files (normally in `/var/log/postgresql`) may shed some light on what happened last time it was running. – Daniel Vérité Aug 22 '12 at 12:53
  • It was runned only one time (and it still works). Log folder is empty. But I have located pg folder: `/usr/lib/postgresql/8.4/` which contains `bin` and `lib` folders – Daniil Ryzhkov Aug 22 '12 at 13:12
  • http://serverfault.com/questions/422727/backup-broken-postgresql-8-4-without-pg-dump/422738#422738 — solution. Thanks to @Daniel Vérité making my problem clearer – Daniil Ryzhkov Aug 30 '12 at 03:48

1 Answers1

0

From the online documentation...

pg_ctl restart [-w] [-t seconds] [-s] [-D datadir] [-c] [-m s[mart] | f[ast] | i[mmediate] ] [-o options]

pg_ctl is a utility for starting, stopping, or restarting the PostgreSQL backend server (postgres), or displaying the status of a running server. Although the server can be started manually, pg_ctl encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.

Oh, and since I ignored this detail in your answer, but now have reason to question it... the default location of postgresql 8.4 is: /etc/init.d/postgresql-8.4, not /etc/init.d/postgresql as you have in your question.

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
  • 1
    `pg_ctl` doesn't work in Debian (command not found). They have `pg_ctlcluster`, but it requires name of the cluster. How to I get the name of my cluster? – Daniil Ryzhkov Aug 22 '12 at 04:28
  • @Daniil See edit. Do you actually have anything at `/etc/init.d/postgresql`, or do you need to be looking at `/etc/init.d/postgresql-8.4`? – HopelessN00b Aug 22 '12 at 04:42
  • `/etc/init.d/postgresql` contains large bash script. `/etc/init.d/postgresql-8.4` does not exsist. – Daniil Ryzhkov Aug 22 '12 at 04:47
  • Also `/etc/init.d/postgresql --help` actually gives output: `Usage: /etc/init.d/postgresql {start|stop|restart|reload|force-reload|status} [version ..]`. And yes, I tried `/etc/init.d/postgresql restart 8.4` – Daniil Ryzhkov Aug 22 '12 at 04:48
  • @Daniil And what do the `status` and `force-reload` switches do? I guess you could always force kill the process, but it's probably more constructive to figure out why it's giving you no output when you try to start, stop or restart it. – HopelessN00b Aug 22 '12 at 04:54
  • @Daniil - Can you post the output of $ ps ax | grep postmaster – Chida Aug 22 '12 at 05:38
  • @ HopelessN00b everything except help outputs nothing. @Chida, ok, wait please – Daniil Ryzhkov Aug 22 '12 at 05:58
  • @HopelessN00b `3814 ttyp2 S+ 0:00 grep postmaster` – Daniil Ryzhkov Aug 22 '12 at 06:13