Java微服务分布式分库分表ShardingSphere - ShardingSphere-JDBC

news/2024/5/9 8:40:55/文章来源:https://blog.csdn.net/s445320/article/details/136995262

🌹作者主页:青花锁 🌹简介:Java领域优质创作者🏆、Java微服务架构公号作者😄

🌹简历模板、学习资料、面试题库、技术互助

🌹文末获取联系方式 📝

在这里插入图片描述


往期热门专栏回顾

专栏描述
Java项目实战介绍Java组件安装、使用;手写框架等
Aws服务器实战Aws Linux服务器上操作nginx、git、JDK、Vue
Java微服务实战Java 微服务实战,Spring Cloud Netflix套件、Spring Cloud Alibaba套件、Seata、gateway、shadingjdbc等实战操作
Java基础篇Java基础闲聊,已出HashMap、String、StringBuffer等源码分析,JVM分析,持续更新中
Springboot篇从创建Springboot项目,到加载数据库、静态资源、输出RestFul接口、跨越问题解决到统一返回、全局异常处理、Swagger文档
Spring MVC篇从创建Spring MVC项目,到加载数据库、静态资源、输出RestFul接口、跨越问题解决到统一返回
华为云服务器实战华为云Linux服务器上操作nginx、git、JDK、Vue等,以及使用宝塔运维操作添加Html网页、部署Springboot项目/Vue项目等
Java爬虫通过Java+Selenium+GoogleWebDriver 模拟真人网页操作爬取花瓣网图片、bing搜索图片等
Vue实战讲解Vue3的安装、环境配置,基本语法、循环语句、生命周期、路由设置、组件、axios交互、Element-ui的使用等
Spring讲解Spring(Bean)概念、IOC、AOP、集成jdbcTemplate/redis/事务等

系列文章目录

第一章 Java线程池技术应用
第二章 CountDownLatch和Semaphone的应用
第三章 Spring Cloud 简介
第四章 Spring Cloud Netflix 之 Eureka
第五章 Spring Cloud Netflix 之 Ribbon
第六章 Spring Cloud 之 OpenFeign
第七章 Spring Cloud 之 GateWay
第八章 Spring Cloud Netflix 之 Hystrix
第九章 代码管理gitlab 使用
第十章 SpringCloud Alibaba 之 Nacos discovery
第十一章 SpringCloud Alibaba 之 Nacos Config
第十二章 Spring Cloud Alibaba 之 Sentinel
第十三章 JWT
第十四章 RabbitMQ应用
第十五章 RabbitMQ 延迟队列
第十六章 spring-cloud-stream
第十七章 Windows系统安装Redis、配置环境变量
第十八章 查看、修改Redis配置,介绍Redis类型
第十九章 Redis RDB AOF
第二十章 Spring boot 操作 Redis
第二十一章 Java多线程安全与锁
第二十二章 Java微服务分布式事务框架seata
第二十三章 Java微服务分布式事务框架seata的TCC模式
第二十四章 Java微服务分库分表ShardingSphere - ShardingSphere-JDBC


前言

Apache ShardingSphere 是一款分布式的数据库生态系统, 可以将任意数据库转换为分布式数据库,并通过数据分片、弹性伸缩、加密等能力对原有数据库进行增强。

Apache ShardingSphere 设计哲学为 Database Plus,旨在构建异构数据库上层的标准和生态。 它关注如何充分合理地利用数据库的计算和存储能力,而并非实现一个全新的数据库。 它站在数据库的上层视角,关注它们之间的协作多于数据库自身。

1、ShardingSphere-JDBC

ShardingSphere-JDBC 定位为轻量级 Java 框架,在 Java 的 JDBC 层提供的额外服务。

1.1、应用场景

Apache ShardingSphere-JDBC 可以通过Java 和 YAML 这 2 种方式进行配置,开发者可根据场景选择适合的配置方式。

  • 数据库读写分离
  • 数据库分表分库

1.2、原理

  • Sharding-JDBC中的路由结果是通过分片字段和分片方法来确定的,如果查询条件中有 id 字段的情况还好,查询将会落到某个具体的分片
  • 如果查询没有分片的字段,会向所有的db或者是表都会查询一遍,让后封装结果集给客户端。
    在这里插入图片描述

1.3、spring boot整合

1.3.1、添加依赖

