个人笔记:启动脚本

目录:

1、hadoop启动脚本
2、hive启动脚本
3、nginx-获取数据
4、数据切分脚本
5、定时切分脚本
6、flume上传脚本

1、hadoop启动脚本

 vim myhadoop.sh
 
 #!/bin/bash
 
 if [ $# -lt 1 ]
 then
        echo "No Args Input..."
        exit;
 fi
 
 case $1 in
 "start")
        echo "==================== 启动 hadoop 集群 ===================="
        echo "==================== 启动 hdfs ===================="
        ssh caiji "/opt/installs/hadoop-3.3.1/sbin/start-dfs.sh"
        echo "==================== 启动 yarn ===================="
        ssh caiji "/opt/installs/hadoop-3.3.1/sbin/start-yarn.sh"
 ;;
 "stop")
        echo "==================== 关闭 hadoop 集群 ===================="
        echo "==================== 关闭 yarn ===================="
        ssh caiji "/opt/installs/hadoop-3.3.1/sbin/stop-yarn.sh"
        echo "==================== 关闭 hdfs ===================="
        ssh caiji "/opt/installs/hadoop-3.3.1/sbin/stop-dfs.sh"
 ;;
 *)
        echo "Input Args Error..."
 ;;
 esac

2、hive 启动脚本

 myhive.sh
 
 #!/bin/bash
 
 if [ $# -lt 1 ]
 then
        echo "No Args Input..."
        exit;
 fi
 
 
 case $1 in
 "start")
        echo "================ 启动 hive-metastore 服务 --> /dev/null ================"
        ssh caiji "nohup hive --service metastore >/dev/null 2>&1 &"
        echo "================ 启动 hiveserver2 服务 --> /dev/null ================"
        ssh caiji "nohup /opt/installs/hive/bin/hiveserver2 >/dev/null 2>&1 &"
 ;;
 *)
        echo "Input Args Error..."
 ;;
 esac

3、nginx启动 与 获取数据 脚本

 mynginx.sh
 
 #!/bin/bash
 
 if [ $# -lt 1 ]
 then
        echo "No Args Input..."
        exit;
 fi
 
 
 case $1 in
 "start")
        echo "==================== 启动 配置的nginx 服务 ===================="
        ssh caiji "openresty -p /opt/apps/collect-app/"
        echo "==================== 启动 数据采集 服务 ===================="
        ssh caiji "frpc http --sd xiong -l 8802 -s frp.qfbigdata.com:7001 -u xiong"
 ;;
 "stop")
        echo "==================== 停止 数据采集 服务 ===================="
        ssh caiji "kill -9 $(pidof frpc)"
        echo "==================== 停止 nginx 服务 ===================="
        ssh caiji "openresty -p /opt/apps/collect-app/ -s stop"
 ;;
 *)
        echo "Input Args Error..."
 ;;
 esac

4、数据切分脚本

 split_logs.sh
 
 #!/bin/bash
 log_file=/opt/apps/collect-app/logs/collect-app-access.log
 data_file=/opt/apps/collect-app/datas
 pid_file=/opt/apps/collect-app/logs/nginx.pid
 line=`tail -n 1 ${log_file}`
 # 假如日志文件是空的,就不切了。
 if [ ! "${line}" ]; then
 echo "warning:${log_file} file no data, don's split !!!"
 exit -1
 fi
 mv ${log_file} ${data_file}/collect-app-access.$(date +"%s").log
 kill -USR1 `cat ${pid_file}`

5、定时计划脚本

 mycrontab.sh
 
 #!/bin/bash
 
 if [ $# -lt 1 ]
 then
        echo "No Args Input..."
        exit;
 fi
 
 
 case $1 in
 "start")
        ssh caiji "echo '*/1 * * * * sh /root/bin/split_logs.sh' > /root/bin/collect-app.cron"
        echo "==================== 启动 定时切分计划 ===================="
        ssh caiji "crontab /root/bin/collect-app.cron"
 ;;
 "stop")
        echo "==================== 删除 定时切分计划 ===================="
        ssh caiji "crontab -r"
 ;;
 *)
        echo "Input Args Error..."
 ;;
 esac

6、flume -上传日志 到 hdfs

 #!/bin/bash
 
 if [ $# -lt 1 ]
 then
 echo "No Args Input..."
 exit;
 fi
 
 
 case $1 in
 "start")
 echo "==================== 启动 flume 监控日志 上传至 hdfs ===================="
 ssh caiji "/opt/installs/flume/bin/flume-ng agent -c /opt/installs/flume/conf/ -n a1 -f /opt/installs/flume/job/collect-app-agent.conf -Dflume.root.logger=INFO,console"
 ;;
 "stop")
 echo "==================== 停止 flume 监控日志 上传至 hdfs ===================="
 ssh caiji "ps -aux | grep flume | grep collect-app-agent.conf | gawk '{print $2}' | xargs -n1 kill -9"
 ;;
 *)
 echo "Input Args Error..."
 ;;
 esac
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值