(6)日志生成/集群脚本6

4.3 日志生成
4.3.1日志启动

1)代码参数说明
// 参数一:控制发送每条的延时时间,默认是0
Long delay = args.length > 0 ? Long.parseLong(args[0]) : 0L;

// 参数二:循环遍历次数
int loop_len = args.length > 1 ? Integer.parseInt(args[1]) : 1000;
2)将生成的jar包log-collector-0.0.1-SNAPSHOT-jar-with-dependencies.jar拷贝到hadoop102、服务器上,并同步到hadoop103的/opt/module路径下,
[atguigu@hadoop102 module]$ xsync log-collector-1.0-SNAPSHOT-jar-with-dependencies.jar
3)在hadoop102上执行jar程序
[atguigu@hadoop102 module]$ java -classpath log-collector-1.0-SNAPSHOT-jar-with-dependencies.jar com.atguigu.appclient.AppMain>/opt/module/test.log
4)在/tmp/logs路径下查看生成的日志文件
[atguigu@hadoop102 module]$ cd /tmp/logs/
[atguigu@hadoop102 logs]$ ls
app-2019-02-10.log
4.3.2集群日志生成启动脚本

1)在/home/atguigu/bin目录下创建脚本lg.sh
[atguigu@hadoop102 bin]$ vim lg.sh
2)在脚本中编写如下内容
#! /bin/bash

for i in hadoop102 hadoop103
do
ssh $i "java -classpath /opt/module/log-collector-1.0-SNAPSHOT-jar-with-dependencies.jar com.atguigu.appclient.AppMain$1 KaTeX parse error: Expected 'EOF', got '&' at position 23: …module/test.log&̲" done 3)修改脚本执行… chmod 777 lg.sh
4)启动脚本
[atguigu@hadoop102 module]$ lg.sh
5)分别在hadoop102、hadoop103的/tmp/logs目录上查看生成的数据
[atguigu@hadoop102 logs]$ ls
app-2019-02-10.log
[atguigu@hadoop103 logs]$ ls
app-2019-02-10.log
4.3.3 集群时间同步修改脚本

1)在/home/atguigu/bin目录下创建脚本dt.sh
[atguigu@hadoop102 bin]$ vim dt.sh
2)在脚本中编写如下内容
#!/bin/bash

log_date=$1

for i in hadoop102 hadoop103 hadoop104
do
ssh -t $i "sudo date -s l o g d a t e "

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值