<!-- 分表分库依赖 -->
<dependency><groupId>org.apache.shardingsphere</groupId><artifactId>sharding-jdbc-spring-boot-starter</artifactId><version>4.1.1</version>
</dependency>

1.3.2、添加配置

spring:main:# 一个实体类对应多张表,覆盖allow-bean-definition-overriding: trueshardingsphere:datasource:ds0:#配置数据源具体内容,包含连接池,驱动,地址,用户名和密码driver-class-name: com.mysql.cj.jdbc.Driverjdbc-url: jdbc:mysql://127.0.0.1:3306/account?autoReconnect=true&allowMultiQueries=truepassword: roottype: com.zaxxer.hikari.HikariDataSourceusername: rootds1:driver-class-name: com.mysql.cj.jdbc.Driverjdbc-url: jdbc:mysql://127.0.0.1:3306/account?autoReconnect=true&allowMultiQueries=truepassword: roottype: com.zaxxer.hikari.HikariDataSourceusername: root# 配置数据源,给数据源起名称names: ds0,ds1props:sql:show: truesharding:tables:user_info:#指定 user_info 表分布情况,配置表在哪个数据库里面,表名称都是什么actual-data-nodes: ds0.user_info_${0..9}database-strategy:standard:preciseAlgorithmClassName: com.xxxx.store.account.config.PreciseDBShardingAlgorithmrangeAlgorithmClassName: com.xxxx.store.account.config.RangeDBShardingAlgorithmsharding-column: idtable-strategy:standard:preciseAlgorithmClassName: com.xxxx.store.account.config.PreciseTablesShardingAlgorithmrangeAlgorithmClassName: com.xxxx.store.account.config.RangeTablesShardingAlgorithmsharding-column: id

1.3.3、制定分片算法

