文章目录
小结
在ECS优化的AWS Linux修改ECS配置后ECS Agent服务无法启动,进行了解决。
问题解决
在ECS优化的AWS Linux修改ECS配置ecs.config
, 如下:
shell
[ec2-user@ip-10-0-3-241 ~]$ cat /etc/ecs/ecs.config
ECS_CLUSTER=John-Cluster
ECS_WARM_POOLS_CHECK=true
对以上设置后,ECS服务重启失败:
shell
[ec2-user@ip-10-0-1-55 ~]$ sudo vi /etc/ecs/ecs.config
[ec2-user@ip-10-0-1-55 ~]$ sudo systemctl restart ecs
[ec2-user@ip-10-0-1-55 ~]$ sudo systemctl status ecs
● ecs.service - Amazon Elastic Container Service - container agent
Loaded: loaded (/usr/lib/systemd/system/ecs.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2023-12-01 08:57:52 UTC; 1s ago
Docs: https://aws.amazon.com/documentation/ecs/
Process: 21273 ExecStopPost=/usr/libexec/amazon-ecs-init post-stop (code=exited, status=0/SUCCESS)
Process: 21004 ExecStop=/usr/libexec/amazon-ecs-init stop (code=exited, status=0/SUCCESS)
Process: 21140 ExecStart=/usr/libexec/amazon-ecs-init start (code=exited, status=5)
Process: 21084 ExecStartPre=/usr/libexec/amazon-ecs-init pre-start (code=exited, status=0/SUCCESS)
Main PID: 21140 (code=exited, status=5)
Dec 01 08:57:51 ip-10-0-1-55.ap-southeast-1.compute.internal amazon-ecs-init[21140]: 2023-12-01T08:57:51Z [INFO] Starting Amazon Elastic Container Service Agent
Dec 01 08:57:52 ip-10-0-1-55.ap-southeast-1.compute.internal amazon-ecs-init[21140]: 2023-12-01T08:57:52Z [INFO] Agent exited with code 5
Dec 01 08:57:52 ip-10-0-1-55.ap-southeast-1.compute.internal amazon-ecs-init[21140]: 2023-12-01T08:57:52Z [ERROR] agent exited with terminal exit code: 5
解决方法:删除/var/lib/ecs/data/agent.db
文件,这个文件保存了现有ECS设置,可能有冲突,删除后再重启ECS Agent服务,问题解决。
shell
[ec2-user@ip-10-0-1-55 ~]$ sudo ls /var/lib/ecs/data/
agent.db
[ec2-user@ip-10-0-1-55 ~]$ sudo rm /var/lib/ecs/data/agent.db
[ec2-user@ip-10-0-1-55 ~]$ sudo systemctl restart ecs
[ec2-user@ip-10-0-1-55 ~]$ sudo systemctl status ecs
● ecs.service - Amazon Elastic Container Service - container agent
Loaded: loaded (/usr/lib/systemd/system/ecs.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2023-12-01 09:00:15 UTC; 3s ago