Обсуждение:

Поиск
Список
Период
Сортировка

От
"Janet"
Дата:
Hello!

I don't know if there is the right place to ask my question. If not, please
accept my apology.

I'm totally new to Linux. And I have troubles using the PostgreSQL.

I installed Redhat 6.0 and find there is postgresql already installed on my
computer.
Running the following command I get:
////////////////////////////////////////////////////
$rpm -ql postgresql
/etc/rc.d/init.d/postgresql
/usr/bin/cleardbdir
/usr/bin/createdb
/usr/bin/createuser
/usr/bin/destroydb
/usr/bin/destroyuser
/usr/bin/initdb
/usr/bin/initlocation
/usr/bin/pg_passwd
/usr/bin/pg_version
/usr/bin/postgres
/usr/bin/postmaster
/usr/doc/postgresql-6.4.2
.....
(All the /usr/doc entried are omitted here since they are too many)
......
/var/lib/pgsql
///////////////////////////////////////////

I thought it's ok to start the postgresql server, so I run the following
command but it complains:
(the command was found in the "/etc/rc.d/init.d/postgresql" file)
//////////////////////////////////////////////
$postmaster -i -D/var/lib/pgsql
/usr/bin/postmaster does not find the database system.  Expected to find it
in the PGDATA directory "/var/lib/pgsql", but unable to open file with
pathname "/var/lib/pgsql/base/template1/pg_class".

No data directory -- can't proceed.
////////////////////////////////////////////

I read the installation instruction of the PostgreSQL but it teaches you how
to install from the beginning and expect you to use the file
"postgresql-v6.4.tar.gz", which I haven't got on my computer.

I also tried to run the following command:
$initdb
but it cannot work yet.

Someone told me I should establish a data store for the PostgreSQL. What's
that? How to?

Do I need to download "postgresql-v6.4.tar.gz" to re-install the PostgreSQL?
Or how can I
solve my problem? What's in the earth wrong? What's indeed the PGDATA mean?

Any suggestion or hints are appreciated greatly!

With my best regard:
Janet





Re:

От
"Robert B. Easter"
Дата:
Maybe try getting postgresql-7.0.tar.gz. from www.postgresql.org.  Then do
something like the following commands:

su -
groupadd postgres
adduser postgres
    Note: make postgres user with default group postgres
cd /usr/local/src
tar -xvzf postgresql-7.0.tar.gz
cd postgresql-7.0
less INSTALL
./configure
    --prefix=/usr/local/pgsql
    --with-perl --with-tcl
    --with-maxbackends=256
make
make install
cd doc
make install
cd /usr/local
chown -R postgres:postgres pgsql
cd /etc
vi profile
    Note:    add /usr/local/pgsql/bin to PATH
        add /usr/local/pgsql/man to MANPATH
        set PGLIB=/usr/local/pgsql/lib
        set PGDATA=/usr/local/pgsql/data
    Then exit and log back in to take effect.
su - postgres
initdb
exit

Now you can start the database.  To start it, you can use pg_ctl that comes
with postgresql, or you can make a script like the following
/etc/rc.d/init.d/postgresql:

#!/bin/sh
# See how we were called.
case "$1" in
  start)
        # Start daemons.
        echo -n "Starting postgres Postmaster daemon:"
        if [ -z "`pidof -s postmaster`" ]
        then
                su postgres -c "/usr/local/pgsql/bin/postmaster -S -D /usr/local/pgsql/data &"
                echo -n " postmaster"
        else
                echo -n " (already running)"
        fi
        echo
        #touch /var/lock/subsys/postgres
        ;;
  stop)
        # Stop daemons.
        echo -n "Shutting down postgres Postmaster daemon: "
        killall -TERM postmaster 2>/dev/null
        killall -TERM postgres 2>/dev/null
        echo postmaster postgres
        rm -f /tmp/.s.PGSQL.5432
        ;;
  *)
        echo "Usage: postgres {start|stop}"
        exit 1
