Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Linux / UNIX and the fly likes Postgresql Service can't start anymore Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Postgresql Service can Watch "Postgresql Service can New topic
Author

Postgresql Service can't start anymore

Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Hi all,

I just installed new ram into my laptop....soon after that Fedora forced me to run fcsk (or something like that)..I think it's kind of like ScanDisk??
Anyway after running that , my postgresql service cannot start... I'm not sure how to fix it...Any ideas?

If I try connect this is the error I get :

Server doesn't listen
The server doesn't accept connections: the connection library reports
could not connect to server: Connection refused Is the server running on host "localhost" and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" and accepting TCP/IP connections on port 5432?


Here is my hba.conf :

local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust


===>SCJP 1.5(72%)<===
==>SCWCD1.5(76%)<===
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
Did the the server start successfully?
Check the log files where your pg_ctl start command outputs to.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5838
    
    7

Did you run a ps to see if postgres is running? If it is running, run a "netstat -lp | grep postgres" to see what ports it has open.

If it is not running, you could try starting it, most likely: /etc/init.d/postgres start
If it doesn't start, you might get an error as to why not (could be a corrupted config file)

If all else fails, you could reinstall it.


JBoss In Action
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Thanks, will try out your suggestions now..need to get it fixed quick so I can finish writing unit tests for a release on friday
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Hi Guys,

If I su to the postgres user and run pg_ctl start
It says :

FATAL: could not open lock file "/tmp/.s.PGSQL.5432.lock": No such device or address


Going to re-install now...think that might be the quick solution
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

After doing yum remove postgresql,
then deleting the pgsql directory,
then doing yum install postgresql,
then doing service postgresql initdb

I still cannot start the server and am getting the same error :
FATAL: could not open lock file "/tmp/.s.PGSQL.5432.lock": No such device or address

If I look at the permissions for the lock file they were owned by gdm:gdm .... I chowned it to postgres:postgres but the error is still appearing if I try start the server...

Help?
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Removing the lock file solved the problem... I guess I should really learn more about linux...probably wouldv'e known to do this?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16160
    
  21

The fsck was probably requested because when you create a filesystem in Linux, a parameter gets set that tells Linux how many times the system may be restarted before fsck will be run automatically to detect/repair damage. Which is a pretty useless option on my servers, which reboot on average about once every 8 months.

You can also get an fsck request if the filesystem was not shut down cleanly. Either because the system crashed or because you got impatient and pulled power before the filesystem had been closed for shutdown. Since you had a dangling lockfile, I'd say that your fsck came from a non-clean shutdown, as the "service postgres stop" command issued by /sbin/shutdown processing would have deleted the lockfile.

A lot of Linux apps use a lockfile to prevent multiple instances of a service or application from being started. The exact location of that file may vary, depending on the program, but there are a few places that are popular, such as /var/run and /var/lock. An astute observer would notice that part of the lockfile for PostgreSQL was the port ID 5432. That's because you can run multiple PostgreSQL instances as long as they each listen on a port of their own. Mostly you'd only do that if you're either customizing and testing a PostgreSQL server or if you have a critical database that you want isolated.

So now you know. If a server/the system crashes and you cannot restart, look for a lock file and delete it manually. But do check to make sure that the program in question really isn't running!


Customer surveys are for companies who didn't pay proper attention to begin with.
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Thanks Tim,

Any idea why the lock file was owned by gdm ? I was unaware of a user by that name on my machine..
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16160
    
  21

GDM is the Graphical Display Manager, I think, but why it should own the PostgreSQL lock I do not know unless somehow the PostgreSQL and GDM group names both got assigned to the same numeric ID (check /etc/group).
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Ahh... I was trying out different window managers the other day... maybe when I tried xmonad something happened?
 
Consider Paul's rocket mass heater.
 
subject: Postgresql Service can't start anymore