Thread: Why can't I do this (setup question)

Why can't I do this (setup question)

From
Paul Tomblin
Date:
I've got PostgreSQL 7.1 installed from rpms on a RedHat 6.2 system.  I
want the data directory on a separate partition, so I shut down, tar the
whole directory into the other directory, mount it, and when I start up
postgresSQL it says it's up, but I can't connect to any databases using
psql.
psql: connectDBStart() -- connect() failed: Connection refused
        Is the postmaster running locally
        and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'?
There is a postmaster running, but no socket in /tmp/

Here's the whole sequence of commands as root:
    mkdir data.new
    chown postgres.postgres data.new
    mount /dev/hdc6 data.new
    cd data.new
    (cd ../data; tar cvBf - .) | tar xvBpf -
    cd ..
    mv data data.old
    umount data.new
    mkdir data
    chown postgres.postgres data
    mount /dev/hdc6 data
    /etc/rc.d/init.d/postgresql start

Is there a way to make this work, or am I going to have to export and
import?

--
Paul Tomblin <ptomblin@xcski.com>, not speaking for anybody
Command, n.:
    Statement presented by a human and accepted by a computer in
such a manner as to make the human feel as if he is in control.

Re: Why can't I do this (setup question)

From
Tom Lane
Date:
Paul Tomblin <ptomblin@xcski.com> writes:
> I've got PostgreSQL 7.1 installed from rpms on a RedHat 6.2 system.  I
> want the data directory on a separate partition, so I shut down, tar the
> whole directory into the other directory, mount it, and when I start up
> postgresSQL it says it's up, but I can't connect to any databases using
> psql.
> psql: connectDBStart() -- connect() failed: Connection refused
>         Is the postmaster running locally
>         and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'?
> There is a postmaster running, but no socket in /tmp/

Odd.  Seems unlikely that that has anything to do with your having moved
the data directory.  Any interesting messages in the postmaster log?
Can you connect via TCP?

            regards, tom lane

Re: Why can't I do this (setup question)

From
Paul Tomblin
Date:
Quoting Tom Lane (tgl@sss.pgh.pa.us):
> Paul Tomblin <ptomblin@xcski.com> writes:
> > I've got PostgreSQL 7.1 installed from rpms on a RedHat 6.2 system.  I
> > want the data directory on a separate partition, so I shut down, tar the
> > whole directory into the other directory, mount it, and when I start up
> > postgresSQL it says it's up, but I can't connect to any databases using
> > psql.
> > psql: connectDBStart() -- connect() failed: Connection refused
> >         Is the postmaster running locally
> >         and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'?
> > There is a postmaster running, but no socket in /tmp/
>
> Odd.  Seems unlikely that that has anything to do with your having moved
> the data directory.  Any interesting messages in the postmaster log?
> Can you connect via TCP?

Is there a postmaster log other than what's in /var/log/messages?
Because there is nothing useful in there other than a message that it
started successfully.

--
Paul Tomblin <ptomblin@xcski.com>, not speaking for anybody
"All life is transitory. A dream. We all come together in the same place at
the end of time. If I don't see you again here, I will see you in a little
while in the place where no shadows fall." - Delenn

Re: Why can't I do this (setup question)

From
Karl DeBisschop
Date:
Paul Tomblin wrote:
>
> Quoting Tom Lane (tgl@sss.pgh.pa.us):
> > Paul Tomblin <ptomblin@xcski.com> writes:
> > > I've got PostgreSQL 7.1 installed from rpms on a RedHat 6.2 system.  I
> > > want the data directory on a separate partition, so I shut down, tar the
> > > whole directory into the other directory, mount it, and when I start up
> > > postgresSQL it says it's up, but I can't connect to any databases using
> > > psql.
> > > psql: connectDBStart() -- connect() failed: Connection refused
> > >         Is the postmaster running locally
> > >         and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'?
> > > There is a postmaster running, but no socket in /tmp/
> >
> > Odd.  Seems unlikely that that has anything to do with your having moved
> > the data directory.  Any interesting messages in the postmaster log?
> > Can you connect via TCP?
>
> Is there a postmaster log other than what's in /var/log/messages?
> Because there is nothing useful in there other than a message that it
> started successfully.

As for your original question, which I missed, I assume you set '-i' in
postmaster.opts.default.

As for the log issue, you can also set log level in
postmaster.opts.default

--
Karl

Re: Why can't I do this (setup question)

From
Tom Lane
Date:
Paul Tomblin <ptomblin@xcski.com> writes:
> Is there a postmaster log other than what's in /var/log/messages?

Yes, the postmaster's stderr output.  What is your startup script doing
with that?

            regards, tom lane

Re: Why can't I do this (setup question)

From
Paul Tomblin
Date:
Quoting Tom Lane (tgl@sss.pgh.pa.us):
> Paul Tomblin <ptomblin@xcski.com> writes:
> > Is there a postmaster log other than what's in /var/log/messages?
>
> Yes, the postmaster's stderr output.  What is your startup script doing
> with that?

I'm using the one that comes with the 7.1 RPM, (from Lamar Owen) which
redirects stderr to /dev/null.

        su -l postgres -c "LC_ALL=C /usr/bin/pg_ctl  -D $PGDATA -p /usr/bin/postmaster start >/dev/null 2>&1" <
/dev/null

I guess I should stop that from happening and see what messages come out.
I'll report back.

--
Paul Tomblin <ptomblin@xcski.com>, not speaking for anybody
In 1665 Issac Newton became discouraged when he fell up a flight of
stairs.

Re: Why can't I do this (setup question)

