3

I have installed postgresql 9.3 on ubuntu 14.04 using "apt-get install postgresql".

Everything was going well until I discovered that I do not have access to the "pg_ctl" commands. Installing the postgres-xc literally breaks postgresql server. The package links become broken. I cannot re-install and have had to revert my VM and keep working without pg_ctl.

My question is, to get access to this package, should I start from scratch or uninstall and re-install postgresql? What should I have installed in the first place? Alternatively, is there something wrong with my path?

(I am new to postgresql and have been tossed into it for work purposes)

6
  • Please show the error messages. Why are you installing postgres-xc? What does that have to do with anything? There is no "pctl" - do you mean pg_ctl? Commented Jul 28, 2014 at 15:27
  • "The program 'pg_ctl' is currently not installed. To run 'pg_ctl' please ask your administrator to install the package 'postgres-xc'"
    – Dina
    Commented Jul 28, 2014 at 15:34
  • 5
    Oh man, is that why people keep on installing Postgres-XC when they don't know what it is? I need to chase that up with the Ubuntu folks, it should recommend postgres or at least list all the options. pg_ctl is part of the PostgreSQL server package. You do not need postgres-XC, which is a different thing. Commented Jul 28, 2014 at 15:54
  • 1
    I strongly recommend starting here: help.ubuntu.com/community/PostgreSQL Commented Jul 28, 2014 at 16:02
  • @CraigRinger - perhaps you could write up an answer detailing why the Ubuntu apt-get advise is incorrect, and what potentially someone might do to fix this problem? Might help future visitors quite a lot!
    – Hannah Vernon
    Commented Jul 28, 2014 at 18:18

2 Answers 2

8

In Debian/Ubuntu, the functionalities of pg_ctl are provided by pg_ctlcluster. Quoted from its manpage:

NAME

       pg_ctlcluster - start/stop/restart/reload a PostgreSQL cluster

SYNOPSIS

       pg_ctlcluster [options] cluster-version cluster-name action -- [pg_ctl
       options]

       where action = start|stop|restart|reload|promote

DESCRIPTION

       This program controls the postmaster server for a particular cluster.
       It essentially wraps the pg_ctl(1) command. It determines the cluster
       version and data path and calls the right version of pg_ctl with
       appropriate configuration parameters and paths.

It's not technically true that pg_ctl is not installed with postgres packaged for Debian/Ubuntu. It's actually installed in /usr/lib/postgresql/X.Y/bin, where X.Y is the postgres version. This path is intentionally not in any user's default PATH since it should never needed to be invoked directly.

The reason for this setup is that the Debian/Ubuntu packaging supports several PostgreSQL instances running in parallel, either identical or different major versions.

To learn about that, it's best to read first https://help.ubuntu.com/community/PostgreSQL , before the real PostgreSQL manual or any other non-Ubuntu documentation.

postgres-xc is a multi-master fork of PostgreSQL that shouldn't be confused with PostgreSQL itself. The hint suggesting to install it to get pg_ctl is an unfortunate nonsense, probably a machine-generated advice based on the contents of postgres-xc.

3
  • yes, this worked.
    – Dina
    Commented Jul 29, 2014 at 22:06
  • 1
    If you don't generally work with clusters, you may need to know that to find the name of your cluster, use: pg_lscluster. pg_ctlcluster requires the cluster name to complete whatever action you are trying to do. Commented Feb 9, 2015 at 15:51
  • pg_ctlcluster does not completely replace pg_ctl, as it does not allow passing a port number as a command line argument. Commented Sep 1, 2016 at 23:29
0

As these command pg_ctl and initdb were installed with postgresql and these are present at "/usr/lib/postgresql/9.3/bin" so change the $PATH environment variable so that you can use it like export PATH=/usr/lib/postgresql/9.3/bin:$PATH

but make sure that you are logged in at postgres user as this is the one who is creating the server for you.

I hope i was able to provide you solution Thank you,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.