Logo
场景三:手动安装 Proxy

场景三:手动安装 Proxy #

安装治理中心 #

SphereEx-DBPlusEngine 的 Job 信息存储在治理中心中,CDC、迁移、重分片、洗数功能是需要启动 Job 执行并依赖治理中心,所以使用到这些内容是需要额外安装治理中心,治理中心推荐使用 Zookeeper。

SphereEx-DBPlusEngine 支持 Zookeeper 3.6+ 的版本

安装 Zookeeper 请参考官方文档

ZooKeeper 部署注意事项 #

  1. 根据官网建议 ZooKeeper 标准配置为:2C、4G,最大堆内存设置 3G
  2. 建议独立使用 SSD 固态磁盘,减少 IO 竞争
  3. 合理配置日志清理策略,zoo_cfg 文件中如下配置:
# 设置保留的快照(snapshot)文件数量。默认为 3。推荐设置 3~5
autopurge.snapRetainCount=3

# 触发清除日志任务的时间间隔(以小时为单位)。默认为 0(禁用),建议启用并设置为 1 
autopurge.purgeInterval=1 

部署 SphereEx-DBPlusEngine-Proxy #

部署多台 Proxy 时在不同的主机上执行步骤 1-6

  1. 创建普通用户 sphereex,对应程序目录授权
useradd sphereex
chown -R sphereex: /app
su - sphereex
  1. 获取安装包
# 请从商务处获得
  1. 安装 Proxy 所需 JAVA 环境
yum install -y java-1.8.0-openjdk.x86_64
  1. 配置 proxy

在配置文件:/app/sphereex-dbplusengine-proxy-x.x.x/conf/global.yaml 配置 zookeeper 地址。

注意:

  • authority 用于定义能够登录到 proxy 的账户,可选配
  • 不配置 authority 时,使用内置账户 root/root

注:使用 CDC 时可以将 CDC 配置的注释打开

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

######################################################################################################
# 
# If you want to configure governance, authorization and proxy properties, please refer to this file.
# 
######################################################################################################
#
mode:
  type: Cluster
  repository:
    type: ZooKeeper
    props:
      namespace: governance_ds
      server-lists: [ZooKeeper ip]:[ZooKeeper port],[ZooKeeper ip]:[ZooKeeper port],[ZooKeeper ip]:[ZooKeeper port]
      retryIntervalMilliseconds: 500
      timeToLiveSeconds: 60
      maxRetries: 3
      operationTimeoutMilliseconds: 500
#
#authority:
#  users:
#    - user: root@%
#      password: root
#      admin: true
#    - user: sharding
#      password: sharding
#  privilege:
#  # SPEX CHANGED: BEGIN
#    type: Enterprise
#  # SPEX CHANGED: END
#
#transaction:
#  defaultType: XA
#  # SPEX CHANGED: BEGIN
#  providerType: Narayana
#  props:
#    # 1.Use JDBC store configuration
#    recoveryStoreDataSource: com.zaxxer.hikari.HikariDataSource
#    recoveryStoreUrl: 
#    recoveryStoreUser: 
#    recoveryStorePassword: 
#    # 2.Or use File store configuration
#    # recoveryStoreType: File
#  # SPEX CHANGED: END
#
#sqlParser:
#  sqlStatementCache:
#    initialCapacity: 2000
#    maximumSize: 65535
#  parseTreeCache:
#    initialCapacity: 128
#    maximumSize: 1024
#  # SPEX CHANGED: BEGIN
#  sqlParserType:
#  # SPEX CHANGED: END
#
#sqlFederation:
#  sqlFederationEnabled: false
#  executionPlanCache:
#    initialCapacity: 2000
#    maximumSize: 65535
#
#props:
#  system-log-level: INFO
#  max-connections-size-per-query: 1
#  kernel-executor-size: 16  # Infinite by default.
#  proxy-frontend-flush-threshold: 128  # The default value is 128.
#  # sql-show is the same as props in logger ShardingSphere-SQL, and its priority is lower than logging rule
#  sql-show: false
#  check-table-metadata-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
#  proxy-frontend-executor-size: 0 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
#  proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
#  proxy-default-port: 3307 # Proxy default port.
#  proxy-netty-backlog: 1024 # Proxy netty backlog.
#  cdc-server-port: 33071 # CDC server port
#  proxy-frontend-ssl-enabled: false
#  proxy-frontend-ssl-cipher: ''
#  proxy-frontend-ssl-version: TLSv1.2,TLSv1.3
#  # SPEX ADDED: BEGIN
#  proxy-frontend-ssl-cert-file: ''
#  proxy-frontend-ssl-key-file: ''
#  cdc-decrypt-enabled: false
#  # SPEX ADDED: END
  1. 启动 proxy

/app/sphereex-dbplusengine-proxy-x.x.x/

bin/start.sh [port]
  • 默认端口 3307,可通过 bin/start.sh [port] 方式指定运行端口。
  • 查看日志:tail -f logs/stdout.log
  1. 停止 proxy

/app/sphereex-dbplusengine-proxy-x.x.x/

bin/stop.sh [port]

登录 Proxy #

前提安装数据库的客户端,直接执行数据库的连接语句即可,以 MySQL 为例

mysql -uroot -proot -h 127.0.0.1 -P 3307

注册 License #

连接任意一台 Proxy 执行注册 License 的语句

注:License 文件请从商务处获得

register license 'XXXXXXXXXXXXX';
# XXXXXXXXXXXXX  License 文件中的文本

查看 License 是否生效

sql> SHOW LICENSE INFO;
| company_name | instance_count | resource_count | expiry_date         | generation_data     | status | license 
| sphereextest | 8              | 8              | 2023-01-01 00:00:00 | 2022-09-08 18:00:00 | valid  | Ic5OXgAAACMAAAACAAAACwAAAAxjcmVEaWdlc3RTSEEtNTEy

创建逻辑库 #

create database dbname

注册存储单元,加载单表 #

注:前提是数据库 server、DB、USER 已经存在

use dbname
REGISTER STORAGE UNIT ds_0 (
   HOST="127.0.0.1",
   PORT=3306,
   DB="db0",
   USER="root",
   PASSWORD="root");

load single table ds_0.*;

注册存储单元请参考 加载单表请参考

至此就可以开始使用 Proxy 了