postgresql does not start
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
postgresql-8.2 (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: postgresql-8.2
uname -a
Linux s2 2.6.22-14-generic #1 SMP Sun Oct 14 21:45:15 GMT 2007 x86_64 GNU/Linux
apt-get install postgresql-8.2
installs the server but does not start it.
Directory /etc/postgres and configuration files missing
Any suggestions?
Thomas Babut (thbabut) wrote : | #1 |
Volker Paul (v.paul) wrote : | #2 |
Maybe you need to run initdb.
Wolf Rogner (war-rsb) wrote : | #3 |
sudo dpkg -l | grep postgres:
ii postgresql 8.2.5-1.1 object-relational SQL database (latest versi
ii postgresql-8.2 8.2.5-1.1 object-relational SQL database, version 8.2
ii postgresql-
ii postgresql-
ii postgresql-common 78 manager for PostgreSQL database clusters
ii postgresql-doc 8.2.5-1.1 documentation for the PostgreSQL database ma
ii postgresql-doc-8.2 8.2.5-1.1 documentation for the PostgreSQL database ma
ii postgresql-
running /usr/lib/
Starting postgres manually works now, but starting postgres at boot time still does not work.
Thomas Babut (thbabut) wrote : | #4 |
Is there a symlink in the default runlevel?
# ls -l /etc/rc*
Have you also tried to remove and purge all postgresql packages and to install it again?
# apt-get remove --purge libpq5 postgresql postgresql-8.2 postgresql-
# apt-get install postgresql-8.2
Does after that the problem still exist?
Thomas Babut (thbabut) wrote : | #5 |
Please notice that purging the postgresql packages all postgresql related configuration files and I think databases too will be deleted.
Thomas Babut (thbabut) wrote : | #6 |
I cannot confirm this bug, so more informations are needed.
Changed in postgresql-8.2: | |
status: | New → Incomplete |
Wolf Rogner (war-rsb) wrote : | #7 |
First: Thanks for the hints. I could start postgres and get webmin to show databases.
Re. your questions:
1. Yes there are symlinks in the rc?.d directories. They point to /etc/init.
2. Initially I have tried to remove and reinstall postgresql
3. I am going on from here (postgresql and addons installed) and try to fix the problem here
Question: Should postgres database should be launched after installing the package or is there some preconfiguration required (there is no documentation about this available)
Thomas Babut (thbabut) wrote : | #8 |
1. Are there also symlinks beginning with the letter S? What makes you sure, that postgresql is not being started after boot?
2. Did you use remove with --purge and have you installed postgresql again?
To your Question: After installing postgresql the database should automatically get initialized and started. There is no preconfiguration required.
Wolf Rogner (war-rsb) wrote : | #9 |
S19post.... in run level 2 .. 5 and K19post... in run level 1, 6
I did use purge when removing it.
What makes me sure postgres is not running?
If I launch postgres manually (su -c '/usr/lib/
If I restart, or try to launch the database using /etc/init/
To my question: If that should be the case then the package under x64 is broken. In order to run the database, configuration files have to be copied somewhere running the initdb first. The pg_hba.conf has to be manually configured to point to the db directory (which initdb creates in the same directory). Default values for this directory (/etc/postgresql) are set, but the corresponding directories are not created.
My problem now seems: How can I convince /etc/init.
Thomas Babut (thbabut) wrote : | #10 |
After purging all postgresql packages you have installed postgresql again. What happens then? Does it work directly with the default configuration? If not, could you please post the output of the total installation process from apt-get?
Unfortunately I have no Ubuntu x64 installation at this moment.
Wolf Rogner (war-rsb) wrote : | #11 |
root@s2:~# apt-get install postgresql postgresql-doc postgresql-
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
postgresql-8.2 postgresql-
postgresql-common postgresql-doc-8.2
Suggested packages:
oidentd ident-server
The following NEW packages will be installed:
postgresql postgresql-8.2 postgresql-
postgresql-common postgresql-doc postgresql-doc-8.2 postgresql-
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/6492kB of archives.
After unpacking 27.5MB of additional disk space will be used.
Do you want to continue [Y/n]? y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "de_AT.utf8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
Preconfiguring packages ...
Selecting previously deselected package postgresql-
(Reading database ... 58191 files and directories currently installed.)
Unpacking postgresql-
Selecting previously deselected package postgresql-
Unpacking postgresql-
Selecting previously deselected package postgresql-common.
Unpacking postgresql-common (from .../postgresql-
Selecting previously deselected package postgresql-8.2.
Unpacking postgresql-8.2 (from .../postgresql-
Selecting previously deselected package postgresql.
Unpacking postgresql (from .../postgresql_
Selecting previously deselected package postgresql-doc-8.2.
Unpacking postgresql-doc-8.2 (from .../postgresql-
Selecting previously deselected package postgresql-doc.
Unpacking postgresql-doc (from .../postgresql-
Selecting previously deselected package postgresql-
Unpacking postgresql-
Setting up postgresql-
Setting up postgresql-
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "de_AT.utf8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Setting up postgresql-common (78) ...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "de_AT.utf8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
perl: warning...
Thomas Babut (thbabut) wrote : | #12 |
Please run as root:
# dpkg-reconfigure locales
Did you do a fresh install or an upgrade of your Ubuntu?
Wolf Rogner (war-rsb) wrote : | #13 |
root@s2:~# dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "de_AT.utf8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
Generating locales...
en_US.UTF-8... up-to-date
Generation complete.
root@s2:~# locale
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE=
LC_NUMERIC=
LC_TIME=de_AT.utf8
LC_COLLATE=
LC_MONETARY=
LC_MESSAGES=
LC_PAPER=
LC_NAME=
LC_ADDRESS=
LC_TELEPHONE=
LC_MEASUREMENT=
LC_IDENTIFICATI
LC_ALL=
You might find that all settings are en_US (as I use English as my default language) only the time locale is set to Austrian.
I did an update from 7.04 -> 7.10. (and just that you don't get any ideas: I have no intention of reinstalling Ubuntu on this server as it is productive ;-)
The problem lies in the way, /etc/init.
Wolf Rogner (war-rsb) wrote : | #14 |
This is an excerpt from /usr/share/
do_ctl_all() {
[ "$1" ] || { echo "Error: invalid command '$1'" >&2; exit 1; }
[ "$2" ] || { echo "Error: invalid version '$2'" >&2; exit 1; }
[ -d "/etc/postgresq
[ "$(ls /etc/postgresql
[ -x "/usr/lib/
status=0
log_daemon_msg "$3"
for c in /etc/postgresql
[ -e "$c/pgdata" ] || continue
:
:
As you can see, there is a check for the directory /etc/postgresql
If you install 8.2 plain, I doubt that it will get started regardless of i386 or x64 architecture (as both packages have similar postinst files).
Question: Where do I find information what needs to be in the directory /etc/postgresql ?
Wolf Rogner (war-rsb) wrote : | #15 |
I downloaded the required files from postgresql.org. Take the source tar, extract the startup file and edit it to your needs. Here is mine
#! /bin/sh
# chkconfig: 2345 98 02
# description: PostgreSQL RDBMS
# This is an example of a start/stop script for SysV-style init, such
# as is used on Linux systems. You should edit some of the variables
# and maybe the 'echo' commands.
#
# Place this file at /etc/init.
# /etc/rc.
# /etc/rc.
# /etc/rc.
# /etc/rc.
# /etc/rc.
# /etc/rc.
# /etc/rc.
# Or, if you have chkconfig, simply:
# chkconfig --add postgresql
#
# Proper init scripts on Linux systems normally require setting lock
# and pid files under /var/run as well as reacting to network
# settings, so you should treat this with care.
# Original author: Ryan Kirkpatrick <email address hidden>
# $PostgreSQL: pgsql/contrib/
## EDIT FROM HERE
# Installation prefix
prefix=
# Data directory
PGDATA="/home/db"
# Who to run the postmaster as, usually "postgres". (NOT "root")
PGUSER=postgres
# Where to keep a log file
PGLOG="
## STOP EDITING HERE
# The path that is to be used for the script
PATH=/usr/
# What to use to start up the postmaster (we do NOT use pg_ctl for this,
# as it adds no value and can cause the postmaster to misrecognize a stale
# lock file)
DAEMON=
# What to use to shut down the postmaster
PGCTL="
set -e
# Only start if we can find the postmaster.
test -x $DAEMON || exit 0
# Parse command line parameters.
case $1 in
start)
echo -n "Starting PostgreSQL: "
su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
;;
stop)
echo -n "Stopping PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"
echo "ok"
;;
restart)
echo -n "Restarting PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"
su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
;;
reload)
echo -n "Reload PostgreSQL: "
su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"
echo "ok"
;;
status)
su - $PGUSER -c "$PGCTL status -D '$PGDATA'"
;;
*)
# Print help
echo "Usage: $0 {start|
exit 1
;;
esac
exit 0
Now it works
Martin Pitt (pitti) wrote : | #16 |
Apparently you set a default locale in /etc/environment or somewhere else which does not exist. Please create it (with sudo locale-gen en_US.UTF-8) and then reinstall postgresql or use pg_createcluster.
Please note that directories manually created with initdb cannot be handled through the default init scripts. You should use pg_createcluster (see manpage).
Changed in postgresql-8.2: | |
status: | Incomplete → Invalid |
Wolf Rogner (war-rsb) wrote : | #17 |
Martin, I appreciate your effort to help me but I am afraid you are missing the point here. Locales have nothing to do with startup scripts.
I analyzed the deb package and especially the installation files. I did the same with the standard installation files from postgres.org.
There is one file missing that I cited above. This is an error in the installation routine.
It might have been there in previous versions and provides the startup after upgrade. But if you install fresh, it is not there. So there is no automatic startup of the database.
Postgres can be started manually and maybe people are happy with it. I am not. I want 100%.
As I stated: copy the file above into /etc/init.d and the problem is solved.
If someone would update the installation package, it would be solved permanently. This is the only solution possible. And its simple.
As to your comment about the locals:
Locals are set correctly, however I use an English system with a German keyboard. The result is ugly error messages. This is a different issue.
Wolf
Martin Pitt (pitti) wrote : | #18 |
The startup scripts are fine. /etc/init.
The root cause is that when you installed postgresql-8.2 the first time, the default locale did not exist and thus the package maintainer script could not create the initial default instance for 8.2 (called 'main', configuration in /etc/postgresql
So you have two options:
* Ignore the Ubuntu packacking and continue using your custom configuration (but then you loose all the tools like pg_upgradecluster for automatic upgrading).
* Dump your custom database, and revert to the distribution scripts, to retain distro support and tools. To do that I would recommend the following steps:
- pg_dumpall your current db
- Purge postgresql-8.2 (removal is NOT sufficient): sudo apt-get remove --purge postgresql-8.2
- Remove all scripts you installed manually, like /etc/init.
- sudo apt-get install postgresql-8.2
- sudo -u postgres -i # to get a shell as the PostgreSQL superuser
- feed back your dump: psql template1 -f dump.sql
Martin Pitt (pitti) wrote : | #19 |
Oh, Wolf, and please fix your locales first. Seems that en_US.UTF-8 is still invalid. Please do
sudo locale-gen en_US.UTF-8
Otherwise it will fail again.
Wolf Rogner (war-rsb) wrote : | #20 |
How can we procede if I try the things you suggest and the startup script is still missing.
I went back to locale en_US.UTF-8 (this cripples my Thunderbird and OpenOffice time display)
I removed and purged postgres (well I moved the files to a save place) and reinstalled.
I would be happy if after a reboot postgres was here. It does not start as the directory /etc/postgres/8.2 is ... not there.
Did you test it on 64 or 32 bit (as on 32 the required files are installed)?
Martin Pitt (pitti) wrote : Re: [Bug 162517] Re: postgresql does not start | #21 |
> I went back to locale en_US.UTF-8 (this cripples my Thunderbird and OpenOffice time display)
That would be weird, since we only support UTF-8 locales, and everyone
else is using OO.o and Thunderbird with Unicode, too. Anyway, if you
prefer to use ISO-8859, you can create that as well (sudo locale-gen en_US)
and set en_US as default locale instead of en_US.UTF-8
(/etc/environment, LANG=en_US).
> I would be happy if after a reboot postgres was here. It does not
> start as the directory /etc/postgres/8.2 is ... not there.
Can you please cut&paste the exact commands you used and their output?
(I guess 'postgres' is just a typo in the bug mail, it should be
'postgresql').
> Did you test it on 64 or 32 bit (as on 32 the required files are
> installed)?
I am usually on 64 bit, but it shouldn't make a difference.
postgresql-common is architecture independent (written in Perl).
Wolf Rogner (war-rsb) wrote : | #22 |
I think we are back to square one and it leads us nowhere.
Sorry that you wont take the lead.
My conclusion: Problem is not related to locales and problem occures because of crippled package (missing installation files).
Close the incident and thanks for your efforts.
Wolf
Martin Pitt (pitti) wrote : | #23 |
Wolf, I am willing to get to the cause of the problem, but I need the copy&paste of the command outputs:
sudo apt-get remove --purge postgresql-8.2
sudo rm -r /etc/postgresql /var/lib/postgresql
sudo apt-get install postgresql-8.2
(Please do backups before if you have something important.)
Reopening bug.
Wolf Rogner (war-rsb) wrote : | #24 |
root@s2:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
postgresql-common postgresql-
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
postgresql-8.2* postgresql-
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
Need to get 0B of archives.
After unpacking 12.7MB disk space will be freed.
Do you want to continue [Y/n]? y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "de_AT.utf8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 59525 files and directories currently installed.)
Removing postgresql-
Removing postgresql-8.2 ...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "de_AT.utf8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Purging configuration files for postgresql-8.2 ...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "de_AT.utf8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
root@s2:
rm: cannot remove `/etc/postgresql': No such file or directory
root@s2:
rm: cannot remove `/var/lib/
root@s2:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
oidentd ident-server
The following NEW packages will be installed:
postgresql-8.2
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/3372kB of archives.
After unpacking 12.4MB of additional disk space will be used.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "de_AT.utf8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
Selecting previously deselected package postgresql-8.2.
(Reading database ... 59446 files and directories currently installed.)
Unpacking postgresql-8.2 (from .../postgresql-
Setting up postgresql-8.2 (8.2.6-
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings...
Wolf Rogner (war-rsb) wrote : | #25 |
If I replace your init script with mine it works quite fine.
rroot@s2:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "de_AT.utf8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Version Cluster Port Status Owner Data directory Log file
root@s2:
root@s2:
root@s2:
Usage: ./postgresql-8.2 {start|
root@s2:
Stopping PostgreSQL: No directory, logging in with HOME=/
server stopped
ok
Wolf Rogner (war-rsb) wrote : | #26 |
Finally:
doing a
pg_createcluster 8.2 main --start
started the database !!!
So it can be done, but not with the init script in /etc/init.d
Please fix it
Martin Pitt (pitti) wrote : | #27 |
Hi,
Wolf Rogner [2008-01-22 20:23 -0000]:
> Selecting previously deselected package postgresql-8.2.
> (Reading database ... 59446 files and directories currently installed.)
> Unpacking postgresql-8.2 (from .../postgresql-
> Setting up postgresql-8.2 (8.2.6-
> perl: warning: Setting locale failed.
> perl: warning: Please check that your locale settings:
> LANGUAGE = (unset),
> LC_ALL = (unset),
> LC_TIME = "de_AT.utf8",
> LANG = "en_US.UTF-8"
> are supported and installed on your system.
> perl: warning: Falling back to the standard locale ("C").
> Error: The locale requested by the environment is invalid.
> Error: could not create default cluster. Please create it manually with
This is exactly what I mentioned above: Your locales are invalid. If
you do
sudo locale-gen de_AT.UTF-8 en_US.UTF-8
it will work fine. The scripts deliberately don't create a DB with a
broken locale, since this would lead to wrong collation and string
operations.
status invalid
Wolf Rogner (war-rsb) wrote : | #28 |
How do I have to put it:
create_db works fine. The database gets created
pg_createcluster works fine and even starts (magically as I have not read the code) the database server
it is the init script that checks for a nonexistent directory
only postgresql_common is created.
If you insist that locales are the fault, how could I possibly have created a database and even used it from OpenOffice.
The locales have NOTHING whatsoever to do with it.
btw: I even tried the sudo locale-gen as you suggested. Remove Postgresql, install Postgresql same nonexistent directory and broken startup script.
I get the feeling that you prefer spending time discussing instead of fixing.
Read my blog on this: http://
Martin Pitt (pitti) wrote : | #29 |
Wolf Rogner [2008-01-23 19:38 -0000]:
> I get the feeling that you prefer spending time discussing instead
> of fixing.
No, I don't. I spent a hell of a lot of time to make the locale
handling in Postgresql work right. Without working locales, collation
and string comparisons will fail, and the client libs will return
strings which have an invalid encoding. I am not going to deliberately
break postgresql to create DB instances which have nonobvious bugs in
it.
http://
http://
> Read my blog on this:
> http://
That's FUD. We live in a free world, so I won't stop you from doing
whatever blogs you want, or configuring your local psql installation
however you want. If you don't need non-ASCII characters, that's fine.
But don't insist that the PostgreSQL packages are broken without even
listening to my explanation. Your system is broken (it sets LANG and
LC_* to invalid values), the PostgreSQL packages clearly tell you
about the condition. If you ignore it, that's fine. Calling it a bug
is not justified.
Wolf Rogner (war-rsb) wrote : | #30 |
Don't know what FUD is.
I can create databases using different character sets manually.
However your argument about collation sequences and string handling got me thinking again.
Tried to repeat the sequence you suggested step by step (without thinking this time).
Sure enough, postgresql installed and started.
Tried to understand what I did wrong (I administer my machine using webmin. So setting all locales during the installation process was not required. webmin covers most locale handling). Hope I did.
So:
1. I am sorry
2. you were right
3. I was wrong
4. I'll change my blog accordingly
5. Thank you for patience and even putting up with my bad temper
6. (I dare not say it) how can I change the location of my database :-?
Martin Pitt (pitti) wrote : | #31 |
Hi Wolf,
Wolf Rogner [2008-01-24 20:46 -0000]:
> Tried to understand what I did wrong (I administer my machine using
> webmin. So setting all locales during the installation process was
> not required. webmin covers most locale handling). Hope I did.
If you changed the locales in webmin, then webmin apparently has a bug
that it does not actually create the locales you set.
> 5. Thank you for patience and even putting up with my bad temper
Sorry in return for becoming a bit rude in my previous reply.
> 6. (I dare not say it) how can I change the location of my database :-?
On cluster creation: pg_createcluster -d /path/to/data/dir (see
manpage).
On already existing clusters:
- stop the db (init script or pg_ctlcluster)
- move /var/lib/
- do either of (whichever you like more):
* change the /etc/postgresql
location
* set data_directory in /etc/postgresql
and remove above symlink [1]
Martin
[1] I know that removal of the symlink should not be necessary, the
config file option should trump the pgdata symlink. This is fixed in
the current versions in Hardy.
I am running Ubuntu 7.10 (i386) and postgresql-8.2 starts fine after installation.
Could you post the output of the installation process? And what packages are installed?
# sudo dpkg -l|grep postgres