Environment
Software Version:
Ubuntu: 16.04
elasticsearch : 6.2.4 下载地址
jdk:1.8.0_151 略
apache-skywalking-apm:6.5 下载地址
需要注意的
官网:http://skywalking.apache.org/
如果端口8080,10800,11800,12800不被占用,你可以直接解压tar / unzip,然后启动,不需要更改冲突的端口号。
apache-skywalking-apm 对版本要求比较严格,还有各个版本的配置变化可能比较大。
ES服务需要设置name和cluster_name,注意监听地址
ui界面的同步,每个人测试环境的性能和测试软件的不同,刷新数据的时间可能会有不同。
Install
前提
jdk es 安装好,配置好
jdk验证
[root@paa4-0-253 opt]# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
es验证(注意name和cluster_name)
[root@paa4-0-253 opt]# curl localhost:9200
{
"name" : "es-name",
"cluster_name" : "my-es-skywalking",
"cluster_uuid" : "KoSb4HfNTme5uj8WflxhIA",
"version" : {
"number" : "6.2.4",
"build_hash" : "ccec39f",
"build_date" : "2018-04-12T20:37:28.497551Z",
"build_snapshot" : false,
"lucene_version" : "7.2.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
vim /to/path/elasticsearch-6.2.4/config/elasticsearch.yml
···
node.name: es-name
cluster.name: my-es-skywalking
network.host: 0.0.0.0
···
./bin/elasticsearch -d
下载和启动
$ wget https://archive.apache.org/dist/skywalking/6.5.0/apache-skywalking-apm-6.5.0.tar.gz
$ tar apache-skywalking-apm-6.5.0.tar.gz && cd apache-skywalking-apm-bin
$ vim config/application.yml # 主配置文件,只需要修改存储为es
···
storage:
elasticsearch:
nameSpace: ${SW_NAMESPACE:"my-es-skywalking"}
clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200}
indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:2}
indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:0}
bulkActions: ${SW_STORAGE_ES_BULK_ACTIONS:2000} # Execute the bulk every 2000 requests
bulkSize: ${SW_STORAGE_ES_BULK_SIZE:20} # flush the bulk every 20mb
flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:10}
concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2}
···
$ ./bin/startup.sh # 启动
SkyWalking OAP started successfully!
SkyWalking Web Application started successfully!
检查日志,在根目录的logs下
UI
http://ip:8080
Agent set
官方步骤 :https://github.com/apache/skywalking/blob/5.x/docs/cn/Deploy-skywalking-agent-CN.md
java mvc demo
下载示例代码
$ mkdir -p /opt/mvc-demo && cd /opt/mvc-demo && wget https://github.com/lijinghuatongxue/Blog_Example/blob/master/skywalking-apm/sprintbootdemo-0.0.1-SNAPSHOT.jar
拷贝 apache-skywalking-apm-bin 目录下面的 agent目录到我们测试的代码根目录下
agent配置好的话,命令行则不需要再写
$ cp -rf apache-skywalking-apm-bin/agent /opt/mvc-demo
$ vim /opt/mvc-demo/agent/config/agent.config
···
agent.service_name=${SW_AGENT_NAME:java-test}
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:192.168.0.253:11800} # 这里是我们远程server的地址
···
$ java -javaagent:/opt/mvc-demo/agent/skywalking-agent.jar -Dserver.port=9999 -jar sprintbootdemo-0.0.1-SNAPSHOT.jar
DEBUG 2019-12-18 04:39:35:970 main AgentPackagePath : The beacon class location is jar:file:/git/java/target/agent/skywalking-agent.jar!/org/apache/skywalking/apm/agent/core/boot/AgentPackagePath.class.
INFO 2019-12-18 04:39:35:972 main SnifferConfigInitializer : Config file found in /git/java/target/agent/config/agent.config.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.4.RELEASE)
··························
2019-12-18 04:39:46.035 INFO 18480 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9999 (http) with context path ''
2019-12-18 04:39:46.044 INFO 18480 --- [ main] c.m.s.SprintbootdemoApplication : Started SprintbootdemoApplication in 5.215 seconds (JVM running for 10.228)
2019-12-18 04:41:28.537 INFO 18480 --- [nio-9999-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2019-12-18 04:41:28.537 INFO 18480 --- [nio-9999-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2019-12-18 04:41:28.559 INFO 18480 --- [nio-9999-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 22 ms
jenkins demo
按上面同样的方法把agent目录复制到 /opt/jenkins下面,但是需要更改配置
$ mkdir -p /opt/jenkins-demo && cd /opt/jenkins-demo && wget http://mirrors.jenkins.io/war-stable/latest/jenkins.war
$ $ vim /opt/jenkins-demo/agent/config/agent.config
···
agent.service_name=${SW_AGENT_NAME:jenkins-test}
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:192.168.0.253:11800} # 这里是我们远程server的地址
···
启动
$ java -javaagent:/opt/jenkins-demo/agent/skywalking-agent.jar -Dhudson.util.ProcessTree.disable=true -jar /opt/jenkins-demo/jenkins.war --httpPort=8888
然后按照以往的配置去配置完jenkins,耐心等待一会,然后去skywalking控制台去查看。
Demo
当然,可玩性很高,祝你路途愉快
本文由 李阿斗创作 旅途愉快~ 我的主页 ( ̄▽ ̄)
最后编辑时间为:
2019/12/18 06:04