梦幻联动-MogDB/openGauss与ShardingSphere在TPC-C上的表现(二)

本文涉及的产品
云原生数据库 PolarDB MySQL 版,通用型 2核4GB 50GB
云原生数据库 PolarDB PostgreSQL 版,标准版 2核4GB 50GB
简介: 梦幻联动-MogDB/openGauss与ShardingSphere在TPC-C上的表现

3. 修改配置文件

文件过长注释部分已经省略

  • 主配置文件
[root@db1 conf]# cat server.yaml 
rules:
  - !AUTHORITY
    users:
      - root@%:root
      - sharding@:sharding
    provider:
      type: ALL_PRIVILEGES_PERMITTED
props:
  max-connections-size-per-query: 2
  proxy-frontend-flush-threshold: 128  # The default value is 128.
  proxy-backend-query-fetch-size: 1000
  • users部分为ShardingSphere的账号密码,属于ShardingSphere的对象和数据库对象无关。
  • 分片文件
[root@db1 conf]# cat config-sharding.yaml
schemaName: tpcc
dataSources:
  ds_0:
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 3000
    minPoolSize: 1
    password: tpcc@123
    url: jdbc:postgresql://192.168.2.157:26000/tpcc?serverTimezone=UTC&useSSL=false&loggerLevel=OFF
    username: tpcc
  ds_1:
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 3000
    minPoolSize: 1
    password: tpcc@123
    url: jdbc:postgresql://192.168.2.158:26000/tpcc?serverTimezone=UTC&useSSL=false&loggerLevel=OFF
    username: tpcc  
rules:
  - !SHARDING
    bindingTables:
      - bmsql_warehouse, bmsql_customer
      - bmsql_stock, bmsql_district, bmsql_order_line
    defaultDatabaseStrategy:
      none:
    defaultTableStrategy:
      none:
    keyGenerators:
      snowflake:
        props:
          worker-id: 123
        type: SNOWFLAKE
    tables:
      bmsql_config:
        actualDataNodes: ds_0.bmsql_config
      bmsql_warehouse:
        actualDataNodes: ds_${0..1}.bmsql_warehouse
        databaseStrategy:
          standard:
            shardingColumn: w_id
            shardingAlgorithmName: bmsql_warehouse_database_inline
      bmsql_district:
        actualDataNodes: ds_${0..1}.bmsql_district
        databaseStrategy:
          standard:
            shardingColumn: d_w_id
            shardingAlgorithmName: bmsql_district_database_inline
      bmsql_customer:
        actualDataNodes: ds_${0..1}.bmsql_customer
        databaseStrategy:
          standard:
            shardingColumn: c_w_id
            shardingAlgorithmName: bmsql_customer_database_inline
      bmsql_item:
        actualDataNodes: ds_${0..1}.bmsql_item
        databaseStrategy:
          standard:
            shardingColumn: i_id
            shardingAlgorithmName: bmsql_item_database_inline
      bmsql_history:
        actualDataNodes: ds_${0..1}.bmsql_history
        databaseStrategy:
          standard:
            shardingColumn: h_w_id
            shardingAlgorithmName: bmsql_history_database_inline
      bmsql_oorder:
        actualDataNodes: ds_${0..1}.bmsql_oorder_${0..1}
        databaseStrategy:
          standard:
            shardingColumn: o_w_id
            shardingAlgorithmName: bmsql_oorder_database_inline
        tableStrategy:
          standard:
            shardingColumn: o_c_id
            shardingAlgorithmName: bmsql_oorder_table_inline
      bmsql_stock:
        actualDataNodes: ds_${0..1}.bmsql_stock
        databaseStrategy:
          standard:
            shardingColumn: s_w_id
            shardingAlgorithmName: bmsql_stock_database_inline
      bmsql_new_order:
        actualDataNodes: ds_${0..1}.bmsql_new_order
        databaseStrategy:
          standard:
            shardingColumn: no_w_id
            shardingAlgorithmName: bmsql_new_order_database_inline
      bmsql_order_line:
        actualDataNodes: ds_${0..1}.bmsql_order_line
        databaseStrategy:
          standard:
            shardingColumn: ol_w_id
            shardingAlgorithmName: bmsql_order_line_database_inline
    shardingAlgorithms:
      bmsql_warehouse_database_inline:
        type: INLINE
        props:
          algorithm-expression: ds_${w_id % 2}
      bmsql_district_database_inline:
        type: INLINE
        props:
          algorithm-expression: ds_${d_w_id % 2}
      bmsql_customer_database_inline:
        type: INLINE
        props:
          algorithm-expression: ds_${c_w_id % 2}
      bmsql_item_database_inline:
        type: INLINE
        props:
          algorithm-expression: ds_${i_id % 2}
      bmsql_history_database_inline:
        type: INLINE
        props:
          algorithm-expression: ds_${h_w_id % 2}
      bmsql_oorder_database_inline:
        type: INLINE
        props:
          algorithm-expression: ds_${o_w_id % 2}
      bmsql_oorder_table_inline:
        type: INLINE
        props:
          algorithm-expression: bmsql_oorder_${o_c_id % 2}
      bmsql_stock_database_inline:
        type: INLINE
        props:
          algorithm-expression: ds_${s_w_id % 2}
      bmsql_new_order_database_inline:
        type: INLINE
        props:
          algorithm-expression: ds_${no_w_id % 2}
      bmsql_order_line_database_inline:
        type: INLINE
        props:
          algorithm-expression: ds_${ol_w_id % 2}
  • schemaName 为数据库用户名
  • dataSources为数据源可配置1至多个
  • rules为分片规则,%2为取id列分成2份到两个数据库。

4. 启动proxy

[root@db1 bin]# pwd
/lee/ss/proxy/bin
[root@db1 bin]# ./start.sh 3307
Starting the ShardingSphere-Proxy ...
The classpath is /lee/ss/proxy/conf:.:/lee/ss/proxy/lib/*:/lee/ss/proxy/ext-lib/*
Please check the STDOUT file: /lee/ss/proxy/logs/stdout.log
[root@db1 bin]# cat /lee/ss/proxy/logs/stdout.log
Thanks for using Atomikos! Evaluate http://www.atomikos.com/Main/ExtremeTransactions for advanced features and professional support
or register at http://www.atomikos.com/Main/RegisterYourDownload to disable this message and receive FREE tips & advice
[INFO ] 2021-11-01 15:53:05.643 [main] o.a.s.p.i.BootstrapInitializer - Database name is `PostgreSQL`, version is `9.2.4`
[INFO ] 2021-11-01 15:53:05.837 [main] o.a.s.p.frontend.ShardingSphereProxy - ShardingSphere-Proxy start success
  • 可以在脚本后指定proxy的启动端口

5. 测试连接

[lee@node157 ~]$ gsql -d tpcc -Usharding -h 192.168.2.136 -p3307 -Wsharding
gsql ((MogDB 2.1.0 build ) compiled at 2021-10-26 19:07:06 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
tpcc=>

六、 调试BenchmarkSQL

1. 查看配置文件

[root@db1 run]# cat props.mogdb.ss 
db=postgres
driver=org.postgresql.Driver
conn=jdbc:postgresql://192.168.2.136:3307/tpcc?prepareThreshold=1&batchMode=on&fetchsize=10&loggerLevel=off
user=sharding
password=sharding
warehouses=100
loadWorkers=50
terminals=500
runTxnsPerTerminal=0
runMins=10
limitTxnsPerMin=0
terminalWarehouseFixed=true
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4
resultDirectory=ss_result_%tY-%tm-%td_%tH%tM%tS

2. 生成原始数据

[root@db1 run]# ./runDatabaseBuild.sh props.mogdb.ss 
部分日志
# ------------------------------------------------------------
# Loading SQL file ./sql.postgres/buildFinish.sql
------------------------------------------------------------
-- ----
-- Extra commands to run after the tables are created, loaded,
-- indexes built and extra's created.
-- PostgreSQL version.
-- ----

3. 运行TPCC程序

[root@db1 data]# numactl -C 0-25,30-55 ./runBenchmark.sh props.mogdb.ss 
13:55:30,137 [main] INFO   jTPCC : Term-00, 
13:55:30,140 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
13:55:30,140 [main] INFO   jTPCC : Term-00,      BenchmarkSQL v5.0
13:55:30,140 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
13:55:30,140 [main] INFO   jTPCC : Term-00,  (c) 2003, Raul Barbosa
13:55:30,140 [main] INFO   jTPCC : Term-00,  (c) 2004-2016, Denis Lussier
13:55:30,142 [main] INFO   jTPCC : Term-00,  (c) 2016, Jan Wieck
13:55:30,142 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
13:55:30,142 [main] INFO   jTPCC : Term-00, 
13:55:30,142 [main] INFO   jTPCC : Term-00, db=postgres
13:55:30,142 [main] INFO   jTPCC : Term-00, driver=org.postgresql.Driver
13:55:30,143 [main] INFO   jTPCC : Term-00, conn=jdbc:postgresql://192.168.2.136:3307/tpcc?prepareThreshold=1&batchMode=on&fetchsize=10&loggerLevel=off
13:55:30,143 [main] INFO   jTPCC : Term-00, user=sharding
13:55:30,143 [main] INFO   jTPCC : Term-00, 
13:55:30,143 [main] INFO   jTPCC : Term-00, warehouses=100
13:55:30,143 [main] INFO   jTPCC : Term-00, terminals=500
13:55:30,144 [main] INFO   jTPCC : Term-00, runMins=10
13:55:30,144 [main] INFO   jTPCC : Term-00, limitTxnsPerMin=0
13:55:30,145 [main] INFO   jTPCC : Term-00, terminalWarehouseFixed=true
13:55:30,145 [main] INFO   jTPCC : Term-00, 
13:55:30,145 [main] INFO   jTPCC : Term-00, newOrderWeight=45
13:55:30,145 [main] INFO   jTPCC : Term-00, paymentWeight=43
13:55:30,145 [main] INFO   jTPCC : Term-00, orderStatusWeight=4
13:55:30,145 [main] INFO   jTPCC : Term-00, deliveryWeight=4
13:55:30,145 [main] INFO   jTPCC : Term-00, stockLevelWeight=4
13:55:30,145 [main] INFO   jTPCC : Term-00, 
13:55:30,145 [main] INFO   jTPCC : Term-00, resultDirectory=ss_result_%tY-%tm-%td_%tH%tM%tS
13:55:30,145 [main] INFO   jTPCC : Term-00, osCollectorScript=null
13:55:30,145 [main] INFO   jTPCC : Term-00, 
13:55:30,157 [main] INFO   jTPCC : Term-00, copied props.mogdb.ss to ss_result_2021-11-01_135530/run.properties
13:55:30,157 [main] INFO   jTPCC : Term-00, created ss_result_2021-11-01_135530/data/runInfo.csv for runID 835
13:55:30,157 [main] INFO   jTPCC : Term-00, writing per transaction results to ss_result_2021-11-01_135530/data/result.csv
13:55:30,158 [main] INFO   jTPCC : Term-00,
13:55:30,237 [main] INFO   jTPCC : Term-00, C value for C_LAST during load: 165
13:55:30,237 [main] INFO   jTPCC : Term-00, C value for C_LAST this run:    92
13:55:30,237 [main] INFO   jTPCC : Term-00, Running Average tpmTOTAL: 626491.25    Current tpmTOTAL: 41415216    Memory Usage: 858MB / 1001MB          
14:05:31,197 [Thread-158] INFO   jTPCC : Term-00, 
14:05:31,197 [Thread-158] INFO   jTPCC : Term-00, 
14:05:31,197 [Thread-158] INFO   jTPCC : Term-00, Measured tpmC (NewOrders) = 281818.72
14:05:31,198 [Thread-158] INFO   jTPCC : Term-00, Measured tpmTOTAL = 626481.78
14:05:31,198 [Thread-158] INFO   jTPCC : Term-00, Session Start     = 2021-11-01 13:55:31
14:05:31,198 [Thread-158] INFO   jTPCC : Term-00, Session End       = 2021-11-01 14:05:31
14:05:31,198 [Thread-158] INFO   jTPCC : Term-00, Transaction Count = 6265412
14:05:31,198 [Thread-158] INFO   jTPCC : executeTime[Payment]=87346178
14:05:31,198 [Thread-158] INFO   jTPCC : executeTime[Order-Status]=3979084
14:05:31,198 [Thread-158] INFO   jTPCC : executeTime[Delivery]=24407579
14:05:31,198 [Thread-158] INFO   jTPCC : executeTime[Stock-Level]=3583178
14:05:31,198 [Thread-158] INFO   jTPCC : executeTime[New-Order]=180651188
  • 数据未经过充分调优仅供参考

七、何谓梦幻

  • 单一数据库整合成一个大型分布式,即兼顾了单机数据库的稳定,又产生了分布式数据库的能力。
  • 兼容多种数据库,目前支持 MySQL, PostgreSQL, SQLServer, Oracle, openGauss 以及符合 SQL92 规范的 SQL 方言。
  • 面对超负荷的流量或其他不正常状态下,针对某一节点进行熔断和限流,实现从数据库到计算节点打通的一体化管理能力,在故障中为组件提供细粒度的控制能力,并尽可能的提供自愈的可能。
  • 透明化分库分表,尽量对业务无感知,像使用一个数据库一样使用水平分片之后的数据库集群。
  • 支持多种事物粒度选择

本地事物:在不开启任何分布式事务管理器的前提下,让每个数据节点各自管理自己的事务。

两阶段提交:基于XA协议实现的分布式事务对业务侵入很小。 它最大的优势就是对使用方透明,用户可以像使用本地事务一样使用基于XA协议的分布式事务。 XA协议能够严格保障事务 ACID 特性。

柔性事务: 如果将实现了 ACID 的事务要素的事务称为刚性事务的话,那么基于 BASE 事务要素的事务则称为柔性事务。 BASE 是基本可用、柔性状态和最终一致性这三个要素的缩写。

本地事物 两(三)阶段事务 柔性事务
业务改造 实现相关接口
一致性 不支持 支持 最终一致
隔离性 不支持 支持 业务方保证
并发性能 无影响 严重衰退 略微衰退
适合场景 业务方处理不一致 短事务 & 低并发 长事务 & 高并发

  • 读写分离,通过负载均衡策略将查询请求疏导至不同从库。

263ef5eb02bbd96bf7ec753ba5325dfc_20211109-265594de-c4d6-4c54-b7fd-2e37676451d4.png

  • 架构,平台,系统,数据库版本,灵活多变,通过ShardingSphere可以实现MogDB和openGauss甚至和PostgreSQL在同一个集群中,参与灵活。
  • 18e02b73bac7acdd9da47ee8c858e030_20211110-fbbe5ec5-5f9a-4fd8-95fa-18f1d1fa66f6.png
相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
SQL 存储 数据挖掘
Dremio架构分析
一.Dremio架构 Dremio是基于Apache calcite、Apache arrow和Apache parquet3个开源框架构建,结构其核心引擎Sabot,形成这款DaaS(Data-as-a-Service)数据即服务平台;整体体验风格与其公司开源的Apache Drill非常接近。
9255 0
|
3月前
|
存储 SQL 负载均衡
GaussDB技术解读——GaussDB架构介绍
GaussDB技术解读——GaussDB架构介绍
80 3
|
3月前
|
存储 OLAP 数据处理
GaussDB技术解读——GaussDB架构介绍(三)
GaussDB技术解读——GaussDB架构介绍(三)
73 1
|
消息中间件 前端开发 关系型数据库
|
SQL 存储 关系型数据库
梦幻联动-MogDB/openGauss与ShardingSphere在TPC-C上的表现(一)
梦幻联动-MogDB/openGauss与ShardingSphere在TPC-C上的表现
304 0
梦幻联动-MogDB/openGauss与ShardingSphere在TPC-C上的表现(一)
|
存储 SQL 人工智能
GaussDB - 浅析华为高斯GaussDB
GaussDB - 浅析华为高斯GaussDB
1950 0
GaussDB - 浅析华为高斯GaussDB
|
存储 SQL 并行计算
一起学习国产自研数据库GaussDB(DWS)【这次高斯不是数学家】
一起学习国产自研数据库GaussDB(DWS)【这次高斯不是数学家】
一起学习国产自研数据库GaussDB(DWS)【这次高斯不是数学家】
|
SQL 并行计算 搜索推荐
如何将PostgreSQL与MySQL相结合,实现1+1>2的组合拳?(上)
阿里云智能数据库产品事业部高级产品专家德哥为大家带来如何将PostgreSQL与MySQL相结合,实现1+1>2的组合拳的介绍。 MySQL是最流行的开源数据库,PostgreSQL(PG)是最先进的开源数据库。两者结合,可以发挥1+1大于2的超级效果,解决应用原本无法解决的问题。 本议题将为您详细介绍如何将PG与MySQL结合使用,提升应用价值,以及5大业务场景和联合应用解读。
1176 0
如何将PostgreSQL与MySQL相结合,实现1+1>2的组合拳?(上)
|
人工智能 关系型数据库 MySQL
如何将PostgreSQL与MySQL相结合,实现1+1>2的组合拳?(下)
阿里云智能数据库产品事业部高级产品专家德哥为大家带来如何将PostgreSQL与MySQL相结合,实现1+1>2的组合拳的介绍。 MySQL是最流行的开源数据库,PostgreSQL(PG)是最先进的开源数据库。两者结合,可以发挥1+1大于2的超级效果,解决应用原本无法解决的问题。 本议题将为您详细介绍如何将PG与MySQL结合使用,提升应用价值,以及5大业务场景和联合应用解读。
824 0
如何将PostgreSQL与MySQL相结合,实现1+1>2的组合拳?(下)
|
OceanBase 数据库 存储