Thread: Linux not starting postgres automatically

Linux not starting postgres automatically

From
Jagdish rao
Date:
hi friends

pls help me

i have a Linux redhat 9 machine
and i have installed the POstgres 7.4.5 using the
sources

the problem heppens when i want the postgres to start
automatically when my server is booted
i have written a shell script in rc.local for doing
this which looks as shown below
my applications like jonas are stared as User : root
i login as root which starts my applicatios
automatically
but as postgres has to be started only as user :
postgres
shell scripts stops at the command su postgres and
does not execute further.

i searched for help and some suggestions were

using chkconfig --add postgresql
when i did that it says error reading info on
postgresql service no such file or directory
i guess this is bcos postgres is not installed as a
service

so this didn't help

pls help me in achieving this .

#!bin/tcsh

ANT_HOME=/home/deploy/local/ant

JAVA_HOME=/home/deploy/local/jdk

JONAS_ROOT=/usr/local/JONAS414

PGDATA=/usr/local/pgsql/data

PATH=$JAVA_HOME/bin:/home/deploy/local/ant/bin:/usr/local/pgsql/bin:$PATH:/usr/local/JONAS414/bin/unix


CLASSPATH=:.:$JAVA_HOME/lib:/usr/local/kesintlclasses:/usr/local/JONAS414/lib/commons/j2ee/ejb-2_1-api.jar:/usr/local/JONAS414/lib/commons/j2ee/jta-spec1_0_1.jar

#export JONAS_ROOT PATH JAVA_HOME TOMCAT_HOME

export CLASSPATH PATH JAVA_HOME CATALINA_HOME
JONAS_ROOT PGDATA

echo 'set java home .........'
echo $JAVA_HOME
echo 'starting postgres.....'

(su postgres ; postmaster)

echo 'started postgres.....'


echo 'starting jonas.....'

jonas start









__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Re: Linux not starting postgres automatically

From
Devrim GUNDUZ
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi,

On Wed, 20 Oct 2004, Jagdish rao wrote:

> i have a Linux redhat 9 machine
> and i have installed the POstgres 7.4.5 using the
> sources

RPMs for Red Hat 9 are also available from any PostgreSQL FTP mirrors; you
could install the RPMs also: www.postgresql.org/mirrors-ftp.html

> the problem heppens when i want the postgres to start
> automatically when my server is booted
> i have written a shell script in rc.local for doing
> this which looks as shown below
> my applications like jonas are stared as User : root
> i login as root which starts my applicatios
> automatically
> but as postgres has to be started only as user :
> postgres
> shell scripts stops at the command su postgres and
> does not execute further.

You should execute something like this:

su -l postgres -c "/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data start"

Put this line in /etc/rc.local. (If you've installed PostgreSQL under a
different directory, then edit the line above)

...or download

http://postgresql.gunduz.org/init_scripts/RedHat9/postgresql-source

and move it under /etc/init.d with the name  postgresql . Then
run

chkconfig --add postgresql
chkconfig --levels 2345 postgresql on

Modify the script if you've installed postgresql under a different
directory than /usr/local/pgsql

> i searched for help and some suggestions were
>
> using chkconfig --add postgresql
> when i did that it says error reading info on
> postgresql service no such file or directory
> i guess this is bcos postgres is not installed as a
> service

Since you haven't installed from RPMs, there is no default init script
installed under /etc/init.d. So chkconfig does not make sense there. If
you install postgresql from the RPMs, then running

chkconfig --levels 2345 postgresql on

will help you.

Regards,
- --
Devrim GUNDUZ
devrim~gunduz.org                devrim.gunduz~linux.org.tr
             http://www.tdmsoft.com
             http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFBd1WOtl86P3SPfQ4RAv+JAKDif1al63T8pfY1s7Rqi6qBcasAsgCdG9lB
wGNSfnmwtWzYkuUnbkmHZ80=
=dPf1
-----END PGP SIGNATURE-----

indexes are not working for

From
Anshaj
Date:
Dear group,

         I have a table foo
anshajdb=# \d foo
           Table "public.foo"
 Column  |       Type        | Modifiers
---------+-------------------+-----------
 snumber | numeric(18,0)     |
 test    | character varying |
Indexes:
    "snum_idx" btree (snumber)

when I try to do a query like
explain analyze select * from foo where snumber > 1000;

Seq Scan on foo  (cost=0.00..69.00 rows=320 width=391) (actual
time=0.011..0.721 rows=323 loops=1)
   Filter: (snumber > 1000::numeric)
 Total runtime: 0.979 ms
(3 rows)
It do a sequence scan on table. Why it is not using the snum_idx in this
query. Do I need to change some setting or indexes don't work on this
types of query.


Thanks and Regards
Anshaj



 --
"Normal people believe that if it ain't broke, don't
fix it. Engineers believe that if it ain't broke, it
doesn't have enough features yet."


Re: indexes are not working for

From
Robert Treat
Date:
Please do not post new topic as reply's to unrelated threads!!

On Friday 22 October 2004 02:10, Anshaj wrote:
> Dear group,
>
>          I have a table foo
> anshajdb=# \d foo
>            Table "public.foo"
>  Column  |       Type        | Modifiers
> ---------+-------------------+-----------
>  snumber | numeric(18,0)     |
>  test    | character varying |
> Indexes:
>     "snum_idx" btree (snumber)
>
> when I try to do a query like
> explain analyze select * from foo where snumber > 1000;
>
> Seq Scan on foo  (cost=0.00..69.00 rows=320 width=391) (actual
> time=0.011..0.721 rows=323 loops=1)
>    Filter: (snumber > 1000::numeric)
>  Total runtime: 0.979 ms
> (3 rows)
> It do a sequence scan on table. Why it is not using the snum_idx in this
> query. Do I need to change some setting or indexes don't work on this
> types of query.
>

You query is not selective enough for the database to use an index. ie. your
retrieving 323 rows from at best 1323 rows in the table, so the database
figures it can grab all of the records much faster by just doing a seq scan
on the table.   Try adding some more data to the table and/or selecting a
specific value and you'll see your index get used.

--
Robert Treat
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL

Re: indexes are not working for

From
Tom Lane
Date:
Anshaj <anshaj@in2m.com> writes:
> when I try to do a query like
> explain analyze select * from foo where snumber > 1000;
> It do a sequence scan on table.

One-sided inequalities are frequently not selective enough to justify an
indexscan.  A rule of thumb is that if the WHERE selects more than one
or two percent of the table, you will (and should) get a seqscan.

            regards, tom lane