Subject: Re: First try of pgsql start complains "initdb: unknown option --
To: Stefan 'Kaishakunin' Schumacher <stefan@net-tex.de>
From: Gan Uesli Starling <alias@starling.us>
List: netbsd-help
Date: 10/02/2005 21:05:44
Stefan 'Kaishakunin' Schumacher wrote:
> Also sprach Gan Uesli Starling (alias@starling.us)
>
>>Trying out PostgreSQL for the very first time. I
>>get an error when I try this for an initial
>>experimental run...
>>
>>baal: {16} sudo /etc/rc.d/pgsql start &
>>[1] 1245
>>baal: {17} Initializing PostgreSQL databases.
>>initdb: unknown option -- m
>>Try "initdb --help" for more information.
>>
>>[1] Exit 1 sudo /etc/rc.d/pgsql start
>>baal: {17}
>
>
> What is the content of /etc/rc.d/pgsql?
>
>
>>...so I next enquire thus...
>>
>>baal: {17} initdb --help
>
> [...]
>
>
>>...and sure enough, there is no option 'm'. Anybody know what gives?
>
>
> To setup PostgreSQL, you have to create a database cluster
> # mkdir /usr/pgdata
> # chown -R pgsql.pgsql /usr/pgdata
> # su pgsql
> $ initdb -D /usr/pgdata (see man page for further options)
>
> And create a new PostgreSQL user (pgsql is the PostgreSQL admin)
> $ createuser foobar (can be different from your NetBSD login)
>
> You can go back to your normal NetBSD login and create the first DB:
> $ createdb -Ufoobar MyDatabase
> $ psql MyDatabase
>
> To start PostgreSQL, you can use (as pgsql NOT as root)
> /usr/pkg/bin/pg_ctl -D /usr/pgdata/ start&
>
>
> I guess your /etc/rc.d/pgsql is old, PG changed it's syntax.
>
Thank you Stefan,
I will try the above suggestions shortly. But for now I answer
Stephan's follow-up question stated last just above.
Below is my /etc/rc.d/pgsql which was made by the the install
from pkgsrc using make && make install. It is not left-over from
prior version. Just to be sure, I removed it, and built the package
again and it came back again just like so...
<BEGIN pgsql>
pgsql_precmd()
{
if [ ! -d ${pgsql_home}/data/base ]; then
pgsql_initdb
fi
}
pgsql_initdb()
{
initdb="/usr/pkg/bin/initdb"
if [ ! -x ${initdb} ]; then
return 1
fi
if [ -d ${pgsql_home}/data/base ]; then
echo "The PostgreSQL template databases have already
been initialized."
echo "Skipping database initialization."
else
echo "Initializing PostgreSQL databases."
/bin/mkdir -p -p ${pgsql_home}
/usr/sbin/chown ${pgsql_user} ${pgsql_home}
/usr/bin/chgrp ${pgsql_group} ${pgsql_home}
/bin/chmod 0750 ${pgsql_home}
eval doit_command=\"${initdb} ${common_args} ${flags}\"
doit="/usr/bin/su -m ${pgsql_user} -c '${doit_command}'"
eval $doit
fi
}
pgsql_doit()
{
action=$1
case ${action} in
start|restart)
if [ -n "${pgsql_flags}" ]; then
start_command_args="${start_command_args} -o
\\\"${pgsql_flags}\\\""
fi
command_args="${common_args} ${start_command_args}
${command_args}"
;;
stop)
command_args="${common_args} ${stop_command_args}
${command_args}"
;;
*)
command_args="${common_args} ${command_args}"
;;
esac
if [ ! -x ${ctl_command} ]; then
return
fi
case ${action} in
start) echo "Starting ${name}." ;;
stop) echo "Stopping ${name}." ;;
restart) echo "Restarting ${name}." ;;
esac
eval doit_command=\"${ctl_command} ${action} ${command_args}\"
doit="/usr/bin/su -m ${pgsql_user} -c '${doit_command}'"
eval $doit
}
if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
load_rc_config $name
run_rc_command "$1"
else
if [ -f /etc/rc.conf ]; then
. /etc/rc.conf
fi
case "$1" in
initdb)
eval ${initdb_cmd}
;;
restart)
eval ${restart_cmd}
;;
stop)
eval ${stop_cmd}
;;
*)
eval ${start_precmd}
eval ${start_cmd}
;;
esac
fi
<END pgsql>