读写分离

资源操作

  1. ADD RESOURCE 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_RESOURCE=write_ds,
  3. READ_RESOURCES(read_ds),
  4. TYPE(NAME=random)
  5. );
  • 修改读写分离规则
  1. ALTER READWRITE_SPLITTING RULE group_0 (
  2. WRITE_RESOURCE=write_ds,
  3. READ_RESOURCES(read_ds),
  4. TYPE(NAME=random,PROPERTIES(read_weight='2:0'))
  5. );
  • 删除读写分离规则
  1. DROP READWRITE_SPLITTING RULE group_0;
  • 删除数据源
  1. DROP RESOURCE write_ds,read_ds;
  • 删除分布式数据库
  1. DROP DATABASE readwrite_splitting_db;