读写分离

语法说明

  1. SHOW READWRITE_SPLITTING RULES [FROM schemaName]

返回值说明

说明
name规则名称
auto_aware_data_source_name自动发现数据源名称(配置动态读写分离规则显示)
write_data_source_name写数据源名称
read_data_source_names读数据源名称列表
load_balancer_type负载均衡算法类型
load_balancer_props负载均衡算法参数

示例

静态读写分离规则

  1. mysql> show readwrite_splitting rules;
  2. +------------+-----------------------------+------------------------+------------------------+--------------------+---------------------+
  3. | name | auto_aware_data_source_name | write_data_source_name | read_data_source_names | load_balancer_type | load_balancer_props |
  4. +------------+-----------------------------+------------------------+------------------------+--------------------+---------------------+
  5. | ms_group_0 | NULL | ds_primary | ds_slave_0, ds_slave_1 | random | |
  6. +------------+-----------------------------+------------------------+------------------------+--------------------+---------------------+
  7. 1 row in set (0.00 sec)

动态读写分离规则

  1. mysql> show readwrite_splitting rules from readwrite_splitting_db;
  2. +-------+-----------------------------+------------------------+------------------------+--------------------+---------------------+
  3. | name | auto_aware_data_source_name | write_data_source_name | read_data_source_names | load_balancer_type | load_balancer_props |
  4. +-------+-----------------------------+------------------------+------------------------+--------------------+---------------------+
  5. | pr_ds | ms_group_0 | NULL | | random | read_weight=2:1 |
  6. +-------+-----------------------------+------------------------+------------------------+--------------------+---------------------+
  7. 1 row in set (0.01 sec)

静态读写分离规则和动态读写分离规则

  1. mysql> show readwrite_splitting rules from readwrite_splitting_db;
  2. +-------+-----------------------------+------------------------+------------------------+--------------------+---------------------+
  3. | name | auto_aware_data_source_name | write_data_source_name | read_data_source_names | load_balancer_type | load_balancer_props |
  4. +-------+-----------------------------+------------------------+------------------------+--------------------+---------------------+
  5. | pr_ds | ms_group_0 | write_ds | read_ds_0, read_ds_1 | random | read_weight=2:1 |
  6. +-------+-----------------------------+------------------------+------------------------+--------------------+---------------------+
  7. 1 row in set (0.00 sec)