Retro Eye care Haitian Deep Dark Default
Logo
Quickly Build a Sample Cluster

Quickly Build a Sample Cluster #

This section guides users on how to quickly set up a local sample cluster using SphereEx-Boot.

Server Preparation #

  • Worker node IP: 127.0.0.1
  • Login account: root
  • Password: root

Note:

The above should be replaced with your own IP address, login account and password.

Prerequisite #

The manager node and the worker node need to login with SSH account and password through sshpass for mutual trust authorization.

Verify whether the manager node can log in to the worker node with an account and password.

$ ssh root@127.0.0.1
[root@centos71 .ssh]# ssh root@127.0.0.1
Last login: Tue Dec 21 15:33:32 2021 from 127.0.0.1

Operation #

Suppose the cluster name is demo.

  1. Create a cluster.
$ mkdir demo 
$ cd demo
$ spex cluster init --name demo --download all
$ ls -l
total 126672
-rw-r--r-- 1 spex-demo  48M 12 9 14:46 apache-shardingsphere-5.0.0-shardingsphere-proxy-bin.tar.gz
-rw-r--r-- 1 spex-demo  12M 12 9 14:46 apache-zookeeper-3.6.3-bin.tar.gz
-rw-r--r-- 1 spex-demo  741B 12 9 14:47 cluster-config.yaml
drwxr-xr-x 9 spex-demo  288B 12 9 14:54 conf
-rw-r--r-- 1 spex-demo  984K 12 9 14:47 mysql-connector-java-5.1.47.jar
-rw-r--r-- 1 spex-demo  1.1K 12 9 14:47 zoo.cfg
  1. Add the cluster configuration file to the SphereEx-Boot tool management environment.
[root@centos71 demo]# spex config add -f cluster-config.yaml 
Successfully add cluster
  1. Install cluster.
$ spex cluster install --name demo 
Operation ShardingSphere-Proxy
check proxy install dir exist!          
Completed....... 
Operation ShardingSphere-Proxy
create install directory          
127.0.0.1 : 3307 => success
install proxy          
127.0.0.1 : 3307 => success
copying shell file          
127.0.0.1 : 3307 => success
copying config file          
127.0.0.1 : 3307 => success
copying agent config file          
skipped host:127.0.0.1 item : None
copying depend file          
127.0.0.1 : 3307 => success
Completed......
  1. Start cluster.
$ spex cluster start --name demo  
Operation ShardingSphere-Proxy
start proxy          
127.0.0.1 : 3307 => success
The port is 3307
The classpath is /root/shardingsphere-proxy/apache-shardingsphere-5.0.0-shardingsphere-proxy-bin/conf:.:/root/sharding-proxy/apache-shardingsphere-5.0.0-shardingsphere-proxy-bin/lib/*:/root/sharding-proxy/apache-shardingsphere-5.0.0-shardingsphere-proxy-bin/ext-lib/*
Please check the STDOUT file: /root/sharding-proxy/apache-shardingsphere-5.0.0-shardingsphere-proxy-bin/logs/stdout.log
Completed......
  1. View cluster running status.
$ spex cluster status --name demo  
Operation ShardingSphere-Proxy
proxy status          
127.0.0.1 : 3307 => success
PID:6355 PORT:3307 %CPU:20.6 %MEM:10.1 START:00:33 TIME:0:03
Results summary
+--------------+------+------+------+------+-------+------+
|     HOST     | PORT | PID  | %CPU | %MEM | START | TIME |
+--------------+------+------+------+------+-------+------+
| 127.0.0.1    | 3307 | 6355 | 20.6 | 10.1 | 00:33 | 0:03 |
+--------------+------+------+------+------+-------+------+
Completed......
Operation ZooKeeper
zookeeper status          
127.0.0.1 : 2181 => success
/usr/bin/java
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: standalone
ZooKeeper JMX enabled by default
Using config: /root/zookeeper/apache-zookeeper-3.6.3-bin/bin/../conf/zoo.cfg
Results summary
+--------------+------+------------------+
|     HOST     | PORT |      STATUS      |
+--------------+------+------------------+
| 127.0.0.1    | 2181 | Mode: standalone |
+--------------+------+------------------+
Completed......
  1. Uninstall the cluster.

To uninstall the installed demo cluster, run the command $ spex cluster uninstall --name demo to uninstall the corresponding cluster.

$ spex cluster uninstall --name demo 
Are you sure to uninstall demo cluster ? [y/N]: y
Operation ShardingSphere-Proxy
stop proxy          
127.0.0.1 : 3307 => success
ShardingSphere-Proxy does not started!
remove install directory          
127.0.0.1 : 3307 => success
Completed......
Operation ZooKeeper
stop zookeeper          
127.0.0.1 : 2181 => success
/usr/bin/java
Stopping zookeeper ... no zookeeper to stop (could not find file /root/zookeeper/data/zookeeper_server.pid)
ZooKeeper JMX enabled by default
Using config: /root/zookeeper/apache-zookeeper-3.6.3-bin/bin/../conf/zoo.cfg
remove zookeeper data directory          
127.0.0.1 : 2181 => success
remove zookeeper install directory          
127.0.0.1 : 2181 => success
Completed......