wgcloud的agent在启动时候,日志打印如下错误
[wgcloud-agent]2023/02/10 14:14:00 daemonUtil.go:68: Get "http://localhost:9999/wgcloud/license/getDaemon": dial tcp [::1]:9999: connectex: No connection could be made because the target machine actively refused it.
[wgcloud-agent]2023/02/10 14:14:00 daemonUtil.go:48: runtime error: invalid memory address or nil pointer dereference
[wgcloud-agent]2023/02/10 14:14:00 WgcloudAgent.go:356: 防篡改校验失败: 1
[wgcloud-agent]2023/02/10 14:14:02 licenseUtil.go:34: Get "http://localhost:9999/wgcloud/license/get": dial tcp [::1]:9999: connectex: No connection could be made because the target machine actively refused it.
[wgcloud-agent]2023/02/10 14:14:02 licenseUtil.go:20: runtime error: invalid memory address or nil pointer dereference
[wgcloud-agent]2023/02/10 14:14:02 WgcloudAgent.go:469: Agent started successfully. v3.4.0 . ©2017-2022 www.wgstart.com . All rights reserved.
[wgcloud-agent]2023/02/10 14:14:02 WgcloudAgent.go:470: serverUrl: http://localhost:9999/wgcloud
[wgcloud-agent]2023/02/10 14:14:02 WgcloudAgent.go:471: bindIp: 192.168.1.6
[wgcloud-agent]2023/02/10 14:14:10 WgcloudAgent.go:110: 主机监控信息上报server错误: Post "http://localhost:9999/wgcloud/agentGo/minTask": dial tcp [::1]:9999: connectex: No connection could be made because the target machine actively refused it.
[wgcloud-agent]2023/02/10 14:14:15 WgcloudAgent.go:44: runtime error: invalid memory address or nil pointer dereference
[wgcloud-agent]2023/02/10 14:14:17 WgcloudAgent.go:256: 主机磁盘信息上报server错误: Post "http://localhost:9999/wgcloud/agentDiskGo/minTask": dial tcp [::1]:9999: connectex: No connection could be made because the target machine actively refused it.
[wgcloud-agent]2023/02/10 14:14:17 WgcloudAgent.go:226: runtime error: invalid memory address or nil pointer dereference
解决方案
这个是因为agent连不上server导致的问题,我们在agent主机上,测试下能否ping通server主机
ping [server主机IP]
在agent主机再测试下,能否连通server端口9999(这个是默认的端口,如果我们修改过,就用修改过的端口)
telnet [server主机IP] 9999
如果端口不通,可能是防火墙没有放行端口,或安全软件规则没有放行端口导致的,放行就好了
最后,我们检查下agent配置文件agent/config/application.properties中,serverUrl配置是否正确
#wgcloud-server端访问地址,将下方替换为server主机IP和web端口即可,端口一定要写,即使是80也要写哈
serverUrl=http://localhost:9999
我这里是因为serverUrl配置错了,用的是默认localhost,这个应该修改为server的实际IP
然后重启agent就ok了