README.md 1.8 KB
Newer Older
ShardingSphere's avatar
ShardingSphere 已提交
1
# ShardingSphere-example
张亮 已提交
2

ShardingSphere's avatar
ShardingSphere 已提交
3
ShardingSphere example.
张亮 已提交
4

L
Liang Zhang 已提交
5
Example for 1.x please see tags in `https://github.com/apache/incubator-shardingsphere/tree/${tag}/sharding-jdbc-example`
C
Chris Cao 已提交
6

L
Liang Zhang 已提交
7
Example for 2.x or 3.x please see tags in `https://github.com/apache/incubator-shardingsphere-example/tree/${tag}`
T
terrymanu 已提交
8 9

Please do not use `dev` branch to run your example, example of `dev` branch is not released yet. 
T
terrymanu 已提交
10

L
Liang Zhang 已提交
11
The manual schema initial script is in `https://github.com/apache/incubator-shardingsphere-example/blob/dev/src/resources/manual_schema.sql`, 
T
terrymanu 已提交
12
please execute it before you first run the example.
T
terrymanu 已提交
13 14

Please make sure master-slave data sync on MySQL is running correctly. Otherwise this example will query empty data from slave.
15 16

## Using docker-compose to config startup environment
17 18 19 20
before we use docker compose, please install docker first : https://docs.docker.com/compose/install/

#### sharding-jdbc
1. access the docker folder (cd docker/sharding-jdbc/sharding)
21 22 23
2. launch the environment by docker compose (docker-compose up -d)
3. access mysql / etcd / zookeeper as you want
4. if there is conflict on port, just modify the mapper port in docker-compose.yml and then launch docker compose again(docker-compose up -d)
24 25 26 27 28 29 30 31
5. if you want to stop these environment, use command docker-compose down

#### sharding-proxy
1. access the docker folder (cd docker/sharding-proxy/sharding)
2. launch the environment by docker compose (docker-compose up -d)
3. access proxy by `mysql -h127.0.0.1 -P13308 -proot -uroot`
4. if there is conflict on port, just modify the mapper port in docker-compose.yml and then launch docker compose again(docker-compose up -d)
5. if you want to stop these environment, use command docker-compose down
32 33 34

to clean the docker container , you could use docker rm `docker ps -a -q` (be careful)