数据库管理语句

最近更新时间:2019-06-26 10:42:23

说明:

如果您期望阅读或下载全量开发文档,请参见 TDSQL 开发指南

数据库管理语句

状态查询
通过 sql 可以查看 proxy 的配置以及状态信息,目前支持如下命令:

    mysql> /*proxy*/help;
    +-----------------------+-------------------------------------------------------+
    | command               | description                                           |
    +-----------------------+-------------------------------------------------------+
    | show config           | show config from conf                                 |
    | show status           | show proxy status,like route,shardkey and so on       |
    | set sys_log_level=N   | change the sys debug level N should be 0,1,2,3        |
    | set inter_log_level=N | change the interface debug level N should be 0,1      |
    | set inter_time_open=N | change the interface time debug level N should be 0,1 |
    | set sql_log_level=N   | change the sql debug level N should be 0,1            |
    | set slow_log_level=N  | change the slow debug level N should be 0,1           |
    | set slow_log_ms=N     | change the slow ms                                    |
    | set log_clean_time=N  | change the log clean days                             |
    | set log_clean_size=N  | change the log clean size in GB                       |
    +-----------------------+-------------------------------------------------------+
    10 rows in set (0.00 sec)

    mysql> /*proxy*/show config;
    +-----------------+--------------------+
    | config_name     | value              |
    +-----------------+--------------------+
    | version         | V2R120D001         |
    | mode            | group shard        |
    | rootdir         | /shard_922         |
    | sys_log_level   | 0                  |
    | inter_log_level | 0                  |
    | inter_time_open | 0                  |
    | sql_log_level   | 0                  |
    | slow_log_level  | 0                  |
    | slow_log_ms     | 1000               |
    | log_clean_time  | 1                  |
    | log_clean_size  | 1                  |
    | rw_split        | 1                  |
    | ip_pass_through | 0                  |
    +-----------------+--------------------+
    14 rows in set (0.00 sec)

    mysql> /*proxy*/show status;
    +-----------------------------+------------------------------------------------------------------------------+
    | status_name                 | value                                                                        |
    +-----------------------------+------------------------------------------------------------------------------+
    | cluster                     | group_1499858910_79548                                                       |
    | set_1499859173_1:ip         | xxx.xxx.xxx.xxx:xxxx;xxx.xxx.xxx.xxx:xxxx@1@IDC_4@0,xxx.xxx.xxx.xxx:xxxx@1@IDC_2@0 |
    | set_1499859173_1:hash_range | 0---31                                                                       |
    | set_1499911640_3:ip         | xxx.xxx.xxx.xxx:xxxx;xxx.xxx.xxx.xxx:xxxx@1@IDC_4@0,xxx.xxx.xxx.xxx:xxxx@1@IDC_2@0 |
    | set_1499911640_3:hash_range | 32---63                                                                      |
    | set                         | set_1499859173_1,set_1499911640_3                                            |

同时 proxy 增强了 explain 的返回结果,显示 proxy 修改后的 sql;

    mysql> explain select * from test1;
    +------+-------------+-------+------+---------------+------+---------+------+------+-------+-----------------------------------------+
    | id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra | info                                    |
    +------+-------------+-------+------+---------------+------+---------+------+------+-------+-----------------------------------------+
    |    1 | SIMPLE      | test1 | ALL  | NULL          | NULL | NULL    | NULL |   16 |       | set_2,explain select * from shard.test1 |
    |    1 | SIMPLE      | test1 | ALL  | NULL          | NULL | NULL    | NULL |   16 |       | set_1,explain select * from shard.test1 |
    +------+-------------+-------+------+---------------+------+---------+------+------+-------+-----------------------------------------+
    2 rows in set (0.03 sec)