概述
之前在华为做过一段时间的APM,使用的skywalking进行二次开发,当时是8.X版本,现在一看已经10.X了,就下载下来跑跑看
编译
直接参考官方文档进行编译即可,编译文件如下
# How to build a project
This document will help you compile and build a project in your maven and set your IDE.
## Building the Project
**Since we are using Git submodule, we do not recommend using the `GitHub` tag or release page to download source codes for compiling.**
### Maven behind the Proxy
If you need to execute build behind the proxy, edit the *.mvn/jvm.config* and set the follow properties:
```properties
-Dhttp.proxyHost=proxy_ip
-Dhttp.proxyPort=proxy_port
-Dhttps.proxyHost=proxy_ip
-Dhttps.proxyPort=proxy_port
-Dhttp.proxyUser=username
-Dhttp.proxyPassword=password
Building from GitHub
-
Prepare git, JDK 11, 17, 21 (LTS versions), and Maven 3.6+.
-
Clone the project.
If you want to build a release from source codes, set a
tag name
by usinggit clone -b [tag_name] ...
while cloning.git clone --recurse-submodules https://github.com/apache/skywalking.git cd skywalking/ OR git clone https://github.com/apache/skywalking.git cd skywalking/ git submodule init git submodule update
-
Run
./mvnw clean package -Dmaven.test.skip
-
All packages are in
/dist
(.tar.gz for Linux and .zip for Windows).
Building from Apache source code release
- What is the
Apache source code release
?
For each official Apache release, there is a complete and independent source code tar, which includes all source codes. You could download it from SkyWalking Apache download page. There is no requirement related to git when compiling this. Just follow these steps.
- Prepare JDK11+ and Maven 3.6+.
- Run
./mvnw clean package -Dmaven.test.skip
. - All packages are in
/dist
.(.tar.gz for Linux and .zip for Windows).
Advanced compiling
SkyWalking is a complex maven project that has many modules. Therefore, the time to compile may be a bit longer than usual. If you just want to recompile part of the project, you have the following options:
- Compile backend and package
./mvnw package -Pbackend,dist
or
make build.backend
If you intend to compile a single plugin, such as one in the dev stage, you could
cd plugin_module_dir & mvn clean package
- Compile UI and package
./mvnw package -Pui,dist
or
make build.ui
Building docker images
You can build docker images of backend
and ui
with Makefile
located in root folder.
Refer to Build docker image for more details.
Setting up your IntelliJ IDEA
NOTE: If you clone the codes from GitHub, please make sure that you have finished steps 1 to 3 in section Build from GitHub. If you download the source codes from the official website of SkyWalking, please make sure that you have followed the steps in section Build from Apache source code release.
- Import the project as a maven project.
- Run
./mvnw compile -Dmaven.test.skip=true
to compile project and generate source codes. The reason is that we use gRPC and protobuf. - Set Generated Source Codes folders.
grpc-java
andjava
folders in apm-protocol/apm-network/target/generated-sources/protobufgrpc-java
andjava
folders in oap-server/server-core/target/generated-sources/protobufgrpc-java
andjava
folders in oap-server/server-receiver-plugin/receiver-proto/target/generated-sources/fbsgrpc-java
andjava
folders in oap-server/server-receiver-plugin/receiver-proto/target/generated-sources/protobufgrpc-java
andjava
folders in oap-server/exporter/target/generated-sources/protobufgrpc-java
andjava
folders in oap-server/server-configuration/grpc-configuration-sync/target/generated-sources/protobufgrpc-java
andjava
folders in oap-server/server-alarm-plugin/target/generated-sources/protobufgrpc-java
andjava
folders in oap-server/server-fetcher-plugin/fetcher-proto/target/generated-sources/protobufantlr4
folder in oap-server/oal-grammar/target/generated-sources
### 避坑
更新子模块的时候可能由于网络原因导致失败,编译的时候缺少文件,可以用上梯子更新或者手动更新到指定目录,需要更新的文件(项目根目录文件.gitmodules)在如下目录
[submodule "apm-protocol/apm-network/src/main/proto"]
path = apm-protocol/apm-network/src/main/proto
url = https://github.com/apache/skywalking-data-collect-protocol.git
[submodule "oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol"]
path = oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
url = https://github.com/apache/skywalking-query-protocol.git
[submodule "test/e2e-v2/java-test-service/e2e-protocol/src/main/proto"]
path = test/e2e-v2/java-test-service/e2e-protocol/src/main/proto
url = https://github.com/apache/skywalking-data-collect-protocol.git
[submodule "skywalking-ui"]
path = skywalking-ui
url = https://github.com/apache/skywalking-booster-ui.git
编译成功后输出文件目录
[INFO] Executing tasks
[INFO] [copy] Copying 1 file to E:\skywalking\skywalking\dist
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for apm 10.3.0-SNAPSHOT:
开始部署
在文件夹E:\skywalking\skywalking\dist下找到编译的文件 上传到服务器进行部署(这里是阿里云linux)
使用tar命令解压文件,进入解压后目录,配置文件在config文件夹,启动脚本在bin文件夹
1、修改配置 application.yml 根据自己配置的数据库,在数据库节点storage:配置数据库类型,并在mysql节点修改连接信息
# 默认是banyandb数据库
storage:
selector: ${SW_STORAGE:banyandb}
mysql:
properties:
jdbcUrl: ${SW_JDBC_URL:"jdbc:mysql://120.77.205:xxx/xxxxx?rewriteBatchedStatements=true&allowMultiQueries=true"}
dataSource.user: ${SW_DATA_SOURCE_USER:xxxx}
dataSource.password: ${SW_DATA_SOURCE_PASSWORD:xxxxx}
dataSource.cachePrepStmts: ${SW_DATA_SOURCE_CACHE_PREP_STMTS:true}
dataSource.prepStmtCacheSize: ${SW_DATA_SOURCE_PREP_STMT_CACHE_SQL_SIZE:250}
dataSource.prepStmtCacheSqlLimit: ${SW_DATA_SOURCE_PREP_STMT_CACHE_SQL_LIMIT:2048}
dataSource.useServerPrepStmts: ${SW_DATA_SOURCE_USE_SERVER_PREP_STMTS:true}
metadataQueryMaxSize: ${SW_STORAGE_MYSQL_QUERY_MAX_SIZE:5000}
maxSizeOfBatchSql: ${SW_STORAGE_MAX_SIZE_OF_BATCH_SQL:2000}
asyncBatchPersistentPoolSize: ${SW_STORAGE_ASYNC_BATCH_PERSISTENT_POOL_SIZE:4}
然后进入bin目录,执行启动脚本
oapServiceInit.sh
后续启动执行startup.sh
## 验证
启动成功可见前台页面,前端访问端口8080可以在web工程配置文件修改。后台接口默认访问端口 12800 可在配置文件修改
前台效果
http://120.77.205.1:8080/