shardingsphere初体验-shardingsphere-UI

15 篇文章 0 订阅
9 篇文章 1 订阅

shardingsphere初体验-shardingsphere-UI

官方介绍

ShardingSphere-UI 是 ShardingSphere 的一个简单而有用的web管理控制台。它用于帮助用户更简单的使用 ShardingSphere 的相关功能,目前提供注册中心管理、动态配置管理、数据库编排等功能。

项目结构上采取了前后端分离的方式,前端使用 Vue 框架,后端采用 Spring Boot 框架。使用标准的 Maven 方式进行打包,部署,同时也可以采用前后端分离的方式本地运行,方便开发调试。

下载链接

ShardingSphere-UI下载链接
https://mirrors.bfsu.edu.cn/apache/shardingsphere/shardingsphere-ui-5.0.0-alpha/apache-shardingsphere-5.0.0-alpha-shardingsphere-ui-bin.tar.gz

对应版本的 shardingsphere-proxy 下载链接
https://archive.apache.org/dist/shardingsphere/5.0.0-alpha/

解压两个文件,然后修改 shardingsphere-proxy 的配置,alpha版本和beta版本配置稍微有些不一样,alpha版本的 server.yaml 的配置如下

authentication:
  users:
    root:
      password: root
    sharding:
      password: sharding
      authorizedSchemas: sharding_db

props:
#  max-connections-size-per-query: 1
#  acceptor-size: 16  # The default value is available processors count * 2.
#  executor-size: 16  # Infinite by default.
#  proxy-frontend-flush-threshold: 128  # The default value is 128.
#    # LOCAL: Proxy will run with LOCAL transaction.
#    # XA: Proxy will run with XA transaction.
#    # BASE: Proxy will run with B.A.S.E transaction.
#  proxy-transaction-type: LOCAL
#  proxy-opentracing-enabled: false
#  proxy-hint-enabled: false
#  query-with-cipher-column: true
  sql-show: true
#  check-table-metadata-enabled: false

体验shardingsphere-ui

然后启动mysql

在启动 shardingsphere-proxy
windos下使用 start.bat命令启动,linux下使用start.sh进行启动。

最后启动 shardingsphere-ui
windos下使用 start.bat命令启动,linux下使用start.sh进行启动。

访问 http://localhost:8088/
在这里插入图片描述

点击运行状态提示没有注册中心,然后我们点击添加注册中心,可以看到shardingsphere 支持zk和etcd
我们启动zk,然后填上配置,添加注册中心
在这里插入图片描述
添加完后,点击右侧的连接,效果如下
在这里插入图片描述
但是我们发现查看配置里面还是没有数据,后面发现是,要打开 shardingsphere-proxy 的这段配置,把信息注册到zk上

governance:
  name: governance_ds
  registryCenter:
    type: ZooKeeper
    serverLists: localhost:2181
    props:
      retryIntervalMilliseconds: 500
      timeToLiveSeconds: 60
      maxRetries: 3
      operationTimeoutMilliseconds: 500
  overwrite: false

重启 shardingsphere-proxy ,发现重启失败,原来是配置里的实例名称和创建的zk实例名称不一致,重建注册中心如下:
在这里插入图片描述

再次重启 shardingsphere-proxy ,虽然还报错,但是可以看到配置信息已经注册上来了,和 server.yaml 里的配置一样

在这里插入图片描述
在这里插入图片描述
经过一番挣扎,发现proxy的lib目录里面zk的jar版本是3.6.0,而我用的是zk是3.5.8,于是我重新下载了zk

下载链接如下:
http://archive.apache.org/dist/zookeeper/zookeeper-3.6.0/
重新跑一边流程,发现proxy 启动不报错了。

运行 examples/shardingsphere-proxy-example/shardingsphere-proxy-boot-mybatis-example/SpringBootStarterExample.java

可以看proxy 控制台的sql输出

试着修改配置,把展示sql改为false
在这里插入图片描述
再次运行SpringBootStarterExample.java

可以看到修改的配置生效了,proxy没有打印sql了
在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值