473,657 Members | 2,556 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Connecting to postgres from a romote machhine

Hi, I've just installed postgres on the Linux server. It is supposed
to start automatically which I think it does since I can run an sql
stmt right away. When I'm trying to connect from a remote machine I
get a message that the remote machine IP address is not specified in
pg_hba.conf, that there is no record of that machine there.
ph_hba.conf is set up correctly, because when I run the following:
postmaster -i -D /var/lib/pgsql/data
from the command line, I'm able to easily connect to postgre from the
remote machine.
What's the deal here? It's probably how postgres is started.

here is my startup script:

#! /bin/sh
# postgresql This is the init script for starting up the PostgreSQL
# server
#
# chkconfig: - 85 15
# description: Starts and stops the PostgreSQL backend daemon that
handles \
# all database requests.
# processname: postmaster
# pidfile: /var/run/postmaster.pid

# Version 6.5.3-2 Lamar Owen
# Added code to determine if PGDATA exists, whether it is current
version
# or not, and initdb if no PGDATA (initdb will not overwrite a
database).

# Version 7.0 Lamar Owen
# Added logging code
# Changed PGDATA.
#

# Version 7.0.2 Trond Eivind Glomsrød <te*@redhat.com >
# use functions, add conditional restart

# Version 7.0.3 Lamar Owen <la***@postgres ql.org>
# Check for the existence of functions before blindly using them
# in particular -- check for success () and failure () before using.
# More Cross-distribution support -- PGVERSION variable, and docdir
checks.

# Version 7.1 Release Candidate Lamar Owen <la***@postgres ql.org>
# initdb parameters have changed.

# Version 7.1.2 Trond Eivind Glomsrød <te*@redhat.com >
# Specify shell for su
# Handle stop better - kill unwanted output, make it wait until the
database is ready
# Handle locales slightly differently - always using "C" isn't a valid
option
# Kill output from database initialization
# Mark messages for translation

# Version 7.1.2-2.PGDG Lamar Owen <la********@wgc r.org>
# sync up.
# Karl's fixes for some quoting issues.

# Version 7.2b2 Lamar Owen <la********@wgc r.org>
# version change.

# Version 7.2 final. Lamar Owen <la********@wgc r.org>
# reload from Peter E.
# Eliminate the pidof postmaster test in stop -- we're using pg_ctl so
we don't need pidof.
# Tested the $? return for the stop script -- it does in fact
propagate.
# TODO: multiple postmasters.

# PGVERSION is:
PGVERSION=7.2

# Source function library.
INITD=/etc/rc.d/init.d
.. $INITD/functions

# Get function listing for cross-distribution logic.
TYPESET=`typese t -f|grep "declare"`

# Get config.
.. /etc/sysconfig/network

# Check that networking is up.
# Pretty much need it for postmaster.
[ "${NETWORKI NG}" = "no" ] && exit 0

