Introduction to the

ShardingSphere-UI is a simple and useful Web management console for ShardingSphere. It is used to help users use the relevant functions of ShardingSphere more easily, and currently provides registry management, dynamic configuration management, database orchestration and other functions.

The project structure adopts the way of separating the front and back ends, with Vue framework used in the front end and Spring Boot framework used in the back end. It is packaged and deployed in standard Maven mode, and can also be run locally by separating the front and back ends for easy development and debugging.

To prepare

To use ShardingSphere-UI, you need to register ShardingSphere proxy with ZooKeeper. Previous article: juejin.cn/post/700002… We have described how to set up ShardingSphere Proxy service, here we need to set up a new ZooKeeper registry to register our proxy.

The proxy configuration

Add the ZooKeeper configuration to the previous configuration

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

Download zookeeper:www.apache.org/dyn/closer…. After decompressing ZooKeeper, add two folders to the folder to store data

Modify the config folder zoo_sample. CFG to zoo. CFG and then in the zoo. The CFG to modify two address for the newly created folder dataDir = / Users/XXXX zookeeper/data

dataLogDir=/Users/xxx/zookeeper/log

Change the external folder to ZooKeeper and use it

Sh start Check the status: sh zkServer.sh status ZooKeeper JMX enabled by default Using config: /Users/.. /conf/zoo.cfg mkdir: illegal option -- e usage: mkdir [-pv] [-m mode] directory ... Client port found: 2181. Client address: localhost. Client SSL: false. Mode: standaloneCopy the code

See the above results to prove that ZooKeeper successfully started and then start ShardingSphere Proxy according to the previous article

download

Directly on the website to download the tar package decompression using www.apache.org/dyn/closer….

The configuration file

You can modify the configuration in the unzipped file, located in the conf application. Properites

# # # 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=adminCopy the code

Start the program

Open the stsrt.sh folder in bin to run the program

Start the result

Open stdout.log in the logs folder to see the successful startup logs. Other run logs are also in this folder

[the main] [INFO] 16:59:52. 084 O.S.B.A.W.W ebMvcAutoConfiguration $WelcomePageHandlerMapping - Adding the welcome page: Class path resource [public/index. HTML] [INFO] 16:59:52. [the main] 204 O.S.J.E.A.A nnotationMBeanExporter - Registering Beans for JMX exposure on startup. [INFO] 16:59:52 214 [main] O.A.C oyote. Http11. Http11NioProtocol - Starting ProtocolHandler [HTTP - nio - 8088 ""] [INFO] 16:59:52, 240 [main] o.a.tomcat.util.net.NioSelectorPool - Using a Shared The selector for the servlet write/read/INFO 16:59:52. [the main] 251 O.S.B.C.E.T.T omcatEmbeddedServletContainer - Tomcat is started on port(s): 8088 (HTTP) [INFO] 16:59:52. 256. [the main] o.a pache, shardingsphere. UI. The Bootstrap - Started the Bootstrap in 2.826 seconds (JVM Running for 3.363)Copy the code

Log in to the port just configured in the configuration file:

You can see that the ShardingSphere-UI page has been successfully launched and then add your newly configured name and Z address to the page

Click link after the configuration is successful.

Then in the rule Config page, you can see the tables in the various proxies we configured previously, and modify the rules we configured in this page:

The problem

The version of ShardingSphere Proxy used this time is the latest 5.0.0-alpha. At the beginning, ZooKeeper used the version 3.4.1, but the abnormal connection was reported all the time. After downloading the latest zooKeeper version 3.7.0 from the official website, The connection is successful and the correct library and table strategy is displayed.