一、安装
1.下载
https://shardingsphere.apache.org/document/current/cn/downloads/
2.安装和配置
(1)解压:
[root@database ~]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/shardingsphere/shardingsphere-ui-4.1.1/apache-shardingsphere-4.1.1-shardingsphere-ui-bin.tar.gz
--2020-11-13 13:32:01-- https://mirrors.tuna.tsinghua.edu.cn/apache/shardingsphere/shardingsphere-ui-4.1.1/apache-shardingsphere-4.1.1-shardingsphere-ui-bin.tar.gz
正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:26093395 (25M) [application/x-gzip]
正在保存至: “apache-shardingsphere-4.1.1-shardingsphere-ui-bin.tar.gz”
100%[===============================================================================================================>] 26,093,395 4.07MB/s 用时 7.5s
2020-11-13 13:32:10 (3.31 MB/s) - 已保存 “apache-shardingsphere-4.1.1-shardingsphere-ui-bin.tar.gz” [26093395/26093395])
[root@database ~]# ll
总用量 25488
-rw-------. 1 root root 1242 10月 1 19:39 anaconda-ks.cfg
-rw-r--r--. 1 root root 26093395 7月 3 12:15 apache-shardingsphere-4.1.1-shardingsphere-ui-bin.tar.gz
[root@database ~]# tar -zxvf apache-shardingsphere-4.1.1-shardingsphere-ui-bin.tar.gz
(2)进入程序目录并运行
[root@database logs]# cd ..
[root@database apache-shardingsphere-4.1.1-shardingsphere-ui-bin]# ll
总用量 32
drwxr-xr-x. 2 root root 54 6月 3 03:50 bin
drwxr-xr-x. 2 root root 55 11月 13 13:33 conf
drwxr-xr-x. 2 root root 4096 11月 13 13:32 lib
-rw-r--r--. 1 root root 15993 6月 4 15:25 LICENSE
drwxr-xr-x. 2 root root 4096 11月 13 13:32 licenses
drwxr-xr-x. 2 root root 24 11月 13 13:33 logs
-rw-r--r--. 1 root root 7167 6月 3 03:50 NOTICE
[root@database apache-shardingsphere-4.1.1-shardingsphere-ui-bin]# bin/start.sh
Starting the ShardingSphere-UI ...
Please check the STDOUT file: /root/apache-shardingsphere-4.1.1-shardingsphere-ui-bin/logs/stdout.log
[root@database apache-shardingsphere-4.1.1-shardingsphere-ui-bin]# netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1223/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1457/master
tcp6 0 0 :::27017 :::* LISTEN 2119/docker-proxy
tcp6 0 0 :::3306 :::* LISTEN 2105/docker-proxy
tcp6 0 0 :::6379 :::* LISTEN 2153/docker-proxy
tcp6 0 0 :::22 :::* LISTEN 1223/sshd
tcp6 0 0 :::8088 :::* LISTEN 15970/java
tcp6 0 0 ::1:25 :::* LISTEN 1457/master
sharding-ui是一个标准的springboot程序,可以通过conf/application.properties
配置相关信息:
#
# 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.
#
server.port=8088
user.admin.username=admin
user.admin.password=admin
123456789101112131415161718192021
这里是下面要用到的连接配置信息,端口、用户名和密码可在此修改。
二、配置与使用
输入你部署的服务器的ip地址:8088进入管理界面。
例如我的地址是: http://192.168.1.104:8088
默认用户名和密码是: admin/admin
j
设置开机自启:
cat > /lib/systemd/system/sharding-ui.service <<-EOF
[Unit]
Description=shardingsphere-ui
After=network.target
[Service]
Type=forking
Environment=RUN_AS_USER=root
Environment=PATH=/home/oracle/app/oracle/product/11.2.0/dbhome_2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
ExecStart=/root/apache-shardingsphere-4.1.1-shardingsphere-ui-bin/bin/start.sh
ExecStop=/root/apache-shardingsphere-4.1.1-shardingsphere-ui-bin/bin/stop.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
[root@database bin]# systemctl start sharding-ui
[root@database bin]# systemctl status sharding-ui
● sharding-ui.service - shardingsphere-ui
Loaded: loaded (/usr/lib/systemd/system/sharding-ui.service; disabled; vendor preset: disabled)
Active: active (running) since 五 2020-11-13 14:00:23 CST; 9s ago
Process: 23764 ExecStart=/root/apache-shardingsphere-4.1.1-shardingsphere-ui-bin/bin/start.sh (code=exited, status=0/SUCCESS)
Main PID: 23773 (java)
Tasks: 43
Memory: 538.5M
CGroup: /system.slice/sharding-ui.service
└─23773 java -server -Xmx1g -Xms1g -Xmn512m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:Large...
11月 13 14:00:21 database systemd[1]: Starting shardingsphere-ui...
11月 13 14:00:21 database start.sh[23764]: Starting the ShardingSphere-UI ...
11月 13 14:00:23 database start.sh[23764]: Please check the STDOUT file: /root/apache-shardingsphere-4.1.1-shardingsphere-ui-bin/logs/stdout.log
11月 13 14:00:23 database systemd[1]: Started shardingsphere-ui.
[root@database bin]# systemctl enable sharding-ui
Created symlink from /etc/systemd/system/multi-user.target.wants/sharding-ui.service to /usr/lib/systemd/system/sharding-ui.service.
[root@database bin]# netstat -nlpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1223/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1457/master
tcp6 0 0 :::27017 :::* LISTEN 2119/docker-proxy
tcp6 0 0 :::3306 :::* LISTEN 2105/docker-proxy
tcp6 0 0 :::6379 :::* LISTEN 2153/docker-proxy
tcp6 0 0 :::22 :::* LISTEN 1223/sshd
tcp6 0 0 :::8088 :::* LISTEN 23773/java
tcp6 0 0 ::1:25 :::* LISTEN 1457/master
[root@database bin]#
之前的环境都没有了,等后面都配置好,再把图贴上,下面的图来自于:https://blog.csdn.net/a112626290/article/details/104558424
1.添加注册中心
这里对应server.yaml
中的配置,不多赘述,如图:
2.配置管理
这里可以进行公共信息
、认证信息
及分表分库
的配置,可实时生效。
3.运行状态
这里可以看到连接的sharding-proxy节点信息,并且可实时禁用。
从库信息界面主要是读写分离的信息: