修改电脑java虚拟机内存,Confluence 提高Java虚拟机内存

Confluence 提高Java虚拟机内存

版本

系统:CentOS release 6.8 (Final)

Java版本:1.8.0_162

Confluence版本:6.8.5

问题描述

confluence内存使用率的配置都是默认的,相对会比较低,可以根据实际server的配置情况,升级内存。

通过“右上角配置 --> 一般配置 --> 系统信息”查看

466b6a72e2a20bdaba73b4290fe1cec5.png

Linux 提高内存步骤

进入到${confluence}/bin目录下(默认/opt/atlassian/confluence/bin),修改setenv.sh文件

[[email protected] ~]# cd /opt/atlassian/confluence/bin

[[email protected] bin]# cp -a setenv.sh{,_$(date +%F)}

[[email protected] bin]# ll setenv.*

-rw-r--r-- 1 root root 2553 7月 11 04:13 setenv.bat

-rwxr-xr-x 1 root root 3034 11月 26 11:40 setenv.sh

-rwxr-xr-x 1 root root 3034 11月 26 11:40 setenv.sh_2018-11-26

[[email protected] bin]# vim setenv.sh

62 # Set the JVM arguments used to start Confluence. For a description of the options, see

63 # http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

64 CATALINA_OPTS="-XX:-PrintGCDetails -XX:+PrintGCDateStamps -XX:-PrintTenuringDistribution ${CATALINA_OPTS}"

65 CATALINA_OPTS="-Xloggc:$LOGBASEABS/logs/gc-`date +%F_%H-%M-%S`.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2M ${CATALINA_OPTS}"

66 CATALINA_OPTS="-XX:G1ReservePercent=20 ${CATALINA_OPTS}"

67 CATALINA_OPTS="-Djava.awt.headless=true ${CATALINA_OPTS}"

68 CATALINA_OPTS="-Datlassian.plugins.enable.wait=300 ${CATALINA_OPTS}"

69 CATALINA_OPTS="-Xms1024m -Xmx1024m -XX:+UseG1GC ${CATALINA_OPTS}"

70 CATALINA_OPTS="-Dsynchrony.enable.xhr.fallback=true ${CATALINA_OPTS}"

71 CATALINA_OPTS="-Dorg.apache.tomcat.websocket.DEFAULT_BUFFER_SIZE=32768 ${CATALINA_OPTS}"

72 CATALINA_OPTS="${START_CONFLUENCE_JAVA_OPTS} ${CATALINA_OPTS}"

73 CATALINA_OPTS="-Dconfluence.context.path=${CONFLUENCE_CONTEXT_PATH} ${CATALINA_OPTS}"

74 CATALINA_OPTS="-XX:ReservedCodeCacheSize=256m -XX:+UseCodeCacheFlushing ${CATALINA_OPTS}"

75

76

77 export CATALINA_OPTS

把69行的-Xmx1024m参数改为自己要求的最大内存,例如:-Xmx3072m

69 CATALINA_OPTS="-Xms1024m -Xmx3072m -XX:+UseG1GC ${CATALINA_OPTS}"

重启 confluence(需要管理员权限)

# 关闭服务

service confluence stop

# 启动服务

service confluence start

查看confluence内存配置是否生效。

ea33ffd1daa209c7d39d89b57b1dd93f.png

Windows 提高内存步骤

进入到${confluence}\bin目录下(默认C:\Atlassian\Confluence\bin),修改setenv.bat文件

62 # Set the JVM arguments used to start Confluence. For a description of the options, see

63 # http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

64 CATALINA_OPTS="-XX:-PrintGCDetails -XX:+PrintGCDateStamps -XX:-PrintTenuringDistribution ${CATALINA_OPTS}"

65 CATALINA_OPTS="-Xloggc:$LOGBASEABS/logs/gc-`date +%F_%H-%M-%S`.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2M ${CATALINA_OPTS}"

66 CATALINA_OPTS="-XX:G1ReservePercent=20 ${CATALINA_OPTS}"

67 CATALINA_OPTS="-Djava.awt.headless=true ${CATALINA_OPTS}"

68 CATALINA_OPTS="-Datlassian.plugins.enable.wait=300 ${CATALINA_OPTS}"

69 CATALINA_OPTS="-Xms1024m -Xmx1024m -XX:+UseG1GC ${CATALINA_OPTS}"

70 CATALINA_OPTS="-Dsynchrony.enable.xhr.fallback=true ${CATALINA_OPTS}"

71 CATALINA_OPTS="-Dorg.apache.tomcat.websocket.DEFAULT_BUFFER_SIZE=32768 ${CATALINA_OPTS}"

