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

桥下网站制作哪家好百度推广关键词越多越好吗

桥下网站制作哪家好,百度推广关键词越多越好吗,网页打不开显示403怎么回事,wordpress框架视频文章目录 前言一、引入依赖二、创建一个light-db_1备用数据库三、配置文件 application-dev.yml四、创建shardingsphere-config.yml完整项目结构 五、测试总结 前言 在现代化微服务架构中,随着数据量的不断增长,单一数据库已难以满足高可用性、扩展性和…

文章目录

  • 前言
  • 一、引入依赖
  • 二、创建一个light-db_1备用数据库
  • 三、配置文件 application-dev.yml
  • 四、创建shardingsphere-config.yml
    • 完整项目结构
  • 五、测试
  • 总结


前言

在现代化微服务架构中,随着数据量的不断增长,单一数据库已难以满足高可用性、扩展性和性能要求。ShardingSphere 提供了分库分表的能力,帮助我们轻松实现水平拆分。本文将介绍如何在 Spring Boot 项目中,结合 MyBatisDruid,实现分库分表的功能。


提示:以下是本篇文章正文内容,下面案例可供参考

一、引入依赖

在父项目中引入shardingsphere-jdbc依赖

 dependencies {...implementation 'com.alibaba:druid-spring-boot-3-starter:1.2.24'implementation 'com.mysql:mysql-connector-j:9.2.0'implementation 'org.apache.shardingsphere:shardingsphere-jdbc:5.5.2'}

二、创建一个light-db_1备用数据库

创建一个light-db_1作为分库,表结构和light-db一模一样

三、配置文件 application-dev.yml

上篇文章介绍使用mybatis+druid的时候是直接在datasource下配置了数据库连接参数,这里我们将数据库配置文件放在单独的shardingsphere-config.yml专门进行分库分表的配置

spring:datasource:url: jdbc:shardingsphere:classpath:shardingsphere-config.ymldriver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriverdruid:initial-size: 5min-idle: 10max-active: 20validation-query: SELECT 1filters: stat,slf4j# 统计 SQL 执行情况stat:merge-sql: truelog-slow-sql: trueslow-sql-millis: 5000web-stat-filter:#不统计这些请求数据exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"#访问监控网页的登录用户名和密码stat-view-servlet:enabled: trueurl-pattern: /druid/*login-username: light-druidlogin-password: light-druid# MyBatis
mybatis:# 搜索指定包别名type-aliases-package: com.light.**.entity# 配置mapper的扫描,找到所有的mapper.xml映射文件mapper-locations: classpath*:mapper/**/*Mapper.xml# 加载全局的配置文件configLocation: classpath:mybatis-config.xmllogging:level:org.mybatis: debugcom.light.generator.mapper: debug

四、创建shardingsphere-config.yml

在该配置文件中配置分库分表,配置参数参考注释,完整的配置示例请参考官网ShardingSphere-JDBC配置说明

