读写分离

存储单元操作

  1. REGISTER STORAGE UNIT write_ds (
  2. HOST="127.0.0.1",
  3. PORT=3306,
  4. DB="ds_0",
  5. USER="root",
  6. PASSWORD="root"
  7. ),read_ds (
  8. HOST="127.0.0.1",
  9. PORT=3307,
  10. DB="ds_0",
  11. USER="root",
  12. PASSWORD="root"
  13. );

规则操作

  • 创建读写分离规则
  1. CREATE READWRITE_SPLITTING RULE group_0 (
  2. WRITE_STORAGE_UNIT=write_ds,
  3. READ_STORAGE_UNITS(read_ds),
  4. TYPE(NAME="random")
  5. );
  • 修改读写分离规则
  1. ALTER READWRITE_SPLITTING RULE group_0 (
  2. WRITE_STORAGE_UNIT=write_ds,
  3. READ_STORAGE_UNITS(read_ds),
  4. TYPE(NAME="random",PROPERTIES("read_weight"="2:0"))
  5. );
  • 删除读写分离规则
  1. DROP READWRITE_SPLITTING RULE group_0;
  • 移除数据源
  1. UNREGISTER STORAGE UNIT write_ds,read_ds;
  • 删除分布式数据库
  1. DROP DATABASE readwrite_splitting_db;