三 副本配置
CockroachDB 副本配置可分为三个等级,集群级别>数据库级别>表级别
格式 YAML
range_min_bytes: <size-in-bytes> //
range_max_bytes: <size-in-bytes> // 默认64M
gc:
ttlseconds: <time-in-seconds> //默认24h
num_replicas: <number-of-replicas> //默认3
constraints: [comma-separated constraint list] //由于指定区域或存储类型
constraints 特别说明
a 节点启动时属性描述 cockroach start
--locality 举例:--locality=region=east,datacenter=us-east-1
--attrs 举例:--attrs=ram:64gb、ssd、hhd
--store attrs 举例: --store=path=/mnt/ssd01,attrs=ssd 、 --store=path=/mnt/hda1,attrs=hdd:7200rpm
b 语法
constraints:[+ssd] 使用
constraints:[-ssd] 禁用
基本命令
# View the replication zone for a database:
cockroach zone get <database> <flags>
# View the replication zone for a table:
cockroach zone get <database.table> <flags>
# Edit the default replication zone for the cluster:
cockroach zone set .default --file=<zone-content.yaml> <flags>
# Create/edit the replication zone for a database:
cockroach zone set <database> --file=<zone-conent.yaml> <flags>
# Create/edit the replication zone for a table:
cockroach zone set <database.table> --file=<zone-content.yaml> <flags>
# Remove the replication zone for a database:
cockroach zone rm <database> <flags>
# Remove the replication zone for a table:
cockroach zone rm <database.table> <flags>
应用场景举例
略