文件名称 | 版本号 | 作者 | 版本 | |
---|---|---|---|---|
SpringCloud观察 | v1.0.1 | 学生宫布 | 8416837 | SpringBoot 2.2.6 SpringCloud Hoxton.SR4 |
参考,谢谢!
blade.datasource.demo.master.url=jdbc:mysql://127.0.0.1:3306/blade?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8;blade.datasource.dev.username=root;blade.datasource.dev.password=root;spring.cloud.nacos.discovery.server-addr=192.168.59.133:8849;spring.cloud.nacos.config.server-addr=192.168.59.133:8849;spring.profiles.active=dev;spring.cloud.nacos.config.prefix=blade-system;blade.datasource.demo.slave.url=jdbc:mysql://192.168.59.133:3306/blade?useSSL\=false&useUnicode\=true&characterEncoding\=utf-8&zeroDateTimeBehavior\=convertToNull&transformedBitIsBoolean\=true&tinyInt1isBit\=false&allowMultiQueries\=true&serverTimezone\=GMT%2B8
tar xvzf nacos-server-1.1.4.tar.gz -C /home/app/nacos/ # 老规矩,解压
ufw allow 8848
ufw reload
nohup bin/startup.sh & # 启动
sudo vim ~/.bashrc
# 填入内容
export JAVA_HOME=/home/app/java/jdk1.8.0_201
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
source ~/.bashrc
jps
报错:
-bash: /home/app/java/jdk1.8.0_201/bin/java: No such file or directory
报错原因:不是64位的jdk,下载64位的jdk
再次启动:
sh bin/startup.sh -m standalone # 若报错:bin/startup.sh: 81: bin/startup.sh: [[: not found,则改为:bash bin/...
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 ([email protected]).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.system.user;
import org.springblade.core.launch.BladeApplication;
import org.springblade.core.launch.constant.AppConstant;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* 用户启动器
*
* @author
*/
@SpringCloudApplication
@EnableFeignClients(AppConstant.BASE_PACKAGES)
public class UserApplication {
public static void main(String[] args) {
BladeApplication.run(AppConstant.APPLICATION_USER_NAME, UserApplication.class, args);
}
}
BladeApplication.java封装了启动逻辑,以利复用:
LauncherConstant.java
LauncherServiceImpl.java
,函数launcher的配置会覆盖之前的配置public interface LauncherConstant {
/**
* nacos namespace id
*/
String NACOS_NAMESPACE = "f447a694-519a-4255-95f9-bcbb5a5d636";
/**
* nacos dev 地址
*/
String NACOS_DEV_ADDR = "192.168.59.133:8849";
... ...
@ComponentScan(basePackages = "test")
# 修正为
@ComponentScan(basePackages = {"test", "org.springblade"})
调用成功,不过我们最好增加OAuth2.0
作为服务之间通信的标准:
微服务作为终端,与zipkin-collector建立连接,发送轨迹信息给collector,zipkin-ui基于数据绘制视图,因此,与注册中心关系不大,除非需要用到路由、服务id
自带的zipkin报错,没启动起来,而且报错的类是不推荐使用、划线的类
那就用Docker整一个不报错的来吧:
docker run -d -p 9411:9411 --name zipkin-dev-cc openzipkin/zipkin
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-sleuthartifactId>
dependency>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-zipkinartifactId>
dependency>
注意yaml文件空格
spring:
sleuth:
web:
client:
enabled: true
sampler:
probability: 1.0 # 测试环境中,将采样比例设置为 1.0,也就是全部都需要。默认是 0.1
zipkin:
base-url: http://192.168.59.134:9411/ # 指定了 Zipkin 服务器的地址
同时注意服务启动时,配置的base-url地址,因为有的代码里面会配置zipkin地址。
解决办法:改变依赖包:
<dependency>
<groupId>io.lettucegroupId>
<artifactId>lettuce-coreartifactId>
<version>5.2.2.RELEASEversion>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-data-redisartifactId>
<version>2.2.6.RELEASEversion>
dependency>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-sleuth-zipkinartifactId>
<version>2.2.2.RELEASEversion>
<exclusions>
<exclusion>
<artifactId>spring-cloud-sleuth-coreartifactId>
<groupId>org.springframework.cloudgroupId>
exclusion>
exclusions>
dependency>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-sleuth-coreartifactId>
<version>2.2.2.RELEASEversion>
dependency>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-sleuthartifactId>
<version>2.2.2.RELEASEversion>
<exclusions>
<exclusion>
<artifactId>spring-cloud-sleuth-coreartifactId>
<groupId>org.springframework.cloudgroupId>
exclusion>
exclusions>
dependency>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-zipkinartifactId>
<version>2.2.2.RELEASEversion>
<exclusions>
<exclusion>
<artifactId>spring-cloud-starter-sleuthartifactId>
<groupId>org.springframework.cloudgroupId>
exclusion>
<exclusion>
<artifactId>spring-cloud-sleuth-coreartifactId>
<groupId>org.springframework.cloudgroupId>
exclusion>
<exclusion>
<artifactId>spring-cloud-sleuth-zipkinartifactId>
<groupId>org.springframework.cloudgroupId>
exclusion>
exclusions>
dependency>
升级依赖后,却导致redis不能正常操作。可能redis版本太低。目前发现3.0.6
、4.0.10
是不行的。
解决jedis连接池的redis不能工作,两种方法二选一:
spring-cloud-starter-sleuth|zipkin
版本为2.1.0
;注意:链路视图在请求或者连接执行完毕一小会儿后,才会创建。
微服务与zipkin连接成功后,与其它微服务或者redis等组件的链路、拓扑图:点这个
使用FeignClient调用API,链路图的变化:
上图的红点表示出故障了。
SkyWalking 是一款开源的应用性能监控系统,包括指标监控,分布式追踪,分布式系统性能诊断
见我的博客SkyWalking
查看在线演示
npm install -g yarn --registry=https://registry.npm.taobao.org
# 查看yarn的镜像
yarn config get registry
yarn config set registry https://registry.npm.taobao.org -g
# 查看yarn的镜像
yarn config get registry
$ git clone https://gitee.com/smallc/Saber.git
$ cd Saber
# 安装
$ yarn install
# 启动
$ yarn run serve
FROM anapsix/alpine-java:8_server-jre_unlimited
MAINTAINER [email protected]
RUN mkdir -p /blade/system
WORKDIR /blade/system
EXPOSE 8106
ADD ./target/blade-system.jar ./app.jar
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
CMD ["--spring.profiles.active=dev"]
# 后面有个点
docker build -t blade-system-dev-cc-0.0.1 .
docker run --name blade-system-dev-cc -d -p 8116:8016 -v /home/project/reference/cloud/blade/logs:/logs/ SpringCloud/blade-system-dev-cc-0.0.1 --blade.datasource.dev.url=jdbc:mysql://192.168.59.1:3306/blade?useSSL=false\&useUnicode=true\&characterEncoding=utf-8\&zeroDateTimeBehavior=convertToNull\&transformedBitIsBoolean=true\&tinyInt1isBit=false\&allowMultiQueries=true\&serverTimezone=GMT%2B8 --blade.datasource.dev.username=root --blade.datasource.dev.password=root --spring.cloud.nacos.discovery.server-addr=192.168.59.134:8848 --spring.cloud.nacos.config.server-addr=192.168.59.134:8848