1.3.3.1、精确分库算法
/*** 精确分库算法*/
public class PreciseDBShardingAlgorithm implements PreciseShardingAlgorithm<Long> {/**** @param availableTargetNames 配置所有的列表* @param preciseShardingValue 分片值* @return*/@Overridepublic String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<Long> preciseShardingValue) {Long value = preciseShardingValue.getValue();//后缀 0,1String postfix = String.valueOf(value % 2);for (String availableTargetName : availableTargetNames) {if(availableTargetName.endsWith(postfix)){return availableTargetName;}}throw new UnsupportedOperationException();}}
1.3.3.2、范围分库算法
/*** 范围分库算法*/
public class RangeDBShardingAlgorithm implements RangeShardingAlgorithm<Long> {@Overridepublic Collection<String> doSharding(Collection<String> collection, RangeShardingValue<Long> rangeShardingValue) {return collection;}
}
1.3.3.3、精确分表算法
/*** 精确分表算法*/
public class PreciseTablesShardingAlgorithm implements PreciseShardingAlgorithm<Long> {/**** @param availableTargetNames 配置所有的列表* @param preciseShardingValue 分片值* @return*/@Overridepublic String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<Long> preciseShardingValue) {Long value = preciseShardingValue.getValue();//后缀String postfix = String.valueOf(value % 10);for (String availableTargetName : availableTargetNames) {if(availableTargetName.endsWith(postfix)){return availableTargetName;}}throw new UnsupportedOperationException();}}
1.3.3.4、范围分表算法
/*** 范围分表算法*/
public class RangeTablesShardingAlgorithm implements RangeShardingAlgorithm<Long> {@Overridepublic Collection<String> doSharding(Collection<String> collection, RangeShardingValue<Long> rangeShardingValue) {Collection<String> result = new ArrayList<>();Range<Long> valueRange = rangeShardingValue.getValueRange();Long start = valueRange.lowerEndpoint();Long end = valueRange.upperEndpoint();Long min = start % 10;Long max = end % 10;for (Long i = min; i < max +1; i++) {Long finalI = i;collection.forEach(e -> {if(e.endsWith(String.valueOf(finalI))){result.add(e);}});}return result;}}

1.3.4、数据库建表

DROP TABLE IF EXISTS `user_info_0`;
CREATE TABLE `user_info_0` (`id` bigint(20) NOT NULL,`account` varchar(255) DEFAULT NULL,`user_name` varchar(255) DEFAULT NULL,`pwd` varchar(255) DEFAULT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

1.3.5、业务应用

1.3.5.1、定义实体类
@Data
@TableName(value = "user_info")
public class UserInfo {/*** 主键*/private Long id;/*** 账号*/private String account;/*** 用户名*/private String userName;/*** 密码*/private String pwd;}
1.3.5.2、定义接口
public interface UserInfoService{/*** 保存* @param userInfo* @return*/public UserInfo saveUserInfo(UserInfo userInfo);public UserInfo getUserInfoById(Long id);public List<UserInfo> listUserInfo();
}
1.3.5.3、实现类
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {@Override@Transactionalpublic UserInfo saveUserInfo(UserInfo userInfo) {userInfo.setId(IdUtils.getId());this.save(userInfo);return userInfo;}@Overridepublic UserInfo getUserInfoById(Long id) {return this.getById(id);}@Overridepublic List<UserInfo> listUserInfo() {QueryWrapper<UserInfo> userInfoQueryWrapper = new QueryWrapper<>();userInfoQueryWrapper.between("id",1623695688380448768L,1623695688380448769L);return this.list(userInfoQueryWrapper);}
}

1.3.6、生成ID - 雪花算法

package com.xxxx.tore.common.utils;import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;/*** 生成各种组件ID*/
public class IdUtils {/*** 雪花算法* @return*/public static long getId(){Snowflake snowflake = IdUtil.getSnowflake(0, 0);long id = snowflake.nextId();return id;}
}

1.4、seata与sharding-jdbc整合

https://github.com/seata/seata-samples/tree/master/springcloud-seata-sharding-jdbc-mybatis-plus-samples

1.4.1、common中添加依赖

<!--seata依赖-->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-seata</artifactId><version>2021.0.4.0</version>
</dependency>
<!-- sharding-jdbc整合seata分布式事务-->
<dependency><groupId>org.apache.shardingsphere</groupId><artifactId>sharding-transaction-base-seata-at</artifactId><version>4.1.1</version>
</dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>2021.0.4.0</version><exclusions><exclusion><groupId>com.alibaba.nacos</groupId><artifactId>nacos-client</artifactId></exclusion></exclusions>
</dependency>
<dependency><groupId>com.alibaba.nacos</groupId><artifactId>nacos-client</artifactId><version>1.4.2</version>
</dependency>

1.4.2、改造account-service服务

@Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> implements AccountService {@Autowiredprivate OrderService orderService;@Autowiredprivate StorageService storageService;/*** 存放商品编码及其对应的价钱*/private static Map<String,Integer> map = new HashMap<>();static {map.put("c001",3);map.put("c002",5);map.put("c003",10);map.put("c004",6);}@Override@Transactional@ShardingTransactionType(TransactionType.BASE)public void debit(OrderDTO orderDTO) {//扣减账户余额int calculate = this.calculate(orderDTO.getCommodityCode(), orderDTO.getCount());AccountDTO accountDTO = new AccountDTO(orderDTO.getUserId(), calculate);QueryWrapper<Account> objectQueryWrapper = new QueryWrapper<>();objectQueryWrapper.eq("id",1);objectQueryWrapper.eq(accountDTO.getUserId() != null,"user_id",accountDTO.getUserId());Account account = this.getOne(objectQueryWrapper);account.setMoney(account.getMoney() - accountDTO.getMoney());this.saveOrUpdate(account);//扣减库存this.storageService.deduct(new StorageDTO(null,orderDTO.getCommodityCode(),orderDTO.getCount()));//生成订单this.orderService.create(orderDTO);      }/*** 计算购买商品的总价钱* @param commodityCode* @param orderCount* @return*/private int calculate(String commodityCode, int orderCount){//商品价钱Integer price = map.get(commodityCode) == null ? 0 : map.get(commodityCode);return price * orderCount;}
}

注意:调单生成调用的逻辑修改,减余额->减库存->生成订单。调用入口方法注解加上:@ShardingTransactionType(TransactionType.BASE)

1.4.3、修改business-service服务

@Service
public class BusinessServiceImpl implements BusinessService {@Autowiredprivate OrderService orderService;@Autowiredprivate StorageService storageService;@Autowiredprivate AccountService accountService;@Overridepublic void purchase(OrderDTO orderDTO) {//扣减账号中的钱accountService.debit(orderDTO);        }
}

1.4.4、修改order-service服务

@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper,Order> implements OrderService {/*** 存放商品编码及其对应的价钱*/private static Map<String,Integer> map = new HashMap<>();static {map.put("c001",3);map.put("c002",5);map.put("c003",10);map.put("c004",6);}@Override@Transactional@ShardingTransactionType(TransactionType.BASE)public Order create(String userId, String commodityCode, int orderCount) {int orderMoney = calculate(commodityCode, orderCount);Order order = new Order();order.setUserId(userId);order.setCommodityCode(commodityCode);order.setCount(orderCount);order.setMoney(orderMoney);//保存订单this.save(order);try {TimeUnit.SECONDS.sleep(30);} catch (InterruptedException e) {e.printStackTrace();}if(true){throw new RuntimeException("回滚测试");}return order;}/*** 计算购买商品的总价钱* @param commodityCode* @param orderCount* @return*/private int calculate(String commodityCode, int orderCount){//商品价钱Integer price = map.get(commodityCode) == null ? 0 : map.get(commodityCode);return price * orderCount;}
}

1.4.5、配置文件参考

server:port: 8090spring:main:# 一个实体类对应多张表,覆盖allow-bean-definition-overriding: trueshardingsphere:datasource:ds0:#配置数据源具体内容,包含连接池,驱动,地址,用户名和密码driver-class-name: com.mysql.cj.jdbc.Driverjdbc-url: jdbc:mysql://127.0.0.1:3306/account?autoReconnect=true&allowMultiQueries=truepassword: roottype: com.zaxxer.hikari.HikariDataSourceusername: rootds1:driver-class-name: com.mysql.cj.jdbc.Driverjdbc-url: jdbc:mysql://127.0.0.1:3306/account?autoReconnect=true&allowMultiQueries=truepassword: roottype: com.zaxxer.hikari.HikariDataSourceusername: root# 配置数据源,给数据源起名称names: ds0,ds1props:sql:show: truesharding:tables:account_tbl:actual-data-nodes: ds0.account_tbl_${0..1}database-strategy:standard:preciseAlgorithmClassName: com.xxxx.store.account.config.PreciseDBExtShardingAlgorithm#rangeAlgorithmClassName: com.xxxx.store.account.config.RangeDBShardingAlgorithmsharding-column: idtable-strategy:standard:preciseAlgorithmClassName: com.xxxx.store.account.config.PreciseTablesExtShardingAlgorithm#rangeAlgorithmClassName: com.xxxx.store.account.config.RangeTablesShardingAlgorithmsharding-column: iduser_info:#指定 user_info 表分布情况,配置表在哪个数据库里面,表名称都是什么actual-data-nodes: ds0.user_info_${0..9}database-strategy:standard:preciseAlgorithmClassName: com.xxxx.store.account.config.PreciseDBShardingAlgorithmrangeAlgorithmClassName: com.xxxx.store.account.config.RangeDBShardingAlgorithmsharding-column: idtable-strategy:standard:preciseAlgorithmClassName: com.xxxx.store.account.config.PreciseTablesShardingAlgorithmrangeAlgorithmClassName: com.xxxx.store.account.config.RangeTablesShardingAlgorithmsharding-column: id#以上是sharding-jdbc配置cloud:nacos:discovery:server-addr: localhost:8848namespace: 1ff3782d-b62d-402f-8bc4-ebcf40254d0aapplication:name: account-service  #微服务名称
#  datasource:
#    username: root
#    password: root
#    url: jdbc:mysql://127.0.0.1:3306/account
#    driver-class-name: com.mysql.cj.jdbc.Driverseata:enabled: trueenable-auto-data-source-proxy: falseapplication-id: account-servicetx-service-group: default_tx_groupservice:vgroup-mapping:default_tx_group: defaultdisable-global-transaction: falseregistry:type: nacosnacos:application: seata-serverserver-addr: 127.0.0.1:8848namespace: 1ff3782d-b62d-402f-8bc4-ebcf40254d0agroup: SEATA_GROUPusername: nacospassword: nacosconfig:nacos:server-addr: 127.0.0.1:8848namespace: 1ff3782d-b62d-402f-8bc4-ebcf40254d0agroup: SEATA_GROUPusername: nacospassword: nacos

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_1026295.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

JetBrains全家桶激活,分享 WebStorm 2024 激活的方案

大家好&#xff0c;欢迎来到金榜探云手&#xff01; WebStorm公司简介 JetBrains 是一家专注于开发工具的软件公司&#xff0c;总部位于捷克。他们以提供强大的集成开发环境&#xff08;IDE&#xff09;而闻名&#xff0c;如 IntelliJ IDEA、PyCharm、和 WebStorm等。这些工具…

固态硬盘数据恢复难度为何大 固态硬盘数据丢失如何恢复 数据恢复软件

随着时代不断的发展&#xff0c;我们办公工作的内容不断增大&#xff0c;固态硬盘已经成为很多人不可缺少的电脑存储设备。固态硬盘与机械硬盘相比较而言&#xff0c;固态硬盘具备读写速度更快、能耗更低、耐用性更好的优点。虽然固态硬盘优点较多&#xff0c;但是固态硬盘也会…

关于使用TCP-S7协议读写西门子PLC字符串的问题

我们可以使用TCP-S7协议读写西门子PLC&#xff0c; 比如PLC中定义一个String[50] 的地址DB300.20 地址DB300.20 DB块编号为300&#xff0c;偏移量【地址】是30 S7协议是西门子PLC自定义的协议&#xff0c;默认端口102&#xff0c;本质仍然是TCP协议的一种具体实现&#xff…

01-DBA自学课-安装部署MySQL

一、安装包下载 1&#xff0c;登录官网 MySQL :: MySQL Downloads 2&#xff0c;点击社区版下载 3&#xff0c;找到社区服务版 4&#xff0c;点击“档案”Archives 就是找到历史版本&#xff1b; 5&#xff0c;选择版本进行下载 本次学习&#xff0c;我们使用MySQL-8.0.26版本…

将Git LFS大文件转换为普通文件

Git LFS&#xff08;Large File Storage&#xff09;常用于大文件的管理&#xff0c;比如大型的预训练模型、数据集等内容&#xff0c;由于GitHub对上传文件大小的限制&#xff0c;太大的文件一般使用LFS格式上传 将GitHub、Hugging Face等网站上的LFS格式的大文件转换为普通文…

深度学习语义分割篇——DeepLabV1原理详解篇

&#x1f34a;作者简介&#xff1a;秃头小苏&#xff0c;致力于用最通俗的语言描述问题 &#x1f34a;专栏推荐&#xff1a;深度学习网络原理与实战 &#x1f34a;近期目标&#xff1a;写好专栏的每一篇文章 &#x1f34a;支持小苏&#xff1a;点赞&#x1f44d;&#x1f3fc;、…

ssm小区车库停车系统开发mysql数据库web结构java编程计算机网页源码eclipse项目

一、源码特点 ssm小区车库停车系统是一套完善的信息系统&#xff0c;结合springMVC框架完成本系统&#xff0c;对理解JSP java编程开发语言有帮助系统采用SSM框架&#xff08;MVC模式开发&#xff09;&#xff0c;系统具有完整的源代码和数据库&#xff0c;系统主要采用B/S模…

Excel 导入指定分隔符的 csv 文件

原文&#xff1a;https://blog.iyatt.com/?p14373 基于 Excel 2024 预览版测试 csv 文件本身是纯文本的&#xff0c;同行数据之间通过一定的分隔符打断识别为不同的列&#xff0c;常用的分隔符是英文逗号&#xff0c;使用逗号分隔符的 csv 文件直接用 Excel 打开能正常识别单…

python之(19)CPU性能分析常见工具

Python之(19)CPU性能分析常见工具 Author: Once Day Date: 2024年3月24日 一位热衷于Linux学习和开发的菜鸟&#xff0c;试图谱写一场冒险之旅&#xff0c;也许终点只是一场白日梦… 漫漫长路&#xff0c;有人对你微笑过嘛… 全系列文章可参考专栏:Python开发_Once-Day的博客…

迁移android studio 模拟器位置

android studio 初始位置是安装在c盘&#xff0c;若是要迁移需 1创建一个目标位置如我的F:/avd 2在系统环境变量里面设置新的地址 变量名&#xff1a;ANDROID_SDK_HOME 变量值&#xff1a;F:/avd 3最重要的是文件复制&#xff0c;将C盘里面avd的上层目录.android的目录整体…

机器学习——聚类算法-层次聚类算法

机器学习——聚类算法-层次聚类算法 在机器学习中&#xff0c;聚类是一种将数据集划分为具有相似特征的组或簇的无监督学习方法。聚类算法有许多种&#xff0c;其中一种常用的算法是层次聚类算法。本文将介绍聚类问题、层次聚类算法的原理、算法流程以及用Python实现层次聚类算…

SpringCloudAlibaba之Nacos Config

1、服务配置中心介绍 首先我们来看一下,微服务架构下关于配置文件的一些问题&#xff1a; 配置文件相对分散。在一个微服务架构下&#xff0c;配置文件会随着微服务的增多变的越来越多&#xff0c;而且分散在各个微服务中&#xff0c;不好统一配置和管理。配置文件无法区分环境…

ETL数据倾斜与资源优化

1.数据倾斜实例 数据倾斜在MapReduce编程模型中比较常见&#xff0c;由于key值分布不均&#xff0c;大量的相同key被存储分配到一个分区里&#xff0c;出现只有少量的机器在计算&#xff0c;其他机器等待的情况。主要分为JOIN数据倾斜和GROUP BY数据倾斜。 1.1GROUP BY数据倾…

蓝桥杯嵌入式学习笔记(6):IIC程序设计

目录 前言 1. IIC基本原理 2. 电路原理 3. 代码编程 3.1 预备工作 3.2 AT24C02写读功能编写 3.2.1 AT24C02写操作实现 3.2.2 AT24C02读操作实现 3.3 MCP4017写读功能编写 3.3.1 MCP4017写操作实现 3.3.2 MCP4017读操作实现 3.4 main.c编写 3.4.1 头文件引用 3.4.…

FASTAPI系列 16-其他响应类型

FASTAPI系列 16-其他响应类型 文章目录 FASTAPI系列 16-其他响应类型前言一、HTMLResponse 响应 HTML二、纯文本响应三、另外的JSON 响应四、FileResponse文件五、StreamingResponse六、RedirectResponse 重定向请求总结更多内容&#xff0c;请关注公众号, 发送666 更可以得到免…

面试算法-92-不同的二叉搜索树 II

题目 给你一个整数 n &#xff0c;请你生成并返回所有由 n 个节点组成且节点值从 1 到 n 互不相同的不同 二叉搜索树 。可以按 任意顺序 返回答案。 示例 1&#xff1a; 输入&#xff1a;n 3 输出&#xff1a;[[1,null,2,null,3],[1,null,3,2],[2,1,3],[3,1,null,null,2],…

移动硬盘盒结合PD技术为电脑供电:一种便携高效的供电新方案

在数字化时代&#xff0c;电脑已经成为我们生活和工作中不可或缺的工具。而在电脑的使用过程中&#xff0c;供电问题一直是我们需要关注的重要方面。近年来&#xff0c;随着技术的不断进步&#xff0c;移动硬盘盒子与PD&#xff08;Power Delivery&#xff09;技术的结合&#…

pnpm :无法加载文件 D:\nodejs\node_global\pnpm.ps1,因为在此系统上禁止运行脚本

一、问题描述 pnpm : 无法加载文件 D:\zyt\work\soft\node\node_global\pnpm.ps1&#xff0c;因为在此系统上禁止运行脚本。有关详细信息&#xff0c;请参阅 https:/go.microsoft.com/fwlink/?LinkID135170 中的 about_Execution_Policies。 所在位置 行:1 字符: 1pnpm --ver…

UOS、Linux下的redis的详细部署流程(适用于内网)

提示&#xff1a;适用于Linux以及UOS等内外网系统服务器部署。 文章目录 一.上传离线包二.部署基本环境三.解压并安装redis四.后台运行redis五.uos系统可能遇到的问题六.总结 一.上传离线包 1.自己去Redis官网下载适配自己部署系统的redis安装包。 2.通过文件传输工具&#xf…

『Apisix进阶篇』动态负载均衡:APISIX的实战演练与策略应用

&#x1f680;『Apisix系列文章』探索新一代微服务体系下的API管理新范式与最佳实践 【点击此跳转】 &#x1f4e3;读完这篇文章里你能收获到 &#x1f3af; 掌握APISIX中多种负载均衡策略的原理及其适用场景。&#x1f4c8; 学习如何通过APISIX的Admin API和Dashboard进行负…