cat监控平台环境搭建

来源:互联网 发布:韩火火的淘宝店 编辑:程序博客网 时间:2024/06/06 07:10

cat监控平台环境搭建

项目地址:https://github.com/dianping/cat

编译步骤:

这个项目比较另类,把编译需要的jar包,单独放在git分支mvn-repo里了,而且官方文档里给了一个错误的命令提示:

 git git@github.com:dianping/cat.git mvn-repo

当你直接把这条命令贴到terminal里执行时,会提示命令无效,正确的姿势如下:

1、先安装jdk 1.7 

这点很重要,cat项目的开发时间比较早,当时估计jdk8还没有,在1.8下编译虽然能成功,但是最后运行时会报错。

注:对于已经安装了jdk1.8的mac,可以参考Mac下同时安装多个版本的JDK ,如果弄多版本jdk切换,不要在PATH变量里加$JAVA_HOME/bin,否则alias切换只切换了JAVA_HOME,但是PATH里的值不会变。

2、将分支mvn-repo下的jar包复制到本机maven仓库

1
2
3
4
5
6
git clone https://github.com/dianping/cat.git
cd cat
git checkout mvn-repo
cp -R * ~/.m2/repository
git checkout master
mvn clean install -DskipTests

然后再编译就可以了,再次提醒:如果安装了多个版本的jdk,编译前先将jdk版本切换到jdk 1.7(包括编译成功后,运行时也要jdk 1.7环境) 

 

部署步骤:

1
mvn cat:install

安装过程中,会提示输入mysql的连接地址,输入格式严格按 jdbc:mysql://127.0.0.1:3306 这种格式来,后面不要加一些额外参数,然后输入用户名、密码(该用户要有创建database的权限),之后会自动在mysql中创建cat数据库,然后创建一堆表。

1
2
cd cat-home
mvn jetty:run

如果启动过程无错,就能见到传说中的CAT界面了

  

 

windows下的注意事项:

Windows 则是对系统运行盘下的/data/appdatas/cat和/data/applogs/cat有读写权限 //这个地方要特别说明一下,如有cat的源文件在E盘,则相关配置文件就应该放在e:/data/appdatas/cat/下面



其它运行模式:
命令进入cat下的cat-home目录 
执行命令
 mvn jetty:run ,启动cat服务 


成功后,浏览器打开http://localhost:2281/cat 可以看到cat监控的界面 
或者在cat目录下输入 mvn eclipse:clean eclipse:eclipse 然后将项目导入到eclipse中,运行cat-home项目里得‘com.dianping.cat.TestServer’来启动CAT。

cat监控平台环境搭建

 

FAQ:

异常解决:

要按readme的要求,使用jdk1.8以下进行编译生成war。否则,就有下面的错:

[ERROR] [ServletHolder] Servlet initializing failed. org.unidal.lookup.LookupException: Component(org.unidal.web.lifecycle.RequestLifecycle) lookup failure. details: Unable to lookup component 'org.unidal.web.lifecycle.RequestLifecycle', it could not be started.

role: org.unidal.web.lifecycle.RequestLifecycle
roleHint: mvc

 

maven用的jdk环境和我编译的环境不一样,maven要依赖javahome

http://www.oschina.net/question/1463652_2152237

 

 

 

更改tomcat JDK:

经测试,更改catalina.bat设置也可以

@echo offset JAVA_HOME=C:\Program Files\Java\jdk1.7.0_13set JRE_HOME=C:\Program Files\Java\jre7

 

1、windows下:
修改 tomcat/bin/setclasspath.bat
rem Otherwise either JRE or JDK are fine
之前加上
set JAVA_HOME = C:\....   jdk路径
set JRE_HOME = C:\....\jre  Jre路径
 
2、linux环境下
修改tomcat/bin/setclasspath.sh
# First clear out the user classpath
CLASSPATH=
下面添加上
export JAVA_HOME=/home/tool/jdk1.6.0_18  --jdk路径
export JRE_HOME=/home/tool/jdk1.6.0_18/jre --jre路径
 
保存,重新启动tomcat
 
 
 

mvn编译cat的代码进报下面的错:

A required class is missing:com/thoughtworks/xstream/io/HierarchicalStreamDriver

解决办法:

在mvn本地仓库中com\thoughtworks\xstream这个文件夹。重新执行mvn clean install -DskipTests即可

因为没有这个文件夹,相关的jar都会重新下载,然后就下载到了。

http://www.myexception.cn/xml-soap/1898572.html

 
 
mvn jetty:run
报错:

[INFO] Final Memory: 11M/307M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories 
[local (e:\m2repository), central (http://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundF
orPrefixException

 

原因:

settings.xml没有配置插件应此需要

mvn org.mortbay.jetty:maven-jetty-plugin:run 

这样来运行。

如果需要使用jetty:run,那么必须在maven的setting.xml下配置

 

解决办法:

在.m2的settings.xml文件的pluginGroups节点添加关于jetty的信息:

复制代码
  <!-- pluginGroups   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.   |-->  <pluginGroups>    <!-- pluginGroup     | Specifies a further group identifier to use for plugin lookup.    <pluginGroup>com.your.plugins</pluginGroup>    -->     <pluginGroup>org.mortbay.jetty</pluginGroup>    </pluginGroups>
复制代码

http://www.xuebuyuan.com/1115208.html

 

0 0
原创粉丝点击