esac
exit 0

Now start the database:
/etc/rc.d/init.d/postgresql start
You will have to add this into your startup scripts.
/etc/rc.d/init.d/postgresql stop,  can be put in your shutdown scripts.

Then do the following with the server started:

su - postgres
createuser <some username>
    Do this for each user you will have.

Once you have your user created, you can login to the user and run:

createdb
    Note: creates a database called <username> by default.
psql
    Note: connect to your <username> database by default.

At this point you'll be able to start using SQL and create tables etc.
I think these instructions are ok.  Hope it helps.


On Tue, 23 May 2000, Janet wrote:
> Hello!
>
> I don't know if there is the right place to ask my question. If not, please
> accept my apology.
>
> I'm totally new to Linux. And I have troubles using the PostgreSQL.
>
> I installed Redhat 6.0 and find there is postgresql already installed on my
> computer.
> Running the following command I get:
> ////////////////////////////////////////////////////
> $rpm -ql postgresql
> /etc/rc.d/init.d/postgresql
> /usr/bin/cleardbdir
> /usr/bin/createdb
> /usr/bin/createuser
> /usr/bin/destroydb
> /usr/bin/destroyuser
> /usr/bin/initdb
> /usr/bin/initlocation
> /usr/bin/pg_passwd
> /usr/bin/pg_version
> /usr/bin/postgres
> /usr/bin/postmaster
> /usr/doc/postgresql-6.4.2
> .....
> ((All the /usr/doc entried are omitted here since they are too many)
> ......
> //var/lib/pgsql
> ///////////////////////////////////////////
>
> I thought it's ok to start the postgresql server, so I run the following
> command but it complains:
> (the command was found in the "/etc/rc.d/init.d/postgresql" file)
> //////////////////////////////////////////////
> $postmaster -i -D/var/lib/pgsql
> /usr/bin/postmaster does not find the database system.  Expected to find it
> in the PGDATA directory "/var/lib/pgsql", but unable to open file with
> pathname "/var/lib/pgsql/base/template1/pg_class".
>
> No data directory -- can't proceed.
> ////////////////////////////////////////////
>
> I read the installation instruction of the PostgreSQL but it teaches you how
> to install from the beginning and expect you to use the file
> "postgresql-v6.4.tar.gz", which I haven't got on my computer.
>
> I also tried to run the following command:
> $initdb
> but it cannot work yet.
>
> Someone told me I should establish a data store for the PostgreSQL. What's
> that? How to?
>
> Do I need to download "postgresql-v6.4.tar.gz" to re-install the PostgreSQL?
> Or how can I
> solve my problem? What's in the earth wrong? What's indeed the PGDATA mean?
>
> Any suggestion or hints are appreciated greatly!
>
> With my best regard:
> Janet
--
Robert B. Easter
reaster@comptechnews.com

Re:

От
Mike Mascari
Дата:
Janet wrote:
>
> Hello!
>
> I don't know if there is the right place to ask my question. If not,
> please accept my apology.
>
> I'm totally new to Linux. And I have troubles using the PostgreSQL.
>
> I installed Redhat 6.0 and find there is postgresql already installed
> on my computer.
> Running the following command I get:
> ////////////////////////////////////////////////////
> $rpm -ql postgresql
> /etc/rc.d/init.d/postgresql
> /usr/bin/cleardbdir
> /usr/bin/createdb
> /usr/bin/createuser
> /usr/bin/destroydb
> /usr/bin/destroyuser
> /usr/bin/initdb
> /usr/bin/initlocation
> /usr/bin/pg_passwd
> /usr/bin/pg_version
> /usr/bin/postgres
> /usr/bin/postmaster
> /usr/doc/postgresql-6.4.2

6.4 is particularly old. So I would do the following:

1. Become the root user:

su

2. Uninstall the old packagaes:

rpm -e postgresql
rpm -e postgresql-clients
rpm -e postgresql-devel

3. Ftp the new rpms from ftp.postgresql.org:

ftp://ftp.postgresql.org/pub/binary/v7.0/redhat-RPM/RPMS/redhat-6.x/

At a minimum, you'll want to download:

postgresql-7.0-2.i386.rpm -- this includes clients and shared
code
postgresql-devel-7.0-2.i386.rpm -- this is for development
postgresql-server-7.0-2.i386.rpm -- this is the actual server

4. Install the rpms:

rpm -i postgresql-7.0-2*

5. Start the server:

cd /etc/rc.d/init.d
./postgresql start

The newer RPMS, thanks to Lamar Owen, will *automatically* create
the appropriate postgres user and group when installed, and
initialize the database system for you the first time you start
the server using the script above. Once the database starts, you
can create users and a non-template database:

6. Become user postgres from root:

su postgres

7. Connect to the template database:

psql template1

bash$ psql template1
Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

template1=#

8. Create a database user. Your normal unix account would be
appropriate:

template1=# CREATE USER mascarj CREATEDB;
CREATE USER

9. Disconnect from the database as user postgres and reconnect as
your normal unix account:

template1=# \q
bash$ exit
exit
[root@ferrari init.d]# exit
exit
[mascarj@ferrari init.d]$

10. Reconnect to template1 using your normal unix account and
create a database:

[mascarj@ferrari mascarj]$ psql template1;
Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

template1=> CREATE DATABASE example;
CREATE DATABASE
template1=>

You'll notice that the psql prompt is a '>' instead of a '#' to
denote that you are not the postgres DBA user.

11. Disconnect from the template1 database and connect to the
database you've just created:

template1=> \q
[mascarj@ferrari mascarj]$ psql example;
Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

example=>

Now your ready to create tables, views, sequences and all that
other good stuff.

Hope that helps,

Mike Mascari

RE:

От
"Charlie Derr"
Дата:
First of all, thank you very much for this detailed answer.  (and also thanx
to Janet for asking :-] )   I am a postgresql newbie as well, and this is
very very helpful.  I had been trying to get things to work under NT, but
decided to reboot to linux and try it there when I saw these detailed
instructions.

