SPAM: Staring programs at boot - first time at doing this
On SuSE 10.0 booting to level 3 command line only. I'm looking to start a postgresql database on boot and have a command line ready to key in. Into which file(s) should I put it to ensure that it executes on system reboot? Do I need to do anything else to activate it apart from a reboot? Thanks John
* John
On SuSE 10.0 booting to level 3 command line only.
I'm looking to start a postgresql database on boot and have a command line ready to key in.
Into which file(s) should I put it to ensure that it executes on system reboot?
for system, put in /etc/init.d/boot.local for user, put in ~/.bash_login (assuming bash)
Do I need to do anything else to activate it apart from a reboot?
reboot? this is *not* windoz, the above will suffice. -- Patrick Shanahan Registered Linux User #207535 http://wahoo.no-ip.org @ http://counter.li.org HOG # US1244711 Photo Album: http://wahoo.no-ip.org/gallery2
On Friday 13 October 2006 00:00, Patrick Shanahan wrote:
* John
[10-12-06 16:40]: On SuSE 10.0 booting to level 3 command line only.
I'm looking to start a postgresql database on boot and have a command line ready to key in.
Into which file(s) should I put it to ensure that it executes on system reboot?
for system, put in /etc/init.d/boot.local for user, put in ~/.bash_login (assuming bash)
.bash_login is run at LOGIN time. He wants it run at BOOT time. Also, he wants it to run in runlevel 3. boot.local is run before runlevel 1 is entered: owl:/etc/init.d # cat boot.local #! /bin/sh <snip> # Here you should add things, that should happen directly after booting # before we're going to the first run level. So, the answer looks something like this: cd /etc/init.d take any of those scripts and modify it to start, stop, and restart postgress (at a minimum, start and stop). For example's sake, we'll call the script postgres. cd rc3.d ln -s /etc/init.d/postgres ./S99postgres ln -s /etc/init.d/postgres ./K01postgres That's all there is to it. The only tricky part is creating the stop/start script if you don't know how to write/edit shell scripts. In that case, you can get by with something simple like: cd /etc/init.d create a file called postgres.start and put these lines in it: #!/bin/sh ... actual command which starts postgres ... now create a file called postgres.stop, which should look like: #!/bin/sh .... command which stops postgres ... chmod 0755 postgres.* cd rc3.d ln -s /etc/init.d/postgres.start S99postgres ln -s /etc/init.d/postgres.stop K01postgres Done. i would be very surprised if Suse does not come with a postgres init script already (i don't have pg installed, so i don't have such a script). -- ----- stephan@s11n.net http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Friday 2006-10-13 at 00:34 +0200, stephan beal wrote:
cd rc3.d ln -s /etc/init.d/postgres ./S99postgres ln -s /etc/init.d/postgres ./K01postgres
Caution! In SuSE Linux those symlinks can be erased by Yast at the first chance it has. That's not the correct way, read the "man init.d" and the corresponding chapter in the admin book. The script should be created according to a certain syntax shown in "/etc/init.d/skeleton", and activated via "chkconfig scriptname on" or via insserv or yast.
i would be very surprised if Suse does not come with a postgres init script already (i don't have pg installed, so i don't have such a script).
It does. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFFLt/6tTMYHG2NR9URAk8iAJ4w38+EmlMtKMNlQhtkhw+YXjXLHwCgiSRr 1f3KmoOfTZVP8zy1k6NpNuQ= =sZR0 -----END PGP SIGNATURE-----
stephan beal wrote:
So, the answer looks something like this:
cd /etc/init.d
take any of those scripts and modify it
There is a skeleton script for just that purpose. /etc/init.d/skeleton
to start, stop, and restart postgress (at a minimum, start and stop). For example's sake, we'll call the script postgres.
cd rc3.d ln -s /etc/init.d/postgres ./S99postgres ln -s /etc/init.d/postgres ./K01postgres
No, better use "insserv" for that.
i would be very surprised if Suse does not come with a postgres init script already
Me too. /Per Jessen, Zürich
stephan beal wrote:
On Friday 13 October 2006 00:00, Patrick Shanahan wrote:
* John
[10-12-06 16:40]: On SuSE 10.0 booting to level 3 command line only.
I'm looking to start a postgresql database on boot and have a command line ready to key in.
Into which file(s) should I put it to ensure that it executes on system reboot?
for system, put in /etc/init.d/boot.local for user, put in ~/.bash_login (assuming bash)
.bash_login is run at LOGIN time. He wants it run at BOOT time. Also, he wants it to run in runlevel 3. boot.local is run before runlevel 1 is entered:
owl:/etc/init.d # cat boot.local #! /bin/sh <snip> # Here you should add things, that should happen directly after booting # before we're going to the first run level.
So, the answer looks something like this:
cd /etc/init.d
take any of those scripts and modify it to start, stop, and restart postgress (at a minimum, start and stop). For example's sake, we'll call the script postgres.
cd rc3.d ln -s /etc/init.d/postgres ./S99postgres ln -s /etc/init.d/postgres ./K01postgres
That's all there is to it. The only tricky part is creating the stop/start script if you don't know how to write/edit shell scripts. In that case, you can get by with something simple like:
cd /etc/init.d
create a file called postgres.start and put these lines in it:
#!/bin/sh ... actual command which starts postgres ...
now create a file called postgres.stop, which should look like:
#!/bin/sh .... command which stops postgres ...
chmod 0755 postgres.* cd rc3.d ln -s /etc/init.d/postgres.start S99postgres ln -s /etc/init.d/postgres.stop K01postgres
Done.
i would be very surprised if Suse does not come with a postgres init script already (i don't have pg installed, so i don't have such a script).
Now I'm getting confused (which, let's face it doesn't take much these days). To recap, my SuSE 10 server boots to runlevel 3. In event of power outage, for example, I need to issue a command line similar to: su -c postmaster -D ... postgresql_user & to get my database started. If I put it into boot-local, it looks as if this command will run before postgres is loaded and will, therefore, fail. I don't think I'm looking for the complexity of adapting the /etc/init.d/skeleton file but I'm willing to be proven wrong here since this is the first time I've looked seriously at a boot script. To my simplistic, naive way of thinking, what I'd like to do is put this command line into a script file and get the boot process to fire it for me, regardless of the target run level, although I have restricted the server to 3. TIA John
John wrote:
stephan beal wrote:
On Friday 13 October 2006 00:00, Patrick Shanahan wrote:
* John
[10-12-06 16:40]: On SuSE 10.0 booting to level 3 command line only.
I'm looking to start a postgresql database on boot and have a command line ready to key in.
Into which file(s) should I put it to ensure that it executes on system reboot?
for system, put in /etc/init.d/boot.local for user, put in ~/.bash_login (assuming bash)
.bash_login is run at LOGIN time. He wants it run at BOOT time. Also, he wants it to run in runlevel 3. boot.local is run before runlevel 1 is entered:
owl:/etc/init.d # cat boot.local #! /bin/sh <snip> # Here you should add things, that should happen directly after booting # before we're going to the first run level.
So, the answer looks something like this:
cd /etc/init.d
take any of those scripts and modify it to start, stop, and restart postgress (at a minimum, start and stop). For example's sake, we'll call the script postgres.
cd rc3.d ln -s /etc/init.d/postgres ./S99postgres ln -s /etc/init.d/postgres ./K01postgres
That's all there is to it. The only tricky part is creating the stop/start script if you don't know how to write/edit shell scripts. In that case, you can get by with something simple like:
cd /etc/init.d
create a file called postgres.start and put these lines in it:
#!/bin/sh ... actual command which starts postgres ...
now create a file called postgres.stop, which should look like:
#!/bin/sh .... command which stops postgres ...
chmod 0755 postgres.* cd rc3.d ln -s /etc/init.d/postgres.start S99postgres ln -s /etc/init.d/postgres.stop K01postgres
Done.
i would be very surprised if Suse does not come with a postgres init script already (i don't have pg installed, so i don't have such a script).
Now I'm getting confused (which, let's face it doesn't take much these days).
To recap, my SuSE 10 server boots to runlevel 3.
In event of power outage, for example, I need to issue a command line similar to:
su -c postmaster -D ... postgresql_user &
to get my database started.
If I put it into boot-local, it looks as if this command will run before postgres is loaded and will, therefore, fail.
I don't think I'm looking for the complexity of adapting the /etc/init.d/skeleton file but I'm willing to be proven wrong here since this is the first time I've looked seriously at a boot script.
To my simplistic, naive way of thinking, what I'd like to do is put this command line into a script file and get the boot process to fire it for me, regardless of the target run level, although I have restricted the server to 3.
TIA
John
Or do I just need to copy /etc/init.d/skeleton to, say, my_postgres_startup in the same directory and add my command line in the section case start)? J
John wrote:
Or do I just need to copy /etc/init.d/skeleton to, say, my_postgres_startup in the same directory and add my command line in the section case start)?
Given that you don't appear too comfortable with editing these scripts and such, why don't you just install the SUSE postgresql package which has the init-script and everything else ready to go? /Per Jessen, Zürich
Per Jessen wrote:
John wrote:
Or do I just need to copy /etc/init.d/skeleton to, say, my_postgres_startup in the same directory and add my command line in the section case start)?
Given that you don't appear too comfortable with editing these scripts and such, why don't you just install the SUSE postgresql package which has the init-script and everything else ready to go?
/Per Jessen, Zürich
Editing the scripts is no problem, I just want to be sure that I get it reasonably right first time without screwing up too much. Don't forget that this is my first venture in this direction; I'm just being cautious! I understand from the postgresql documentation that after I've run initdb to set up my data repository, I have to run postmaster (or psql) each time the server reboots so that that database repository is available for use and its connection port is specified. If that is incorrect, then I don't need a script but if it is correct, then this script comes into play. Thanks for your tolerance John
John wrote:
I understand from the postgresql documentation that after I've run initdb to set up my data repository, I have to run postmaster (or psql) each time the server reboots so that that database repository is available for use and its connection port is specified.
This is correct, but [I am 99.99% sure] it will be done for you by scripts that Suse supply. The postgresql documentation is generic, of necessity, so you also need to read the Suse docs. I use mysql and that is how that works. You may also find more info on the lists at http://www.postgresql.org/community/lists/ Cheers, Dave
Dave Howorth wrote:
John wrote:
I understand from the postgresql documentation that after I've run initdb to set up my data repository, I have to run postmaster (or psql) each time the server reboots so that that database repository is available for use and its connection port is specified.
This is correct, but [I am 99.99% sure] it will be done for you by scripts that Suse supply. The postgresql documentation is generic, of necessity, so you also need to read the Suse docs.
I use mysql and that is how that works.
You may also find more info on the lists at http://www.postgresql.org/community/lists/
Cheers, Dave
Thanks for clarifying that, Dave. OK, if I take the defaults from SuSE's installation then I don't need a separate script for rebooting because it's already setup for me. However, if I wish to have a second repository (e.g. to keep work and home databases separate) then I need to setup a command line to invoke postmaster to open a database repository on a different port for that. I think the mud is starting to clear a bit. All I need now is to find the best place to put that command line and it seems that a new file in /etc/init.d (adhering to the init instructions) and containing suitable entries under start and stop should fit the bill. Thanks J
John wrote:
Thanks for clarifying that, Dave.
OK, if I take the defaults from SuSE's installation then I don't need a separate script for rebooting because it's already setup for me.
However, if I wish to have a second repository (e.g. to keep work and home databases separate) then I need to setup a command line to invoke postmaster to open a database repository on a different port for that.
One database server can serve several databases at the same time. Access to each database is controlled separately. So there's no need to run two servers on different ports. You can just use one server with two databases. That will simplify your configuration - e.g. no need for a separate startup script, no need to tweak your firewall.
I think the mud is starting to clear a bit. All I need now is to find the best place to put that command line and it seems that a new file in /etc/init.d (adhering to the init instructions) and containing suitable entries under start and stop should fit the bill.
If you really want to start two servers, then copy whatever script Suse uses and change the details appropriately. Again, you'll likely find better answers on the pg lists (or in their archives) Cheers, Dave
On Friday 13 October 2006 17:54, John wrote:
I think the mud is starting to clear a bit. All I need now is to find the best place to put that command line and it seems that a new file in /etc/init.d (adhering to the init instructions) and containing suitable entries under start and stop should fit the bill.
Right, but you can also put the command in the existing postgres startup script. Or copy the original, rename it to postgres.local (or similar), edit it to suit, and symlink that under /etc/rc3.d as described in earlier posts. -- ----- stephan@s11n.net http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts
stephan beal wrote:
On Friday 13 October 2006 17:54, John wrote:
I think the mud is starting to clear a bit. All I need now is to find the best place to put that command line and it seems that a new file in /etc/init.d (adhering to the init instructions) and containing suitable entries under start and stop should fit the bill.
Right, but you can also put the command in the existing postgres startup script. Or copy the original, rename it to postgres.local (or similar), edit it to suit, and symlink that under /etc/rc3.d as described in earlier posts.
Thanks to everyone for your help on this. My course of action will be, although I generally do not like modifying files which could be overwritten by an upgrade, is to modify the existing postgres in /etc/init.d and to keep a backup copy elsewhere (in case it does get overwritten!). Yes, I understand that one instance of PostgreSQL can contain many databases; I do not wish to mix work and home databases in the same grouping. I also plan a separate instance for web-based databases later. Each such instance must have its own directory and run on a unique port and so must be started with their own command line having unique -D and -p options I note also that the existing postgres init file handles the change of user and also ensures that PostgreSQL is already started so it makes sense to edit it rather than start from scratch. What this discussion has also shewn me is that, in effect, I get a database for which I hadn't planned, for free - the default! Many Thanks John
John wrote:
Now I'm getting confused (which, let's face it doesn't take much these days).
To recap, my SuSE 10 server boots to runlevel 3.
In event of power outage, for example, I need to issue a command line similar to:
su -c postmaster -D ... postgresql_user &
to get my database started.
If I put it into boot-local, it looks as if this command will run before postgres is loaded and will, therefore, fail.
I think there may be some terminological differences that are causing confusion. postgresql is a database server. It contains data in one or more databases. Assuming you installed postgresql from Suse's packages, then all that is needed to start the database server, and all the databases in it at boot-time is to use the run-level editor in YaST. You don't need to write any scripts.
I don't think I'm looking for the complexity of adapting the /etc/init.d/skeleton file but I'm willing to be proven wrong here since this is the first time I've looked seriously at a boot script.
I think you're saying that you have a separate script - postgresql_user - that presumably uses one of the databases? And that you want to start as a server process at boot time? If so, then yes, you want to adapt the skeleton. If not, what's in your script? Read the section on adding init scripts in the admin guide.
To my simplistic, naive way of thinking, what I'd like to do is put this command line into a script file and get the boot process to fire it for me, regardless of the target run level, although I have restricted the server to 3.
Yup, that's what init.d is all about. Cheers, Dave PS
Or do I just need to copy /etc/init.d/skeleton to, say, my_postgres_startup in the same directory and add my command line in the section case start)?
Quite likely. You may also need to add something to close it down, and in an ideal world, something to get the operational status. Depends what your server is doing.
participants (6)
-
Carlos E. R.
-
Dave Howorth
-
John
-
Patrick Shanahan
-
Per Jessen
-
stephan beal