问题现象
机器重启后发现个别 OCP Agent 进程(如 ocp_mgragent 进程)没有自动启动起来,通过手工命令启动 OCP Agent 或者 OCP Web 界面重装 OCP Agent 也均失败报错。
"error":"Module=agent, kind=DEADLINE_EXCEEDED, code=wait_for_ready_timeout; "
通过手工命令启动 OCP Agent
手工命令停止 OCP Agent。
[root@observer ~]# /home/admin/ocp_agent/bin/ocp_agentctl stop {"successful":true,"message":"ok","error":""}手动命令启动 OCP Agent。
[root@observer ~]# /home/admin/ocp_agent/bin/ocp_agentctl start {"successful":false,"message":null,"error":"Module=agent, kind=DEADLINE_EXCEEDED, code=wait_for_ready_timeout; "}显示 OCP agent 进程信息。
[root@observer log]# ps -ef | grep agent root 1680 1 0 10:45 ? 00:00:00 /home/admin/ocp_agent/bin/ocp_agentd -c /home/admin/ocp_agent/conf/agentd.yaml root 1766 1680 8 10:45 ? 00:01:43 /home/admin/ocp_agent/bin/ocp_monagent root 5094 4904 0 11:06 pts/0 00:00:00 grep agent显示 OBServer 进程信息。
[root@observer log]# ps -ef | grep observer root 5097 4904 0 11:06 pts/0 00:00:00 grep observer显示 OBProxy 进程信息。
[root@observer log]# ps -ef | grep obproxy root 5139 4904 0 11:06 pts/0 00:00:00 grep obproxy
OCP Web 界面重装 OCP Agent

同时 /home/admin/ocp_agent/log/agentd.log 中有如下报错日志。
2024-09-02T11:46:37.56857+08:00 INFO [36732,] caller=agentd/limit_linux.go:20:newLimiter: create service ocp_mgragent resource limit skipped, no limit in config
2024-09-02T11:46:37.5696+08:00 INFO [36732,] caller=agentd/limit_linux.go:31:newLimiter: create service ocp_monagent resource limit done, cpu: 2, memory: 2GiB
2024-09-02T11:46:37.56983+08:00 ERROR [36732,] caller=agentd/watchdog.go:259:cleanupPidPattern: cleanup pid file /home/admin/ocp_agent/run/ocp_mgragent.pid got error fields: error="Module=agent, kind=INTERNAL, code=read_pid_failed; [/home/admin/ocp_agent/run/ocp_mgragent.pid]\ncause:\nstrconv.Atoi: parsing \"\": invalid syntax"
2024-09-02T11:46:37.56992+08:00 INFO [36732,] caller=agentd/watchdog.go:80:Start: starting agentd
2024-09-02T11:46:37.57131+08:00 INFO [36732,] caller=agentd/watchdog.go:93:Start: starting socket listener on '/home/admin/ocp_agent/run/ocp_agentd.36732.sock'
2024-09-02T11:46:37.57156+08:00 INFO [36732,] caller=agentd/watchdog.go:103:Start: starting service 'ocp_mgragent'
2024-09-02T11:46:37.57168+08:00 ERROR [36732,] caller=agentd/watchdog.go:106:Start: start service 'ocp_mgragent' failed: Module=agentd, kind=INTERNAL, code=write_pid_failed; [/home/admin/ocp_agent/run/ocp_mgragent.pid]
cause:
open /home/admin/ocp_agent/run/ocp_mgragent.pid: file exists
2024-09-02T11:46:37.5717+08:00 INFO [36732,] caller=agentd/watchdog.go:103:Start: starting service 'ocp_monagent'
2024-09-02T11:46:37.5718+08:00 INFO [36732,] caller=agentd/service.go:133:startProc: starting service fields: service=ocp_monagent
2024-09-02T11:46:37.57223+08:00 INFO [36732,] caller=agentd/service.go:140:startProc: service process started. pid: 36748 fields: service=ocp_monagent
2024-09-02T11:46:37.57228+08:00 INFO [36732,] caller=agentd/watchdog.go:109:Start: agentd started
问题原因
正常情况下 /home/admin/ocp_agent/run/*pid 文件中记录了对应的 OCP Agent 进程当前正在运行的进程号,但是如果 pid 文件所在的文件系统被写满了,或者出现了文件系统的 input/output error,或者人为清空了该 pid 文件,就会出现 pid 文件内容为空的情况。如果 pid 文件内容为空,启动 OCP Agent 进程时,为了避免启动多个同名的 Agent 进程,程序这边做了一层防御保护,直接让启动步骤报错失败。
问题的风险及影响
OCP Agent 部分进程无法实现开机自启动或手工重启,如果是 ocp_mgragent 进程无法启动,会导致 OBServer/OBProxy 也没法实现开机自启动。
影响租户
影响 OceanBase 数据库中的 SYS 租户和 Oracle 租户以及 MySQL 租户。
适用版本
OCP Agent V2.x、V3.x、V4.x 版本。
解决方法
方法一:直接选择重启 OCP Agent,而不是先停下、再启动。
[root@observer ~]# /home/admin/ocp_agent/bin/ocp_agentctl restart方法二:删除
/home/admin/ocp_agent/run/目录下面的大小为 0 的空 pid 文件。[root@observer ~]# find . -name "ocp_mgragent.pid" -type f -size 0c | xargs -n 1 rm -f注意
在删除系统目录下的文件时务必确认清楚再执行带有
rm -f操作的命令。方法三:向
/home/admin/ocp_agent/run/目录下面的大小为 0 的空 pid 文件中写入一个随机的进程号,比如 123456789。[root@observer ~]# echo 123456789 > /home/admin/ocp_agent/run/ocp_mgragent.pid然后重新运行失败的操作即可。