Fantastic stuff. Thank you so much Mr. Easter.

~
~ Maybe try getting postgresql-7.0.tar.gz. from www.postgresql.org.  Then do
~ something like the following commands:
~
~ su -
~ groupadd postgres
~ adduser postgres

I found that on RedHat 6.1, I was only able to add a user or a group if I
was actually logged in as root.  "su" didn't do it for me.


~     Note: make postgres user with default group postgres
~ cd /usr/local/src
~ tar -xvzf postgresql-7.0.tar.gz
~ cd postgresql-7.0
~ less INSTALL

cd /src

~ ./configure
~     --prefix=/usr/local/pgsql
~     --with-perl --with-tcl
~     --with-maxbackends=256
~ make
~ make install

cd ..

~ cd doc
~ make install
~ cd /usr/local
~ chown -R postgres:postgres pgsql
~ cd /etc
~ vi profile
~     Note:    add /usr/local/pgsql/bin to PATH
~         add /usr/local/pgsql/man to MANPATH
~         set PGLIB=/usr/local/pgsql/lib
~         set PGDATA=/usr/local/pgsql/data
~     Then exit and log back in to take effect.

I found that this affected "my" environment variables, but it didn't affect
the environment variables for the postgres user i had created, so i added
these statements to the /home/postgres/.bashrc file.  Is this good enough?
Or is there somewhere else that i should set these vars instead?


~ su - postgres
~ initdb

I got an error message here about needing to set PGDATA or use the --pgdata
switch (unfortunately i didn't paste the error message onto a floppy like i
thought i could so i could read it here in NT)  -- i did make sure i had
created an empty data directory though

~ exit
~
~ Now you can start the database.

