EDAS staragent 排查

浅谈

staragent 是什么?部署在 ECS 上的一个组件,两个主要功能:

  • 数据功能,上报 ECS 上的系统日志
  • 命令功能,接收控制台的下发指令,上报心跳状态,记录执行任务过程等功能。

主要目录结构

主要的目录都统计出来,不重要的目录这里就不过介绍。


├── bin
│   ├── agent.sh
│   ├── agent_start_cmd.txt
│   ├── dnsresolver
│   ├── fakeStaragentctl7u
│   ├── pluginctl
│   ├── pluginplatform
│   ├── post_install.sh
│   ├── sa_healthCheck.sh
│   ├── sa_install_lock.sh
│   ├── sa_install.sh
│   ├── sa_recovery.sh
│   ├── staragent2
│   ├── staragentctl
│   ├── staragentctl7u
│   ├── staragentd
│   └── unzip
 |
├── conf
│   ├── channels.conf
│   └── staragent.conf
 |
├── log
│   ├── dbscanner.log
│   ├── dbscanner.log.20181118195157
│   ├── staragent_channels.log
│   ├── staragent_channels.log.20181116175937
│   ├── staragent_core.log
│   ├── staragent_core.log.20181111214336
│   ├── staragent_core.log.20181117070750
│   ├── staragent_ctl.log
│   ├── staragent_master.log
│   └── staragent_tasks.log
└── 

主要配置文件如下

1)/home/staragent/conf/staragent.conf,配置 staragent 注册的服务地址

{
"Common":
    {
           "LogLevel"      : "debug"     //error,warn,info,debug
    },
"Sub_Core": {
    "ConfServer":{
        "ConfServer" : [
            "http://staragent-edas.aliyuncs.com"  //服务端域名
        ]
     }
}
}

2)/home/staragent/conf/channels.conf 服务端的备份 IP

100.100.27.142  80
100.100.36.55   80

排查命令

  • ps aux | grep -E "staragentd|staragent-core|staragent-ppf" | grep -v grep
    检查 staragent 进程是否存活
  • sudo /home/staragent/bin/agent.sh {start|stop|restart}
    启动、停止、重启Agent
  • /home/staragent/bin/staragent2 -e GetStatus
/home/staragent/bin/staragent2 -e GetStatus
------agent running ok------
  StartTime           : 2016-08-30 19:03:34 CST
  RegisterTime        : 2016-08-30 19:03:44 CST
  ServiceTag          : 94a2a7e7-5baa-4623-95f4-ef2f22741bff
  ServerConnected     : 1
  ServerAddr          : 10.125.250.64:8000
  LocalAddr           : 10.101.94.148
  Max Core count      : 0
  Total CPU Count     : 2
  Total CPU Rate      : 1.01%
  Total MEM Rate      : 12.85%
  Process CPU Rate    : 0.00%
  Load Avg (1,5,15)   : 6,4,5
  Virtual Memory      : 397MB
  Physical Memory     : 11MB
检查
 1) ServerConnected 是否为 1
  如果ServerConnected为1,表示已连接,agent已工作正常。
  • 重启 logagent 插件
    /home/staragent/plugins/logAgent/logagentctl.sh restart
  • wget -q -O /root/install.sh http://edas-sz.oss-cn-shenzhen-internal.aliyuncs.com/install.sh && sh /root/install.sh -full -force
    强制重新安装 agent 脚本,其中 sz 代表深圳,可以替换成你自己的 region 比如 hz 就是杭州。shenzhen 替换成你的 region ,其他的不用变。

使用遇到的问题

案例:

ECS 进行集群转移,报错 "issue config fail on ecu"

1

image

排查:

1)先看下要迁移的源 ECS 是否还在应用中,确认是已经摘除掉应用的才能进行迁移;

2)源机器的 VPC 和目标机器的 VPC 必须是同一个;

3)客户端上执行下 /home/staragent/bin/staragent2 -e GetStatus 看下 ServerConnected 的状态是否为 1 ,如果不为 1 说明 agent 的状态异常,可以重启下 agent /home/staragent/bin/agent.sh restart

4)执行 ps aux | grep -E "staragentd|staragent-core|staragent-ppf" | grep -v grep
如果进程一直起不来,说明 agent 本身就有问题。要手动执行脚本重装 agent ;

5)第 3 步没有效果的话,再继续看下 /home/staragent/conf/ 目录下的配置文件 channels.conf staragent.conf;

  • 5.1)先看下 staragent.conf 配置的服务端注册地址是否正确,有的客户把这里固定 IP 协议,结果 IP 更换后这里没有更换导致网络不通。
"ConfServer" : [
          "http://staragent-edas.aliyuncs.com"
      ]
  • 5.2)看下 channels.conf 文件中配置的地址的 IP 能否 ping 通,telnet 80 是否能通
[root@hanli-edas-01 plugins]# cat /home/staragent/conf/channels.conf 
100.100.27.142    80
100.100.36.55    80
[root@hanli-edas-01 plugins]# ping -c 4 100.100.27.142
PING 100.100.27.142 (100.100.27.142) 56(84) bytes of data.
64 bytes from 100.100.27.142: icmp_seq=1 ttl=46 time=27.4 ms
64 bytes from 100.100.27.142: icmp_seq=2 ttl=46 time=26.9 ms
64 bytes from 100.100.27.142: icmp_seq=3 ttl=46 time=26.9 ms
64 bytes from 100.100.27.142: icmp_seq=4 ttl=46 time=26.9 ms
--- 100.100.27.142 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 26.924/27.082/27.477/0.229 ms
[root@hanli-edas-01 plugins]# telnet 100.100.27.142 80
Trying 100.100.27.142...
Connected to 100.100.27.142.
Escape character is '^]'.
^]
Connection closed by foreign host.
[root@hanli-edas-01 plugins]#

5)第 4 步还是解决不了的话就需要查看 agent 的异常日志的,进去我们上面说的日志目录,找到 staragent_core.log ,这个是 agent 的启动、上报健康状态、注册的核心日志。这里就用到之前说的 grep error 关键

image

排查到这里基本上我们就知道问题了,接下来我们再客户端上部署下 tcpdump 抓包,然后看下超时的原因:

5.1)nohup tcpdump -i <网卡出口> -s0 host staragent-edas.aliyuncs.com &

image

通过抓包发现客户端发去的 request 后服务端没有响应,这时大致可以判断了是 staragent 在服务端注册失败,这种情况我们重新执行下安装脚本即可解决这个问题。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值