12月24, 2023

部署美团cat的一些问题

想实际看一下美团的cat大概是什么样的,所以打算部署一个看下。

之前基本没有部署过java的项目,不过过程也没有想象中的那么痛苦,主要是代码里面有不少坑。

一定要注意的一个问题是tomcat必须是不高于9,因为10把包名改了,要想兼容得改代码。安装tomcat可以参考这里

问题一

编译cat-home时遇到如下报错:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project cat-home: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war failed: Unable to load the mojo 'war' in the plugin 'org.apache.maven.plugins:maven-war-plugin:2.1.1' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: Cannot access defaults field of Properties
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-war-plugin:2.1.1
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/root/.m2/repository/org/apache/maven/plugins/maven-war-plugin/2.1.1/maven-war-plugin-2.1.1.jar
[ERROR] urls[1] = file:/root/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.6/maven-reporting-api-2.0.6.jar
[ERROR] urls[2] = file:/root/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.jar
[ERROR] urls[3] = file:/root/.m2/repository/commons-cli/commons-cli/1.0/commons-cli-1.0.jar
[ERROR] urls[4] = file:/root/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar
[ERROR] urls[5] = file:/root/.m2/repository/org/apache/maven/maven-archiver/2.4.1/maven-archiver-2.4.1.jar
[ERROR] urls[6] = file:/root/.m2/repository/org/codehaus/plexus/plexus-archiver/1.2/plexus-archiver-1.2.jar
[ERROR] urls[7] = file:/root/.m2/repository/org/codehaus/plexus/plexus-io/1.0.1/plexus-io-1.0.1.jar
[ERROR] urls[8] = file:/root/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.13/plexus-interpolation-1.13.jar
[ERROR] urls[9] = file:/root/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[10] = file:/root/.m2/repository/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar
[ERROR] urls[11] = file:/root/.m2/repository/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar
[ERROR] urls[12] = file:/root/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.5/plexus-utils-2.0.5.jar
[ERROR] urls[13] = file:/root/.m2/repository/org/apache/maven/shared/maven-filtering/1.0-beta-2/maven-filtering-1.0-beta-2.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :cat-home

找到一个Stack Overflow的回答,看起来是版本低了。

了解了一下怎么修改依赖版本。具体是在cat-home/pom.xml修改maven-war-plugin的version,改成3.3.2就解决了。

问题二

编译好war之后,服务一直启动不起来,看了下tomcat的日志/opt/tomcat/logs/catalina.out,报错如下:

Unrecognized VM option 'PermSize=256m'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

tomcat/bin/setenv.shPermSize都改成MetaspaceSize就好了。

然后又报错:

Unrecognized VM option 'UseParNewGC'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

删掉-XX:+UseParallelGC-XX:ParallelGCThreads=4,然后删掉UseConcMarkSweepGC,删除所有CMS相关的option例如-XX:+UseCMSInitiatingOccupancyOnly-XX:+UseCMSCompactAtFullCollection等等。

-XX:+PrintGCTimeStamps->-Xlog:gc*:file=/opt/logs/gc.log:time,level,tags(用你自己的路径),删除-XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC-Xloggc:/data/applogs/heap_trace.txt-XX:+PrintGCDetails

然后XmsXmxNewSize根据内存情况调整一下。

本文链接:https://debug.fanzheng.org/post/bu-shu-mei-tuan-cat-de-yi-xie-wen-ti.html

-- EOF --

Comments

评论加载中...

注:如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理。