将某文件远程拷贝到指定ip机器上的指定目录下:
./scp_file.sh /tmp/xx.sh /tmp/test/
echo "将文件 $1 拷贝到 $2 目录下!"for ip in 192.168.60.243 192.168.60.244 192.168.60.245 192.168.60.246 192.168.60.248do scp -r $1 root@$ip:$2 echo "scp $1 to $ip is : $? "doneecho "$? 分发完毕!!"
远程执行指定ip机器上的指定shell文件命令(需要ssh支持)(可带参数):
./execute.sh /tmp/xx.sh xx
for ip in 192.168.60.243 192.168.60.244 192.168.60.245 192.168.60.246 192.168.60.248do ssh root@$ip $1 $2 echo "execute $1 $2 at $ip is : $? "doneecho "$? $1执行完毕!"
copy-hosts.sh
#!/bin/bashcp /opt/tmp/hosts.txt /opt/tmp/hosts.txt.bakecho "$? copy finish!"exit 0
append-ssh.sh
#!/bin/bashcat /opt/tmp/ssh.txt >> /root/.ssh/authorized_keysecho "$? append ssh finish!"exit 0
rmtest.sh
#!/bin/bashrm -rf $1echo "$? rm finish!"exit 0
install-hadoop-hbase.sh
#!/bin/bashcp /opt/tmp/hadoop-2.5.1.tar.gz /opt/hadoop-2.5.1.tar.gzcp /opt/tmp/hbase-0.98.7-hadoop2-bin.tar.gz /opt/hbase-0.98.7-hadoop2-bin.tar.gzecho "$? copy finish!"cd /opt/tar xvf hbase-0.98.7-hadoop2-bin.tar.gzecho "$? install hbase finish!"tar xvf hadoop-2.5.1.tar.gzecho "$? install hadoop finish!"exit 0
install-jdk.sh
#!/bin/bashmkdir -p /usr/java/cp /opt/tmp/jdk-6u45-linux-x64.bin /usr/java/jdk-6u45-linux-x64.binecho "$? copy finish!"cd /usr/java/sh /usr/java/jdk-6u45-linux-x64.binecho "$? install jdk finish!"exit 0
set-keygen.sh
#!/bin/bashssh-keygen -t dsa -P '' -f ~/.ssh/id_dsaecho "$? set ssh keygen finish!"exit 0