当前位置: 首页 > news >正文

sentinel持久化方案

一.sentinel规则推送原理

1.原有内存规则存储原理

(1)dashborad中请求到服务器后,在controller中通过http把规则直接推送给client,client接收后把规则放入内存;

2.持久化推送规则原理

![在这里插入代码片](https://img-blog.csdnimg.cn/16a99e8e725a4eb6a7011f36ec7f70e0.png)

一.sentinel持久化改造

1.改造dashboard

(1)sentinel提供了持久化方案的数据源,将 test 这一行注释掉

<!-- for Nacos rule publisher sample --><dependency><groupId>com.alibaba.csp</groupId><artifactId>sentinel-datasource-nacos</artifactId><version>${sentinel.project.version}</version>
<!--            <scope>test</scope>--></dependency>

(2)引入nacos配置中心和注册中心

 <!-- Nacos注册中心 --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><!-- Nacos配置中心 --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId></dependency>

(3)添加远程来取配置的bean

在这里插入图片描述

(3)添加从远程配置中心拉取规则

1./v1/flow/rules(GET)请求中把”从客户端内存获取规则配置“修改成”从远程配置中心获取规则配置“

![在这里插入图片描述](https://img-blog.csdnimg.cn/38054ed9356b4e40a355d45079590389.png在这里插入图片描述

2.从nacos中拉取配置,DynamicRuleProvider实现这个接口用来拉取配置的扩展接口,List泛型类list表示配置有多条FlowRuleEntity返回到控制台的实体信息,注入ConfigService配置中心的核心接口,这里从nacos拉到的数组对象是FlowRule,所以需要通过”FlowRuleEntity.fromFlowRule(appName,ip,port,rule))“转换成FlowRuleEntity;

![在这里插入图片描述](https://img-blog.csdnimg.cn/c1289d8c77364744a9cc509754fde0e1.png在这里插入图片描述

(4)将控制台添加的规则信息推送到nacos中

1./v1/flow/rule(POST)请求中把“发布规则到客户端内存中”修改成“发布规则到远程配置中心”

在这里插入图片描述
在这里插入图片描述

2.把dashboard服务内存中的配置推送到nacos中,DynamicRulePublisher实现这个接口用来推送配置的扩展接口,List泛型类list表示配置有多条FlowRuleEntity返回到控制台的实体信息,注入ConfigService配置中心的核心接口,这里推送打nacos中的对象是FlowRule,所以需要通过”NacosConfigUtil.convertToRule(rules)“转换成FlowRule;

在这里插入图片描述
在这里插入图片描述

(5)将控制台添加的规则信息推送到nacos中如果是Gateway网关则需要该如下两个类

![在这里插入图片描述](https://img-blog.csdnimg.cn/1ba449a40e5c4ae29b7c8a87a7714286.png
在这里插入图片描述

(5)注入nacos操作配置中心的核心bean ConfigService和FlowRuleEntity与FlowRule转换工具类

在这里插入图片描述

/** Copyright 1999-2018 Alibaba Group Holding Ltd.** 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 com.alibaba.csp.sentinel.dashboard.rule.nacos;import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.config.ConfigFactory;
import com.alibaba.nacos.api.config.ConfigService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;import java.util.Properties;/*** @author Fox*/
@Configuration
public class NacosConfig {@Value("${spring.cloud.nacos.discovery.server-addr}")private String serverAddr;@Value("${spring.cloud.nacos.discovery.username}")private String username;@Value("${spring.cloud.nacos.discovery.password}")private String password;@Value("${spring.cloud.nacos.discovery.namespace:}")private String namespace;@Beanpublic ConfigService nacosConfigService() throws Exception {
//        return ConfigFactory.createConfigService(serverAddr);Properties properties = new Properties();properties.setProperty(PropertyKeyConst.SERVER_ADDR, serverAddr);properties.setProperty(PropertyKeyConst.USERNAME, username);properties.setProperty(PropertyKeyConst.PASSWORD, password);if (!StringUtils.isEmpty(namespace)) {properties.setProperty(PropertyKeyConst.NAMESPACE, namespace);}return ConfigFactory.createConfigService(properties);}}
/** Copyright 1999-2018 Alibaba Group Holding Ltd.** 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 com.alibaba.csp.sentinel.dashboard.rule.nacos;import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity;
import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity;
import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity;
import com.alibaba.csp.sentinel.util.StringUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;/*** @author Fox*/
public final class NacosConfigUtil {public static final String GROUP_ID = "SENTINEL_GROUP";public static final String FLOW_DATA_ID_POSTFIX = "-flow-rules";public static final String PARAM_FLOW_DATA_ID_POSTFIX = "-param-flow-rules";public static final String DEGRADE_DATA_ID_POSTFIX = "-degrade-rules";public static final String SYSTEM_DATA_ID_POSTFIX = "-system-rules";public static final String AUTHORITY_DATA_ID_POSTFIX = "-authority-rules";public static final String GATEWAY_FLOW_DATA_ID_POSTFIX = "-gateway-flow-rules";public static final String GATEWAY_API_DATA_ID_POSTFIX = "-gateway-api-rules";public static final String CLUSTER_MAP_DATA_ID_POSTFIX = "-cluster-map";/*** cc for `cluster-client`*/public static final String CLIENT_CONFIG_DATA_ID_POSTFIX = "-cc-config";/*** cs for `cluster-server`*/public static final String SERVER_TRANSPORT_CONFIG_DATA_ID_POSTFIX = "-cs-transport-config";public static final String SERVER_FLOW_CONFIG_DATA_ID_POSTFIX = "-cs-flow-config";public static final String SERVER_NAMESPACE_SET_DATA_ID_POSTFIX = "-cs-namespace-set";//超时时间public static final int READ_TIMEOUT = 3000;private NacosConfigUtil() {}/*** RuleEntity----->Rule* @param entities* @return*/public static String convertToRule(List<? extends RuleEntity> entities){return JSON.toJSONString(entities.stream().map(r -> r.toRule()).collect(Collectors.toList()));}/*** ApiDefinitionEntity----->ApiDefinition* @param entities* @return*/public static String convertToApiDefinition(List<? extends ApiDefinitionEntity> entities){return JSON.toJSONString(entities.stream().map(r -> r.toApiDefinition()).collect(Collectors.toList()));}/*** GatewayFlowRuleEntity----->GatewayFlowRule* @param entities* @return*/public static String convertToGatewayFlowRule(List<? extends GatewayFlowRuleEntity> entities){return JSON.toJSONString(entities.stream().map(r -> r.toGatewayFlowRule()).collect(Collectors.toList()));}}

(5)dashboard配置文件修改

1.添加bootstrap.yml配置文件

spring:cloud:nacos:discovery:server-addr: 127.0.0.1:8848username: nacospassword: nacosnamespace: c5b4bd27-4a9c-487f-b3fb-c6a768ee224c# group: DEFAULT_GROUPconfig:server-addr: 127.0.0.1:8848username: nacospassword: nacosnamespace: c5b4bd27-4a9c-487f-b3fb-c6a768ee224c# group: DEFAULT_GROUPfile-extension: yml  # 必须修改成对应尾序refresh-enabled: trueprofiles:active: devapplication:name: scm-sentinel-dashboard

2.nacos中添加scm-sentinel-dashboard-dev.yml配置文件,这里是将原来的application.properties配置放入到nacos配置中心中管理

server:port: 8099max-http-header-size: 10240tomcat:uri-encoding: UTF-8min-spare-threads: 50max-threads: 500max-connections: 3000accept-count: 10000connection-timeout: 12000servlet:encoding:force: truecharset: UTF-8enabled: truesession: cookie: name: sentinel_dashboard_cookie
logging: level: org: springframework: web: INFOfile:# name: ${user.home}/logs/csp/sentinel-dashboard.logname: /mnt/server-log/scm-sentinel-dashboard/sentinel-dashboard.logpattern: file: '%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n'
auth: filter: exclude-urls: /,/auth/login,/auth/logout,/registry/machine,/versionexclude-url-suffixes: htm,html,js,css,map,ico,ttf,woff,pngusername: sentinelpassword: sentinelsentinel: dashboard: version: '@project.version@'

2.改造client

1.gateway网关改造

(1)引入pom依赖

<!-- gateway接入sentinel  --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId><version>${spring.cloud.alibaba.version}</version></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-sentinel</artifactId><version>${spring.cloud.alibaba.version}</version></dependency><!--sentinel持久化 --><dependency><groupId>com.alibaba.csp</groupId><artifactId>sentinel-datasource-nacos</artifactId><version>1.8.4</version></dependency>

(2)配置文件bootstrap.yml

spring:cloud:nacos:discovery:server-addr: 127.0.0.1:8848username: nacospassword: nacosnamespace: c5b4bd27-4a9c-487f-b3fb-c6a768ee224c# group: DEFAULT_GROUPconfig:server-addr: 127.0.0.1:8848username: nacospassword: nacosnamespace: c5b4bd27-4a9c-487f-b3fb-c6a768ee224c# group: DEFAULT_GROUPfile-extension: yml  # 必须修改成对应尾序refresh-enabled: trueshared-configs[0]:data-id: scm-gateway-sentinel.ymlrefresh: trueprofiles:active: devapplication:name: scm-open-gateway

(2)nacos中的配置文件scm-gateway-sentinel.yml,这里面的spring.application.name对象项目名称,注意rule-type表示流控类型

spring:cloud:nacos:sentinel:transport:dashboard: 127.0.0.1:8099# 该配置能够使dashboard主动发现该应用eager: truedatasource:gateway-api:nacos:server-addr: ${spring.cloud.nacos.discovery.server-addr}dataId: ${spring.application.name}-gateway-api-rulesgroupId: SENTINEL_GROUP   # 注意groupId对应Sentinel Dashboard中的定义namespace: ${spring.cloud.nacos.discovery.namespace}data-type: jsonrule-type: gw-api-groupflow-rules:nacos:server-addr: ${spring.cloud.nacos.discovery.server-addr}dataId: ${spring.application.name}-gateway-flow-rulesgroupId: SENTINEL_GROUP   # 注意groupId对应Sentinel Dashboard中的定义namespace: ${spring.cloud.nacos.discovery.namespace}data-type: jsonrule-type: flowdegrade-rules:nacos:server-addr: ${spring.cloud.nacos.discovery.server-addr}dataId: ${spring.application.name}-gateway-degrade-rulesgroupId: SENTINEL_GROUPnamespace: ${spring.cloud.nacos.discovery.namespace}data-type: jsonrule-type: degradeparam-flow-rules:nacos:server-addr: ${spring.cloud.nacos.discovery.server-addr}dataId: ${spring.application.name}-gateway-param-flow-rulesgroupId: SENTINEL_GROUPnamespace: ${spring.cloud.nacos.discovery.namespace}data-type: jsonrule-type: param-flowauthority-rules:nacos:server-addr: ${spring.cloud.nacos.discovery.server-addr}dataId: ${spring.application.name}-gateway-authority-rulesgroupId: SENTINEL_GROUPnamespace: ${spring.cloud.nacos.discovery.namespace}data-type: jsonrule-type: authoritysystem-rules:nacos:server-addr: ${spring.cloud.nacos.discovery.server-addr}dataId: ${spring.application.name}-gateway-system-rulesgroupId: SENTINEL_GROUPnamespace: ${spring.cloud.nacos.discovery.namespace}data-type: jsonrule-type: system

(3) rule-type: gw-api-group对应的是网关中的API管理,这里用来与流控规则中API分钟的API名称对应

在这里插入图片描述
在这里插入图片描述

2.普通服务改造

(1)添加pom依赖

 <!-- nacos服务注册与发现 --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><!-- openfeign 远程调用 --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency><!--sentinel --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-sentinel</artifactId></dependency>

(1)添加bootstrap.yml流控规则nacoa配置和sentinel控制台连接配置

server:port: 8806spring:application:name: mall-user-sentinel-rule-push-demo  #微服务名称#配置nacos注册中心地址cloud:nacos:discovery:server-addr: 127.0.0.1:8848username: nacospassword: nacosnamespace: c5b4bd27-4a9c-487f-b3fb-c6a768ee224csentinel:transport:# 添加sentinel的控制台地址dashboard: 127.0.0.1:8099# 指定应用与Sentinel控制台交互的端口,应用本地会起一个该端口占用的HttpServer#port: 8719datasource:
#        ds1:   #名称自定义,唯一
#          nacos:
#            server-addr: 127.0.0.1:8848
#            dataId: ${spring.application.name}-flow
#            groupId: DEFAULT_GROUP
#            data-type: json
#            rule-type: flowflow-rules:nacos:server-addr: 127.0.0.1:8848dataId: ${spring.application.name}-flow-rulesgroupId: SENTINEL_GROUP   # 注意groupId对应Sentinel Dashboard中的定义namespace: c5b4bd27-4a9c-487f-b3fb-c6a768ee224cdata-type: jsonrule-type: flowdegrade-rules:nacos:server-addr: 127.0.0.1:8848dataId: ${spring.application.name}-degrade-rulesgroupId: SENTINEL_GROUPnamespace: c5b4bd27-4a9c-487f-b3fb-c6a768ee224cdata-type: jsonrule-type: degradeparam-flow-rules:nacos:server-addr: 127.0.0.1:8848dataId: ${spring.application.name}-param-flow-rulesgroupId: SENTINEL_GROUPnamespace: c5b4bd27-4a9c-487f-b3fb-c6a768ee224cdata-type: jsonrule-type: param-flowauthority-rules:nacos:server-addr: 127.0.0.1:8848dataId: ${spring.application.name}-authority-rulesgroupId: SENTINEL_GROUPnamespace: c5b4bd27-4a9c-487f-b3fb-c6a768ee224cdata-type: jsonrule-type: authoritysystem-rules:nacos:server-addr: 127.0.0.1:8848dataId: ${spring.application.name}-system-rulesgroupId: SENTINEL_GROUPnamespace: c5b4bd27-4a9c-487f-b3fb-c6a768ee224cdata-type: jsonrule-type: systemmain:allow-bean-definition-overriding: true#暴露actuator端点   http://localhost:8800/actuator/sentinel
management:endpoints:web:exposure:include: '*'feign:sentinel:enabled: true   #开启sentinel对feign的支持 默认false

3.持久化源码

(1)NacosDataSource:

1.NacosDataSource:自定义的nacos数据源类,继承了AbstractDataSource抽象类是sentinel的持久化数据源的父类,用于持久化扩展;
2.NacosDataSource.readSource()->configService.getConfig()方法读取nacos中的配置;
3.NacosDataSource 构造器-> this.configListener = new Listener() -> receiveConfigInfo()方法,当dashboard中改变配置后,dashboard服务会降配置先推送到nacos配置中心,然后nacos中的规则数据感知到变化后nacos配置中心会发布这个监听事件,此监听器就会监听到最新配置的变化然后更新本地缓存的配置达到实时更新的目的;(注意配置没用变化是不会触发监听事件)

(2)FlowRuleManager:流控规则管理类,负责加载流控规则;

(3)ConfigService是用来拿到nacos配置中心bean对象,使用configService.publishConfig()推送sentinel持久化数据到nacos中心;试用ConfigFactory.createConfigService(properties)创建ConfigService;

相关文章:

sentinel持久化方案

一.sentinel规则推送原理 1.原有内存规则存储原理 (1)dashborad中请求到服务器后&#xff0c;在controller中通过http把规则直接推送给client&#xff0c;client接收后把规则放入内存&#xff1b; 2.持久化推送规则原理 ![在这里插入代码片](https://img-blog.csdnimg.cn/1…...

软件项目进度安排与跟踪:关键路径的计算

在一个软件项目中&#xff0c;管理人员需要按时了解项目进度&#xff0c;制定项目计划&#xff0c;同时需要及时发现所遇到的问题&#xff0c;然后和团队成员制定解决方案&#xff0c;确保整个计划可以顺利的进行&#xff0c;因此项目进度安排与跟踪是项目管理中的一个重要环节…...

mac m2 处理器 iterm2 sz rz 出错/无限重试

mac m2 处理器 iterm2 sz rz 出错/无限重试 1、背景 apple m 系列处理器安装的 homebrew 跟 intel 处理器略有不同&#xff0c;其中安装目录的区别&#xff1a; m 系列处理器安装目录为 /usr/local/bin/homebrewintel 处理器安装目录为 /opt/homebrew 其中 m 系列处理器安装…...

Mysql 与 磁盘交互的过程

从之前的Mysql架构可以了解到&#xff0c;Mysql 客户端不是直接和磁盘打交道&#xff0c;我们在客户端输入的sql语句会被发送给服务端&#xff0c;服务端对sql语句进行解析、缓存等操作&#xff0c;然后再交由存储引擎去读写磁盘。这其实是从 C/S 的角度去了解Mysql。 站在OS的…...

Spring Cloud Gateway集成Nacos实现负载均衡

&#x1f4a1;Nacas可以用于实现Spring Cloud Gateway中网关动态路由功能&#xff0c;也可以基于Nacos来实现对后端服务的负载均衡&#xff0c;前者利用Nacos配置中心功能&#xff0c;后者利用Nacos服务注册功能。接下来我们来看下Gateway集成Nacos实现负载均衡的架构图一. 环境…...

Excel图表教程_编程入门自学教程_菜鸟教程-免费教程分享

教程简介 Excel图表初学者教程 - 从简单和简单的步骤学习Excel图表从基本概念到高级概念&#xff0c;包括简介&#xff0c;创建图表&#xff0c;类型&#xff0c;柱形图&#xff0c;折线图&#xff0c;饼图&#xff0c;圆环图&#xff0c;条形图&#xff0c;面积图&#xff0c…...

2023最新的接口自动化测试面试题

1、请结合你熟悉的项目&#xff0c;介绍一下你是怎么做测试的&#xff1f; -首先要自己熟悉项目&#xff0c;熟悉项目的需求、项目组织架构、项目研发接口等 -功能 接口 自动化 性能 是怎么处理的&#xff1f; -第一步&#xff1a; 进行需求分析&#xff0c;需求评审&#…...

AcWing语法基础课笔记 第一章 C++入门及简单的顺序结构

第一章 C入门及简单的顺序结构 编程是一种控制计算机的方式&#xff0c;和我们平时双击打开文件、关机、重启没有任何区别。 ———闫学灿 C中常用的变量类型 和所占字节大小 输出变量地址符&#xff1a; 软件环境 作业的评测与提交 在线练习地址&#xff1a;www.acwing.com …...

【并发编程】【2】进程与线程

并发编程 2.进程与线程 2.1 进程与线程 进程 程序由指令和数据组成&#xff0c;但这些指令要运行&#xff0c;数据要读写&#xff0c;就必须将指令加载至 CPU&#xff0c;数据加载至内存。在 指令运行过程中还需要用到磁盘、网络等设备。进程就是用来加载指令、管理内存、管…...

MySQL获取当前时间的各种方式

1 获取当前完整时间1.1 now()函数select now();输出:2023-02-15 10:46:171.2 sysdate()函数select sysdate();输出:2023-02-15 10:47:131.3 current_timestamp或current_timestamp()current_timestamp和current_timestamp()函数的效果是一样的&#xff0c;只不过一个是关键字&a…...

redis持久化之AOF(Append Only File)及其总结

1.是什么&#xff1f; 以日志的形式来记录每个写操作&#xff0c;将redis执行过的所有写指令记录下来(读操作不记录)&#xff0c;只许追加文件但不可以改写文件&#xff0c;redis启动之初会读取该文件重新构建数据&#xff0c;换言之&#xff0c;redis重启的话就根据日志文件的…...

LeetCode 刷题之队列

5. 队列 队列&#xff08;queue&#xff09;是只允许在一端进行插入操作&#xff0c;而在另一端进行删除操作的线性表。 队列是一种先进先出的&#xff08;First In First Out&#xff09;的线性表&#xff0c;简称 FIFO。允许插入的一端为队尾&#xff0c;允许删除的一端为队…...

互联网摸鱼日报(2023-02-15)

互联网摸鱼日报&#xff08;2023-02-15&#xff09; InfoQ 热门话题 ChatGPT火爆全球后&#xff0c;OpenAI CEO称“它很酷&#xff0c;但却是个糟糕的产品” 微软发言人证实旗下LinkedIn平台开始裁员 Akamai 推出 Akamai Connected Cloud 和全新云计算服务 AI赋能元宇宙游戏…...

聊聊外包和远程项目的敏捷管理(合辑共7篇)

这是鼎叔的第五十一篇原创文章。行业大牛和刚毕业的小白&#xff0c;都可以进来聊聊。欢迎关注本专栏和微信公众号《敏捷测试转型》&#xff0c;大量原创思考文章陆续推出。第四个合辑完工了&#xff0c;咱们介绍了外包管理或远程项目如何敏捷交付&#xff0c;满足管理层预期。…...

2023-2-15 刷题情况

检查「好数组」 题目描述 给你一个正整数数组 nums&#xff0c;你需要从中任选一些子集&#xff0c;然后将子集中每一个数乘以一个 任意整数&#xff0c;并求出他们的和。 假如该和结果为 1&#xff0c;那么原数组就是一个「好数组」&#xff0c;则返回 True&#xff1b;否则…...

汉诺塔递归算法精讲

文章目录前言一、汉诺塔是个啥&#xff1f;二、手动解法三、解法抽象四、递归解法五、总结前言 递归算法是计算机算法中的基础算法&#xff0c;也是非常重要的算法&#xff0c;从某种程度上讲&#xff0c;它有一点儿AI的影子。人脑是可以完成递归思路的&#xff0c;但是对不起…...

vue的$nextTick的原理

参考&#xff1a;https://cloud.tencent.com/developer/article/1633546 总结一下&#xff1a;就是$nextTick将回调函数放到微任务或者宏任务当中以延迟它地执行顺序&#xff1b;&#xff08;总结的也比较懒&#x1f476;&#xff09; 重要的是理解源码中它的三个参数的意思&a…...

前端学习第一阶段——第五章CSS(下)

5-9 浮动 08-浮动导读 09-传统网页布局三种方式 10-为什么需要浮动 11-什么是浮动 12-浮动特性-脱标 13-浮动特性-浮动元素一行显示 14-浮动特性-浮动元素具有行内块特性 15-浮动元素经常搭配标准流的父元素 16-浮动布局练习1 <!DOCTYPE html> <html lang"en&quo…...

基于django搭建简单的个人博客

文章目录第一步、在Ubuntu中安装虚拟环境并进入第二步、安装blog所需要的包&#xff0c;在requirements.txt中安装mysqlclient可能会报错&#xff0c;输入下列命令后在安装即可成功第三步、创建好数据库&#xff0c;把测试数据导入第四步、修改DjangoBlog包中 settings中数据库…...

JVM解释器与JIT编译器如何并存?

[1] JVM解释器 JVM设计的初衷仅仅只是为了满足Java程序实现跨平台特性&#xff0c;因此避免采用静态编译的方式直接生成本地机器指令&#xff0c;从而诞生了实现解释器在运行时采用逐行解释字节码的执行程序。 解释器真正意义上所承担的角色就是一个运行时“翻译者”&#xff0…...

vscode里如何用git

打开vs终端执行如下&#xff1a; 1 初始化 Git 仓库&#xff08;如果尚未初始化&#xff09; git init 2 添加文件到 Git 仓库 git add . 3 使用 git commit 命令来提交你的更改。确保在提交时加上一个有用的消息。 git commit -m "备注信息" 4 …...

脑机新手指南(八):OpenBCI_GUI:从环境搭建到数据可视化(下)

一、数据处理与分析实战 &#xff08;一&#xff09;实时滤波与参数调整 基础滤波操作 60Hz 工频滤波&#xff1a;勾选界面右侧 “60Hz” 复选框&#xff0c;可有效抑制电网干扰&#xff08;适用于北美地区&#xff0c;欧洲用户可调整为 50Hz&#xff09;。 平滑处理&…...

【网络安全产品大调研系列】2. 体验漏洞扫描

前言 2023 年漏洞扫描服务市场规模预计为 3.06&#xff08;十亿美元&#xff09;。漏洞扫描服务市场行业预计将从 2024 年的 3.48&#xff08;十亿美元&#xff09;增长到 2032 年的 9.54&#xff08;十亿美元&#xff09;。预测期内漏洞扫描服务市场 CAGR&#xff08;增长率&…...

pam_env.so模块配置解析

在PAM&#xff08;Pluggable Authentication Modules&#xff09;配置中&#xff0c; /etc/pam.d/su 文件相关配置含义如下&#xff1a; 配置解析 auth required pam_env.so1. 字段分解 字段值说明模块类型auth认证类模块&#xff0c;负责验证用户身份&am…...

深入理解JavaScript设计模式之单例模式

目录 什么是单例模式为什么需要单例模式常见应用场景包括 单例模式实现透明单例模式实现不透明单例模式用代理实现单例模式javaScript中的单例模式使用命名空间使用闭包封装私有变量 惰性单例通用的惰性单例 结语 什么是单例模式 单例模式&#xff08;Singleton Pattern&#…...

Nuxt.js 中的路由配置详解

Nuxt.js 通过其内置的路由系统简化了应用的路由配置&#xff0c;使得开发者可以轻松地管理页面导航和 URL 结构。路由配置主要涉及页面组件的组织、动态路由的设置以及路由元信息的配置。 自动路由生成 Nuxt.js 会根据 pages 目录下的文件结构自动生成路由配置。每个文件都会对…...

深入解析C++中的extern关键字:跨文件共享变量与函数的终极指南

&#x1f680; C extern 关键字深度解析&#xff1a;跨文件编程的终极指南 &#x1f4c5; 更新时间&#xff1a;2025年6月5日 &#x1f3f7;️ 标签&#xff1a;C | extern关键字 | 多文件编程 | 链接与声明 | 现代C 文章目录 前言&#x1f525;一、extern 是什么&#xff1f;&…...

Redis数据倾斜问题解决

Redis 数据倾斜问题解析与解决方案 什么是 Redis 数据倾斜 Redis 数据倾斜指的是在 Redis 集群中&#xff0c;部分节点存储的数据量或访问量远高于其他节点&#xff0c;导致这些节点负载过高&#xff0c;影响整体性能。 数据倾斜的主要表现 部分节点内存使用率远高于其他节…...

AI书签管理工具开发全记录(十九):嵌入资源处理

1.前言 &#x1f4dd; 在上一篇文章中&#xff0c;我们完成了书签的导入导出功能。本篇文章我们研究如何处理嵌入资源&#xff0c;方便后续将资源打包到一个可执行文件中。 2.embed介绍 &#x1f3af; Go 1.16 引入了革命性的 embed 包&#xff0c;彻底改变了静态资源管理的…...

均衡后的SNRSINR

本文主要摘自参考文献中的前两篇&#xff0c;相关文献中经常会出现MIMO检测后的SINR不过一直没有找到相关数学推到过程&#xff0c;其中文献[1]中给出了相关原理在此仅做记录。 1. 系统模型 复信道模型 n t n_t nt​ 根发送天线&#xff0c; n r n_r nr​ 根接收天线的 MIMO 系…...