Fedora Linux Support Community & Resources Center
  #1  
Old 20th August 2006, 11:04 PM
HeyAZ Offline
Registered User
 
Join Date: Aug 2006
Posts: 8
Starting postgresql service: [FAILED]

FC5. Using yum (which downloaded a few addition dependencies in the process) to install:
postgresql
postgresql-server
postgresql-libs
postgresql-docs
postgresql-contrib
postgresql-jdbd
postgresql-odbc
postgresql-pl
[root@computer-13aaa0 ~]# /sbin/chkconfig postgresql on
[root@computer-13aaa0 ~]# /sbin/service postgresql start
Initializing database: [ OK ]
Starting postgresql service: [FAILED]
[root@computer-13aaa0 ~]# su - postgres
-bash-3.1$ psql template1
psql: FATAL: could not open file "global/pg_database": No such file or directory
-bash-3.1$
Reply With Quote
  #2  
Old 20th August 2006, 11:46 PM
wintersm Offline
Registered User
 
Join Date: Jul 2006
Posts: 293
this should normally create you a empty database but it appears it has not..

lookup information in the /etc/init.d/postgresql script, to find where it is creating the database, and use the initdb command to create a database in that directory..

I had a look (4 u) the data dir by default is /var/lib/pgsql/data
looking at the init script, do a rm -rf /var/lib/pgsql/data first to delete that directory and try /sbin/service postgresql start again, if that fails..

mkdir -p /var/lib/pgsql/data
chown postgresostgres /var/lib/pgsql/data
chmod go-rwx /var/lib/pgsql/data
su -l postgres -c "initdb --pgdata=/var/lib/pgsql/data --auth='ident sameuser'"

then see if you can start postgresql..
Reply With Quote
  #3  
Old 21st August 2006, 12:28 AM
HeyAZ Offline
Registered User
 
Join Date: Aug 2006
Posts: 8
Thanks, still not working, here is the terminal output; further down the pgstartup.log:
******************
[root@computer-13aaa0 ~]# rm -rf /var/lib/pgsql/data
[root@computer-13aaa0 ~]# /sbin/service postgresql start
Initializing database: [ OK ]
Starting postgresql service: [FAILED]
[root@computer-13aaa0 ~]# mkdir -p /var/lib/pgsql/data
[root@computer-13aaa0 ~]# chown postgresostgres /var/lib/pgsql/data
[root@computer-13aaa0 ~]# chmod go-rwx /var/lib/pgsql/data
[root@computer-13aaa0 ~]# su -l postgres -c "initdb --pgdata=/var/lib/pgsql/d ata --auth='ident sameuser'"
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8.
The default database encoding has accordingly been set to UTF8.

initdb: directory "/var/lib/pgsql/data" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/var/lib/pgsql/data" or run initdb
with an argument other than "/var/lib/pgsql/data".
[root@computer-13aaa0 ~]# service postgresql start
Starting postgresql service: [FAILED]

**********************
/* Errors listed at bottom of pgstartup.log */

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8.
The default database encoding has accordingly been set to UTF8.

fixing permissions on existing directory /var/lib/pgsql/data ... ok
creating directory /var/lib/pgsql/data/global ... ok
creating directory /var/lib/pgsql/data/pg_xlog ... ok
creating directory /var/lib/pgsql/data/pg_xlog/archive_status ... ok
creating directory /var/lib/pgsql/data/pg_clog ... ok
creating directory /var/lib/pgsql/data/pg_subtrans ... ok
creating directory /var/lib/pgsql/data/pg_twophase ... ok
creating directory /var/lib/pgsql/data/pg_multixact/members ... ok
creating directory /var/lib/pgsql/data/pg_multixact/offsets ... ok
creating directory /var/lib/pgsql/data/base ... ok
creating directory /var/lib/pgsql/data/base/1 ... ok
creating directory /var/lib/pgsql/data/pg_tblspc ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 1000
creating configuration files ... ok
creating template1 database in /var/lib/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
enabling unlimited row size for system tables ... ok
initializing dependencies ... ok
creating system views ... ok
loading pg_description ... ok
creating conversions ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

Success. You can now start the database server using:

/usr/bin/postmaster -D /var/lib/pgsql/data
or
/usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start

LOG: could not bind IPv4 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
WARNING: could not create listen socket for "localhost"
FATAL: could not create any TCP/IP sockets
runuser: cannot set groups: Inappropriate ioctl for device
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8.
The default database encoding has accordingly been set to UTF8.

