Tomcat Docker容器自动重启问题排查
1. 根据现有的docker容器重建镜像及运行
docker在构建镜像包时,就把jvm的参数预先编写好了,在遇到性能问题后,需要修改jvm参数进行调整。
docker commit命令创建新的镜像
1、运行容器
2、修改容器
docker exec -it 容器id sh
#修改配置
3、将容器保存为新镜像
docker commit 0521893d603d reg.xxx.net/preprod/red-xxx:cce7f12d-jvmparams
sh service-update.sh reg.xxx.net/preprod/red-xxx:cce7f12d-jvmparams
2、调整某个docker的内存限制
[ec2-user@ip---- ~]$ docker service update --limit-memory 1G op-m-front
op-m-front
overall progress: out of tasks
w5hk1y1rgqeh: running [==================================================>]
verify: Waiting seconds to verify that tasks are stable...
Error: No such service: op-m-front
[ec2-user@ip---- ~]$
3、dockerd: time="2019-12-09T05:29:36.169298343Z" level=error msg="fatal task error" error="task: non-zero exit (137)
Issue
If a container is no longer running, use the following command to find the status of the container:
docker container ls -a
This article explains possible reasons for the following exit code:
"task: non-zero exit (137)"
With exit code 137, you might also notice a status of Shutdown or the following failed message:
Failed 42 hours ago
Resolution
The "task: non-zero exit (137)" message is effectively the result of a kill -9 (128 + 9). This can be due to a couple possibilities (seen most often with Java applications):
- The container received a
docker stop, and the application didn't gracefully handleSIGTERM(kill -15) — whenever aSIGTERMhas been issued, the docker daemon waits 10 seconds then issue aSIGKILL(kill -9) to guarantee the shutdown. To test whether your containerized application correctly handlesSIGTERM, simply issue adocker stopagainst the container ID and check to see whether you get the"task: non-zero exit (137)". This is not something to test in a production environment, as you can expect at least a brief interruption of service. Best practices would be to test in a development or test Docker environment. - The application hit an OOM (out of memory) condition. With regards to OOM condition handling, review the node's kernel logs to validate whether this occurred. This would require knowing which node the failed container was running on, or proceed with checking all nodes. Run something like this on your node(s) to help you identify whether you've had a container hit an OOM condition: journalctl -k | grep -i -e memory -e oom Another option would be to inspect the (failed) container: docker inspect <container ID> Review the application's memory requirements and ensure that the container it's running in has sufficient memory. Conversely, set a limit on the container's memory to ensure that wherever it runs, it does not consume memory to the detriment of the node. If the application is Java-based, you may want to review the maximum memory configuration settings.
References
4、docker top 容器id
查看容器里的进程
[ec2-user@ip---- ~]$ docker top 2c1
UID PID PPID C STIME TTY TIME CMD
ec2-user : ? :: sh entrypoint.sh
ec2-user : ? :: java -Xmx1344m -Xms1344m -Xmn448M -XX:MaxMetaspaceSize=192M -XX:MetaspaceSize=192M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/logs/loyalty-dump
5、
启动
systemctl start docker
守护进程重启
systemctl daemon-reload
重启docker服务
systemctl restart docker / service docker restart
关闭
docker service docker stop / docker systemctl stop docker
Tomcat Docker容器自动重启问题排查的更多相关文章
- 使用Watchtower实现Docker容器自动更新
前言:通常情况下我们手动更新容器的步骤比较繁琐,需要四个步骤: 1.停止容器 2.删除容器 3.检查镜像更新情况,更新镜像 4.重新启动容器 容器少还无所谓,但要是需要更新大量的容器就会工作量巨大. ...
- (转)Docker容器的重启策略及docker run的--restart选项详解
1. Docker容器的重启策略 Docker容器的重启策略是面向生产环境的一个启动策略,在开发过程中可以忽略该策略. Docker容器的重启都是由Docker守护进程完成的,因此与守护进程息息相关. ...
- tomcat监控,自动重启shell脚本
tomcat监控,自动重启shell脚本如下,取名 monitor_tomcat.sh: #!/bin/sh # func:自动监控tomcat脚本并且执行重启操作 # 获取tomcat进程ID(其中 ...
- Docker容器的重启策略及docker run的--restart选项详解
https://blog.csdn.net/taiyangdao/article/details/73076019 1. Docker容器的重启策略 Docker容器的重启策略是面向生产环境的一个启动 ...
- docker容器自动退出的问题
如果用了一段时间的docker就会发现,我们的容器经常用了一段时间就自动退出了,docker ps已经找不到了,在docker ps -a里面了,然后我们docker start containerI ...
- supervisor开机自动启动脚本+redis+MySQL+tomcat+nginx进程自动重启配置
[root@mongodb-host supervisord]# cat mongo.conf [program:mongo]command=/usr/local/mongodb/bin/mongod ...
- tomcat宕机自动重启脚本
#!/bin/bash# 获取tomcat进程ID /usr/share/tomcatTomcatID=$(ps -ef |grep tomcat |grep -w 'tomcat'|grep -v ...
- Docker容器优雅重启
默认情况下,当 Docker 守护进程终止时,它将关闭正在运行的容器.您可以配置守护程序,以便容器在守护程序不可用时保持运行.此功能称为live-restore.live-restore选项有助于减少 ...
- Docker容器自动更新
前言: Watchtower 是一个可以实现自动化更新 Docker 基础镜像与容器的实用工具.它监视正在运行的容器以及相关的镜像,当检测到registry中的镜像与本地的镜像有差异时,它会拉取最新 ...
随机推荐
- 服务器死机 导致 mongo 挂掉
1.删除mongod.lock和mongodb.log日志文件 2.携带参数重新启动 mongod --dbpath=/var/lib/mongo --port=27017 --fork --logp ...
- BFS广度优先搜索 炸弹人
题面:一个人在一个坐标放炸弹,请问可以可以杀死的敌人数目最大是,并且输出该点的坐标 G代表敌人 .代表该位置可以走 "#"代表该位置存在障碍物 并且防止炸弹的蔓13 13 3 3 ...
- day39机器学习
2 Numpy快速上手 2.1. 什么是Numpy Numpy是Python的一个科学计算的库 主要提供矩阵运算的功能,而矩阵运算在机器学习领域应用非常广泛 Numpy一般与Scipy.matplot ...
- day3 zookeeper
PS:在生产的场景中,一般有两个需求:1.提供设备的注册 2.对所注册的接口进行监听.zookeeper就是提供这样的功能,它本身就是一个集群,如果存在半数以上的节点活着就能提供服务,本身就具备很高的 ...
- JDBC事务的处理-----模拟银行转账业务
定义: 数据库事务(简称:事务)是数据库管理系统执行过程中的一个逻辑单位,由一个有限的数据库操作序列构成. 概要: 一个数据库事务通常包含了一个序列的对数据库的读/写操作.它的存在包含有以下两个目的: ...
- sqler sql 转rest api 源码解析(三) rest协议
rest 服务说明 rest 协议主要是将配置文件中的宏暴露为rest 接口,使用了labstack/echo web 框架,同时基于context 模型 进行宏管理对象的共享,同时进行了一些中间件的 ...
- 数学与猜想 数学中的归纳和类比 (G. 波利亚 著)
第一章 归纳方法 (已看) $1. 经验和信念 $2. 启发性联想 $3. 支持性联想 $4. 归纳的态度 第二章 一般化,特殊化,类比 (已看) $1. 一般化,特殊化,类比和归纳 $2. 一般化 ...
- NPOI之Excel——合并单元格、设置样式、输入公式、设置筛选等
首先建立一个空白的工作簿用作测试,并在其中建立空白工作表,在表中建立空白行,在行中建立单元格,并填入内容: //建立空白工作簿 IWorkbook workbook = new HSSFWorkboo ...
- 利用JSON将Map转换为类对象
Map类型做为一种常见的Java类型,经常在开发过程中使用,笔者最近遇到要将Map对象做为一种通用的参数变量,下传到多个业务类方法中,然后在各个业务类方法中将Map转换为指定类对象的情况.如何将Map ...
- 记一次挂马清除经历:处理一个利用thinkphp5远程代码执行漏洞挖矿的木马
昨天发现 一台服务器突然慢了 top 显示 几个进程100%以上的cpu使用 执行命令为 : /tmp/php -s /tmp/p2.conf 基本可以确定是被挂马了 下一步确定来源 last 没有 ...