Обсуждение: Error message "psql: could not connect to server: No such file or directory"

Поиск
Список
Период
Сортировка

Error message "psql: could not connect to server: No such file or directory"

От
Stefan Schwarzer
Дата:
Hi there,

I guess this is a typical user error. I searched around to find the solution, but in vain.

I just upgraded to Lion, and used Kyngchaos libraries for installation of Postgres.

Try to get running postgres, and I get this:

      /usr/local/pgsql-9.1/bin/psql -U postgres
      psql: could not connect to server: No such file or directory
         Is the server running locally and accepting
         connections on Unix domain socket "/tmp/.s.PGSQL.5432"?


In my limited understanding, it seems that Postgres is not running. When I use:

       ps auxw | grep post

out comes only the "grep post", but no postgres process.

When I use:

       sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist

it says:

       org.postgresql.postgres: Already loaded

and displays in the "ps" list then:

       user        935   0.0  0.1  2493888   7296   ??  Ss    3:24PM   0:00.12
/System/Library/PrivateFrameworks/DiskImages.framework/Resources/diskimages-helper-uuid
9EFB9424-7971-4A8B-9D73-B93BD7F1DB5F-post-exec 4 

(which looks a bit strange to me (DiskImages ??))


I am somewhat lost (and worse is that it worked the other day, before re-installing Lion anew.).

Thanks for any hints,

Stef

Re: Error message "psql: could not connect to server: No such file or directory"

От
Adrian Klaver
Дата:
On 06/14/2012 06:30 AM, Stefan Schwarzer wrote:
> Hi there,
>
> I guess this is a typical user error. I searched around to find the solution, but in vain.
>
> I just upgraded to Lion, and used Kyngchaos libraries for installation of Postgres.
>
> Try to get running postgres, and I get this:
>
>        /usr/local/pgsql-9.1/bin/psql -U postgres
>        psql: could not connect to server: No such file or directory
>           Is the server running locally and accepting
>           connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
>
>
> In my limited understanding, it seems that Postgres is not running. When I use:
>
>         ps auxw | grep post
>
> out comes only the "grep post", but no postgres process.
>
> When I use:
>
>         sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist
>
> it says:
>
>         org.postgresql.postgres: Already loaded
>
> and displays in the "ps" list then:
>
>         user        935   0.0  0.1  2493888   7296   ??  Ss    3:24PM   0:00.12
/System/Library/PrivateFrameworks/DiskImages.framework/Resources/diskimages-helper-uuid
9EFB9424-7971-4A8B-9D73-B93BD7F1DB5F-post-exec 4 
>
> (which looks a bit strange to me (DiskImages ??))
>
>
> I am somewhat lost (and worse is that it worked the other day, before re-installing Lion anew.).

http://www.kyngchaos.com/software/postgres
"
Notes

NOTE: I've had reports of the installer not initializing the data
cluster, which results in Postgres not starting. It seems to be random,
and I haven't figured out the cause yet. If Postgres won't start (you
get an error "could not connect to server: No such file or directory"
when trying to connect with psql), try manually initializing the cluster
with:
/usr/local/pgsql-9.1/bin/initdb -U postgres \
-D /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US"
Or see the Locales and Encodings readme if you need a different locale
or encoding.
Then stop and start Postgres as specified in the readme.
"
>
> Thanks for any hints,
>
> Stef


--
Adrian Klaver
adrian.klaver@gmail.com

Re: Error message "psql: could not connect to server: No such file or directory"

