Thread: postmasteralive()

postmasteralive()

From
Sandeep Joshi
Date:
In my application I need to know whether the postmaster is alive or not
and
also whether a particular database is accessible or not.

I need  api's  to do this.  Are there any?


thanks,
Sandeep


Re: postmasteralive()

From
"Adam Lang"
Date:
Why don't you just check to see if you can connect to the database through
normal means?  If you can't connect, it isn't accessible. (As long as your
connection routine is correct, of course.)

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
http://www.rutgersinsurance.com
----- Original Message -----
From: "Sandeep Joshi" <sjoshi@Zambeel.com>
To: <pgsql-general@postgresql.org>
Sent: Friday, December 22, 2000 7:24 PM
Subject: [GENERAL] postmasteralive()


>
> In my application I need to know whether the postmaster is alive or not
> and
> also whether a particular database is accessible or not.
>
> I need  api's  to do this.  Are there any?
>
>
> thanks,
> Sandeep


pg_hba.conf on Linux

From
"Peter Ball"
Date:
Hi, we want to create a simple db from the command line, We ARE able to see
the Cobalt Internal db's like sites, users etc. using psql, so PostgreSQL is
installed and running fine.

But we get the following error message (we get much the same error from
phpPGadmin) .


[root upload]# /usr/bin/createdb test
psql: No pg_hba.conf entry for host localhost, user root, database template1
createdb: database creation failed
[root upload]#


We then did ...
[root pgsql]# locate pg_hba.conf
/var/lib/pgsql/data/pg_hba.conf
/home/chiliasp/odbc/internaldb/data/pg_hba.conf
/home/chiliasp/odbc/internaldb/data/pg_hba.conf~
/home/sites/site15/web/upload/pg_hba.conf
/usr/lib/pgsql/pg_hba.conf.sample

We then created a text file with "local trust all" and copied it into
the following
/usr/lib/pgsql/data/
/usr/lib/pgsql/
/var/lib/pgsql/data/

We then get a new error (after the last copy above) - A step foreward though
I suspect ...

Warning: Unable to connect to PostgresSQL server: Missing or erroneous
pg_hba.conf file, see postmaster log for details in lib.inc.php on line 121
Error - /home/sites/site21/web/phpPgAdmin/index.php
PostgreSQL said: Unable to connect to server


BUT, for some reason the Cobalt did NOT like me changing it's pg_hba.conf
file (even though the original was just comment lines explaining how it
worked). The screen to create sites etc. and some other stuff died, but
fortunatly I had a backup which we restored and now it's ok. But I'm sort of
back to square 1 again.

I tried echo $PGDATA but it just goes back to the prompt again.

Someone told me that Cobalt puts a long password (randomly generated) onto
Postgres to lock it down. we know how to get it, does it need to be
specified here or somewhere?

Also we are using telnet from a remote location, do we have to specify our
IP or anything?

Where should this pg_hba.conf file live on a standard cobalt RaQ4 (Redhat)?

Is the syntax of our pg_hba.conf correct?

Any help given to us would be greatly appreciated, and if you ever come to
Australia, please stop in at my place for a few beers.


Peter


p.s. The Cobalt Knowledgebase has these instructions but say "These
instructions refer to the RaQ3 ONLY!" Does anyone know what should be
changed for the RAQ4?



QuestionNum: 823
Product: RaQ3
Category Software
Creation Date: Thu May 25 09:32:55 2000 PDT

Question
How can I accesss the Postgres database server on the RaQ3 to add databases,
create tables, and add users?


Response

The following process will give the postgres user called "admin" the
super-user privilage. Once this is done, a user can log into postgres using
the admin account and modify itself to allow creation of users and
databases.

1. telnet in as admin

2. use su - to switch to root

[admin@raq3 admin]$ su -
Password:

[root@raq3 /root]#

3. use an editor and open the file /home/pgsql/pg_hba.conf

[root@raq3 /root]# vi /home/pgsql/pg_hba.conf

4. Change local all crypt to local all trust

5. use su to switch to the user ID postgres

[root@raq3 /root]# su postgres
[postgres@raq3 /root]$


6. Now run the psql program to connect to the database server.

[postgres@raq3 /root]$ psql cobalt
Welcome to the POSTGRESQL interactive sql monitor:
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
[PostgreSQL 6.5.2 on i686-pc-linux-gnu, compiled by gcc egcs-2.91.66]

type ? for help on slash commands
type q to quit
type g or terminate with semicolon to execute query
You are currently connected to the database: cobalt

cobalt=>

7. Enter the following commands to give super-user privilage to admin and
quit.

cobalt=> update pg_shadow set usesuper='t' where usename='admin';
UPDATE 1
cobalt=> q
[postgres@raq3 /root]$

8. Use the exit command to become "root" again.

9. Now open the /home/pgsql/pg_hba.conf file and change "local all trust"
back to "local all crypt".

It is now possible to access postgres using the postgres account "admin".
The password for this account is stored in the file /etc/cobalt/.meta.id and
should not be changed. If the password needs to be changed, it must be
changed in the pg_shadow table and the /etc/cobalt/.meta.id file. Be sure to
maintain file permissions on the file or system security could be
compromised.