[ -f /usr/bin/postmaster ] || exit 0
start(){
PSQL_START=$"St arting postgresql service: "

# Check for older PGDATA location.
if [ -f /var/lib/pgsql/PG_VERSION ] && [ -d
/var/lib/pgsql/base/template1 ]
then
export PGDATA=/var/lib/pgsql
else
export PGDATA=/var/lib/pgsql/data
fi

# Check for the PGDATA structure
if [ -f $PGDATA/PG_VERSION ] && [ -d $PGDATA/base ]
then
# Check version of existing PGDATA

if [ `cat $PGDATA/PG_VERSION` != '7.2' ]
then
SYSDOCDIR="(You r System's documentation directory)"
if [ -d /usr/doc/postgresql-$PGVERSION ]
then
SYSDOCDIR=/usr/doc
fi
if [ -d /usr/share/doc/postgresql-$PGVERSION ]
then
SYSDOCDIR=/usr/share/doc
fi
if [ -d /usr/doc/packages/postgresql-$PGVERSION ]
then
SYSDOCDIR=/usr/doc/packages
fi
if [ -d /usr/share/doc/packages/postgresql-$PGVERSION ]
then
SYSDOCDIR=/usr/share/doc/packages
fi
echo
echo -e $"An old version of the database format was found.\nYou
need to upgrade the data format before using PostgreSQL.\nSe e
$SYSDOCDIR/postgresql-$PGVERSION/README.rpm-dist for more
information."
exit 1
# This doesn't seem to do anything useful...
# else
# if echo "$TYPESET"| grep "declare -f success ()" >/dev/null
# then
# success "$PSQL_CHEC K"
# else
# echo " [ OK ]"
# fi
# echo
fi

# No existing PGDATA! Initdb it.

else
echo -n $"Initializi ng database: "
if [ ! -d $PGDATA ]
then
mkdir -p $PGDATA
chown postgres.postgr es $PGDATA
fi
# Make sure the locale from the initdb is preserved for later
startups...
[ -f /etc/sysconfig/i18n ] && cp /etc/sysconfig/i18n
$PGDATA/../initdb.i18n
# Just in case no locale was set, use en_US
[ ! -f /etc/sysconfig/i18n ] && echo "LANG=en_US " >
$PGDATA/../initdb.i18n
# Is expanded this early to be used in the command su runs
echo "export LANG LC_ALL LC_CTYPE LC_COLLATE LC_NUMERIC LC_CTYPE
LC_TIME" >> $PGDATA/../initdb.i18n
# Initialize the database
su -l postgres -s /bin/sh -c "/usr/bin/initdb
--pgdata=/var/lib/pgsql/data > /dev/null 2>&1" < /dev/null
[ -f $PGDATA/PG_VERSION ] && echo_success
[ ! -f $PGDATA/PG_VERSION ] && echo_failure
echo
fi

# Check for postmaster already running...
pid=`pidof -s postmaster`
if [ $pid ]
then
echo $"Postmaster already running."
else
#all systems go -- remove any stale lock files
rm -f /tmp/.s.PGSQL.* > /dev/null
echo -n "$PSQL_STAR T"
su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -o '-i' -p
/usr/bin/postmaster start > /dev/null 2>&1" < /dev/null
sleep 1
pid=`pidof -s postmaster`
if [ $pid ]
then
if echo "$TYPESET"| grep "declare -f success ()" >/dev/null
then
success "$PSQL_STAR T"
else
echo " [ OK ]"
fi
touch /var/lock/subsys/postgresql
echo $pid > /var/run/postmaster.pid
echo
else
if echo "$TYPESET"| grep "declare -f failure ()" >/dev/null
then
failure "$PSQL_STAR T"
else
echo " [ FAILED ]"
fi
echo
fi
fi
}

stop(){
echo -n $"Stopping postgresql service: "
# Check for older PGDATA location.
if [ -f /var/lib/pgsql/PG_VERSION ] && [ -d
/var/lib/pgsql/base/template1 ]
then
export PGDATA=/var/lib/pgsql
else
export PGDATA=/var/lib/pgsql/data
fi
su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl stop -D $PGDATA -s -m
fast" > /dev/null 2>&1
ret=$?
if [ $ret -eq 0 ]; then
echo_success
else
echo_failure
fi
echo
rm -f /var/run/postmaster.pid
rm -f /var/lock/subsys/postgresql
}

restart(){
stop
start
}

condrestart(){
[ -e /var/lock/subsys/postgresql ] && restart || :
}

reload(){
su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl reload -D $PGDATA
-s" > /dev/null 2>&1
}

# This script is slightly unusual in that the name of the daemon
(postmaster)
# is not the same as the name of the subsystem (postgresql)

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status postmaster
;;
restart)
restart
;;
condrestart)
condrestart
;;
reload|force-reload)
reload
;;
*)
echo $"Usage: $0 {start|stop|sta tus|restart|con drestart|reload |force-reload}"
exit 1
esac

exit 0
Please, let me know what should I do.
N.K.
Nov 11 '05 #1
3 4183
On Thursday 11 September 2003 21:42, N.K. wrote:
Hi, I've just installed postgres on the Linux server. It is supposed
to start automatically which I think it does since I can run an sql
stmt right away. When I'm trying to connect from a remote machine I
get a message that the remote machine IP address is not specified in
pg_hba.conf, that there is no record of that machine there.
ph_hba.conf is set up correctly, because when I run the following:
postmaster -i -D /var/lib/pgsql/data
from the command line, I'm able to easily connect to postgre from the
remote machine.
What's the deal here? It's probably how postgres is started.

