tristaZero opened a new issue #7324: URL: https://github.com/apache/shardingsphere/issues/7324
Hi, community, #6466 mainly finished the RDL new feature for 5.x release. This issue introduces how to use RDL to create Sharding DBs and tables for your production or test environment. ### What's the RDL? RDL means rule definition language to create your distributed DBs, Tables by SQL. In other words, this is a specific SQLs for ShardingSphere to configure Sharding tables. ### Pre-work 1. Start the service of MySQL instances 2. Create MySQL databases (Viewed as the resources for ShardingProxy) 3. Create a role or user with creating privileges for ShardingProxy 4. Start the service of Zookeeper (For persisting configuration) ### Initialize ShardingProxy 1. Add `governance` and `authentication` setting item to the `server.yaml` (Please refer to the example in this file) 2. Start the ShardingProxy ([Instruction](https://shardingsphere.apache.org/document/current/en/quick-start/shardingsphere-proxy-quick-start/)) ### Create Sharding DBs and Tables 1. Connect to ShardingProxy 2. Create a sharding database ```SQL create database ss1; ``` 3. Use the sharding database ```SQL use ss1; ``` 2. Add database resources for this sharding DB ```SQL create datasources ( ds0=127.0.0.1:3306:demo_ds_2:root, ds1=127.0.0.1:3306:demo_ds_3:root) ``` 3. Create Sharding rules for sharding tables ```SQL create shardingrules ( t_order=hash_mod(order_id, 4), t_item=mod(item_id, 2) ) ``` Here `hash_mode` and `mod` are auto sharding algorithm. Please visit [auto-sharding-algorithm](https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/configuration/built-in-algorithm/sharding/) to learn more. 4. Create tables ```SQL CREATE TABLE `t_order` ( `order_id` int NOT NULL, `user_id` int NOT NULL, `status` varchar(45) DEFAULT NULL, PRIMARY KEY (`order_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 CREATE TABLE `t_item` ( `item_id` int NOT NULL, `order_id` int NOT NULL, `user_id` int NOT NULL, `status` varchar(45) DEFAULT NULL, PRIMARY KEY (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
