1. 程式人生 > 其它 >自動化部署指令碼

自動化部署指令碼

自動進行配置免密登入、安裝jdk

boot.sh

#!/bin/bash

SERVERS="hadoop02 hadoop03"
PASSWORD=hadoop
BASE_SERVER=192.168.1.11

auto_ssh_copy_id() {
    expect -c "set timeout -1;
        spawn ssh-copy-id $1;
        expect {
            *(yes/no)* {send -- yes\r;exp_continue;}
            *assword:* {send -- $2\r;exp_continue;}
            eof        {exit 
0;} }"; } ssh_copy_id_to_all() { for SERVER in $SERVERS do auto_ssh_copy_id $SERVER $PASSWORD done } ssh_copy_id_to_all for SERVER in $SERVERS do scp install.sh root@$SERVER:/root ssh root@$SERVER /root/install_everyone.sh done

install_everyone.sh

#!/bin/bash

BASE_SERVER=hadoop01
wget $BASE_SERVER
/soft/ jdk-7u55-linux-i586.tar.gz tar -zxvf jdk-7u55-linux-i586.tar.gz -C /usr/local cat >> /etc/profile << EOF export JAVA_HOME=/usr/local/jdk1.7.0_55 export PATH=\$PATH:\$JAVA_HOME/bin EOF

更多java、大資料學習面試資料,請掃碼關注我的公眾號:

專注於大資料和java開發,學習交流可以關注我的公眾號:javaydsj