here is my startup script:


Assuming this is the startup script that ships with PG, you probably want to
look in your postgresql.conf file and check the tcp_ip setting is on.

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #2
On Thursday 11 September 2003 21:42, N.K. wrote:
Hi, I've just installed postgres on the Linux server. It is supposed
to start automatically which I think it does since I can run an sql
stmt right away. When I'm trying to connect from a remote machine I
get a message that the remote machine IP address is not specified in
pg_hba.conf, that there is no record of that machine there.
ph_hba.conf is set up correctly, because when I run the following:
postmaster -i -D /var/lib/pgsql/data
from the command line, I'm able to easily connect to postgre from the
remote machine.
What's the deal here? It's probably how postgres is started.

here is my startup script:


Assuming this is the startup script that ships with PG, you probably want to
look in your postgresql.conf file and check the tcp_ip setting is on.

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #3
Thank you so much for your help.
It worked.
Thanks again.
N.K.
na****@parkergl obal.com (N.K.) wrote in message news:<2d******* *************** ****@posting.go ogle.com>...
Hi, I've just installed postgres on the Linux server. It is supposed
to start automatically which I think it does since I can run an sql
stmt right away. When I'm trying to connect from a remote machine I
get a message that the remote machine IP address is not specified in
pg_hba.conf, that there is no record of that machine there.
ph_hba.conf is set up correctly, because when I run the following:
postmaster -i -D /var/lib/pgsql/data
from the command line, I'm able to easily connect to postgre from the
remote machine.
What's the deal here? It's probably how postgres is started.

here is my startup script:

#! /bin/sh
# postgresql This is the init script for starting up the PostgreSQL
# server
#
# chkconfig: - 85 15
# description: Starts and stops the PostgreSQL backend daemon that
handles \
# all database requests.
# processname: postmaster
# pidfile: /var/run/postmaster.pid

# Version 6.5.3-2 Lamar Owen
# Added code to determine if PGDATA exists, whether it is current
version
# or not, and initdb if no PGDATA (initdb will not overwrite a
database).

# Version 7.0 Lamar Owen
# Added logging code
# Changed PGDATA.
#

# Version 7.0.2 Trond Eivind Glomsrød <te*@redhat.com >
# use functions, add conditional restart

# Version 7.0.3 Lamar Owen <la***@postgres ql.org>
# Check for the existence of functions before blindly using them
# in particular -- check for success () and failure () before using.
# More Cross-distribution support -- PGVERSION variable, and docdir
checks.

# Version 7.1 Release Candidate Lamar Owen <la***@postgres ql.org>
# initdb parameters have changed.

# Version 7.1.2 Trond Eivind Glomsrød <te*@redhat.com >
# Specify shell for su
# Handle stop better - kill unwanted output, make it wait until the
database is ready
# Handle locales slightly differently - always using "C" isn't a valid
option
# Kill output from database initialization
# Mark messages for translation

# Version 7.1.2-2.PGDG Lamar Owen <la********@wgc r.org>
# sync up.
# Karl's fixes for some quoting issues.

# Version 7.2b2 Lamar Owen <la********@wgc r.org>
# version change.

# Version 7.2 final. Lamar Owen <la********@wgc r.org>
# reload from Peter E.
# Eliminate the pidof postmaster test in stop -- we're using pg_ctl so
we don't need pidof.
# Tested the $? return for the stop script -- it does in fact
propagate.
# TODO: multiple postmasters.

# PGVERSION is:
PGVERSION=7.2

# Source function library.
INITD=/etc/rc.d/init.d
. $INITD/functions

# Get function listing for cross-distribution logic.
TYPESET=`typese t -f|grep "declare"`

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
# Pretty much need it for postmaster.
[ "${NETWORKI NG}" = "no" ] && exit 0

[ -f /usr/bin/postmaster ] || exit 0
start(){
PSQL_START=$"St arting postgresql service: "

# Check for older PGDATA location.
if [ -f /var/lib/pgsql/PG_VERSION ] && [ -d
/var/lib/pgsql/base/template1 ]
then
export PGDATA=/var/lib/pgsql
else
export PGDATA=/var/lib/pgsql/data
fi

# Check for the PGDATA structure
if [ -f $PGDATA/PG_VERSION ] && [ -d $PGDATA/base ]
then
# Check version of existing PGDATA

if [ `cat $PGDATA/PG_VERSION` != '7.2' ]
then
SYSDOCDIR="(You r System's documentation directory)"
if [ -d /usr/doc/postgresql-$PGVERSION ]
then
SYSDOCDIR=/usr/doc
fi
if [ -d /usr/share/doc/postgresql-$PGVERSION ]
then
SYSDOCDIR=/usr/share/doc
fi
if [ -d /usr/doc/packages/postgresql-$PGVERSION ]
then
SYSDOCDIR=/usr/doc/packages
fi
if [ -d /usr/share/doc/packages/postgresql-$PGVERSION ]
then
SYSDOCDIR=/usr/share/doc/packages
fi
echo
echo -e $"An old version of the database format was found.\nYou
need to upgrade the data format before using PostgreSQL.\nSe e
$SYSDOCDIR/postgresql-$PGVERSION/README.rpm-dist for more
information."
exit 1
# This doesn't seem to do anything useful...
# else
# if echo "$TYPESET"| grep "declare -f success ()" >/dev/null
# then
# success "$PSQL_CHEC K"
# else
# echo " [ OK ]"
# fi
# echo
fi

# No existing PGDATA! Initdb it.

else
echo -n $"Initializi ng database: "
if [ ! -d $PGDATA ]
then
mkdir -p $PGDATA
chown postgres.postgr es $PGDATA
fi
# Make sure the locale from the initdb is preserved for later
startups...
[ -f /etc/sysconfig/i18n ] && cp /etc/sysconfig/i18n
$PGDATA/../initdb.i18n
# Just in case no locale was set, use en_US
[ ! -f /etc/sysconfig/i18n ] && echo "LANG=en_US " >
$PGDATA/../initdb.i18n
# Is expanded this early to be used in the command su runs
echo "export LANG LC_ALL LC_CTYPE LC_COLLATE LC_NUMERIC LC_CTYPE
LC_TIME" >> $PGDATA/../initdb.i18n
# Initialize the database
su -l postgres -s /bin/sh -c "/usr/bin/initdb
--pgdata=/var/lib/pgsql/data > /dev/null 2>&1" < /dev/null
[ -f $PGDATA/PG_VERSION ] && echo_success
[ ! -f $PGDATA/PG_VERSION ] && echo_failure
echo
fi

# Check for postmaster already running...
pid=`pidof -s postmaster`
if [ $pid ]
then
echo $"Postmaster already running."
else
#all systems go -- remove any stale lock files
rm -f /tmp/.s.PGSQL.* > /dev/null
echo -n "$PSQL_STAR T"
su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -o '-i' -p
/usr/bin/postmaster start > /dev/null 2>&1" < /dev/null
sleep 1
pid=`pidof -s postmaster`
if [ $pid ]
then
if echo "$TYPESET"| grep "declare -f success ()" >/dev/null
then
success "$PSQL_STAR T"
else
echo " [ OK ]"
fi
touch /var/lock/subsys/postgresql
echo $pid > /var/run/postmaster.pid
echo
else
if echo "$TYPESET"| grep "declare -f failure ()" >/dev/null
then
failure "$PSQL_STAR T"
else
echo " [ FAILED ]"
fi
echo
fi
fi
}

stop(){
echo -n $"Stopping postgresql service: "
# Check for older PGDATA location.
if [ -f /var/lib/pgsql/PG_VERSION ] && [ -d
/var/lib/pgsql/base/template1 ]
then
export PGDATA=/var/lib/pgsql
else
export PGDATA=/var/lib/pgsql/data
fi
su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl stop -D $PGDATA -s -m
fast" > /dev/null 2>&1
ret=$?
if [ $ret -eq 0 ]; then
echo_success
else
echo_failure
fi
echo
rm -f /var/run/postmaster.pid
rm -f /var/lock/subsys/postgresql
}

