Confluence(wiki)如何扩展内存
2018-12-10 本文已影响39人
Young先生
背景:
Confluence 有一天晚上突然就不能访问了,前端页面提示502 。然后抓紧重启服务,一切恢复正常。第二天开始查看日志记录,翻看logs/catalina.out中的日志记录如下:
03-Dec-2018 01:03:05.107 WARNING [main] org.apache.catalina.core.StandardServer.await StandardServer.await: Invalid command '' received
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000007a7400000, 83886080, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 83886080 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /opt/atlassian/confluence/bin/hs_err_pid2084.log
03-Dec-2018 19:45:07.267 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin [SetPropertiesRule]{Server} Setting property 'debug' to '0' did not find a matching property.
说是要让去/opt/atlassian/confluence/bin/hs_err_pid2084.log 下查看具体的错误内容,具体内容如下:
# 摘录了一部分日志记录:
# 部分一:
# Possible reasons:
# The system is out of physical RAM or swap space
# In 32 bit mode, the process size limit was hit
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Use 64 bit Java on a 64 bit OS
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
# Out of Memory Error (os_linux.cpp:2627), pid=2084, tid=0x00007f89ff5d7700
# 部分二:
Memory: 4k page, physical 16333788k(136664k free), swap 0k(0k free)
vm_info: Java HotSpot(TM) 64-Bit Server VM (25.112-b15) for linux-amd64 JRE (1.8.0_112-b15), built on Sep 22 2016 21:10:53 by "java_re" with gcc 4.3.0 20080428 (Red Hat 4.3.0-8)
time: Mon Dec 3 19:37:07 2018
从第二个日志记录里,我们能看到提示内存不足的可能原因及处理方法。
解决办法:
先升级Confluence所在机器的物理内存。
重点
然后修改Confluence的VM中的内存配置,修改方法如下:
第一步:
关闭Confluence 和 Nginx 服务(如果有)
第二步:
找到Confluence安装路径下的/confluence/bin/setenv.sh 文件,修改文件中的如图选项:
修改前一定要备份文件
image主要修改Xmx
后的数字,根据你的Confluence版本不同,这个选项有略微不同,截图里显示了不同版本对应的配置选项。我的是Confluence6.1 ,所以我的配置是:CATALINA_OPTS="-Xms4096m -Xmx16384m -XX:+UseG1GC ${CATALINA_OPTS}"
这个Xmx
后的数字修改规则为,物理内存的一般,可以略微调大一点
第三步:
启动Nginx 和 Confluence 服务,如果服务正常,就可以使用了
检验方式可以在Confluence的后台【一般配置】系统信息里的Java 栈堆 看到内存扩展后的数据。也可以ps aux | grep java
提醒:
内存不足可能会引发Confluence一系列的问题,建议有问题,先排查内存问题
欢迎大家访问我的博客:BigYoung的博客
欢迎大家关注我的微信公众号:Bigyoung成长之路