LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-29-2004, 01:34 PM   #1
podollb
Member
 
Registered: Oct 2003
Location: Grand Forks, ND
Distribution: Suse/Slackware/RH
Posts: 161

Rep: Reputation: 30
ssh across a bunch of nodes


Hi,
I have a network of computers I am using as a cluster (worker nodes). I need to start a process on each one and make it long lived. I know of the "nohup" prefix, but if I have 100 nodes and I want to ssh to all the nodes in an automated way, how can I do that... So basically run a script like: startWorkers.sh or something that will logon to each one and start a worker process and then logout.
 
Old 04-29-2004, 01:39 PM   #2
Matt Collier
Member
 
Registered: Apr 2004
Distribution: Debian
Posts: 80

Rep: Reputation: 15
#!/bin/sh
hosts="host1 host2 host3 ..."
for i in $hosts; do
ssh login@$i startWorkers.sh
done
 
Old 04-29-2004, 02:11 PM   #3
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 683

Rep: Reputation: 63
You need PDSH.
http://www.llnl.gov/linux/pdsh/pdsh.html

It allows you to run commands across all the nodes in your cluster or just specified nodes. I believe it also comes with pdcp that allows you to copy files around your cluster.

Last edited by Blinker_Fluid; 04-29-2004 at 02:13 PM.
 
Old 04-29-2004, 02:19 PM   #4
podollb
Member
 
Registered: Oct 2003
Location: Grand Forks, ND
Distribution: Suse/Slackware/RH
Posts: 161

Original Poster
Rep: Reputation: 30
That sounds like it doesn't work to well under ssh (especially if passwords are needed), and if I was using rsh I wouldn't use that, a script to start jobs across rsh is trivial.
 
Old 04-29-2004, 03:09 PM   #5
Matt Collier
Member
 
Registered: Apr 2004
Distribution: Debian
Posts: 80

Rep: Reputation: 15
passwordless ssh is easy enough to configure if you trust the machines involved
 
Old 04-29-2004, 03:10 PM   #6
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 683

Rep: Reputation: 63
I sure hope you aren't putting in a password to ssh to 100 nodes in a cluster.
You do have ssh set up on your cluster so you don't have to put a password right?

The advantage of pdsh is you are doing all the nodes at once. The script earlier in this thread is going to do things in a serial fashion. I believe you can compile it to run via ssh but just like rsh you have to set up the nodes so you don't have to put in a password.
 
Old 04-29-2004, 03:26 PM   #7
podollb
Member
 
Registered: Oct 2003
Location: Grand Forks, ND
Distribution: Suse/Slackware/RH
Posts: 161

Original Poster
Rep: Reputation: 30
I guess the clusters I have used always had rsh so it was simple to use, but my current problem is that the cluster (is really a network of computers) and it doesn't have ssh. So your above options sound good, but I don't know too much about how to use passwordless ssh, besides ssh-agent and using an ssh key (is that what you are referring to?)
 
Old 04-29-2004, 03:40 PM   #8
Matt Collier
Member
 
Registered: Apr 2004
Distribution: Debian
Posts: 80

Rep: Reputation: 15
that is what i'm referring to, yes, though if you already know how to do it, i'm afraid i don't understand your 2nd comment about passwords not making things work.

besides, if ssh isn't an option, then it a moot point really.

pdsh looks far better anyway, since it'll manage the connections for you, though if it were me, i'd still rather use pdsh over ssh, particularly if you need to send the same passwords out over and over on an untrusted network
 
Old 04-29-2004, 03:47 PM   #9
podollb
Member
 
Registered: Oct 2003
Location: Grand Forks, ND
Distribution: Suse/Slackware/RH
Posts: 161

Original Poster
Rep: Reputation: 30
Yeah I do know about passwordless I guess and pshd might be an option...
But I do konw that pshd is only used with passwordless (at the prompt anyway) ssh.

For my problem it doesn't matter if things are started sequentially or not since I am basically starting worker nodes that are listening for work...

This may be a silly question but with the sequential script above how do I get around the script waiting at the first host (until that process terminates)? I tried putting a & at the end of my command but to no avail...
 
Old 04-29-2004, 03:54 PM   #10
Matt Collier
Member
 
Registered: Apr 2004
Distribution: Debian
Posts: 80

Rep: Reputation: 15
'daemonise' the script, fork the process and make the parent exit, then set the group of the child to 0, and make sure you have some kind of exit handler for the children to clean up after themselves

#!/usr/bin/perl

my $childpid = fork;
exit if $childpid;
setpgrp(0,$$);
 
Old 04-29-2004, 07:24 PM   #11
podollb
Member
 
Registered: Oct 2003
Location: Grand Forks, ND
Distribution: Suse/Slackware/RH
Posts: 161

Original Poster
Rep: Reputation: 30
Could you give me a simple example? I am not clear where I would start my program with your perl script...
 
Old 05-11-2004, 03:35 PM   #12
podollb
Member
 
Registered: Oct 2003
Location: Grand Forks, ND
Distribution: Suse/Slackware/RH
Posts: 161

Original Poster
Rep: Reputation: 30
Solution Found

I got this to work for my needs:

#!/bin/csh

foreach host (`cat /etc/bhosts`)
echo "***** ${host} *****"
rsh ${host} $* &
end
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
a bunch or problems. Peingune Linux - Newbie 2 04-25-2005 10:05 AM
bunch of questions Sparky1 Linux - Newbie 8 04-19-2005 09:03 PM
Just A Bunch of Thank You XWindows LQ Suggestions & Feedback 1 03-15-2005 04:34 PM
can ping but cannot ssh into nodes dogma Linux - Newbie 2 06-10-2003 06:41 PM
bunch o'questions that_girl Linux - Newbie 10 03-15-2002 01:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration