当前位置:网站首页>集群常用群起脚本
集群常用群起脚本
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
边栏推荐
- Exercise: completion
- [road of system analyst] collection of wrong questions in the chapters of Applied Mathematics and economic management
- China rehabilitation hospital industry operation benefit analysis and operation situation investigation report 2022
- Acwing2013. three lines
- Guess the size of the number
- Sleep quality today 67 points
- Research Report on global and Chinese vaccine market profit forecast and the 14th five year plan development strategy 2022-2028
- What is the IP address
- 北京网上开股票账户安全吗?
- ACWING/2004. Misspelling
猜你喜欢

Cannot activate inspection type when SAP retail uses transaction code mm41 to create commodity master data?

After unplugging the network cable, does the original TCP connection still exist?

@Detailed explanation of valid annotation usage

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

ACWING/2004. 錯字

Cs5092 5V USB input boost two section lithium battery charging management IC, SOT23-6 miniature package

2022-02-19: fence installation. In a two-dimensional garden, there are some trees represented by (x, y) coordinates. As the installation cost is very expensive, your task is to enclose all the trees w

2022 AI trend 8 forecast!

Pre knowledge of asynchronous operation
![[short time average zero crossing rate] short time average zero crossing rate of speech signal based on MATLAB [including Matlab source code 1721]](/img/4a/304f262c1c08800aa95f9e2d537e4d.jpg)
[short time average zero crossing rate] short time average zero crossing rate of speech signal based on MATLAB [including Matlab source code 1721]
随机推荐
Grouped uitableview has 20px of extra padding at the bottom
How to use asemi FET 7n80 and how to use 7n80
Research Report on global and Chinese vaccine market profit forecast and the 14th five year plan development strategy 2022-2028
From file system to distributed file system
Meta universe is over, Web 3.0 will be fooled again?
[no title] dream notes 2022-02-20
[v2.0] automatic update system based on motion step API (support disconnection reconnection and data compensation)
Understand what ICMP Protocol is
IQ debugging of Hisilicon platform ISP and image (1)
delphi-UUID
[kicad image] download and installation
HCIP Day 16
BGP - basic concept
JD 7 head search navigation layout
cos(a-b)=cosa*cosb+sina*sinb的推导过程
[short time average zero crossing rate] short time average zero crossing rate of speech signal based on MATLAB [including Matlab source code 1721]
How to chain multiple different InputStreams into one InputStream
Record of friend guide
Which of the top ten securities companies has the lowest Commission and is the most safe and reliable? Do you know anything
How do I turn off word wrap in iterm2- How to turn off word wrap in iTerm2?