От
Stefan Schwarzer
Дата:
>> Hi there,
>>
>> I guess this is a typical user error. I searched around to find the solution, but in vain.
>>
>> I just upgraded to Lion, and used Kyngchaos libraries for installation of Postgres.
>>
>> Try to get running postgres, and I get this:
>>
>>       /usr/local/pgsql-9.1/bin/psql -U postgres
>>       psql: could not connect to server: No such file or directory
>>          Is the server running locally and accepting
>>          connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
>>
>>
>> In my limited understanding, it seems that Postgres is not running. When I use:
>>
>>        ps auxw | grep post
>>
>> out comes only the "grep post", but no postgres process.
>>
>> When I use:
>>
>>        sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist
>>
>> it says:
>>
>>        org.postgresql.postgres: Already loaded
>>
>> and displays in the "ps" list then:
>>
>>        user        935   0.0  0.1  2493888   7296   ??  Ss    3:24PM   0:00.12
/System/Library/PrivateFrameworks/DiskImages.framework/Resources/diskimages-helper-uuid
9EFB9424-7971-4A8B-9D73-B93BD7F1DB5F-post-exec 4 
>>
>> (which looks a bit strange to me (DiskImages ??))
>>
>>
>> I am somewhat lost (and worse is that it worked the other day, before re-installing Lion anew.).
>
> http://www.kyngchaos.com/software/postgres
> "
> Notes
>
> NOTE: I've had reports of the installer not initializing the data cluster, which results in Postgres not starting. It
seemsto be random, and I haven't figured out the cause yet. If Postgres won't start (you get an error "could not
connectto server: No such file or directory" when trying to connect with psql), try manually initializing the cluster
with:
> /usr/local/pgsql-9.1/bin/initdb -U postgres \
> -D /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US"
> Or see the Locales and Encodings readme if you need a different locale or encoding.
> Then stop and start Postgres as specified in the read me.

Yeah, I had read that somewhere too, although in my disorientation over the last couple of hours didn't find it
anymore.But I did try it out, but got a  

     "initdb: could not access directory "/usr/local/pgsql-9.1/data": Permission denied"

I guess this is solvable with some "su" access or so. But no idea how. The data directory looks like this:

      drwx------  18 _postgres  _postgres   612 Jun 14 14:25 data

So, the user is not anymore "postgres", but "_postgres", right? I read that this changed with Lion, but not sure how
thisapplied to use with Kyngchaos libraries. 

Thanks a lot for your help!




Re: Error message "psql: could not connect to server: No such file or directory"

От
Adrian Klaver
Дата:
On 06/14/2012 06:48 AM, Stefan Schwarzer wrote:
>
>>> Hi there,
>>>
>>> I guess this is a typical user error. I searched around to find the solution, but in vain.
>>>
>>> I just upgraded to Lion, and used Kyngchaos libraries for installation of Postgres.
>>>
>>> Try to get running postgres, and I get this:
>>>
>>>        /usr/local/pgsql-9.1/bin/psql -U postgres
>>>        psql: could not connect to server: No such file or directory
>>>           Is the server running locally and accepting
>>>           connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
>>>
>>>
>>> In my limited understanding, it seems that Postgres is not running. When I use:
>>>
>>>         ps auxw | grep post
>>>
>>> out comes only the "grep post", but no postgres process.
>>>
>>> When I use:
>>>
>>>         sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist
>>>
>>> it says:
>>>
>>>         org.postgresql.postgres: Already loaded
>>>
>>> and displays in the "ps" list then:
>>>
>>>         user        935   0.0  0.1  2493888   7296   ??  Ss    3:24PM   0:00.12
/System/Library/PrivateFrameworks/DiskImages.framework/Resources/diskimages-helper-uuid
9EFB9424-7971-4A8B-9D73-B93BD7F1DB5F-post-exec 4 
>>>
>>> (which looks a bit strange to me (DiskImages ??))
>>>
>>>
>>> I am somewhat lost (and worse is that it worked the other day, before re-installing Lion anew.).
>>
>> http://www.kyngchaos.com/software/postgres
>> "
>> Notes
>>
>> NOTE: I've had reports of the installer not initializing the data cluster, which results in Postgres not starting.
Itseems to be random, and I haven't figured out the cause yet. If Postgres won't start (you get an error "could not
connectto server: No such file or directory" when trying to connect with psql), try manually initializing the cluster
with:
>> /usr/local/pgsql-9.1/bin/initdb -U postgres \
>> -D /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US"
>> Or see the Locales and Encodings readme if you need a different locale or encoding.
>> Then stop and start Postgres as specified in the read me.
>
> Yeah, I had read that somewhere too, although in my disorientation over the last couple of hours didn't find it
anymore.But I did try it out, but got a 
>
>       "initdb: could not access directory "/usr/local/pgsql-9.1/data": Permission denied"
>
> I guess this is solvable with some "su" access or so. But no idea how. The data directory looks like this:
>
>        drwx------  18 _postgres  _postgres   612 Jun 14 14:25 data
>
> So, the user is not anymore "postgres", but "_postgres", right? I read that this changed with Lion, but not sure how
thisapplied to use with Kyngchaos libraries. 

I am not an Apple user so all I can do now is point you at the below. Answer 1 would seem to be a solution:

http://stackoverflow.com/questions/6814127/lion-update-removed-the-postgres-user-how-to-restore-it

>
> Thanks a lot for your help!
>
>
>
>
>


--
Adrian Klaver
adrian.klaver@gmail.com

Re: Error message "psql: could not connect to server: No such file or directory"

От
Stefan Schwarzer
Дата:
>>> I guess this is a typical user error. I searched around to find the solution, but in vain.
>>>
>>> I just upgraded to Lion, and used Kyngchaos libraries for installation of Postgres.
>>>
>>> Try to get running postgres, and I get this:
>>>
>>>      /usr/local/pgsql-9.1/bin/psql -U postgres
>>>      psql: could not connect to server: No such file or directory
>>>         Is the server running locally and accepting
>>>         connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
>>>
>>>
>>> In my limited understanding, it seems that Postgres is not running. When I use:
>>>
>>>       ps auxw | grep post
>>>
>>> out comes only the "grep post", but no postgres process.
>>>
>>> When I use:
>>>
>>>       sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist
>>>
>>> it says:
>>>
>>>       org.postgresql.postgres: Already loaded
>>>
>>> and displays in the "ps" list then:
>>>
>>>       user        935   0.0  0.1  2493888   7296   ??  Ss    3:24PM   0:00.12
/System/Library/PrivateFrameworks/DiskImages.framework/Resources/diskimages-helper-uuid
9EFB9424-7971-4A8B-9D73-B93BD7F1DB5F-post-exec 4 
>>>
>>> (which looks a bit strange to me (DiskImages ??))
>>>
>>>
>>> I am somewhat lost (and worse is that it worked the other day, before re-installing Lion anew.).
>>

I need unfortunately to come back to this issue. I (again) re-installed Lion from scratch, and finally got everything
working.The Postgres was running, I uploaded a couple of dumped SQL files. And then re-started the machine for another
reason.And suddenly it says again the it can't connect to the server. 

I tried
/usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US

and
/usr/local/pgsql-9.1/bin/pg_ctl -D /usr/local/pgsql-9.1/data/ -l logfile start

and
sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist

… but nothing happens. I don't have the feeling that it's a problem with the "postgres" and "_postgres" users (as it
hasworked before already). 

Can anyone give me a hint how I can figure out where the problem lies and what I can do about it? Why did it work
beforeI restarted the computer and why does it not work anymore? 

Thanks a lot for any hints!

Re: Error message "psql: could not connect to server: No such file or directory"

От
Adrian Klaver
Дата:
On 06/19/2012 01:32 AM, Stefan Schwarzer wrote:

>
> I need unfortunately to come back to this issue. I (again) re-installed Lion from scratch, and finally got everything
working.The Postgres was running, I uploaded a couple of dumped SQL files. And then re-started the machine for another
reason.And suddenly it says again the it can't connect to the server. 
>
> I tried
> /usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US
>
> and
> /usr/local/pgsql-9.1/bin/pg_ctl -D /usr/local/pgsql-9.1/data/ -l logfile start
>
> and
> sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist
>
> … but nothing happens. I don't have the feeling that it's a problem with the "postgres" and "_postgres" users (as it
hasworked before already). 
>
> Can anyone give me a hint how I can figure out where the problem lies and what I can do about it? Why did it work
beforeI restarted the computer and why does it not work anymore? 
>
> Thanks a lot for any hints!
>

When troubleshooting I am firm believer in working from the known to the
unknown. In that vein:

1) Is there /usr/local/pgsql-9.1/data/?

    a) If so are there subdirectories in it indicating cluster was
