我很难理解为什么CockroachDB管理控制台我的单节点设置有37个副本。
CockroachDB replicates each range (3 times by default) and stores each replica on a different node.这是直接从docs https://www.cockroachlabs.com/docs/v20.2/architecture/overview#glossary获取的
运行我看到的命令\l
database_name
-----------------
defaultdb
postgres
system
test2
(4 rows)运行命令SHOW ALL ZONE CONFIGURATIONS;,我得到了
target | raw_config_sql
---------------------------------------------------+------------------------------------------------------------------------------
RANGE default | ALTER RANGE default CONFIGURE ZONE USING
| range_min_bytes = 134217728,
| range_max_bytes = 536870912,
| gc.ttlseconds = 90000,
| num_replicas = 3,
| constraints = '[]',
| lease_preferences = '[]'
DATABASE system | ALTER DATABASE system CONFIGURE ZONE USING
| range_min_bytes = 134217728,
| range_max_bytes = 536870912,
| gc.ttlseconds = 90000,
| num_replicas = 5,
| constraints = '[]',
| lease_preferences = '[]'
RANGE meta | ALTER RANGE meta CONFIGURE ZONE USING
| range_min_bytes = 134217728,
| range_max_bytes = 536870912,
| gc.ttlseconds = 3600,
| num_replicas = 5,
| constraints = '[]',
| lease_preferences = '[]'
RANGE system | ALTER RANGE system CONFIGURE ZONE USING
| range_min_bytes = 134217728,
| range_max_bytes = 536870912,
| gc.ttlseconds = 90000,
| num_replicas = 5,
| constraints = '[]',
| lease_preferences = '[]'
RANGE liveness | ALTER RANGE liveness CONFIGURE ZONE USING
| range_min_bytes = 134217728,
| range_max_bytes = 536870912,
| gc.ttlseconds = 600,
| num_replicas = 5,
| constraints = '[]',
| lease_preferences = '[]'
TABLE system.public.replication_constraint_stats | ALTER TABLE system.public.replication_constraint_stats CONFIGURE ZONE USING
| gc.ttlseconds = 600,
| constraints = '[]',
| lease_preferences = '[]'
TABLE system.public.replication_stats | ALTER TABLE system.public.replication_stats CONFIGURE ZONE USING
| gc.ttlseconds = 600,
| constraints = '[]',
| lease_preferences = '[]'
(7 rows)我不确定37是从哪里来的,既然我只创建了数据库test2,那么它不应该只是3吗?或者,即使它复制默认的数据库,它仍然只有3*4 = 12?我的数据库都没有超过512M,所以每个数据库最多只能占用1个范围。我一定是搞错了,有人能帮我一下吗?谢谢。
发布于 2021-01-29 03:52:04
蟑螂具有相对较大数量的内部系统范围。它维护内部系统表以及其他引导元数据。Cockroach在表边界上拆分范围,以及其他一些硬编码的拆分点。您可以通过运行如下查询来发现范围集:
> SELECT start_pretty, end_pretty, database_name, table_name, replicas FROM crdb_internal.ranges_no_leases;
start_pretty | end_pretty | database_name | table_name | replicas
--------------------------------+-------------------------------+---------------+---------------------------------+-----------
/Min | /System/NodeLiveness | | | {1,2,3}
/System/NodeLiveness | /System/NodeLivenessMax | | | {1,2,3}
/System/NodeLivenessMax | /System/tsd | | | {1,2,3}
/System/tsd | /System/"tse" | | | {1,2,3}
/System/"tse" | /Table/SystemConfigSpan/Start | | | {1,2,3}
/Table/SystemConfigSpan/Start | /Table/11 | | | {1,2,3}
/Table/11 | /Table/12 | system | lease | {1,2,3}
/Table/12 | /Table/13 | system | eventlog | {1,2,3}
/Table/13 | /Table/14 | system | rangelog | {1,2,3}
/Table/14 | /Table/15 | system | ui | {1,2,3}
/Table/15 | /Table/16 | system | jobs | {1,2,3}
/Table/16 | /Table/17 | | | {1,2,3}
/Table/17 | /Table/18 | | | {1,2,3}
/Table/18 | /Table/19 | | | {1}
/Table/19 | /Table/20 | system | web_sessions | {1,2,3}
/Table/20 | /Table/21 | system | table_statistics | {1,2,3}
/Table/21 | /Table/22 | system | locations | {1,2,3}
/Table/22 | /Table/23 | | | {1,2,3}
/Table/23 | /Table/24 | system | role_members | {1,2,3}
/Table/24 | /Table/25 | system | comments | {1,2,3}
/Table/25 | /Table/26 | system | replication_constraint_stats | {1,2,3}
/Table/26 | /Table/27 | system | replication_critical_localities | {1,2,3}
/Table/27 | /Table/28 | system | replication_stats | {1,2,3}
/Table/28 | /Table/29 | system | reports_meta | {1}
/Table/29 | /NamespaceTable/30 | | | {1,2,3}
/NamespaceTable/30 | /NamespaceTable/Max | system | namespace2 | {1,2,3}
/NamespaceTable/Max | /Table/32 | system | protected_ts_meta | {1,2,3}
/Table/32 | /Table/33 | system | protected_ts_records | {1,2,3}
/Table/33 | /Table/34 | system | role_options | {1,2,3}
/Table/34 | /Table/35 | system | statement_bundle_chunks | {1,2,3}
/Table/35 | /Table/36 | system | statement_diagnostics_requests | {1,2,3}
/Table/36 | /Table/37 | system | statement_diagnostics | {1}
/Table/37 | /Table/38 | system | scheduled_jobs | {1,2,3}
/Table/38 | /Table/39 | | | {1,2,3}
/Table/39 | /Max | system | sqlliveness | {1,2,3}
(35 rows)replicas字段中的每个条目代表一个副本。希望这篇文章能给你一些关于存在哪些范围的见解。
https://stackoverflow.com/questions/65943748
复制相似问题