MyCat java 阿里 中间件

https://www.cnblogs.com/jpfss/p/8192818.html?share_token=3BA13916-7C0F-446E-82EC-987912C744D5&tt_from=mobile_qq&utm_source=mobile_qq&utm_medium=toutiao_ios&utm_campaign=client_share

https://www.cnblogs.com/rangle/archive/2018/01/02/8176362.html?share_token=AA9FC556-1375-40D3-A319-1A0E01ABC054&tt_from=mobile_qq&utm_source=mobile_qq&utm_medium=toutiao_ios&utm_campaign=client_share

分库分表博文

https://blog.csdn.net/yimenglin/article/details/108101867

分库分表后效果

分库分表关系表


db.provider.{env}.json

1、复制重命名~/App_Data/DB/rg3_master_shred.db 为 ~/App_Data/DB/{ownerId}/{ownerId}boshred.db

,
  //分库分表 库、表、列、值 映射数据
  "ConnShred": {
    "databaseType": "Sqlite",
    "name": "ConnShred",
    "providerName": "Microsoft.Data.Sqlite",
    "read": [
      "Data Source=~/App_Data/DB/rg/rg_bo_shred.db"
    ],
    "write": [
      "Data Source=~/App_Data/DB/rg/rg_bo_shred.db"
    ]
  }

IShredDbTable.cs 使用接口

bo_shred_dbtable.sql 分库分表中间交换表

1、时间类型,通过shred_min_date过滤
2、求模类型,通过shred_mod_value过滤
3、值类型,通过shred_min_value过滤

/*
 Navicat Premium Data Transfer

 Source Server         : rg3_master_shred
 Source Server Type    : SQLite
 Source Server Version : 3017000
 Source Schema         : main

 Target Server Type    : SQLite
 Target Server Version : 3017000
 File Encoding         : 65001

 Date: 25/08/2021 22:26:15
*/

PRAGMA foreign_keys = false;

-- ----------------------------
-- Table structure for bo_shred_dbtable
-- ----------------------------
DROP TABLE IF EXISTS "bo_shred_dbtable";
CREATE TABLE "bo_shred_dbtable" (
  "shred_id" text(50) NOT NULL,
  "shred_db_mkey" text(200),
  "shred_table_mkey" text(200),
  "shred_db_name" text(200),
  "shred_table_name" text(200),
  "ori_table_name" text(200),
  "ori_db_name" text(200),
  "write_db_Index" integer,
  "read_db_index" integer,
  "conn_name" TEXT(200),
  "shred_column" TEXT(100),
  "shred_primary" TEXT(100),
  "sys_id" TEXT(100),
  "owner_id" TEXT(100),
  "shred_max_value" double(100),
  "shred_min_value" double(100),
  "shred_min_date" timestamp(100),
  "shred_max_date" timestamp(100),
  "shred_mod_value" integer,
  PRIMARY KEY ("shred_id")
);

-- ----------------------------
-- Indexes structure for table bo_shred_dbtable
-- ----------------------------
CREATE UNIQUE INDEX "pk_sub_push_id"
ON "bo_shred_dbtable" (
  "id" COLLATE BINARY ASC
);

PRAGMA foreign_keys = true;

ShredBasis


   /// <summary>
    /// 切片配置  2021-08-23 cbg
    /// </summary>
    public class ShredBasis : IEntity
    {

        /// <summary>
        /// OwnerId
        /// </summary>
        public string OwnerId { get; set; }
        /// <summary>
        /// SysId
        /// </summary>
        public string SysId { get; set; }


        /// <summary>
        /// 存储如  mkey 或者 mapperKey  ,  数据在 db.provider.shreding.json
        /// </summary>
        public string ShredKey { get; set; }

        /// <summary>
        /// shreding_resource_data_his.i_table_mysql
        /// </summary>
        public string ShredTableMKey { get; set; }

        /// <summary>
        /// shreding_resource_data_his.i_db_mysql
        /// </summary>
        public string ShredDbMKey { get; set; }


        /// <summary>
        /// 切片列   如时间列、自增列、数值列
        /// </summary>
        public string ShredColumn { get; set; }

        /// <summary>
        /// 主键列   自增列、雪花算法列
        /// </summary>
        public string ShredPrimary { get; set; }


        /// <summary>
        /// 读取  db.provider 里面 write索引
        /// </summary>
        public int WriteDbIndex { get; set; }

        /// <summary>
        /// 读取  db.provider 里面 read索引
        /// </summary>
        public int ReadDbIndex { get; set; }

    }

ShredDbTable

 /// <summary>
    /// 切片配置  2021-08-23 cbg
    /// </summary>
    public class ShredDbTable : ShredBasis
    {

        /// <summary>
        ///tb_20210801
        /// </summary>
        public string ShredTableName{ get; set; }

        /// <summary>
        /// db_202108
        /// </summary>
        public string ShredDbName{ get; set; }


        /// <summary>
        ///tb
        /// </summary>
        public string OriTableName { get; set; }

        /// <summary>
        /// db
        /// </summary>
        public string OriDbName { get; set; }


        /// <summary>
        /// 
        /// </summary>
        public string ConnName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public long ShredMaxValue { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public long ShredMinValue { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public DateTime? ShredMinDate { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public DateTime? ShredMaxDate { get; set; }


        /// <summary>
        /// 
        /// </summary>
        public long ShredModValue { get; set; }

    }
文档更新时间: 2021-10-16 12:37   作者:admin