created? i.e. base/ global/ pg_clog/, etc
    b) If not is there a Postgres data directory anywhere on machine?

2) When you say nothing happens does that mean nothing is written to log
file and/or terminal? No process shows up in process list?

3) If something does happen in, terms of error messages, what are they?

4) Have you looked at system (not Postgres specific) logs to see if this
a system issue?

5) What user are you running the above commands as?
   a) What user is associated with the Postgres data directory(if it
exists)?

--
Adrian Klaver
adrian.klaver@gmail.com



Re: Error message "psql: could not connect to server: No such file or directory"

От
Stefan Schwarzer
Дата:
>> I need unfortunately to come back to this issue. I (again) re-installed Lion from scratch, and finally got
everythingworking. The Postgres was running, I uploaded a couple of dumped SQL files. And then re-started the machine
foranother reason. And suddenly it says again the it can't connect to the server. 
>>
>> I tried
>> /usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US
>>
>> and
>> /usr/local/pgsql-9.1/bin/pg_ctl -D /usr/local/pgsql-9.1/data/ -l logfile start
>>
>> and
>> sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist
>>
>> … but nothing happens. I don't have the feeling that it's a problem with the "postgres" and "_postgres" users (as it
hasworked before already). 
>>
>> Can anyone give me a hint how I can figure out where the problem lies and what I can do about it? Why did it work
beforeI restarted the computer and why does it not work anymore? 
>>
>> Thanks a lot for any hints!
>>
>
> When troubleshooting I am firm believer in working from the known to the unknown. In that vein:
>
> 1) Is there /usr/local/pgsql-9.1/data/?

