Обсуждение: error on start up "could not change directory to"

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

error on start up "could not change directory to"

От
Kevin Duffy
Дата:
Hello All:

I recently installed Postgresql 9.1 on Fedora 16. 
I must admit I may not have run the install procedures correctly.

I have found postings that talk about the difference between
"su postgres"  vs  "su - postgres".  The dash (-) makes it a login shell
But do understand the difference.  I suspect that, in my ignorance, I used su postgres

So here is what happens when I start the server as follows:
     /usr/bin/pg_ctl  -D  /usr/local/pgsql/data  start
I get:
   could not change directory to "/home/kbd"
   server starting

But the server starts OK.  Would like to fix the above issue.

If I do:
     /usr/bin/pg_ctl  -D  /usr/local/pgsql/data  status
I get:
   could not change directory to "/home/kbd"
   pg_ctl: server is running (PID: 3142)

On Shut down I get the same
  could not change directory to "/home/kbd"

How can I make this message go away?

Many thanks for your kind assistance.

KD

Re: error on start up "could not change directory to"

От
Tom Lane
Дата:
Kevin Duffy <kevind0718@gmail.com> writes:
> I have found postings that talk about the difference between
> "su postgres"  vs  "su - postgres".  The dash (-) makes it a login shell
> But do understand the difference.  I suspect that, in my ignorance, I used
> su postgres

> So here is what happens when I start the server as follows:
>      /usr/bin/pg_ctl  -D  /usr/local/pgsql/data  start
> I get:
>    could not change directory to "/home/kbd"
>    server starting

> But the server starts OK.  Would like to fix the above issue.

That message happens if you execute the command while in a directory
that the postgres user can't read.  It's unsurprising that postgres
can't read your home directory, since mode 700 is typical for user home
directories on Linux.  What is surprising is that you are still cd'd
to your home directory when you do this.  One reason for recommending
"su -" and not just "su" is that the former should result in changing to
postgres' home directory.

BTW, if you're using a prepackaged version of postgres, which you
probably should be, this whole technique is inappropriate anyway.
You should be doing something like "sudo service postgresql start"
rather than invoking pg_ctl by hand.

            regards, tom lane

Re: error on start up "could not change directory to"

От
Tom Lane
Дата:
Kevin Duffy <kevind0718@gmail.com> writes:
> I am would guess that I am using the "pre-packaged" version,  because I did
> the install using yum.
> If I start postgresql using "sudo service postgresql start"  it will find
> my data
> directory?  Do I need to do a SU - postgres first?
> Is there a recent tutorial for starting, stopping and other simple
> postgresql
> admin tasks?

There should be a README file in /usr/share/doc/postgresql...
covering the idiosyncrasies of the RPM distribution.

            regards, tom lane

Re: error on start up "could not change directory to"

От
Kevin Duffy
Дата:
I am would guess that I am using the "pre-packaged" version,  because I did the install using yum. 
If I start postgresql using "sudo service postgresql start"  it will find my data
directory?  Do I need to do a SU - postgres first?
Is there a recent tutorial for starting, stopping and other simple postgresql
admin tasks?

Many thanks for your quick reply on the weekend.

Best

KD



On Sun, Feb 5, 2012 at 2:48 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Kevin Duffy <kevind0718@gmail.com> writes:
> I have found postings that talk about the difference between
> "su postgres"  vs  "su - postgres".  The dash (-) makes it a login shell
> But do understand the difference.  I suspect that, in my ignorance, I used
> su postgres

> So here is what happens when I start the server as follows:
>      /usr/bin/pg_ctl  -D  /usr/local/pgsql/data  start
> I get:
>    could not change directory to "/home/kbd"
>    server starting

> But the server starts OK.  Would like to fix the above issue.

That message happens if you execute the command while in a directory
that the postgres user can't read.  It's unsurprising that postgres
can't read your home directory, since mode 700 is typical for user home
directories on Linux.  What is surprising is that you are still cd'd
to your home directory when you do this.  One reason for recommending
"su -" and not just "su" is that the former should result in changing to
postgres' home directory.

BTW, if you're using a prepackaged version of postgres, which you
probably should be, this whole technique is inappropriate anyway.
You should be doing something like "sudo service postgresql start"
rather than invoking pg_ctl by hand.

                       regards, tom lane