当前位置:网站首页>集群常用群起脚本
集群常用群起脚本
2022-06-25 06:33:00 【BigData_LYT】
集群常用群起脚本
这里以三台结点为例
首先进入/root/bin目录下
cd /root/bin
查看所有结点的java进程(jpsall)
创建jpsal文件
vim jpsall
输入以下内容
#!/bin/bash
for host in master node1 node2
do
echo =============== $host ===============
ssh $host jps
done
给jpsall文件赋权限
chmod 777 jpsall
使用以下命令运行
jasall
重启所有结点(reboot.sh)
创建reboot.sh文件
vim reboot.sh
输入以下内容
#!/bin/bash
for i in node2 node1 master
do
echo ============== $i 重启 =============
ssh $i "sudo reboot"
sleep 1s;
done
给reboot.sh文件赋权限
chmod 777 reboot.sh
使用以下命令运行
reboot.sh
关闭所有结点(shutdown.sh)
创建shutdown.sh文件
vim shutdown.sh
输入以下内容
#!/bin/bash
for i in node2 node1 master
do
echo ============= $i 关机 =============
ssh $i "sudo shutdown -h now"
sleep 1s;
done
给shutdown.sh文件赋权限
chmod 777 shutdown.sh
使用以下命令运行
shutdown.sh
同步文件到其他结点(xsync)
创建xsync文件
vim xsync
输入以下内容
#!/bin/bash
#1. 判断参数个数
if [ $# -lt 1 ]
then
echo Not Enough Arguement!
exit;
fi
#2. 遍历集群所有机器
for host in master node1 node2
do
echo ==================== $host ====================
#3. 遍历所有目录,挨个发送
for file in [email protected]
do
#4. 判断文件是否存在
if [ -e $file ]
then
#5. 获取父目录
pdir=$(cd -P $(dirname $file); pwd)
#6. 获取当前文件的名称
fname=$(basename $file)
ssh $host "mkdir -p $pdir"
rsync -av $pdir/$fname $host:$pdir
else
echo $file does not exists!
fi
done
done
给xsync文件赋权限
chmod 777 xsync
使用以下命令运行
xsync 文件路径
ZooKeeper集群的启动、关闭和状态(zk.sh)
创建zk.sh文件
vim zk.sh
输入以下内容
#!/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 启动 =============
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 停止 =============
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 状态 =============
ssh $i "source /etc/profile;/usr/local/soft/zookeeper-3.4.6/bin/zkServer.sh status"
done
}
;;
*)
echo "Input args Error!!"
;;
esac
给zk.sh文件赋权限
chmod 777 zk.sh
使用以下命令运行
zk.sh start
zk.sh status
zk.sh stop
kafka集群的启动和关闭(kk.sh)
创建kk.sh文件
vim kk.sh
输入以下内容
#!/bin/bash
case $1 in
"start"){
for i in master node1 node2
do
echo ========$i 启动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 停止kafka========
ssh $i "source /etc/profile;/usr/local/soft/kafka_2.11-1.0.0/bin/kafka-server-stop.sh stop"
done
};;
esac
给kk.sh文件赋权限
chmod 777 kk.sh
使用以下命令运行
kk.sh start
kk.sh stop
边栏推荐
- With a younger brother OCR, say no to various types of verification codes!
- Why can't GC () free memory- Why does gc() not free memory?
- @The difference between notempty, @notnull and @notblank
- Introduction to sap ui5 tools
- Are these old system codes written by pigs?
- Global and China chemical mechanical polishing abrasive materials market demand outlook and investment scale forecast report 2022 Edition
- Analysis report on demand scale and Supply Prospect of global and Chinese thermal insulation materials market during the 14th Five Year Plan period 2022-2028
- Sword finger offer II 095 Longest common subsequence
- [data visualization application] draw spatial map (with R language code)
- Understand what MSS is
猜你喜欢

IQ debugging of Hisilicon platform ISP and image (1)

Understand what MSS is

2022 AI trend 8 forecast!

Understand what ICMP Protocol is
![[core content and derivation] the mystery of human memory system may be just like this](/img/7c/98f27bb55a1a3b74c0ed8fd7fd2cc5.jpg)
[core content and derivation] the mystery of human memory system may be just like this
![[kicad image] download and installation](/img/88/cebf8cc55cb8904c91f9096312859a.jpg)
[kicad image] download and installation

Viewing Chinese science and technology from the Winter Olympics (V): the Internet of things

The perfect presentation of Dao in the metauniverse, and platofarm creates a farm themed metauniverse

ctfshow-misc

有能力的人从不抱怨大环境!
随机推荐
'how do I create an enumeration with constant values in rust?'- How can I create enums with constant values in Rust?
Single lithium battery 3.7V power supply 2x12w stereo boost audio power amplifier IC combination solution
Global and Chinese medical protective clothing market supply and demand research and investment value proposal report 2022-2028
sin(a+b)=sina*cosb+sinb*cosa的推导过程
Ht513 I2S input 2.8W mono class D audio power amplifier IC
Detailed explanation of @jsoninclude annotation in Jackson
[v2.0] automatic update system based on motion step API (support disconnection reconnection and data compensation)
Report on the application prospect and investment potential of global and Chinese cell therapy industry 2022-2028
What does cardinality mean in set
Grouped uitableview has 20px of extra padding at the bottom
In a single-page app, what is the right way to deal with wrong URLs (404 errors)?
What is the IP address
STL map的用法
Face++ realizes face detection by flow
Talk about TCP and UDP
BigDecimal. Summary of setscale usage
Cs8683 (120W mono class D power amplifier IC)
How do I turn off word wrap in iterm2- How to turn off word wrap in iTerm2?
Is it safe to open a stock account on the Internet in Beijing?
Sophomores majoring in mechanics build a manipulator by hand -- full of compromise