Yes:

drwx------  18 _postgres  _postgres   612 Jun 19 09:41 data


>   a) If so are there subdirectories in it indicating cluster was created? i.e. base/ global/ pg_clog/, etc

Yes:

drwx------   7 _postgres  _postgres    238 Jun 19 08:59 base
drwx------  43 _postgres  _postgres   1462 Jun 19 09:41 global
….


> 2) When you say nothing happens does that mean nothing is written to log file and/or terminal? No process shows up in
processlist? 

When I do:     sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist
it says:         org.postgresql.postgres: Already loaded

When I do:      /usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US
it says:            The files belonging to this database system will be owned by user "xxx".
                       This user must also own the server process.
                       The database cluster will be initialized with locale en_US.
                       The default text search configuration will be set to "english".
                       initdb: could not access directory "/usr/local/pgsql-9.1/data": Permission denied

Same when using "_postgres" instead of "postgres".

When I do:     sudo su - _postgres /usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data
--encoding=UTF8--locale=en_US 
it seems to run, but still, same error message "psql: could not connect…."

And still nothing in the process list (using "ps auxw | grep post").


> 3) If something does happen in, terms of error messages, what are they?
>
> 4) Have you looked at system (not Postgres specific) logs to see if this a system issue?

I looked at Apple's Console, where all (?) logs/messages are being assembled, but nothing worrisome there. is there any
otherspecific place where I can look for error messages? 


> 5) What user are you running the above commands as?

I am user with "Administrator" rights.


>  a) What user is associated with the Postgres data directory(if it exists)?

See above, "_postgres". There is or could be confusion between Apple's "_postgres" and the normal "postgres" user. But
itlooks as it isn't in this case.. 

Thanks for your help!


Re: Error message "psql: could not connect to server: No such file or directory"

