0
点赞
收藏
分享

微信扫一扫

angular17+ionic7集成开发

天悦哥 03-09 21:30 阅读 2

目录

 一、实验

1.环境

 2.Linux 部署 Sentinel 

3. 微服务接入Sentinel配置

二、 问题

1.Linux本地启动Sentinel控制台

2.JDBC连接失败


 一、实验

1.环境

(1)主机

表1  主机

系统软件版本IP备注
Linuxopenjdk 1.8.0192.168.204.200

maven3.5.0
nacos1.3.2

依赖jdk

      与maven

sentinel-dashboard1.8.0                  依赖jdk
WindowsMySQL8.0.36localhostNavicat 连接

(2) 查看java版本

[root@localhost ~]# java -version

(3)查看数据库状态

(4)微服务引入Sentinel依赖

<dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

 2.Linux 部署 Sentinel 

(1)官网

home | Sentinel

(2)Github

查看版本

https://github.com/alibaba/Sentinel

控制台

https://github.com/alibaba/Sentinel/wiki/控制台

(3)下载

wget https://github.com/alibaba/Sentinel/releases/download/v1.8.0/sentinel-dashboard-1.8.0.jar

(4) 启动Sentinel控制台

 Sentinel 控制台目前仅支持单机部署,需要 JDK 版本为 1.8 及以上版本

//-Dserver.port=8080 用于指定 Sentinel 控制台端口为 8080 

java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=192.168.204.200:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.8.0.jar

 (5) 查看进程

[root@localhost sysconfig]#  ps -ef | grep 8080
root      71819  69264  9 13:33 pts/2    00:00:46 java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=192.168.204.200:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.8.0.jar
root      72160  71458  0 13:41 pts/3    00:00:00 grep --color=auto 8080

 (6)查看开放的端口

8080端口未开放

[root@localhost ~]# iptables -L -n

(7)开放Linux本地的8080端口

[root@localhost ~]# cd /etc/sysconfig

[root@localhost sysconfig]# vim iptables
……
 -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
……

(8)重启服务

[root@localhost sysconfig]# service iptables restart

(9)再次查看开放的端口

8080端口已开放

[root@localhost sysconfig]# iptables -L -n

 (10)访问

http://192.168.204.200:8080

输入账户密码

默认账号密码 sentinel/sentinel

进入系统

3. 微服务接入Sentinel配置

(1)模块一修改配置文件

application.yml

#dashboard: 8080 控制台端口
#port: 9999 本地启的端口,随机选个不能被占用的,与dashboard进行数据交互,会在应用对应的机器上启动一个 Http Server,该 Server 会与 Sentinel 控制台做交互, 若被占用,则开始+1一次扫描

spring:
……
  cloud:
    sentinel:
      transport:
        dashboard: 192.168.204.200:8080 
        port: 9999 
​……

(2)  模块二修改配置文件

application.yml

配置文件与模块一基本相同,端口修改为9998

#dashboard: 8080 控制台端口
#port: 9999 本地启的端口,随机选个不能被占用的,与dashboard进行数据交互,会在应用对应的机器上启动一个 Http Server,该 Server 会与 Sentinel 控制台做交互, 若被占用,则开始+1一次扫描

spring:
……
  cloud:
    sentinel:
      transport:
        dashboard: 192.168.204.200:8080 
        port: 9998 
​……

(3)微服务进行Debug

运行

查看

(4)Nacos查看服务列表

(5)Sentinel查看

此时没有新增微服务,依然为本机的监控

(6)Postman发送测试

(7)查看微服务模块一的簇点链路

(8)查看微服务模块二的簇点链路

(9)微服务模块二进行流控

点击流控

修改前:

修改后:阈值修改为2

(10)查看流控规则

(11)浏览器快速访问

localhost:9000/api/v1/video/find_by_id?videoId=40

出现流量控制

二、 问题

1.Linux本地启动Sentinel控制台

(1)启动

Sentinel 控制台目前仅支持单机部署,需要 JDK 版本为 1.8 及以上版本

//-Dserver.port=8080 用于指定 Sentinel 控制台端口为 8080 

java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.8.0.jar

(5) 查看进程

[root@localhost ~]# ps -ef | grep 8080
root      69621  69264 10 13:05 pts/2    00:01:32 java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.8.0.jar
root      71499  71458  0 13:20 pts/3    00:00:00 grep --color=auto 8080

(6)访问

http://localhost:8080

输入账户密码

默认账号密码 sentinel/sentinel

进入系统

2.JDBC连接失败

(1)报错

The server time zone value '?й???????' is unrecognized or represents more than one time zone

(2)原因分析

因为使用mysql的jdbc驱动最新版(6.0+)时,会因为数据库和系统时区差异引起的无法连接问题。

(3)解决方法

在jdbc的url中加入时区serverTimezone

//CST代表的是中国上海时间(与北京时间,东八区相同)

url: jdbc:mysql://127.0.0.1:3306/cloud_order?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CST

举报

相关推荐

0 条评论