古道长亭

Contact me with ixiaoqiang0011@gmail.com


  • 首页

  • 归档

  • 分类

  • 关于

  • Book

  • 搜索

分布式事务实战

时间: 2023-01-05   |   分类: mysql高级   sharding-sphere   | 字数: 1565 字 | 阅读约: 4分钟

分布式事务实战

实战代码示例: https://gitee.com/ixinglan/mysql-demo.git

sharding-jdbc-demo: 详见README.md 介绍

ShardingSphere整合了XA、Saga和Seata模式后,为分布式事务控制提供了极大的便利,我们可以在应用程序编程时,采用以下统一模式进行使用。

阅读全文 »

分布式事务剖析

时间: 2023-01-04   |   分类: mysql高级   sharding-sphere   | 字数: 5531 字 | 阅读约: 12分钟

分布式事务剖析

1. 分布式事务理论

CAP, BASE理论, 可参考 [分布式架构理论] 分类查看详情

2. 分布式事务模式

在 [分布式架构理论], **[分布式事务]**分类也有相关介绍

阅读全文 »

数据脱敏实战

时间: 2023-01-03   |   分类: mysql高级   sharding-sphere   | 字数: 296 字 | 阅读约: 1分钟

数据脱敏实战

实战代码示例: https://gitee.com/ixinglan/mysql-demo.git

sharding-jdbc-demo: 详见README.md 介绍

我们以c_user表示例,只需1个库即可

CREATE TABLE `c_user` (
  `Id` bigint(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(256) DEFAULT NULL,
  `pwd_plain` varchar(256) DEFAULT NULL,
  `pwd_cipher` varchar(256) DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  1. entity创建: CUser, 注意: pwd为逻辑列,对应数据库中明文和密文列
  2. repository创建: CUserRepository
  3. 创建application-encrypt配置文件, 将主配置文件active改为encrypt
# datasource
spring:
  shardingsphere:
    datasource:
      names: ds0
      ds0:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class: com.mysql.jdbc.Driver
        jdbc-url: jdbc:mysql://localhost:3306/sharding-demo1
        username: root
        password: 123456
    # 指定是否用密文列作查询
    props:
      query:
        with:
          cipher:
            column: true
    #encrypt
    encrypt:
      tables:
        c_user:
          columns:
            pwd:
              plainColumn: pwd_plain # 逻辑列pwd对应的明文列
              cipherColumn: pwd_cipher #逻辑列pwd对应的密文列
              encryptor: demo_pwd #下面定义的自定义名称
          # 主键生成器
          keyGenerator:
            column: id
            type: SNOWFLAKE
      #指定算法
      encryptors:
        demo_pwd: #自定义名称
          type: aes
          props:
            aes:
              key:
                value: 1234 #密钥
  1. 测试方法 TestEncryptor: testAdd, testFind

数据脱敏剖析

时间: 2023-01-02   |   分类: mysql高级   sharding-sphere   | 字数: 1716 字 | 阅读约: 4分钟

数据脱敏剖析

数据脱敏是指对某些敏感信息通过脱敏规则进行数据的变形,实现敏感隐私数据的可靠保护。涉及客户安全数据或者一些商业性敏感数据,如身份证号、手机号、卡号、客户号等个人信息按照规定,都需要进行数据脱敏。

阅读全文 »

强制路由实战

时间: 2023-01-01   |   分类: mysql高级   sharding-sphere   | 字数: 140 字 | 阅读约: 1分钟

强制路由实战

实战代码示例: https://gitee.com/ixinglan/mysql-demo.git

sharding-jdbc-demo: 详见README.md 介绍

我们以city表示例

  • 新建 application-hint-database.yml, 并将主配置文件active改为hint-database
# datasource
spring:
  shardingsphere:
    datasource:
      names: ds0,ds1
      ds0:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class: com.mysql.jdbc.Driver
        jdbc-url: jdbc:mysql://localhost:3306/sharding-demo1
        username: root
        password: 123456
      ds1:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class: com.mysql.jdbc.Driver
        jdbc-url: jdbc:mysql://localhost:3306/sharding-demo2
        username: root
        password: 123456
    # sharding-database
    sharding:
      tables:
        city:
          databaseStrategy:
            hint:
              algorithmClassName: com.hint.MyHintShardingAlgorithm
  • 创建 MyHintShardingAlgorithm 类实现HintShardingAlgorithm
  • 测试方法 TestHintAlgorithm: test1
16 17 18 19 20 21 22 23 24
古道长亭

古道长亭

Always remember that your present situation is not your final destination. The best is yet to come.

226 日志
57 分类
104 标签
GitHub Gitee
友情链接
  • 古道长亭的BOOK
  • JAVA学习
标签云
  • Mysql
  • 搜索引擎
  • Mybatis
  • 容器
  • 架构
  • 消息队列
  • Flink
  • Sharding sphere
  • 流处理
  • 缓存
© 2019 - 2024 京ICP备19012088号-1
0%