And that's as far as I got.  I'll start it as soon as I'm sure I've got
everything right.

I'm presently trying the same (well,... similar) instructions on NT.  The
obvious question is what to do about creating a user.  On NT it just isn't
possible to su postgres
initdb
exit


So does that mean i just run it as myself?   This is in a non-production
environment on my workstation, where I'm hoping to eventually be addressing
the database w/zope.

Again, I can't thank this list enough for all the great info i've picked up
while lurking,
        ~c


~ To start it, you can use pg_ctl
~ that comes
~ with postgresql, or you can make a script like the following
~ /etc/rc.d/init.d/postgresql:
~
~ #!/bin/sh
~ # See how we were called.
~ case "$1" in
~   start)
~         # Start daemons.
~         echo -n "Starting postgres Postmaster daemon:"
~         if [ -z "`pidof -s postmaster`" ]
~         then
~                 su postgres -c "/usr/local/pgsql/bin/postmaster
~ -S -D /usr/local/pgsql/data &"
~                 echo -n " postmaster"
~         else
~                 echo -n " (already running)"
~         fi
~         echo
~         #touch /var/lock/subsys/postgres
~         ;;
~   stop)
~         # Stop daemons.
~         echo -n "Shutting down postgres Postmaster daemon: "
~         killall -TERM postmaster 2>/dev/null
~         killall -TERM postgres 2>/dev/null
~         echo postmaster postgres
~         rm -f /tmp/.s.PGSQL.5432
~         ;;
~   *)
~         echo "Usage: postgres {start|stop}"
~         exit 1
~ esac
~ exit 0
~
~ Now start the database:
~ /etc/rc.d/init.d/postgresql start
~ You will have to add this into your startup scripts.
~ /etc/rc.d/init.d/postgresql stop,  can be put in your shutdown scripts.
~
~ Then do the following with the server started:
~
~ su - postgres
~ createuser <some username>
~     Do this for each user you will have.
~
~ Once you have your user created, you can login to the user and run:
~
~ createdb
~     Note: creates a database called <username> by default.
~ psql
~     Note: connect to your <username> database by default.
~
~ At this point you'll be able to start using SQL and create tables etc.
~ I think these instructions are ok.  Hope it helps.
~


sorry for the waste of bandwidth but that stuff is just too valuable to snip
:-]


RE:

От
"Joseph"
Дата:
> I'm presently trying the same (well,... similar) instructions
> on NT.  The
> obvious question is what to do about creating a user.  On NT
> it just isn't
> possible to su postgres
> initdb
> exit

Here is what someone sent me to get Postgres working on NT
and it worked.
If you follow the instructions below it will look at NT's user manager and
setup user numbers as Linux expects to find them.
The one problem is you need to use an NT server that has proper
domain configuration
EX: I tried a workstation that was a domain member and it didn't work.
But it worked on the domain controller.
(I gave up and went with Linux for the server)

***************************************
Directions to get Postgres working on NT


           Sometime back I was looking for answers like you. Here is what
you can do.
   Go to this site http://www.freebsd.org/~kevlo/postgres/portNT.html
and read it.
   Then get the Cygwin and Any piper and cygipc tools.You can get Cygipc
from
   http://cygutils.netpedia.net/V1.1/cygipc-1.05/index.html.Take the NT
port from one of
   the nasa sites.Follow the instructions to the word and you will get
it.
   before you do make install there are some template files in
src/backend directory
   like *.bki.source and *.bki.description which contain Ctrl-M
characters.If you use vi editor
   you can use '%s/^M//g' to get rid of them.or u can use sed like echo
infile | sed 's/^M//g' >    outfile.

   You have to run postgres from bash prompt.However you can run the
psql client from any DOS    window.Yes it runs on NTFS .
   Get a Windows GUI client for Postgres from
http://www.pgadmin.freeserve.co.uk/
   Pass this mail to whoever is interested.
 Good Luck
PKD


Joseph