fixing permissions on existing directory /var/lib/pgsql/data ... ok
creating directory /var/lib/pgsql/data/global ... ok
creating directory /var/lib/pgsql/data/pg_xlog ... ok
creating directory /var/lib/pgsql/data/pg_xlog/archive_status ... ok
creating directory /var/lib/pgsql/data/pg_clog ... ok
creating directory /var/lib/pgsql/data/pg_subtrans ... ok
creating directory /var/lib/pgsql/data/pg_twophase ... ok
creating directory /var/lib/pgsql/data/pg_multixact/members ... ok
creating directory /var/lib/pgsql/data/pg_multixact/offsets ... ok
creating directory /var/lib/pgsql/data/base ... ok
creating directory /var/lib/pgsql/data/base/1 ... ok
creating directory /var/lib/pgsql/data/pg_tblspc ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 1000
creating configuration files ... ok
creating template1 database in /var/lib/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
enabling unlimited row size for system tables ... ok
initializing dependencies ... ok
creating system views ... ok
loading pg_description ... ok
creating conversions ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

Success. You can now start the database server using:

/usr/bin/postmaster -D /var/lib/pgsql/data
or
/usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start

LOG: could not bind IPv4 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
WARNING: could not create listen socket for "localhost"
FATAL: could not create any TCP/IP sockets
LOG: could not bind IPv4 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
WARNING: could not create listen socket for "localhost"
FATAL: could not create any TCP/IP sockets
Reply With Quote
  #4  
Old 21st August 2006, 12:32 AM
HeyAZ Offline
Registered User
 
Join Date: Aug 2006
Posts: 8
And then here is the postgresql init.d file, if you have any suggestions; thanks.
***********
#!/bin/sh
# postgresql This is the init script for starting up the PostgreSQL
# server
#
# chkconfig: - 64 36
# 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 Glomsrd <teg@redhat.com>
# use functions, add conditional restart

# Version 7.0.3 Lamar Owen <lamar@postgresql.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 <lamar@postgresql.org>
# initdb parameters have changed.

# Version 7.1.2 Trond Eivind Glomsrd <teg@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 <lamar.owen@wgcr.org>
# sync up.
# Karl's fixes for some quoting issues.

# Version 7.2b2 Lamar Owen <lamar.owen@wgcr.org>
# version change.

# Version 7.2 final. Lamar Owen <lamar.owen@wgcr.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.

# Version 7.3 Lamar Owen <lamar.owen@ramifordistat.net>
# Multiple postmasters, courtesy Karl DeBisschop

# Version 7.4 Lamar Owen.

# Version 7.4.3 Tom Lane <tgl@sss.pgh.pa.us>
# Support condstop for uninstall
# Minor other changes suggested by Fernando Nasser.

# Version 7.4.5 Tom Lane <tgl@sss.pgh.pa.us>
# Rewrite to start postmaster directly, rather than via pg_ctl; this avoids
# fooling the postmaster's stale-lockfile check by having too many
# postgres-owned processes laying about.


# PGVERSION is the full package version, e.g., 7.4.7
# Note: the specfile ordinarily updates this during install
PGVERSION=8.1.4
# PGMAJORVERSION is major version, e.g., 7.4 (this should match PG_VERSION)
PGMAJORVERSION=`echo "$PGVERSION" | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/'`

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

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

# Get config.
. /etc/sysconfig/network

# Find the name of the script
NAME=`basename $0`
if [ ${NAME:0:1} = "S" -o ${NAME:0:1} = "K" ]
then
NAME=${NAME:3}
fi

# For SELinux we need to use 'runuser' not 'su'
if [ -x /sbin/runuser ]
then
SU=runuser
else
SU=su
fi


# Set defaults for configuration variables
PGENGINE=/usr/bin
PGPORT=5432
PGDATA=/var/lib/pgsql
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base/template1" ]
then
echo "Using old-style directory structure"
else
PGDATA=/var/lib/pgsql/data
fi
PGLOG=/var/lib/pgsql/pgstartup.log

# Override defaults from /etc/sysconfig/pgsql if file is present
[ -f /etc/sysconfig/pgsql/${NAME} ] && . /etc/sysconfig/pgsql/${NAME}

export PGDATA
export PGPORT

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

[ -f "$PGENGINE/postmaster" ] || exit 1

script_result=0

start(){
PSQL_START=$"Starting ${NAME} service: "

# Make sure startup-time log file is valid
if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]
then
touch "$PGLOG" || exit 1
chown postgresostgres "$PGLOG"
chmod go-rwx "$PGLOG"
[ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$PGLOG" 2>/dev/null
fi

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

if [ x`cat "$PGDATA/PG_VERSION"` != x"$PGMAJORVERSION" ]
then
SYSDOCDIR="(Your 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 $"An old version of the database format was found."
echo $"You need to upgrade the data format before using PostgreSQL."
echo $"See $SYSDOCDIR/postgresql-$PGVERSION/README.rpm-dist for more information."
exit 1
fi

# No existing PGDATA! Initdb it.

else
echo -n $"Initializing database: "
if [ ! -e "$PGDATA" -a ! -h "$PGDATA" ]
then
mkdir -p "$PGDATA" || exit 1
chown postgresostgres "$PGDATA"
chmod go-rwx "$PGDATA"
fi
# Clean up SELinux tagging for PGDATA
[ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA"
# Initialize the database
$SU -l postgres -c "$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident sameuser'" >> "$PGLOG" 2>&1 < /dev/null
# Create directory for postmaster log
mkdir "$PGDATA/pg_log"
chown postgresostgres "$PGDATA/pg_log"
chmod go-rwx "$PGDATA/pg_log"

[ -f "$PGDATA/PG_VERSION" ] && echo_success
[ ! -f "$PGDATA/PG_VERSION" ] && echo_failure
echo
fi

echo -n "$PSQL_START"
$SU -l postgres -c "$PGENGINE/postmaster -p '$PGPORT' -D '$PGDATA' ${PGOPTS} &" >> "$PGLOG" 2>&1 < /dev/null
sleep 2
pid=`pidof -s "$PGENGINE/postmaster"`
if [ $pid ] && [ -f "$PGDATA/postmaster.pid" ]
then
success "$PSQL_START"
touch /var/lock/subsys/${NAME}
head -n 1 "$PGDATA/postmaster.pid" > "/var/run/postmaster.${PGPORT}.pid"
echo
else
failure "$PSQL_START"
echo
script_result=1
fi
}

stop(){
echo -n $"Stopping ${NAME} service: "
$SU -l postgres -c "$PGENGINE/pg_ctl stop -D '$PGDATA' -s -m fast" > /dev/null 2>&1 < /dev/null
ret=$?
if [ $ret -eq 0 ]
then
echo_success
else
echo_failure
script_result=1
fi
echo
rm -f "/var/run/postmaster.${PGPORT}.pid"
rm -f "/var/lock/subsys/${NAME}"
}

restart(){
stop
start
}

condrestart(){
[ -e /var/lock/subsys/${NAME} ] && restart
}

condstop(){
[ -e /var/lock/subsys/${NAME} ] && stop
}

reload(){
$SU -l postgres -c "$PGENGINE/pg_ctl reload -D '$PGDATA' -s" > /dev/null 2>&1 < /dev/null
}

# 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
script_result=$?
;;
restart)
restart
;;
condrestart)
condrestart
;;
condstop)
condstop
;;
reload|force-reload)
reload
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|condstop|re load|force-reload}"
exit 1
esac

exit $script_result
Reply With Quote
  #5  
Old 21st August 2006, 12:51 AM
wintersm Offline
Registered User
 
Join Date: Jul 2006
Posts: 293
maybe postgres is actually already running?

try

service postgres status
Reply With Quote
  #6  
Old 21st August 2006, 01:06 AM
HeyAZ Offline
Registered User
 
Join Date: Aug 2006
Posts: 8
[root@computer-13aaa0 ~]# sudo ps -af | grep postgres
root 5726 5711 0 16:56 pts/2 00:00:00 su postgres
postgres 5727 5726 0 16:56 pts/2 00:00:00 bash
root 5783 5771 0 16:59 pts/2 00:00:00 grep postgres
[root@computer-13aaa0 ~]# service postgres status
postgres: unrecognized service
[root@computer-13aaa0 ~]# su postgres
bash-3.1$ service postgres status
postgres: unrecognized service
bash-3.1$

