当前位置:网站首页>Common cluster scripts
Common cluster scripts
2022-06-25 06:41:00 【BigData_ LYT】
Clusters often use group scripts
Take three nodes as an example
First of all to enter /root/bin Under the table of contents
cd /root/bin
View all nodes java process (jpsall)
establish jpsal file
vim jpsall
Enter the following
#!/bin/bash
for host in master node1 node2
do
echo =============== $host ===============
ssh $host jps
done
to jpsall File permissions
chmod 777 jpsall
Run with the following command
jasall
Restart all nodes (reboot.sh)
establish reboot.sh file
vim reboot.sh
Enter the following
#!/bin/bash
for i in node2 node1 master
do
echo ============== $i restart =============
ssh $i "sudo reboot"
sleep 1s;
done
to reboot.sh File permissions
chmod 777 reboot.sh
Run with the following command
reboot.sh
Close all nodes (shutdown.sh)
establish shutdown.sh file
vim shutdown.sh
Enter the following
#!/bin/bash
for i in node2 node1 master
do
echo ============= $i To turn it off =============
ssh $i "sudo shutdown -h now"
sleep 1s;
done
to shutdown.sh File permissions
chmod 777 shutdown.sh
Run with the following command
shutdown.sh
Synchronize files to other nodes (xsync)
establish xsync file
vim xsync
Enter the following
#!/bin/bash
#1. Judge the number of parameters
if [ $# -lt 1 ]
then
echo Not Enough Arguement!
exit;
fi
#2. Traverse all machines in the cluster
for host in master node1 node2
do
echo ==================== $host ====================
#3. Traverse all directories , Send... One by one
for file in [email protected]
do
#4. Judge whether the file exists
if [ -e $file ]
then
#5. Get parent directory
pdir=$(cd -P $(dirname $file); pwd)
#6. Get the name of the current file
fname=$(basename $file)
ssh $host "mkdir -p $pdir"
rsync -av $pdir/$fname $host:$pdir
else
echo $file does not exists!
fi
done
done
to xsync File permissions
chmod 777 xsync
Run with the following command
xsync File path
ZooKeeper Cluster startup 、 Off and status (zk.sh)
establish zk.sh file
vim zk.sh
Enter the following
#!/bin/bash
if [ $# -lt 1 ]
then
echo "NO Args Input Error!!!"
exit
fi
case $1 in
"start") {
for i in master node1 node2
do
echo ============= zookeeper $i start-up =============
ssh $i "source /etc/profile;/usr/local/soft/zookeeper-3.4.6/bin/zkServer.sh start"
done
}
;;
"stop") {
for i in master node1 node2
do
echo ============= zookeeper $i stop it =============
ssh $i "source /etc/profile;/usr/local/soft/zookeeper-3.4.6/bin/zkServer.sh stop"
done
}
;;
"status") {
for i in master node1 node2
do
echo ============= zookeeper $i state =============
ssh $i "source /etc/profile;/usr/local/soft/zookeeper-3.4.6/bin/zkServer.sh status"
done
}
;;
*)
echo "Input args Error!!"
;;
esac
to zk.sh File permissions
chmod 777 zk.sh
Run with the following command
zk.sh start
zk.sh status
zk.sh stop
kafka Startup and shutdown of cluster (kk.sh)
establish kk.sh file
vim kk.sh
Enter the following
#!/bin/bash
case $1 in
"start"){
for i in master node1 node2
do
echo ========$i start-up kafka========
ssh $i "source /etc/profile;/usr/local/soft/kafka_2.11-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/soft/kafka_2.11-1.0.0/config/server.properties"
done
};;
"stop"){
for i in master node1 node2
do
echo ========$i stop it kafka========
ssh $i "source /etc/profile;/usr/local/soft/kafka_2.11-1.0.0/bin/kafka-server-stop.sh stop"
done
};;
esac
to kk.sh File permissions
chmod 777 kk.sh
Run with the following command
kk.sh start
kk.sh stop
边栏推荐
- System dilemma and software complexity: Why are our systems so complex?
- How to realize the stable output of 3.3v/3.6v (1.2-5v) voltage of lithium battery by using the voltage rise and fall chip cs5517
- 燕京啤酒何以至此?
- How to find happiness in programming and get lasting motivation?
- Difference between rest and WebServices
- CTFHub-Web-信息泄露-目錄遍曆
- ACWING2013. 三条线
- How do I turn off word wrap in iterm2- How to turn off word wrap in iTerm2?
- Ht8513 single lithium battery power supply with built-in Dynamic Synchronous Boost 5W mono audio power amplifier IC solution
- Are these old system codes written by pigs?
猜你喜欢

What is the real future of hardware engineers?

Introduction to sap ui5 tools

Kubernetes core components etcd details

How to realize the stable output of 3.3v/3.6v (1.2-5v) voltage of lithium battery by using the voltage rise and fall chip cs5517

Three laws of go reflection

From file system to distributed file system

Can TCP syn handshake messages transmit data

Understand what ICMP Protocol is

Who can teach me how to learn SCM, what to learn first and how to get started?

DataX tutorial (09) - how does dataX achieve speed limit?
随机推荐
Ctfhub web - divulgation d'informations - traversée du Répertoire
这些老系统代码,是猪写的么?
DNS domain name system
Record of friend guide
Ht81293 built in adaptive dynamic boost 20W mono class D power amplifier IC solution
Navicat防止新建查询误删
Microsoft issued a document to celebrate Net 20th anniversary!
ACWING2013. 三条线
Uncaught TypeError: Cannot read properties of undefined (reading ‘prototype‘)
Viewing Chinese science and technology from the Winter Olympics (V): the Internet of things
【2022黑马程序员】SQL优化
How to chain multiple different InputStreams into one InputStream
Meta universe is over, Web 3.0 will be fooled again?
From file system to distributed file system
SAP QM executes the transaction code qp01, and the system reports an error -material type food is not defined for task list type Q-
With a younger brother OCR, say no to various types of verification codes!
CTFHub-Web-信息泄露-目录遍历
Derivation of sin (a-b) =sina*cosb-sinb*cosa
アルマ / 炼金妹
Analysis on the output, market scale and development status of China's children's furniture industry in 2020 and the competition pattern of children's furniture enterprises [figure]