От
Adrian Klaver
Дата:
On 06/20/2012 10:40 PM, Stefan Schwarzer wrote:
>
>>> I need unfortunately to come back to this issue. I (again) re-installed Lion from scratch, and finally got
everythingworking. The Postgres was running, I uploaded a couple of dumped SQL files. And then re-started the machine
foranother reason. And suddenly it says again the it can't connect to the server. 
>>>
>>> I tried
>>> /usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US
>>>
>>> and
>>> /usr/local/pgsql-9.1/bin/pg_ctl -D /usr/local/pgsql-9.1/data/ -l logfile start
>>>
>>> and
>>> sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist
>>>
>>> … but nothing happens. I don't have the feeling that it's a problem with the "postgres" and "_postgres" users (as
ithas worked before already). 
>>>
>>> Can anyone give me a hint how I can figure out where the problem lies and what I can do about it? Why did it work
beforeI restarted the computer and why does it not work anymore? 
>>>
>>> Thanks a lot for any hints!
>>>
>>
>> When troubleshooting I am firm believer in working from the known to the unknown. In that vein:
>>
>> 1) Is there /usr/local/pgsql-9.1/data/?
>
> Yes:
>
> drwx------  18 _postgres  _postgres   612 Jun 19 09:41 data
>
>
>>    a) If so are there subdirectories in it indicating cluster was created? i.e. base/ global/ pg_clog/, etc
>
> Yes:
>
> drwx------   7 _postgres  _postgres    238 Jun 19 08:59 base
> drwx------  43 _postgres  _postgres   1462 Jun 19 09:41 global
> ….
>
>
>> 2) When you say nothing happens does that mean nothing is written to log file and/or terminal? No process shows up
inprocess list? 
>
> When I do:     sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist
> it says:         org.postgresql.postgres: Already loaded
>
> When I do:      /usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data --encoding=UTF8
--locale=en_US
> it says:            The files belonging to this database system will be owned by user "xxx".
>                         This user must also own the server process.
>                         The database cluster will be initialized with locale en_US.
>                         The default text search configuration will be set to "english".
>                         initdb: could not access directory "/usr/local/pgsql-9.1/data": Permission denied


So at a guess user 'xxx' is not '_postgres'. You need to be the
_postgres user when doing the initdb.

>
> Same when using "_postgres" instead of "postgres".
>
> When I do:     sudo su - _postgres /usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data
--encoding=UTF8--locale=en_US 
> it seems to run, but still, same error message "psql: could not connect…."

See, here the initdb worked. Doing the inidtdb is not the same as
starting the database. initdb only creates the initial database cluster.

To start the database you need to do something like(as _postgres):

/usr/local/pgsql-9.1/bin/pg_ctl start -D /usr/local/pgsql-9.1/data

>
> And still nothing in the process list (using "ps auxw | grep post").
>
>
>> 3) If something does happen in, terms of error messages, what are they?
>>
>> 4) Have you looked at system (not Postgres specific) logs to see if this a system issue?
>
> I looked at Apple's Console, where all (?) logs/messages are being assembled, but nothing worrisome there. is there
anyother specific place where I can look for error messages? 
>
>
>> 5) What user are you running the above commands as?
>
> I am user with "Administrator" rights.

The commands need to be run as the _postgres user. Postgres will not run
as root.

>
>
>>   a) What user is associated with the Postgres data directory(if it exists)?
>
> See above, "_postgres". There is or could be confusion between Apple's "_postgres" and the normal "postgres" user.
Butit looks as it isn't in this case.. 
>
> Thanks for your help!
>


--
Adrian Klaver
adrian.klaver@gmail.com



Re: Error message "psql: could not connect to server: No such file or directory"

От
Stefan Schwarzer
Дата:
>>
>> When I do:     sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist
>> it says:         org.postgresql.postgres: Already loaded
>>
>> When I do:      /usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data --encoding=UTF8
--locale=en_US
>> it says:            The files belonging to this database system will be owned by user "xxx".
>>                        This user must also own the server process.
>>                        The database cluster will be initialized with locale en_US.
>>                        The default text search configuration will be set to "english".
>>                        initdb: could not access directory "/usr/local/pgsql-9.1/data": Permission denied
>
>
> So at a guess user 'xxx' is not '_postgres'. You need to be the _postgres user when doing the initdb.
>
>>
>> Same when using "_postgres" instead of "postgres".
>>
>> When I do:     sudo su - _postgres /usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data
--encoding=UTF8--locale=en_US 
>> it seems to run, but still, same error message "psql: could not connect…."
>
> See, here the initdb worked. Doing the inidtdb is not the same as starting the database. initdb only creates the
initialdatabase cluster. 
>
> To start the database you need to do something like(as _postgres):
>
> /usr/local/pgsql-9.1/bin/pg_ctl start -D /usr/local/pgsql-9.1/data


