Postgres says it starts ok, but doesn't!

onaweb

Well-Known Member
Jan 1, 2004
76
0
156
I was having some problems with getting postgres started. When I tried service postgresql start - it would come back that postgresql is an unrecognized service. At the advice of people on this forum, I reinstalled postgresql. When in whm, it states that posgresql started ok, but in service status it still says failed. I have uncommented the tcp and port lines from postgresql.conf and set the tcp = true. I can log in and create a db and user, but when I try to connect to db, I receive an error message Warning: pg_connect(): Unable to connect to PostgreSQL server: unknown host name: localhost.

Any ideas?

I would really appreciate any help that anyone can offer.

Thanks,
Andy
 

vivek

Well-Known Member
Mar 2, 2004
93
0
156
India
Hello,

If postgresql on Cpanel refuses to start even after reinstalling it from /scripts, try the following steps :

1. Delete the postgre files in /tmp.
2. rm -rf /var/lib/pgsql/data
3. su - postgres
4. initdb
5. start postgre from ssh
6. Go back and try the WHM functions again.

After doing #4 the msg. ends with:

Success. You can now start the database server using:

/usr/bin/postmaster -D /var/lib/pgsql/data
or
/usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start

Chose the first option or start Postgres from WHM.

If any body else have any suggestion regarding please post the reply or suggest another solution .

Thank You.
Vivek
 

onaweb

Well-Known Member
Jan 1, 2004
76
0
156
Hello Vivek,
thanks for your help.

At step 4, I get this:
initdb: You must identify where the the data for this database
system will reside. Do this with either a -D invocation
option or a PGDATA environment variable.
 

onaweb

Well-Known Member
Jan 1, 2004
76
0
156
Got that far, I received the Success message went to start postgres using the /usr/bin/postmaster -D /var/lib/pgsql/data command and it hangs at
LOG: database system is ready - not sure if this is normal but it doesn't bring me back to a prompt yet.
 

casey

Well-Known Member
Jan 17, 2003
2,288
0
191
onaweb said:
Got that far, I received the Success message went to start postgres using the /usr/bin/postmaster -D /var/lib/pgsql/data command and it hangs at
LOG: database system is ready - not sure if this is normal but it doesn't bring me back to a prompt yet.
hit ctrl-c and then change the postgres password in WHM. Then restart it in WHM.
 

onaweb

Well-Known Member
Jan 1, 2004
76
0
156
Now we just took 2 steps back. Now if I try to restart Postgres in WHM I get this:
postgresql has failed, please contact the sysadmin (result was "postmaster is not running").
 

casey

Well-Known Member
Jan 17, 2003
2,288
0
191
initdb -D /var/lib/pgsql/data

and restarting it from whm should work.
 

casey

Well-Known Member
Jan 17, 2003
2,288
0
191
Sheldon said:
didnt work for me!
Then try vivek's post again. That is how I have gotten it running on 3 different stubborn servers. Try both
/usr/bin/postmaster -D /var/lib/pgsql/data
and
/usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start
to get it started. Once it's running you should be able to change the password and set up the configuration file via WHM. Then you can restart it from WHM. Don't give up. Eventually it will work. :)
 

vivek

Well-Known Member
Mar 2, 2004
93
0
156
India
Hey casey,

It works for me perfectly, its not working for other people. hehehehe
correct me if i have given any incorrect steps for resolving the problem.

By the way casey where are you from, can we talk in private if you do not mind :)

Thank You,
Vivek.
 

casey

Well-Known Member
Jan 17, 2003
2,288
0
191
vivek said:
Hey casey,

It works for me perfectly, its not working for other people. hehehehe
correct me if i have given any incorrect steps for resolving the problem.

By the way casey where are you from, can we talk in private if you do not mind :)

Thank You,
Vivek.
No, those are the correct steps. That's why I specifically told them to try your solution again. That is exactly how I have fixed it on a few different servers.

Send me a pm if you wanna chat.
 

mhbrands

Member
Apr 12, 2003
17
0
151
Kansas
I had the same problem after the cpanel update. I downgraded back to stable and then rebuilt postgres... works great now :D
 

vivek

Well-Known Member
Mar 2, 2004
93
0
156
India
Any Body Interested ........

Dear Friends,

If you have any questions you can send private messages :)

Thank You,
Vivek. :D
 
Last edited:

anup123

Well-Known Member
Mar 29, 2004
889
1
168
This Planet
My server is supported by (though i know a lot of admin stuff myself too :)), by a Bangalore based company which has been outsourced by my service provider for their entire 24X7 Support for all their servers in data center. I don't have to pay anything though (part of the deal).

Yes on individual basis, their Admin Support and management packages range from 40$ to 950$ a month

Anup
 

fishfreek

Well-Known Member
Jan 2, 2004
238
0
166
postgres command line issues

When we issue the command su - postgres we are prompted for a password. I have yet to figure out what password it wants. It does not accept the password we put in WHM for the postgres password. It does not accept the root password so I am at a loss as to what password it might be wanting/needing.

If I simply type postgres at the $ prompt I get the following message.

$postgres

postgres does not know where to find the database system data. You must specify the directory that contains the database system either by specifying the -D invocation option or by setting the PGDATA environment variable.
 

mhbrands

Member
Apr 12, 2003
17
0
151
Kansas
what happens when you type in

service postgresql restart


if it tells you postgres doesnt exist, you may have it disabled somehow in WHM, or the file could have corrupted and be unreadable. Check WHM tweak settings first and if it isnt disabled,

cd /scripts (I am not where I can find the name at the moment) and ls
look for an install postgres script or a repair postgres script and run that... then go through WHM and give it a password and try su - postgres again.

Isn't server operation a wonderfully clever way of helping you learn patience? :cool: