暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

shardingsphere-proxy 报错记录

原创 飞鸟 2023-04-01
1942

背景:

信创的大背景下,数据库是重要的一环,背靠国企,因此opengauss 也在我们的计划测试之列,测试opengauss,ssp就不可避免会使用到,本文记录了在使用ssp过程中的一些坑。

ssp只要测试版本是5.1.2

1、关于某个标签报错,要严格按照官方的YAML模板来。不同版本之间标签或者标签值会有差异。


2、关于rules报错

Exception in thread "main" Can't construct a java object for tag:yaml.org,2002:java.util.Collection; exception=No single argument constructor found for interface java.util.Collection : null
 in 'string', line 1, column 1:
    rules
    ^

        at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:336)

解决:overwrite: true  修改true,默认为false。


3、用户名 密码问题 测试ssp所在机器网络是否通畅,是否可以登录到opengauss,验证方式需要MD5,这边不再赘述

Can't construct a java object for !AUTHORITY:; exception=Invalid tag: !AUTHORITY:

 in 'reader', line 38, column 5:
      - !AUTHORITY:
        ^

 in 'reader', line 38, column 3:
      - !AUTHORITY:

解决:配置正确的用户名密码,并使用MD5认证,确保ssp所在机器可以登录到opengauss所在机器

4、标签位置错误

Unable to find property 'props' on class: org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration
 in 'reader', line 65, column 5:
        sql-show: true

解决:在server.yaml中进行配置

总结:

最后贴上正确的配置;

conf/server.yaml

mode:
  type: Cluster
  repository:
    type: ZooKeeper
    props:
      namespace: governance_ds
      server-lists: 10.26.223.160:2181
      retryIntervalMilliseconds: 500
      timeToLiveSeconds: 60
      maxRetries: 3
      operationTimeoutMilliseconds: 500
  overwrite: true

rules:
  - !AUTHORITY
    users:
      - root@%:root
      - sharding@:sharding
    provider:
      type: ALL_PERMITTED
  - !TRANSACTION
    defaultType: XA
    providerType: Atomikos
#    # When the provider type is Narayana, the following properties can be configured or not
#    props:
#      recoveryStoreUrl: jdbc:mysql://127.0.0.1:3306/jbossts
#      recoveryStoreDataSource: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
#      recoveryStoreUser: root
#      recoveryStorePassword: 12345678
  - !SQL_PARSER
    sqlCommentParseEnabled: true
    sqlStatementCache:
      initialCapacity: 2000
      maximumSize: 65535
    parseTreeCache:
      initialCapacity: 128
      maximumSize: 1024

props:
  max-connections-size-per-query: 1
  kernel-executor-size: 16  # Infinite by default.
  proxy-frontend-flush-threshold: 128  # The default value is 128.
  proxy-hint-enabled: false
  sql-show: true
  check-table-metadata-enabled: false
  show-process-list-enabled: false
#    # Proxy backend query fetch size. A larger value may increase the memory usage of ShardingSphere Proxy.
#    # The default value is -1, which means set the minimum value for different JDBC drivers.
#  proxy-backend-query-fetch-size: -1
#  check-duplicate-table-enabled: false
#  proxy-frontend-executor-size: 0 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
#    # Available options of proxy backend executor suitable: OLAP(default), OLTP. The OLTP option may reduce time cost of writing packets to client, but it may increase the latency of SQL execution
#    # and block other clients if client connections are more than `proxy-frontend-executor-size`, especially executing slow SQL.
#  proxy-backend-executor-suitable: OLAP
#  proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
#  sql-federation-enabled: false
#    # Available proxy backend driver type: JDBC (default), ExperimentalVertx
#  proxy-backend-driver-type: JDBC
#  proxy-mysql-default-version: 5.7.22 # In the absence of schema name, the default version will be used.
#  proxy-default-port: 3307 # Proxy default port.
  proxy-netty-backlog: 1024 # Proxy netty backlog.



「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论