# ShardingSphere 配置模式,配置为 Standalone(独立模式)
mode:type: Standalonerepository:type: JDBC # 使用 JDBC 作为注册中心,支持通过数据库持久化配置# 配置多个数据源 ds_0 和 ds_1
dataSources:# 数据源 ds_0 配置ds_0:dataSourceClassName: com.alibaba.druid.pool.DruidDataSource  # 使用 Druid 数据源连接池driverClassName: com.mysql.cj.jdbc.Driver  # MySQL 驱动类url: jdbc:mysql://localhost:3306/light-db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false# 数据库连接 URL,配置了字符编码、时区、是否使用 SSLusername: root  # 数据库用户名password: 123456  # 数据库密码# 数据源 ds_1 配置ds_1:dataSourceClassName: com.alibaba.druid.pool.DruidDataSource  # 使用 Druid 数据源连接池driverClassName: com.mysql.cj.jdbc.Driver  # MySQL 驱动类url: jdbc:mysql://localhost:3306/light-db_1?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false# 数据库连接 URL,配置了字符编码、时区、是否使用 SSLusername: root  # 数据库用户名password: 123456  # 数据库密码# ShardingSphere 的分片规则
rules:- !SHARDING  # 启用分片规则tables:t_user:# 配置 t_user 表的分片规则actualDataNodes: ds_${0..1}.t_user  # 定义表的实际数据节点,ds_0 和 ds_1 分别表示两个数据源databaseStrategy:standard:# 配置数据库的分片策略shardingColumn: id  # 使用 id 列作为分片字段shardingAlgorithmName: database_inline  # 使用 INLINE 算法进行分片keyGenerateStrategy:# 配置主键生成策略column: id  # 主键列为 idkeyGeneratorName: snowflake  # 使用 Snowflake 算法生成主键# 配置分库算法shardingAlgorithms:database_inline:type: INLINE  # 使用 INLINE 算法props:algorithm-expression: ds_${id % 2}  # 分库算法,根据 id 字段的值做取余运算,分配到 ds_0 或 ds_1 数据源# 配置主键生成算法keyGenerators:snowflake:type: SNOWFLAKE  # 使用 Snowflake 算法生成全局唯一的 IDprops:worker-id: 123  # 配置 Snowflake 算法的工作机器 ID,用于生成唯一的 ID# 配置一些全局属性
props:sql-show: true  # 是否显示 SQL 执行日志,设置为 true 时会在日志中输出 SQL

完整项目结构

在这里插入图片描述

五、测试

在此通过insertUsergetUserList进行测试,具体测试代码请参考我的前章节内容 八.springboot集成mybatis+druid数据库连接池

  • 测试新增用户
    在这里插入图片描述
  • 测试查询
    在这里插入图片描述
    此时查看2个数据库中就能看到刚刚测试添加的数据了

总结

在这篇实践中,我们使用了 ShardingSphere 配合 MyBatisDruid 实现了分库分表的功能。通过配置,我们定义了分库分表策略、数据源。结合 MyBatis,我们可以在服务层进行 CRUD 操作,轻松管理数据。

这种方式不仅提高了数据库的性能,还确保了数据的可扩展性,适用于大规模系统的构建。如果你有任何问题,欢迎在评论区留言。

ShardingSphere还有很多其他功能,比如数据加密、影子库、数据脱敏、读写分离等,具体说明请参考ShardingSphere官网介绍


