Services running multiple times?

2

I've installed a postgres db on my debian squeeze. There's a /etc/init.d/postresql to control the database. When I type pstree -c, I get two traces with postgresql. After /etc/init.d/postgresl stop I have still one trace left with postgresql. Where do I have to look for this issue? Is there an entry to start another postgresql at booting time? Where can I see this?

strauberry

Posted 2011-08-01T13:31:23.727

Reputation: 527

Answers

1

Assuming you have PostgreSQL installed from repository packages (e.g. postgresql-8.4) this is perfectly possible if second cluster (let's say test) is set in manual mode:

cat /etc/postgresql/8.4/test/start.conf 
# Automatic startup configuration
# auto: automatically start/stop the cluster in the init script
# manual: do not start/stop in init scripts, but allow manual startup with
#         pg_ctlcluster
# disabled: do not allow manual startup with pg_ctlcluster (this can be easily
#           circumvented and is only meant to be a small protection for
#           accidents).

manual

You can check all registered clusters by pg_lsclusters command:

pg_lsclusters 
Version Cluster   Port Status Owner    Data directory                     Log file
8.4     main      5432 online postgres /var/lib/postgresql/8.4/main       /var/log/..
8.4     test      5433 online postgres /var/lib/postgresql/8.4/test       /var/log/..

pstree -c | grep postgres result:

 |-postgres-+-postgres
 |          |-postgres
 |          |-postgres
 |          `-postgres
 |-postgres-+-postgres
 |          |-postgres
 |          |-postgres
 |          `-postgres

Manual mode (as opposite to auto) means that DB cluster is not handled by /etc/init.d/postgresql script, so after:

# /etc/init.d/postgresql stop

there is still one working server's instance:

pg_lsclusters 
Version Cluster   Port Status Owner    Data directory                     Log file
8.4     main      5432 down   postgres /var/lib/postgresql/8.4/main       /var/log/..
8.4     test      5433 online postgres /var/lib/postgresql/8.4/test       /var/log/..

and pstree returns remaining trace:

 |-postgres-+-postgres
 |          |-postgres
 |          |-postgres
 |          `-postgres

To shut down remaining instance explicitly use:

# pg_ctlcluster 8.4 test stop

Grzegorz Szpetkowski

Posted 2011-08-01T13:31:23.727

Reputation: 76

Thank you very much for this interesting answer!! I'll check this next week at office and after that accept it :-) – strauberry – 2011-08-12T09:07:49.440

Hi, I found the mistake with your manual: in the start.conf I can see "auto", so it is handled via init.d. Additionally, I started a postgres-server manually with /usr/lib/postgresql/8.4/bin/pg_ctl start... so there are many instances. Thank you! – strauberry – 2011-09-29T08:46:45.370