Thanks so much for those tips.  If I understand it correctly, the commands should be then:

sudo su - _postgres /usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data --encoding=UTF8
--locale=en_US
sudo su - _postgres /usr/local/pgsql-9.1/bin/pg_ctl start -D /usr/local/pgsql-9.1/data

Although I don't get an error message, I don't have the feeling that it started the server. There is still nothing in
theprocess list, and a normal "psql" results in the same message as before "psql: could not connect…" 

So sorry for bothering you guys… just being really frustrated now…

If you have any ideas, please let me know… :-)

Stef

Re: Error message "psql: could not connect to server: No such file or directory"

От
Stefan Schwarzer
Дата:
> sudo su - _postgres /usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data --encoding=UTF8
--locale=en_US
> sudo su - _postgres /usr/local/pgsql-9.1/bin/pg_ctl start -D /usr/local/pgsql-9.1/data
>
> Although I don't get an error message, I don't have the feeling that it started the server. There is still nothing in
theprocess list, and a normal "psql" results in the same message as before "psql: could not connect…" 
>
> So sorry for bothering you guys… just being really frustrated now…
>
> If you have any ideas, please let me know… :-)

I just went back to the postgres documentation [1] (actually reading all google results on the error message one after
theother) and tried out what was said there (adapted to my conditions): 

sudo -u _postgres /usr/local/pgsql-9.1/bin/postgres -D /usr/local/pgsql-9.1/data

and suddenly postgres runs….


[1] http://www.postgresql.org/docs/9.1/static/server-start.html

Re: Error message "psql: could not connect to server: No such file or directory"

От
Craig Ringer
Дата:
On 06/22/2012 03:19 PM, Stefan Schwarzer wrote:
>> sudo su - _postgres /usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data --encoding=UTF8
--locale=en_US
>> sudo su - _postgres /usr/local/pgsql-9.1/bin/pg_ctl start -D /usr/local/pgsql-9.1/data
>>
>> Although I don't get an error message, I don't have the feeling that it started the server. There is still nothing
inthe process list, and a normal "psql" results in the same message as before "psql: could not connect…" 
>>
>> So sorry for bothering you guys… just being really frustrated now…
>>
>> If you have any ideas, please let me know… :-)
> I just went back to the postgres documentation [1] (actually reading all google results on the error message one
afterthe other) and tried out what was said there (adapted to my conditions): 
>
> sudo -u _postgres /usr/local/pgsql-9.1/bin/postgres -D /usr/local/pgsql-9.1/data
>
> and suddenly postgres runs….
>

You really should be able to use pg_ctl though.

I'm puzzled about why you don't appear to be looking at the server error
logs (/usr/local/pgsql-9.1/data/pg_log) during troubleshooting. They're
your main source of info.

--
Craig Ringer

Re: Error message "psql: could not connect to server: No such file or directory"

От
Stefan Schwarzer
Дата:
>>> sudo su - _postgres /usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data --encoding=UTF8
--locale=en_US
>>> sudo su - _postgres /usr/local/pgsql-9.1/bin/pg_ctl start -D /usr/local/pgsql-9.1/data
>>>
>>> Although I don't get an error message, I don't have the feeling that it started the server. There is still nothing
inthe process list, and a normal "psql" results in the same message as before "psql: could not connect…" 
>>>
>>> So sorry for bothering you guys… just being really frustrated now…
>>>
>>> If you have any ideas, please let me know… :-)
>> I just went back to the postgres documentation [1] (actually reading all google results on the error message one
afterthe other) and tried out what was said there (adapted to my conditions): 
>>
>> sudo -u _postgres /usr/local/pgsql-9.1/bin/postgres -D /usr/local/pgsql-9.1/data
>>
>> and suddenly postgres runs….
>>
>
> You really should be able to use pg_ctl though.
>
> I'm puzzled about why you don't appear to be looking at the server error logs (/usr/local/pgsql-9.1/data/pg_log)
duringtroubleshooting. They're your main source of info. 

