1 准备工作
Spring Cloud Alibaba 2.X 简易集成 Skywalking 实现微服务链路追踪
2 配置文件
Skywalking OAP 服务配置:
${skywalkingPath}/config/application.yml
storage:
selector: ${SW_STORAGE:mysql}
将默认的持久化方式 h2
改为 mysql
mysql:
properties:
jdbcUrl: ${SW_JDBC_URL:"jdbc:mysql://127.0.0.1:3306/skywalking?useUnicode=true&characterEncoding=utf8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8&useSSL=true&allowMultiQueries=true&autoReconnect=true&nullCatalogMeansCurrent=true&nullCatalogMeansCurrent=true"}
dataSource.user: ${SW_DATA_SOURCE_USER:devUser}
dataSource.password: ${SW_DATA_SOURCE_PASSWORD:yourPassword}
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}
maxSizeOfArrayColumn: ${SW_STORAGE_MAX_SIZE_OF_ARRAY_COLUMN:20}
numOfSearchableValuesPerTag: ${SW_STORAGE_NUM_OF_SEARCHABLE_VALUES_PER_TAG:2}
将数据库配置修改为实际的配置
3 添加数据库驱动
Skywalking 项目不包含 MySQL 的驱动,需要手动下载,并添加到可选依赖库中
${skywalkingPath}/opt-libs
添加之后,重启 Skywalking 即可
4 推荐参考资料
Failed to get driver instance for jdbcUrl=jdbc:mysql
5 Github 源码
Gtihub 源码地址 : https://github.com/Flying9001/springBootDemo
个人公众号:404Code,分享半个互联网人的技术与思考,感兴趣的可以关注.