es集群一鍵安裝指令碼
es集群一鍵啟動指令碼#!/bin/bash
#配置es的安裝目錄 修改的地方1 指令碼可以自己建立
currenttime=$(date '+%y-%m-%d %h:%m:%s')
echo -e "請輸入es的安裝目錄,不存在指令碼自動建立,最後乙個/不要寫 /bigdata/install"
read esinstallpath
#建立es安裝的目錄
if [ ! -d $esinstallpath ]; then
mkdir -p $esinstallpath
fi if [ ! -d $esinstallpath ]; then
echo "建立目錄$esinstallpath失敗!請檢查目錄是否有許可權"
exit
fi#解壓tar包
currentdir=$(cd $(dirname $0); pwd)
ls | grep 'elasticsearch-.*[gz]$'
if [ $? -ne 0 ]; then
#當前目錄沒有es的壓縮包
echo "在$currentdir下沒有發現elasticsearch-*.tar.gz,請自行上傳!"
exit
else
#解壓tar -zxvf $currentdir/$(ls | grep 'elasticsearch-.*[gz]$') -c $esinstallpath
fiesbanben=`ls $esinstallpath| grep 'elasticsearch-.*'`
#path設定
#末行插入
echo "">>~/.bash_profile
echo "#es $currenttime">>~/.bash_profile
echo "export es_home=$esinstallpath/$esbanben">>~/.bash_profile
echo 'export path=$path:$es_home/bin'>>~/.bash_profile
source ~/.bash_profile
confpath=$esinstallpath/$esbanben/config
#修改配置檔案
echo -e "請輸入cluster.name的值:乙個集群的名字保證一樣 例如 gskjescluster"
read esname
echo "cluster.name: $esname" >>$confpath/elasticsearch.yml
echo -e "請輸入node.name的值:唯一值 例如 1"
read nodename
echo "node.name: node-$nodename">>$confpath/elasticsearch.yml
echo -e "請輸入path.data的值:例如 /es6.5.4/data/data/"
read pathdata
echo "path.data: $pathdata">>$confpath/elasticsearch.yml
echo -e "請輸入path.logs的值:例如 /es6.5.4/data/logs/"
read pathlogs
echo "path.logs: $pathlogs">>$confpath/elasticsearch.yml
echo "bootstrap.memory_lock: false">>$confpath/elasticsearch.yml
echo "bootstrap.system_call_filter: false">>$confpath/elasticsearch.yml
echo "network.host: 0.0.0.0">>$confpath/elasticsearch.yml
echo -e "請輸入httpport的值 預設值 9200"
echo -e "請輸入transporttcpport的值 預設值 9300"
read transporttcpport
echo "transport.tcp.port: $transporttcpport">>$confpath/elasticsearch.yml
echo -e '請輸入es集群的所有節點,嚴格符合以下格式 "cdh01","cdh02","cdh03" '
read unicasthosts
echo "discovery.zen.ping.unicast.hosts: [$unicasthosts]">>$confpath/elasticsearch.yml
array=($)
len=$
masternodes=`expr $len / 2 + 1`
#判斷集群節點個數》2,才加
if [[ $len > 2 ]]; then
echo "discovery.zen.minimum_master_nodes: $masternodes">>$confpath/elasticsearch.yml
fiecho -e "是否修改jvm.options 請輸入y/n"
read jvmisflag
if [[ $jvmisflag == "y" ]]; then
echo -e "請輸入jvm大小,注意g是小寫 例如 16g"
read jvmsize
sed -i "s/^-xms1g/-xms$jvmsize/" $confpath/jvm.options
sed -i "s/^-xmx1g/-xmx$jvmsize/" $confpath/jvm.options fi
#修改並分發安裝檔案
echo -e "是否遠端複製 請輸入y/n"
read flag
if [[ $flag == "y" ]]; then
espath=$esinstallpath/$esbanben
espathtemp=$esinstallpath/$esbanben-temp
cp -r $espath $espathtemp
echo "以下輸入的節點必須做免密登入"
echo -e '請輸入除當前之外的節點(當前節點cdh01),嚴格符合以下格式ip:esid,空格隔開, cdh02:2 cdh03:3 cdh04:4 cdh05:5'
read allnodes
user=`whoami`
array2=($)
for allnode in $
do array3=($)
ip=$
esid=$
echo *****== $ip *****==
#修改檔案
ssh $ip "rm -rf $espath"
ssh $ip "mkdir -p $espath"
bak_dir="node.name: node-$nodename"
new_dir="node.name: node-$esid"
sed -i "s!$!$!g" $espathtemp/config/elasticsearch.yml
scp -r $espathtemp/* $@$ip:$espath/
ssh $ip "echo ''>>~/.bash_profile"
ssh $ip "echo '#es $currenttime'>>~/.bash_profile"
ssh $ip "echo 'export es_home=$esinstallpath/$esbanben'>>~/.bash_profile"
ssh $ip 'echo "export path=\$path:\$es_home/bin">>~/.bash_profile'
ssh $ip "source ~/.bash_profile"
#再次修改回來 防止修改錯誤
new_dir="node.name: node-$nodename"
bak_dir="node.name: node-$esid"
sed -i "s!$!$!g" $espathtemp/config/elasticsearch.yml
echo *****== $ip 遠端複製完成 *****==
done
#刪除臨時檔案
rm -rf $espathtemp
for allnode in $
do echo *****== 在 $allnode 手動執行 source ~/.bash_profile 在通過 elasticsearch 檢視是否安裝成功 *****==
done
fi
#!/bin/bash
#配置es的安裝目錄 修改的地方1 指令碼可以自己建立
esservers='cdh01 cdh02'
#啟動所有的zk
for es in $esservers
do ssh -t $es <es集群一鍵停止指令碼
#!/bin/bash
esservers='cdh01 cdh02'
#啟動所有的zk
for es in $esservers
do ssh -t $es
ps aux |grep elasticsearch |grep -v grep |awk '' |xargs kill -9
eofecho 從節點 $es 停止elasticsearch...[ done ]
sleep 5
done
nginx一鍵啟動,停止 重啟指令碼
注 有問題或更好可以一起 謝謝 bin bash nginx usr local nginx sbin nginx echo nginx一鍵啟動,停止,檢視.read ep 請輸入你的操作,1.stop,2.start,3.reload,4.status 1,2,3,4 nginx1 case ng...
kafka集群一鍵啟動shell指令碼
1.我指令碼放在 root bin下面,命名kafka mgr.sh 2.root目錄下面沒有bin目錄就建立 mkdir root bin p 3.建立kafka mgr.sh指令碼,vim kafka mgr.sh 沒有vim可以安裝,也可以用vi,vim安裝yum y install vim ...
storm集群一鍵啟動關閉shell指令碼檔案
vi start storm cluster.sh 這裡面需要注意的是 hdp 1 hdp 2 hdp 3是我的三颱虛擬機器,如果名字不同需要修改 此指令碼必須放在storm bin方能生效 bin bash nimbus節點 nimbusservers hdp 1 hdp 2 supervisor...