restart(){
stop
start
}

condrestart(){
[ -e /var/lock/subsys/postgresql ] && restart || :
}

reload(){
su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl reload -D $PGDATA
-s" > /dev/null 2>&1
}

# This script is slightly unusual in that the name of the daemon
(postmaster)
# is not the same as the name of the subsystem (postgresql)

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status postmaster
;;
restart)
restart
;;
condrestart)
condrestart
;;
reload|force-reload)
reload
;;
*)
echo $"Usage: $0 {start|stop|sta tus|restart|con drestart|reload |force-reload}"
exit 1
esac

exit 0
Please, let me know what should I do.
N.K.

Nov 11 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3628
by: Lance Hoffmeyer | last post by:
Hello, I am trying to learn some basics of python. One of the things I want to do is write a script to access a postgresql database DB as user USER with password PW and SELECT first_name, last_name, birthday FROM contacts print to the screen and then disconnect.
3
1481
by: Donna | last post by:
Hi, I've set up remote debugging following every step in the manu from microsoft. However, I can't see mtx.exe process in romote machine, instead I only see inetinfo.exe. I attached to it and it seem works OK except that I can't set up any break point in any inc file(include file). I can use the command stepinto from an asp page to get to inc code, but I the process never stop at the break point I "set up" before I start the debugger or...
0
592
by: N.K. | last post by:
Hi, I've just installed postgres on the Linux server. It is supposed to start automatically which I think it does since I can run an sql stmt right away. When I'm trying to connect from a remote machine I get a message that the remote machine IP address is not specified in pg_hba.conf, that there is no record of that machine there. ph_hba.conf is set up correctly, because when I run the following: postmaster -i -D /var/lib/pgsql/data...
1
3329
by: Martin_Hurst | last post by:
Is it possible to establish a connection from within a postgres database to another external database on the network, i.e., not a java or scripting connection, BUT by some type of table definition within the postgres database of that external database table source - something similar to a proxy definition. Examples of external database could be MSAccess, Oracle, Sybase, MSQLServer, etc. The idea behind this would to be able to at least...
1
3272
by: tim | last post by:
I have problems to connect my postgres db in Openoffice 1.1 via jdbc. I can open the tables and run queries. But when try to create or alter tables OpenOffice crashes. My Settings ClassPath /usr/share/pgsql/pg73b1jdbc2.jar:/usr/share/pgsql/pg73b1jdbc3.jar JDBC Driver Class org.postgresql.Driver
18
5124
by: Joe Lester | last post by:
This thread was renamed. It used to be: "shared_buffers Question". The old thread kind of died out. I'm hoping to get some more direction by rephrasing the problem, along with some extra observations I've recently made. The core of the problem is that Postgres is filling up my hard drive with swap files at the rate of around 3 to 7 GB per week (that's Gigabytes not Megabytes) . At this rate it takes roughly two months to fill up my 40...
6
3514
by: Alexander Cohen | last post by:
Im trying to connect locally to a database on a running postgres cluster. If i connect with psql, everything is fine and i can transact. I i try and connect in my own app, i get this error: Could not connect to server: permission denied. Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432" I know for a fact postgres is running, i can see with <ps> and also <top> in the terminal on Mac OSX...
1
5471
by: Goutam Paruchuri | last post by:
Hello, I get an error in my log when connecting to postgres server on Windows. Postgres version : 8.0.0-beta4 LOG TEXT 2004-11-10 11:22:47 LOG: invalid entry in file "C:/Program Files/PostgreSQL/8.0.0-beta4/data/pg_hba.conf" at line 64, token "192.168.2.1/254"
0
2779
by: SYT | last post by:
Hello, I wrote C program for connecting to postgresSQL server to retrieve data from the postgres database. The program is: #include <stdio.h> #include <stdlib.h> #include "libpq-fe.h" int Search(inStruct Sentries)
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7333
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.