转载

Confluence(wiki)如何扩展内存

背景:

Confluence 有一天晚上突然就不能访问了,前端页面提示502 。然后抓紧重启服务,一切恢复正常。第二天开始查看日志记录,翻看logs/catalina.out中的日志记录如下:

<span class="hljs-number">03</span>-Dec-<span class="hljs-number">2018</span> <span class="hljs-number">01</span>:<span class="hljs-number">03</span>:<span class="hljs-number">05.107</span> WARNING [main] org.apache.catalina.core.StandardServer.await StandardServer.await: Invalid command <span class="hljs-string">''</span> received
Java HotSpot(TM) <span class="hljs-number">64</span>-Bit Server VM warning: INFO: os::commit_memory(<span class="hljs-number">0</span>x00000007a7400000, <span class="hljs-number">83886080</span>, <span class="hljs-number">0</span>) failed; error=<span class="hljs-string">'Cannot allocate memory'</span> (errno=<span class="hljs-number">12</span>)
#
# There <span class="hljs-keyword">is</span> insufficient memory <span class="hljs-keyword">for</span> the Java Runtime Environment <span class="hljs-keyword">to</span> <span class="hljs-keyword">continue</span>.
# Native memory allocation (mmap) failed <span class="hljs-keyword">to</span> map <span class="hljs-number">83886080</span> bytes <span class="hljs-keyword">for</span> committing reserved memory.
# An error report <span class="hljs-keyword">file</span> <span class="hljs-keyword">with</span> more information <span class="hljs-keyword">is</span> saved <span class="hljs-keyword">as</span>:
# /opt/atlassian/confluence/bin/hs_err_pid2084.log
<span class="hljs-number">03</span>-Dec-<span class="hljs-number">2018</span> <span class="hljs-number">19</span>:<span class="hljs-number">45</span>:<span class="hljs-number">07.267</span> WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.<span class="hljs-keyword">begin</span> [SetPropertiesRule]<span class="hljs-comment">{Server}</span> Setting <span class="hljs-keyword">property</span> <span class="hljs-string">'debug'</span> <span class="hljs-keyword">to</span> <span class="hljs-string">'0'</span> did <span class="hljs-keyword">not</span> find a matching <span class="hljs-keyword">property</span>.
 
 

说是要让去/opt/atlassian/confluence/bin/hs_err_pid2084.log 下查看具体的错误内容,具体内容如下:

<span class="hljs-meta">#</span><span class="bash"> <span class="zh-hans">摘录了一部分日志记录:</span></span>
<span class="hljs-meta">#</span><span class="bash"> <span class="zh-hans">部分一:</span></span>
<span class="hljs-meta">#</span><span class="bash"> Possible reasons:</span>
<span class="hljs-meta">#</span><span class="bash">   The system is out of physical RAM or swap space</span>
<span class="hljs-meta">#</span><span class="bash">   In 32 bit mode, the process size <span class="hljs-built_in">limit</span> was hit</span>
<span class="hljs-meta">#</span><span class="bash"> Possible solutions:</span>
<span class="hljs-meta">#</span><span class="bash">   Reduce memory load on the system</span>
<span class="hljs-meta">#</span><span class="bash">   Increase physical memory or swap space</span>
<span class="hljs-meta">#</span><span class="bash">   Check <span class="hljs-keyword">if</span> swap backing store is full</span>
<span class="hljs-meta">#</span><span class="bash">   Use 64 bit Java on a 64 bit OS</span>
<span class="hljs-meta">#</span><span class="bash">   Decrease Java heap size (-Xmx/-Xms)</span>
<span class="hljs-meta">#</span><span class="bash">   Decrease number of Java threads</span>
<span class="hljs-meta">#</span><span class="bash">   Decrease Java thread stack sizes (-Xss)</span>
<span class="hljs-meta">#</span><span class="bash">   Set larger code cache with -XX:ReservedCodeCacheSize=</span>
<span class="hljs-meta">#</span><span class="bash"> This output file may be truncated or incomplete.</span>
<span class="hljs-meta">#</span>
<span class="hljs-meta">#</span><span class="bash">  Out of Memory Error (os_linux.cpp:2627), pid=2084, tid=0x00007f89ff5d7700</span>
<span class="hljs-meta">
#</span><span class="bash"> <span class="zh-hans">部分二:</span></span>
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 文件,修改文件中的如图选项:

修改前一定要备份文件

Confluence(wiki)如何扩展内存

主要修改 Xmx 后的数字,根据你的Confluence版本不同,这个选项有略微不同,截图里显示了不同版本对应的配置选项。我的是Confluence6.1 ,所以我的配置是: CATALINA_OPTS="-Xms4096m -Xmx16384m -XX:+UseG1GC ${CATALINA_OPTS}"

这个 Xmx 后的数字修改规则为,物理内存的一般,可以略微调大一点

第三步:

启动Nginx 和 Confluence 服务,如果服务正常,就可以使用了

检验方式可以在Confluence的后台【一般配置】系统信息里的Java 栈堆 看到内存扩展后的数据。也可以 ps aux | grep java

提醒:

内存不足可能会引发Confluence一系列的问题,建议有问题,先排查内存问题

#####         如果我的文档给您提供了帮助,请点击一下页面广告,给个支持! #####如有需要沟通的,请直接评论或者是邮件沟通。欢迎小主关注我的微信公众号:BigYoung成长之路,微信搜索可关注。如想交个朋友,可直接加入我的QQ群:615870353;或者加入我的知识星球:ID:45959491

BigYoung版权所有,转载请邮件(Mr_wang_yang@163.com)获取授权,并注明转自:http://www.bigyoung.cn/1029.html

原文  http://www.bigyoung.cn/1029.html
正文到此结束
Loading...