码迷,mamicode.com
首页 > 其他好文 > 详细

集群安装脚本

时间:2018-05-03 00:59:13      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:inux   免密   /usr   roo   install   done   etc   everyone   wget   

#!/bin/bash
#执行之前确认BASE_SERVER已经生成了公钥和私钥  ssh-keygen -t rsa 默认4个enter
#交互式输入脚本-----------免密登陆脚本
SERVERS="192.168.1.111 192.168.1.104"
PASSWORD=a
BASE_SERVER=192.168.1.110

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_everyone.sh root@$SERVER:/root
    ssh root@$SERVER /root/install_everyone.sh
done

install_everyone.sh

#!/bin/bash

BASE_SERVER=192.168.1.110
yum install -y wget
wget $BASE_SERVER/soft/jdk-7u45-linux-x64.tar.gz
tar -zxf jdk-7u45-linux-x64.tar.gz -C /usr/local
cat >> /etc/profile << EOF
export JAVA_HOME=/usr/local/jdk1.7.0_45
export PATH=\$PATH:\$JAVA_HOME/bin
EOF
source /etc/profile
service iptables stop
chkconfig iptables off

 

集群安装脚本

标签:inux   免密   /usr   roo   install   done   etc   everyone   wget   

原文地址:https://www.cnblogs.com/huodaihao/p/8983173.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!