Python 官方文档:入门教程 => 点击学习
目录Sharding-Proxy分库分表和数据加密使用场景配置文件讲解server.yamlconfig-sharding.yamlconfig-encrypt.yaml其他使用情况
主要将实际项目中使用shardingshpere-proxy的经历经验,总结分享一下。
Sharding-Proxy
作为分库分表和数据加密的数据库中间件。主要原因是,它对代码的侵入性很小,开发人员也不需要关注它,减少了学习成本,对DBA也很友好。另一方面,ShardingSphere已进入Apache孵化器,它完全开源免费,社区也很活跃,版本迭代也很快。mode:
type: Cluster # 集群
repository:
type: ZooKeeper # 使用zookeeper
props:
namespace: Governance_ds
server-lists: 192.168.1.100:2181
retryIntervalMilliseconds: 50000
timeToLiveSeconds: 60
maxRetries: 3
operationTimeoutMilliseconds: 50000
overwrite: true
mode.type: Cluster
使用集群配置,单个部署也可以设置为Cluster
,没影响mode.repository
配置存储方式,可以选择使用ZooKeeper
mode.overwrite
,配置加载方式,本地配置是否覆盖配置中心配置。true是可覆盖,以本地为准,将本地配置同步到zookeeper;false则以zookeeper为准schemaName: digital_village
dataSources:
ds:
url: jdbc:postgresql://192.168.1.xxx:5432/digital_village?currentSchema=public&serverTimezone=UTC&useSSL=false
username: postgres
passWord: xxxxxx
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 120
minPoolSize: 1
ds_0:
url: jdbc:postgresql://192.168.1.xxx:5432/digital_village_0?currentSchema=public&serverTimezone=UTC&useSSL=false
ds_1:
url: jdbc:postgresql://192.168.1.xxx:5432/digital_village_1?currentSchema=public&serverTimezone=UTC&useSSL=false
password: xxxxx
rules:
- !SHARDING
tables:
# 需要分库的表,根据租户id分库
cms_basic_info:
actualDataNodes: ds_${0..3}.cms_basic_info
cms_column:
actualDataNodes: ds_${0..3}.cms_column
cms_content:
actualDataNodes: ds_${0..3}.cms_content
cms_content_text:
actualDataNodes: ds_${0..3}.cms_content_text
cms_menu_column_bind:
actualDataNodes: ds_${0..3}.cms_menu_column_bind
cms_message_board:
actualDataNodes: ds_${0..3}.cms_message_board
# 不需要分库分表的表,全部存储在 ds 数据源
auth_cfg_catalog_data_permission:
actualDataNodes: ds.auth_cfg_catalog_data_permission
databaseStrategy:
none:
auth_cfg_column_data_permission:
actualDataNodes: ds.auth_cfg_column_data_permission
databaseStrategy:
# 默认分库策略
defaultDatabaseStrategy:
standard:
shardinGColumn: customer_id #分库字段
shardingAlgorithmName: customer_id_inline #分库规则:
defaultTableStrategy:
none:
# 默认主键策略
defaultKeyGenerateStrategy:
column: id
keyGeneratorName: snowflake
# 自定义分片算法
shardingAlgorithms:
customer_id_inline:
type: CLASS_BASED
props:
strategy: standard
algorithmClassName: cn.lonsun.dv.DigitalVillageShardingAlgorithm
# 主键生成策略
keyGenerators:
snowflake:
type: SNOWFLAKE
worker-id: 123
- !ENCRYPT
encryptors:
aes_encryptor:
type: AES
aes-key-value: xxxwwaS213123SAD
md5_encryptor:
type: MD5
party_position:
columns:
mobile:
plainColumn: mobile
cipherColumn: mobile_cipher
encryptorName: aes_encryptor
village_population:
id_number:
plainColumn: id_number
cipherColumn: id_number_cipher
queryWithCipherColumn: true
到此这篇关于Sharding-Proxy分库分表和数据加密的文章就介绍到这了,更多相关Sharding-Proxy分库分表内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: Sharding-Proxy分库分表和数据加密使用场景分析
本文链接: https://www.lsjlt.com/news/145785.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0