Hmm, I guess it's because I didn't think of it, I was't really aware of it (although I tried to use the Console Error
Messagesto find any errors), and wouldn't have been sure how to access it (as it belongs to the _postgres user). But
then,it doesn't exist. I see pg_clog and pg_xlog... 

Re: Error message "psql: could not connect to server: No such file or directory"

От
Craig Ringer
Дата:
On 06/25/2012 02:50 PM, Stefan Schwarzer wrote:
 > Craig Ringer wrote:
>> I'm puzzled about why you don't appear to be looking at the server error logs (/usr/local/pgsql-9.1/data/pg_log)
duringtroubleshooting. They're your main source of info. 
>
> Hmm, I guess it's because I didn't think of it, I was't really aware of it (although I tried to use the Console Error
Messagesto find any errors), and wouldn't have been sure how to access it (as it belongs to the _postgres user). But
then,it doesn't exist. I see pg_clog and pg_xlog... 

Perhaps your install places it somewhere else. Sorry, I don't really do
mac. The PostgreSQL log directory can be found by examining
postgresql.conf in the data directory. The 'log_directory' parameter
specifies where Pg writes its logs to.

--
Craig Ringer



Re: Error message "psql: could not connect to server: No such file or directory"

От
Stefan Schwarzer
Дата:
> I just went back to the postgres documentation [1] (actually reading all google results on the error message one
afterthe other) and tried out what was said there (adapted to my conditions): 
>
> sudo -u _postgres /usr/local/pgsql-9.1/bin/postgres -D /usr/local/pgsql-9.1/data
>
> and suddenly postgres runs….

And for whatever reason, after having worked this morning, it doesn't work anymore after I restarted the computer in
themiddle of the day. I can't believe it. 

When I type in:

    sudo -u _postgres /usr/local/pgsql-9.1/bin/postgres -D /usr/local/pgsql-9.1/data

it spits out:

    LOG:  00000: could not identify current directory: Permission denied
    LOCATION:  find_my_exec, exec.c:126
    FATAL:  XX000: /usr/local/pgsql-9.1/bin/postgres: could not locate my own executable path
    LOCATION:  getInstallationPaths, postmaster.c:1138

I looked around, but couldn't find a plausible explanation for this.

Re: Error message "psql: could not connect to server: No such file or directory"

От
Craig Ringer
Дата:
On 06/25/2012 04:21 PM, Stefan Schwarzer wrote:
>> I just went back to the postgres documentation [1] (actually reading all google results on the error message one
afterthe other) and tried out what was said there (adapted to my conditions): 
>>
>> sudo -u _postgres /usr/local/pgsql-9.1/bin/postgres -D /usr/local/pgsql-9.1/data
>>
>> and suddenly postgres runs….
> And for whatever reason, after having worked this morning, it doesn't work anymore after I restarted the computer in
themiddle of the day. I can't believe it. 
>
> When I type in:
>
>      sudo -u _postgres /usr/local/pgsql-9.1/bin/postgres -D /usr/local/pgsql-9.1/data
>
> it spits out:
>
>      LOG:  00000: could not identify current directory: Permission denied
'cd' to the postgresql datadir before running the command, or use pg_ctl
instead of trying to launch the postgres server executable directly.

It's trying to get information on the current directory - probably your
home dir - but the _postgres user doesn't have access to it.

--
Craig Ringer

Re: Error message "psql: could not connect to server: No such file or directory"

От
Tom Lane
Дата:
Craig Ringer <ringerc@ringerc.id.au> writes:
> On 06/25/2012 04:21 PM, Stefan Schwarzer wrote:
>> When I type in:
>>
>> sudo -u _postgres /usr/local/pgsql-9.1/bin/postgres -D /usr/local/pgsql-9.1/data
>>
>> it spits out:
>>
>> LOG:  00000: could not identify current directory: Permission denied

> It's trying to get information on the current directory - probably your
> home dir - but the _postgres user doesn't have access to it.

Try adding the "-i" option to the sudo command.  Starting postgres
under whatever environment you happen to have in your interactive shell
isn't a very good idea anyway --- things will be more predictable with
user _postgres' login environment.

            regards, tom lane