读写分离
存储单元操作
REGISTER STORAGE UNIT write_ds (
HOST="127.0.0.1",
PORT=3306,
DB="ds_0",
USER="root",
PASSWORD="root"
),read_ds (
HOST="127.0.0.1",
PORT=3307,
DB="ds_0",
USER="root",
PASSWORD="root"
);
规则操作
- 创建读写分离规则
CREATE READWRITE_SPLITTING RULE group_0 (
WRITE_STORAGE_UNIT=write_ds,
READ_STORAGE_UNITS(read_ds),
TYPE(NAME="random")
);
- 修改读写分离规则
ALTER READWRITE_SPLITTING RULE group_0 (
WRITE_STORAGE_UNIT=write_ds,
READ_STORAGE_UNITS(read_ds),
TYPE(NAME="random",PROPERTIES("read_weight"="2:0"))
);
- 删除读写分离规则
DROP READWRITE_SPLITTING RULE group_0;
- 移除数据源
UNREGISTER STORAGE UNIT write_ds,read_ds;
- 删除分布式数据库
DROP DATABASE readwrite_splitting_db;
当前内容版权归 ShardingSphere 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ShardingSphere .