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中的镜像与本地的镜像有差异时,它会拉取最新 ...
随机推荐
- find 以及linux 和windows 文件互传
1. find 命令 查找文件或目录 同时也会用到的有 which whereis locate 经常也会遇到一些快捷键 ctrl + l e a w u k ...
- 实验吧—Web——WP之 Forms
我们先打开解题链接: 做Web题的第一步就是查看网页源代码,当然,有些网页他不会让你点击右键,那么可以在地址栏里的地址前面加上:view-source: 当然也可以打开控制台F12 我们可以看到代码里 ...
- json(传输格式)、异步加载、时间线
xml:过去传输的数据格式 json:现在的传输数据格式,属性名加双引号来区别,其实也是对象,传输的是个字符串,其实就是json 前端JSON.stringfy(obj) 然后传给后台 后台传回来的j ...
- Intellij部署Tomcat问题
Intellij部署Tomcat问题 Warnings:No artifacts marked for development 切换到Development标签页 选择+按钮,并选择Artifacts ...
- Go Example--Hello
Hello world package main import "fmt" //通过import导入fmt标准包 func main() { //语句结尾不需要;分号, //Pri ...
- LeetCode - Merge Two Binary Trees
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of t ...
- LG5901 【模板】欧拉定理
题意 题目描述 给你三个正整数,$a,m,b$,你需要求: $a^b \mod m$ 输入输出格式 输入格式: 一行三个整数,$a,m,b$ 输出格式: 一个整数表示答案 输入输出样例 输入样例#1: ...
- 在Android上运行Java和C程序
在linux上运行java程序,直接用javac编译,再用java启动虚拟机运行就行了.但是在Android上,由于虚拟机和pc端的不同,所以操作方法也是不一样的.下面介绍Android上运行Hell ...
- day 47 html 学习 css 学习
前端基础之CSS CSS实例 每个CSS样式由两个组成部分:选择器和声明.声明又包括属性和属性值.每个声明之后用分号结束. CSS(Cascading Style Sheet,层叠样式表)定义如何显示 ...
- day43 数据库学习egon的博客 索引
一 介绍 为何要有索引? 一般的应用系统,读写比例在10:1左右,而且插入操作和一般的更新操作很少出现性能问题,在生产环境中,我们遇到最多的,也是最容易出问题的,还是一些复杂的查询操作,因此对查询语句 ...