You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "dobet (via GitHub)" <gi...@apache.org> on 2024/04/11 09:01:02 UTC

[I] how to onlu sharding database? [shardingsphere]

dobet opened a new issue, #30849:
URL: https://github.com/apache/shardingsphere/issues/30849

   ## Question
   
   **For English only**, other languages will not accept.
   
   Before asking a question, make sure you have:
   
   - Googled your question.
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response anymore and we cannot reproduce it on current information, we will **close it**.
   
   
   I use shardingsphere-proxy 5.4.1 to sharding database.
   this is my step
   ```
   1. create database
   
   create database sbtest;
   
   2. register storage unit
   
   register storage unit if not exists sbtest_0 ( HOST='192.168.0.1', PORT=3306, DB='sbtest_0', USER='root', PASSWORD='123456');
   
   register storage unit if not exists sbtest_1 ( HOST='192.168.0.1', PORT=3306, DB='sbtest_1', USER='root', PASSWORD='123456');
   
   3.  create sharding table rule
   
   CREATE SHARDING TABLE RULE d_sbtest ( DATANODES("sbtest_${0..1}"), DATABASE_STRATEGY(TYPE="standard",SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME="inline",PROPERTIES("algorithm-expression"="sbtest_${user_id % 2}")))));
   
   4. create tabel
   
   CREATE TABLE `t_order` (   `order_id` int NOT NULL,   `user_id` int NOT NULL,   `status` varchar(45) DEFAULT NULL,   PRIMARY KEY (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
   
   5. show tables
   in  sbtest_0:
   mysql> show tables;
   Empty set (0.00 sec)
   
   in sbtest_1:
   mysql> show tables;
   +--------------------+
   | Tables_in_sbtest_1 |
   +--------------------+
   | t_order            |
   +--------------------+
   
   
   ```
   
   by result, only sharding database is failed. 
   what can i do?
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] how to onlu sharding database? [shardingsphere]

Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on issue #30849:
URL: https://github.com/apache/shardingsphere/issues/30849#issuecomment-2049944298

   <img width="562" alt="image" src="https://github.com/apache/shardingsphere/assets/5668787/1619dc5d-08f8-4766-92ec-845a9e22f82d">
   
   ---
   
   Hi, @dobet , I found some problems:
   1. You created the sharding rule `d_sbtest`, but the table you created is `t_order`, they are not related.
   2. In the sharding rules, `DATANODES` is incomplete, it may be `"sbtest_${0..1}.d_sbtest"` .
   
   ### Example
   ```sql
   mysql> CREATE SHARDING TABLE RULE d_sbtest ( DATANODES("sbtest_${0..1}.d_sbtest"), DATABASE_STRATEGY(TYPE="standard",SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME="inline",PROPERTIES("algorithm-expression"="sbtest_${user_id % 2}")))));
   Query OK, 0 rows affected (0.14 sec)
   
   mysql> show sharding table nodes;
   +----------+--------------------------------------+
   | name     | nodes                                |
   +----------+--------------------------------------+
   | d_sbtest | sbtest_0.d_sbtest, sbtest_1.d_sbtest |
   +----------+--------------------------------------+
   1 row in set (0.01 sec)
   ```
   
   
   Please refer to https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-rule/#1standard-sharding-table-rule
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] how to onlu sharding database? [shardingsphere]

Posted by "dobet (via GitHub)" <gi...@apache.org>.
dobet closed issue #30849: how to  onlu sharding database?
URL: https://github.com/apache/shardingsphere/issues/30849


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org