在学习大数据的过程中,经常用到集群,软件的启停一个一个点击很麻烦
目录/export中新建onekey文件夹
mkdir onekey
进入文件夹,新建文件slave
vim slave
- ##输入集群节点
-
- node1
- node2
- node3
保存退出,onekey文件夹下新建文件start-kafka.sh
vim start-kafka.sh
- cat /export/onekey/slave | while read line
- do
- {
- echo $line
- ssh $line "source /etc/profile;export JMX_PORT=9988;nohup ${KAFKA_HOME}/bin/kafka-server-start.sh ${KAFKA_HOME}/config/server.properties >/dev/nul* 2>&1 & "
- }&
- wait
- done
onekey文件夹下新建stop-kafka.sh
- cat /export/onekey/slave | while read line
- do
- {
- echo $line
- ssh $line "source /etc/profile;jps |grep Kafka |cut -d' ' -f1 |xargs kill -s 9"
- }&
- wait
- done
给两个文件赋权限
- chmod u+x start-kafka.sh
-
- chmod u+x stop-kafka.sh
可以愉快执行
- ./start-kafka.sh
-
- ./stop-kafka.sh
基本同理Kafka ,在onekey文件夹下新建start-zk.sh
vim start-zk.sh
- ZK_HOME=/export/server/zookeeper-3.4.6
- cat /export/onekey/slave | while read line
- do
- {
- echo $line
- ssh $line "source /etc/profile;nohup ${ZK_HOME}/bin/zkServer.sh start >/dev/null* 2>&1 &"
- }&
- wait
- done
chmod u+x start-zk.sh
./start-zk.sh
关闭
vim stop-zk.sh
- cat /export/onekey/slave | while read line
- do
- {
- echo $line
- ssh $line "source /etc/profile;/export/server/zookeeper-3.4.6/bin/zkServer.sh stop"
- }&
- wait
- done
chmod u+x stop-zk.sh
./stop-zk.sh
- #已设置环境变量,任意路径
-
- start-all.sh
-
- stop-all.sh
- #已设置环境变量,任意路径
-
- start-hbase.sh
-
- stop-hbase.sh