From
Paul Tomblin
Date:
Quoting Paul Tomblin (ptomblin@xcski.com):
> Quoting Tom Lane (tgl@sss.pgh.pa.us):
> > Yes, the postmaster's stderr output.  What is your startup script doing
> > with that?
>
> I'm using the one that comes with the 7.1 RPM, (from Lamar Owen) which
> redirects stderr to /dev/null.

I tried starting it with the following arguments:
    postmaster -d 5 -D /var/lib/pgsql/data
And with the mounted data dir, I don't get *anything* on stderr except for
the initial environ dump, and I can't connect.  But when I do it without
the mounted dir, after the environ dump, I get:
    invoking IpcMemoryCreate(size=1236992)
    FindExec: searching PATH ...
    ValidateBinary: can't stat "/bin/postmaster"
    FindExec: found "/usr/bin/postmaster" using PATH
    DEBUG:  database system was shut down at 2001-05-21 19:31:24 EDT
    DEBUG:  CheckPoint record at (0, 1808844868)
    DEBUG:  Redo record at (0, 1808844868); Undo record at (0, 0); Shutdown TRUE
    DEBUG:  NextTransactionId: 1870223; NextOid: 2060337
    DEBUG:  database system is in production state
    DEBUG:  proc_exit(0)
    DEBUG:  shmem_exit(0)
    DEBUG:  exit(0)
    postmaster: reaping dead processes...



--
Paul Tomblin <ptomblin@xcski.com>, not speaking for anybody
If the automobile had followed the same development as the computer a
Rolls Royce would today cost $100, get a million miles per gallon and
explode once a year killing everybody inside. - Robert Cringeley (InfoWorld)

Re: Why can't I do this (setup question)

From
Paul Tomblin
Date:
Quoting Paul Tomblin (ptomblin@xcski.com):
> I tried starting it with the following arguments:
>     postmaster -d 5 -D /var/lib/pgsql/data
> And with the mounted data dir, I don't get *anything* on stderr except for
> the initial environ dump, and I can't connect.  But when I do it without

So I gave up, did a pg_dumpall, mounted the new directory, did an initdb
and restored the database, and everything is great.

--
Paul Tomblin <ptomblin@xcski.com>, not speaking for anybody
Disclaimer: "These opinions are my own, though for a small fee they be
yours too."

Re: Why can't I do this (setup question)

From
Roland Lauterbach
Date:
Karl DeBisschop wrote:

> Paul Tomblin wrote:
>>
>> Quoting Tom Lane (tgl@sss.pgh.pa.us):
>> > Paul Tomblin <ptomblin@xcski.com> writes:
>> > > I've got PostgreSQL 7.1 installed from rpms on a RedHat 6.2 system.
>> > > I want the data directory on a separate partition, so I shut down,
>> > > tar the whole directory into the other directory, mount it, and when
>> > > I start up postgresSQL it says it's up, but I can't connect to any
>> > > databases using psql.
>> > > psql: connectDBStart() -- connect() failed: Connection refused
>> > >         Is the postmaster running locally
>> > >         and accepting connections on Unix socket
>> > >         '/tmp/.s.PGSQL.5432'?
>> > > There is a postmaster running, but no socket in /tmp/
>> >
>> > Odd.  Seems unlikely that that has anything to do with your having
>> > moved
>> > the data directory.  Any interesting messages in the postmaster log?
>> > Can you connect via TCP?
>>
>> Is there a postmaster log other than what's in /var/log/messages?
>> Because there is nothing useful in there other than a message that it
>> started successfully.
>
> As for your original question, which I missed, I assume you set '-i' in
> postmaster.opts.default.
>
> As for the log issue, you can also set log level in
> postmaster.opts.default
>

What is the version of your Kernel? I'm running PSQL on a 2.2.16-Kernel
without problems. When I updated to 2.4.0 I got problems.

Postgres don't start, though I built it from the source. The error message
is
"IpcSemaphoreCreate: semget(key=1, num=17, 03600) failed: Function not
implemented"

The same message comes when I try to start new compiled Apache.

But if you don't have 2.4-Kernel
try this:


PSQLPREFIX=/usr/local/pgsql
rm -rf $PSQLPREFIX/data
mkdir $PSQLPREFIX/data
chown postgres.daemon $PSQLPREFIX/data
su - postgres -c "$PSQLPREFIX/bin/initdb -D $PSQLPREFIX/data"

Roland

Re: Why can't I do this (setup question)

From
Tom Lane
Date:
Paul Tomblin <ptomblin@xcski.com> writes:
> So I gave up, did a pg_dumpall, mounted the new directory, did an initdb
> and restored the database, and everything is great.

Curious.  The other should have worked AFAICS.  Maybe something silly,
like the files were not copied with the right ownership/permissions?

            regards, tom lane

Re: Why can't I do this (setup question)

From
Paul Tomblin
Date:
Quoting Tom Lane (tgl@sss.pgh.pa.us):
> Paul Tomblin <ptomblin@xcski.com> writes:
> > So I gave up, did a pg_dumpall, mounted the new directory, did an initdb
> > and restored the database, and everything is great.
>
> Curious.  The other should have worked AFAICS.  Maybe something silly,
> like the files were not copied with the right ownership/permissions?

I quite definitely used the "p" option in tar to preserve ownership, and
while I didn't examine all the files, a quick look showed them all with
the right permissions and ownership.

--
Paul Tomblin <ptomblin@xcski.com>, not speaking for anybody
"Mary had a little key,/She kept it in escrow/And everything that Mary
sent/The Feds were sure to know." - Sam Simpson on sci.crypt