72 CATALINA_OPTS="${START_CONFLUENCE_JAVA_OPTS} ${CATALINA_OPTS}"

73 CATALINA_OPTS="-Dconfluence.context.path=${CONFLUENCE_CONTEXT_PATH} ${CATALINA_OPTS}"

74 CATALINA_OPTS="-XX:ReservedCodeCacheSize=256m -XX:+UseCodeCacheFlushing ${CATALINA_OPTS}"

75

76

77 export CATALINA_OPTS

把69行的-Xmx1024m参数改为自己要求的最大内存,例如:-Xmx3072m

69 CATALINA_OPTS="-Xms1024m -Xmx3072m -XX:+UseG1GC ${CATALINA_OPTS}"

重启 confluence(需要管理员权限)

进入到服务管理的界面(我的电脑->右键->管理->服务=====或者=====services.msc)找到confluence的服务,在这里启动关闭服务。

查看confluence内存配置是否生效。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的上传附件的java代码示例: ```java import com.atlassian.confluence.api.ConfluenceApi; import com.atlassian.confluence.api.model.content.Content; import com.atlassian.confluence.api.model.content.ContentType; import com.atlassian.confluence.api.model.content.ContentBody; import com.atlassian.confluence.api.model.content.ContentCreationRequest; import com.atlassian.confluence.api.model.content.ContentUpdateRequest; import com.atlassian.confluence.api.model.content.Space; import com.atlassian.confluence.api.model.content.SpaceSummary; import com.atlassian.confluence.api.model.content.SpaceUpdateRequest; import com.atlassian.confluence.api.model.content.Upload; import com.atlassian.confluence.api.model.content.id.ContentId; import com.atlassian.confluence.api.model.content.id.SpaceId; import com.atlassian.confluence.api.model.exception.ForbiddenException; import com.atlassian.confluence.api.model.exception.InvalidRequestException; import com.atlassian.confluence.api.model.exception.NotFoundException; import com.atlassian.confluence.api.model.exception.PermissionException; import com.atlassian.confluence.api.model.exception.RateLimitExceededException; import com.atlassian.confluence.api.model.exception.ServerErrorException; import com.atlassian.confluence.api.model.exception.UnknownException; import com.atlassian.confluence.api.model.pagination.Pagination; import com.atlassian.confluence.api.model.person.Person; import com.atlassian.confluence.api.model.person.UserDetails; import com.atlassian.confluence.api.model.person.Username; import com.atlassian.confluence.api.model.permissions.PermissionCheckResult; import com.atlassian.confluence.api.service.content.ContentService; import com.atlassian.confluence.api.service.content.SpaceService; import com.atlassian.confluence.api.service.search.SearchService; import com.atlassian.confluence.api.service.user.UserService; import com.atlassian.fugue.Option; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; public class ConfluenceAttachmentUploader { private final ConfluenceApi confluence; private final String pageTitle; private final String pageContent; private final String attachmentFilePath; public ConfluenceAttachmentUploader(ConfluenceApi confluence, String pageTitle, String pageContent, String attachmentFilePath) { this.confluence = confluence; this.pageTitle = pageTitle; this.pageContent = pageContent; this.attachmentFilePath = attachmentFilePath; } public void uploadAttachment() throws IOException, PermissionException { // Create page content ContentBody contentBody = ContentBody.builder() .value(pageContent) .representation(ContentBody.Representation.STORAGE) .build(); ContentCreationRequest contentCreationRequest = ContentCreationRequest.builder() .space(confluence.getContentService().find().byTitle(ContentType.SPACE, "My Space")).get().getId()) .type(ContentType.PAGE) .title(pageTitle) .body(contentBody) .build(); Content page = confluence.getContentService().create(contentCreationRequest).claim(); // Upload attachment InputStream inputStream = new FileInputStream(new File(attachmentFilePath)); Upload upload = confluence.getContentService().upload(page.getId(), "attachment.png", inputStream).claim(); // Update page with attachment ContentUpdateRequest contentUpdateRequest = ContentUpdateRequest.builder() .id(page.getId()) .title(page.getTitle()) .version(page.getVersion()) .body(contentBody) .metadata(page.getMetadata()) .attachments(Arrays.asList(upload)) .build(); confluence.getContentService().update(contentUpdateRequest).claim(); } } ``` 请注意,您需要替换以下变量: - `confluence`: 您的ConfluenceApi对象。 - `pageTitle`: 您要创建的页面的标题。 - `pageContent`: 您要创建的页面的内容。 - `attachmentFilePath`:您要上传的附件的文件路径。 这个示例假设您已经有一个名为"My Space"的空间,您需要将其替换为您实际的空间名称。同时,您还需要进行适当的错误处理和认证,以确保您的代码可以正常运行。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值