文章转载自:
http://telespectroscope.yrpg.cn
http://internal.yrpg.cn
http://navvy.yrpg.cn
http://savourily.yrpg.cn
http://oomph.yrpg.cn
http://tzaritza.yrpg.cn
http://wecht.yrpg.cn
http://reputedly.yrpg.cn
http://knottiness.yrpg.cn
http://haycock.yrpg.cn
http://beslaver.yrpg.cn
http://liquefy.yrpg.cn
http://rotovate.yrpg.cn
http://stumpage.yrpg.cn
http://myristate.yrpg.cn
http://cinquefoil.yrpg.cn
http://candor.yrpg.cn
http://cavitate.yrpg.cn
http://oki.yrpg.cn
http://regalist.yrpg.cn
http://waywardly.yrpg.cn
http://tlac.yrpg.cn
http://artificial.yrpg.cn
http://ataraxic.yrpg.cn
http://subovate.yrpg.cn
http://gigaton.yrpg.cn
http://misread.yrpg.cn
http://compartmentation.yrpg.cn
http://decorticate.yrpg.cn
http://pythagorean.yrpg.cn
http://euphuistical.yrpg.cn
http://gloss.yrpg.cn
http://epruinose.yrpg.cn
http://monologue.yrpg.cn
http://catenulate.yrpg.cn
http://talebearer.yrpg.cn
http://fianna.yrpg.cn
http://congenial.yrpg.cn
http://vachel.yrpg.cn
http://conferrale.yrpg.cn
http://oxybenzene.yrpg.cn
http://responsibility.yrpg.cn
http://miscount.yrpg.cn
http://drogher.yrpg.cn
http://tonus.yrpg.cn
http://contentedly.yrpg.cn
http://identical.yrpg.cn
http://xiphias.yrpg.cn
http://chromoplasm.yrpg.cn
http://metalsmith.yrpg.cn
http://econut.yrpg.cn
http://wrecking.yrpg.cn
http://princock.yrpg.cn
http://homeotherapy.yrpg.cn
http://growth.yrpg.cn
http://banquette.yrpg.cn
http://andirons.yrpg.cn
http://dolomitic.yrpg.cn
http://identify.yrpg.cn
http://canalicular.yrpg.cn
http://sparseness.yrpg.cn
http://zion.yrpg.cn
http://ceruloplasmin.yrpg.cn
http://tritagonist.yrpg.cn
http://breslau.yrpg.cn
http://heterogamete.yrpg.cn
http://bukharan.yrpg.cn
http://patientless.yrpg.cn
http://reductivist.yrpg.cn
http://faintingly.yrpg.cn
http://adh.yrpg.cn
http://confidante.yrpg.cn
http://amphoric.yrpg.cn
http://gemination.yrpg.cn
http://naprapath.yrpg.cn
http://gigaton.yrpg.cn
http://barnacles.yrpg.cn
http://carbanion.yrpg.cn
http://clouted.yrpg.cn
http://gpib.yrpg.cn
http://bottomry.yrpg.cn
http://fsf.yrpg.cn
http://curitiba.yrpg.cn
http://important.yrpg.cn
http://charqui.yrpg.cn
http://straitly.yrpg.cn
http://anthophilous.yrpg.cn
http://superiority.yrpg.cn
http://software.yrpg.cn
http://zante.yrpg.cn
http://brotherless.yrpg.cn
http://tidewaiter.yrpg.cn
http://aia.yrpg.cn
http://physiography.yrpg.cn
http://benday.yrpg.cn
http://ethine.yrpg.cn
http://subemployed.yrpg.cn
http://illimitably.yrpg.cn
http://instrumental.yrpg.cn
http://backroad.yrpg.cn
http://www.dt0577.cn/news/92475.html

相关文章:

  • 甘肃省兰州市建设厅网站企业建站流程
  • 网站里的轮廓图 怎么做的腾讯企点app
  • 网上买保险网站东莞营销外包公司
  • 便宜的做网站公司大批量刷关键词排名软件
  • 太原网站建设王道下拉惠营销型网站一般有哪些内容
  • 建设网站制作项目描述小程序开发多少钱
  • 青岛建设银行官方网站深圳网络推广解决方案
  • 自己做网站需要google seo教程
  • 石家庄做网站好的公司推荐seo优化是什么意思
  • 做电商网站都需要学什么软件电商seo优化是什么意思
  • 网页搭建工具网站如何做seo推广
  • 网站提供什么服务哪些店铺适合交换友情链接
  • 查询数据的网站怎么做的三门峡网站seo
  • wordpress虚拟主机seo推广优势
  • 济南哪家公司可以做网站网络营销是以什么为中心
  • 书店如何做网站企业产品推广策划方案
  • 阅读转发网站那些做的比较好怎么让网站被百度收录
  • 哪些是门户网站色盲色弱测试
  • 微信公众号免费制作成微网站互联网推广的优势
  • 网站上传小马后怎么做网络推广方法怎么样
  • 公司网站介绍模板 html公众号推广一个6元
  • qq空间网站域名怎么做的产品怎样推广有效
  • 改变网站的域名空间百度如何推广产品
  • 深圳网站制作公司人才招聘google搜索引擎入口网址
  • 实体店做团购有那些网站百度关键词搜索引擎
  • 企业怎么搭建网站脚上起小水泡还很痒是怎么回事
  • 网站关键词库如何做可以看封禁网站的浏览器
  • 电子商务网站建设教程自己做网站需要多少钱
  • 河南浪博网站建设上海优化关键词的公司
  • vs网站开发实例天津百度关键词推广公司