Re: Question: script to start DB on server reboot

Поиск
Список
Период
Сортировка
От scott.marlowe
Тема Re: Question: script to start DB on server reboot
Дата
Msg-id Pine.LNX.4.33.0306131430400.21088-100000@css120.ihs.com
обсуждение исходный текст
Ответ на Question: script to start DB on server reboot  ("Aurangzeb M. Agha" <ama-list@mltp.com>)
Ответы Re: Question: script to start DB on server reboot  (weigelt@metux.de)
Re: Question: script to start DB on server reboot  ("Aurangzeb M. Agha" <ama-list@mltp.com>)
Список pgsql-general
What OS are you on?  There are standard startup scripts for both BSD and
Linux in the /contrib/start-scripts directory which should work, but they
need to be run by root I believe.  Are you saying you can't get a script
run by root at startup to start postgresql?

The recommendation on changing the directory permissions is misguided, as
you NEED to have the permissions at 700 for postgresql to start up, and no
one but the postgres superuser (whatever account that may be) should be
able to go in there.

On Sun, 8 Jun 2003, Aurangzeb M. Agha wrote:

> This is more a scripting question than a DB question but since it relates
> to Postgres, and since I'm sure others on this list have tackled this same
> problem, I'm hoping I'll be able to get some help here.  Apologies in
> advance if this is the incorrect forum.
>
> I have a site hosted by an ISP which, for one reason or another, often
> needs to restart their server after upgrades, maintenance, etc...  When
> this happens, I need a script to restart my server and my Java processes.
> While I've got the entire script written, I'm having a major problem
> getting the DB to start up due to the permissions on the DB dir.
>
> The dir out of which my application is served has the following contents:
>
> drwxr-xr-x    9 admin    admin        4096 Mar 30 14:22 .
> drwxr-xr-x    3 admin    admin        4096 Mar 31 08:58 ..
> drwx------    6 postgres postgres     4096 May 19 20:55 DB
> drwxr-xr-x    5 admin    admin        4096 Mar 29 02:01 backup
> ...
> drwxr-xr-x    3 admin    admin        4096 Mar 28 23:06 lib
>
> Note that my DB dir has 700 permissions for the Postgres user and group.
> This has made it impossible for me to effect any change in this dir when
> the script runs--the script is run on startup by the admin user (this is
> requirement due to the setup by the ISP, and I don't have the power to run
> the script as root).
>
> What I need to do is very simple.  Before I start any of my other
> processes (Java, Apache, etc...), I want to start up the DB:
>
>         1.  Remove postmaster.pid if it exists
>         2.  Backup the existing log file
>         3.  Start the DB
>
> However, I can't even get into the dir due to its permission structure.
> Is my permission structure for the DB incorrect?
>
> So far, I have the following for my bash script (Note: This is my first
> bash script, so go easy).  The first line of code is the tricky one, since
> I'm not able to check for the file's existance with the current permission
> structure I have:
>
> # We only run this script if the DB is running (postmaster.pid exists).
> # If the DB is not running, don't bother to do anything else, as the site
> # is probably down for a good reason.  Postmaster.pid is in the DB dir,
> # which is only accessible to the 'postgres' user, so how do we run this
> # script, since we can only run it as 'admin', and the permission
> # structure of the DB dir only allows 'postgres' user access?
> if [ -f /usr/local/G101/App/DB/postmaster.pid ]; then
>
>         # From here on out, everything can be done by the 'admin' user
>
>         # Check how many java processes are running; if there
>     # are less than two (arbitrary), we need to restart Resin
>     $numJavaProcs=`ps -ef | grep -i java | grep -v grep | wc -l`
>         if [ $numJavaProcs -lt 2 ]; then
>
>         # Run the runResin-site.sh script to start up Resin.
>                 # Do we need to specify the nohup if the command is run by
>         # a script?
>                 nohup /usr/local/G101/App/bin/runResin-site.sh &
>
>         # Move the nohup.out file to the logs dir
>                 mv /usr/local/G101/App/bin/nohup.out
> /usr/local/G101/App/bin/logs/nohup-site.out
>
>         # Is there a way to send mail to aagha@greece101.com here
>         # to let the admin know that Resin had to be restarted?
>                 # mail -s "Resin had to be restarted!" aagha@greece101.com
>         fi
> fi
>
> # Do we need this to end the program?
> exit 0;
>
> Anyone have any thoughts or suggestions?
>
>     Thanks in Advance,
>     Aurangzeb
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>


В списке pgsql-general по дате отправления:

Предыдущее
От: Ernest E Vogelsinger
Дата:
Сообщение: Re: using sequences
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: Index not being used in MAX function (7.2.3)