This issue also shows up in user comments in the postgresql.org manual:
"If you get an error like
psql: FATAL: could not open file "global/pg_database": No such file or directory
make sure that in your init.d postgresql file (if you have one) or in the env variables for the shell that runs your server process that PGDATA is set properly. Then try to restart the server. If the server will not restart, check for an already running server process (sudo ps -af | grep postgres). Sometimes they can hang around, secretly, and screw things up."
But then no solution is offered...
[ http://www.postgresql.org/docs/8.1/i...me-config.html ]
Reply With Quote
  #7  
Old 21st August 2006, 01:40 AM
wintersm Offline
Registered User
 
Join Date: Jul 2006
Posts: 293
sorry, typoed on the service name,

service postgresql status

not postgres

postgres starts a process called 'postmaster' (not to be confused with the same from postfix).. so you probably wouldnt see a process by the name of postgres, you could look at the user.. heres what i get..

[root@ ~]# service postgresql status
postmaster (pid 5331 3318 2317 2316 2315 2313 2311 2250 2249 2248 2246 2244) is running...
[root@ ~]# ps -fu postgres
UID PID PPID C STIME TTY TIME CMD
postgres 2244 1 0 11:09 ? 00:00:00 /usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data -
postgres 2246 2244 0 11:09 ? 00:00:00 postgres: logger process
postgres 2248 2244 0 11:09 ? 00:00:00 postgres: writer process
postgres 2249 2244 0 11:09 ? 00:00:00 postgres: stats buffer process
postgres 2250 2249 0 11:09 ? 00:00:00 postgres: stats collector process
postgres 2311 1 0 11:09 ? 00:00:00 /usr/bin/postmaster -p 5433 -D /var/lib/pgsql/data.d
postgres 2313 2311 0 11:09 ? 00:00:00 postgres: logger process
postgres 2315 2311 0 11:09 ? 00:00:00 postgres: writer process
postgres 2316 2311 0 11:09 ? 00:00:00 postgres: stats buffer process
postgres 2317 2316 0 11:09 ? 00:00:00 postgres: stats collector process
postgres 3318 2244 0 11:20 ? 00:00:00 postgres: squirrelmail squirrelmail 127.0.0.1(41156)
postgres 5331 2244 0 12:32 ? 00:00:00 postgres: mail amavis 127.0.0.1(50611) idle
Reply With Quote
  #8  
Old 21st August 2006, 01:43 AM
wintersm Offline
Registered User
 
Join Date: Jul 2006
Posts: 293
if postgresql is not running then check pgdata..

>ls /var/lib/pgsql/data

my result

base pg_hba.conf pg_multixact pg_twophase postgresql.conf
global pg_ident.conf pg_subtrans PG_VERSION postmaster.opts
pg_clog pg_log pg_tblspc pg_xlog postmaster.pid


you might need to empty the directory and start again..

service postgresql stop # make sure stopped
rm -rf /var/lib/pgsql
service postgresql start

PLEASE make sure you are the root user when doing the above..
Reply With Quote
  #9  
Old 21st August 2006, 01:47 AM
HeyAZ Offline
Registered User
 
Join Date: Aug 2006
Posts: 8
[root@computer-13aaa0 ~]# service postgresql status
postmaster (pid 5150 5149 5148 5146 5145) is running.
[root@computer-13aaa0 ~]# ps -fu postgres
UID PID PPID C STIME TTY TIME CMD
postgres 5145 1 0 Aug19 ? 00:00:00 /usr/bin/postmaster -i -D /oppostgres 5146 5145 0 Aug19 ? 00:00:00 postgres: logger process
postgres 5148 5145 0 Aug19 ? 00:00:00 postgres: writer process
postgres 5149 5145 0 Aug19 ? 00:00:00 postgres: stats buffer procespostgres 5150 5149 0 Aug19 ? 00:00:00 postgres: stats collector propostgres 6067 6066 0 17:42 pts/2 00:00:00 bash
Reply With Quote
  #10  
Old 21st August 2006, 01:49 AM
wintersm Offline
Registered User
 
Join Date: Jul 2006
Posts: 293
looks like its running, but maybe only partly..

stop it and re-start to see what happens? otherwise issue my commands from above to re-init the database and try again..
Reply With Quote
  #11  
Old 21st August 2006, 01:55 AM
HeyAZ Offline
Registered User
 
Join Date: Aug 2006
Posts: 8
Thanks for time invested, but am going to re-install FC5 from scratch; this was a new install anyway, nothing to back up, a "learning curve". Also have Suse CDs which may try that as well.
Reply With Quote
Reply

Tags
failed, postgresql, service, starting

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
after update The VPN connection 'xxx' failed because the VPN service failed to start. jlmsprings Servers & Networking 6 7th October 2008 10:25 AM
service postgresql start: could not bind IPv4 socket. s-strong Using Fedora 7 21st October 2007 12:39 AM
trouble starting postgresql glastar2000 Using Fedora 1 28th October 2005 08:06 PM


Current GMT-time: 04:38 (Tuesday, 29-07-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat