原始网页:https://www.cockroachlabs.com/docs/stable/enable-node-map.html#capacity-used-value-displayed-is-more-than-configured-capacity


(New in v2.0) 节点地图通过在世界地图上绘制节点来可视化多区域群集的地理配置。节点地图能够实时监控集群指标,能够深入到单个节点以监视集群健康状况和性能情况,方便进行故障排除。

本小节将展示如何配置并开启节点地图。

NOTE: 节点地图功能属于企业版功能,需要获取企业版License 图片

开启节点地图

开启节点地图,首先需要用户在启动节点的时候,使用—localityFlag指定节点的地理位置,同时需要配置每个地理位置的经纬度。

NOTE: 只有在设置完节点的—locality属性和每个地理位置的经纬度以后,CockroachDB才会在节点地图上绘制对应的节点。

假设用户需要配置4个部署在不同地方的节点:

节点 位置 数据中心
Node1 us-east-1 us-east-1a
Node2 us-east-1 us-east-1b
Node3 us-west-1 us-west-1a
Node4 eu-west-1 eu-west-1a

Step 1: 版本检查

确保CockroachDB版本不低于2.0

cockroach version

Build Tag:   v2.0.5
Build Time:  2018/08/13 14:48:26 (go1.10)
Distribution: CCL
Platform:     darwin amd64 (x86_64-apple-darwin13)
Go Version:   go1.10
C Compiler:   4.2.1 Compatible Clang 3.8.0 (tags/RELEASE_380/final)
Build SHA-1:  367ad4f673b33694df06caaa2d7fc63afaaf3053
Build Type:   release

如果版本低于2.0,需要用户先升级CockroachDB到2.0版本

Step 2: 使用--localityFlag启动节点

#启动节点1 
cockroach start --insecure --locality=region=us-east-1,datacenter=us-east-1a  --host=<node1 address> --cache=.25 --max-sql-memory=.25 --join=<node1 address>:26257,<node2 address>:26257,<node3 address>:26257,<node4 address>:26257

# 启动节点2
cockroach start --insecure --locality=region=us-east-1,datacenter=us-east-1b --host=<node2 address> --cache=.25 --max-sql-memory=.25 --join=<node1 address>:26257,<node2 address>:26257,<node3 address>:26257,<node4 address>:26257

# 启动节点3
cockroach start --insecure --locality=region=us-west-1,datacenter=us-west-1a --host=<node3 address> --cache=.25 --max-sql-memory=.25 --join=<node1 address>:26257,<node2 address>:26257,<node3 address>:26257,<node4 address>:26257

# 启动节点4
cockroach start --insecure --locality=region=eu-west-1,datacenter=eu-west-1a --host=<node4 address> --cache=.25 --max-sql-memory=.25 --join=<node1 address>:26257,<node2 address>:26257,<node3 address>:26257,<node4 address>:26257

启动节点以后,使用cockroach init初始化集群。

cockroach init --insecure

登陆Admin界面,显示如下: 图片

Step 3: 设置企业版License

用户需要参考文档设置企业版License

在设置完企业版License之后,登陆Admin界面,显示如下: 图片

Step 4: 设置经纬度信息

启动内置的SQL客户端

cockroach sql --insecure --host=<address of any node>

执行INSERT语句插入经纬度信息:

INSERT INTO system.locations VALUES
  ('region', 'us-east-1', 37.478397, -76.453077),
  ('region', 'us-west-1', 38.837522, -120.895824),
  ('region', 'eu-west-1', 53.142367, -7.692054);

关于AWS、Azure、Google云的区域经纬度信息,本小节最后部分将展示以上云服务商的区域坐标,提供给用户用做参考。

Step 5: 查看节点地图

登陆Admin界面,在Overview页中点击查看Node Map图片

Step 6: 节点地图导航

假设用户需要查看位于区域us-east-1的数据中心us-east-1a的节点2的详细信息:

图片

相关问题定位

节点地图无法显示

只有在设置完节点的—locality属性和每个地理位置的经纬度以后,CockroachDB才会在节点地图上绘制对应的节点。

用户可以通过Admin界面的Localities Debug页(https://<address of any node>:8080/#/reports/localities)检查是否正确配置节点的locality属性和地理位置经纬度信息。

Localities Debug页中,将显示如下内容:

部分地理位置层级未显示在地图上

节点地图只会在地图上显示地理位置层级中配置了经纬度信息的某些层。 上述场景中,假使:

以此类推,用户可以根据自己的需求设置经纬度信息,定义节点地图上节点的显示形式。

已知限制

重名问题

假设节点地理位置信息如下:

节点 区域 数据中心
Node1 us-east datacenter-1
Node2 us-west datacenter-1

该场景下即使节点1和节点2的所在区域不同,但是由于数据中心名相同,在执行INSERT语句插入数据中心的经纬度信息时,将显示“primary key exists”错误。

节点使用空间超过空间限制

假设多个节点运行在同一台机器上(CockroachDB不推荐一机多节点的部署形式),且每个节点未使用--storeFlag指定最大存储空间,则在Admin界面将显示节点使用空间的数值异常。

地理坐标参考

AWS区域

地域 SQL语句
US East (N. Virginia) INSERT into system.locations VALUES ('region', 'us-east-1', 37.478397, -76.453077)
US East (Ohio) INSERT into system.locations VALUES ('region', 'us-east-2', 40.417287, -76.453077)
US West (N. California) INSERT into system.locations VALUES ('region', 'us-west-1', 38.837522, -120.895824)
US West (Oregon) INSERT into system.locations VALUES ('region', 'us-west-2', 43.804133, -120.554201)
Canada (Central) INSERT into system.locations VALUES ('region', 'ca-central-1', 56.130366, -106.346771)
EU (Frankfurt) INSERT into system.locations VALUES ('region', 'eu-central-1', 50.110922, 8.682127)
EU (Ireland) INSERT into system.locations VALUES ('region', 'eu-west-1', 53.142367, -7.692054)
EU (London) INSERT into system.locations VALUES ('region', 'eu-west-2', 51.507351, -0.127758)
EU (Paris) INSERT into system.locations VALUES ('region', 'eu-west-3', 48.856614, 2.352222)
Asia Pacific (Tokyo) INSERT into system.locations VALUES ('region', 'ap-northeast-1', 35.689487, 139.691706)
Asia Pacific (Seoul) INSERT into system.locations VALUES ('region', 'ap-northeast-2', 37.566535, 126.977969)
Asia Pacific (Osaka-Local) INSERT into system.locations VALUES ('region', 'ap-northeast-3', 34.693738, 135.502165)
Asia Pacific (Singapore) INSERT into system.locations VALUES ('region', 'ap-southeast-1', 1.352083, 103.819836)
Asia Pacific (Sydney) INSERT into system.locations VALUES ('region', 'ap-southeast-2', -33.86882, 151.209296)
Asia Pacific (Mumbai) INSERT into system.locations VALUES ('region', 'ap-south-1', 19.075984, 72.877656)
South America (São Paulo) INSERT into system.locations VALUES ('region', 'sa-east-1', -23.55052, -46.633309)

Azure区域

地域 SQL语句
eastasia (East Asia) INSERT into system.locations VALUES ('region', 'eastasia', 22.267, 114.188)
southeastasia (Southeast Asia) INSERT into system.locations VALUES ('region', 'southeastasia', 1.283, 103.833)
centralus (Central US) INSERT into system.locations VALUES ('region', 'centralus', 41.5908, -93.6208)
eastus (East US) INSERT into system.locations VALUES ('region', 'eastus', 37.3719, -79.8164)
eastus2 (East US 2) INSERT into system.locations VALUES ('region', 'eastus2', 36.6681, -78.3889)
westus (West US) INSERT into system.locations VALUES ('region', 'westus', 37.783, -122.417)
northcentralus (North Central US) INSERT into system.locations VALUES ('region', 'northcentralus', 41.8819, -87.6278)
southcentralus (South Central US) INSERT into system.locations VALUES ('region', 'southcentralus', 29.4167, -98.5)
northeurope (North Europe) INSERT into system.locations VALUES ('region', 'northeurope', 53.3478, -6.2597)
westeurope (West Europe) INSERT into system.locations VALUES ('region', 'westeurope', 52.3667, 4.9)
japanwest (Japan West) INSERT into system.locations VALUES ('region', 'japanwest', 34.6939, 135.5022)
japaneast (Japan East) INSERT into system.locations VALUES ('region', 'japaneast', 35.68, 139.77)
brazilsouth (Brazil South) INSERT into system.locations VALUES ('region', 'brazilsouth', -23.55, -46.633)
australiaeast (Australia East) INSERT into system.locations VALUES ('region', 'australiaeast', -33.86, 151.2094)
australiasoutheast (Australia Southeast) INSERT into system.locations VALUES ('region', 'australiasoutheast', -37.8136, 144.9631)
southindia (South India) INSERT into system.locations VALUES ('region', 'southindia', 12.9822, 80.1636)
centralindia (Central India) INSERT into system.locations VALUES ('region', 'centralindia', 18.5822, 73.9197)
westindia (West India) INSERT into system.locations VALUES ('region', 'westindia', 19.088, 72.868)
canadacentral (Canada Central) INSERT into system.locations VALUES ('region', 'canadacentral', 43.653, -79.383)
canadaeast (Canada East) INSERT into system.locations VALUES ('region', 'canadaeast', 46.817, -71.217)
uksouth (UK South) INSERT into system.locations VALUES ('region', 'uksouth', 50.941, -0.799)
ukwest (UK West) INSERT into system.locations VALUES ('region', 'ukwest', 53.427, -3.084)
westcentralus (West Central US) INSERT into system.locations VALUES ('region', 'westcentralus', 40.890, -110.234)
westus2 (West US 2) INSERT into system.locations VALUES ('region', 'westus2', 47.233, -119.852)
koreacentral (Korea Central) INSERT into system.locations VALUES ('region', 'koreacentral', 37.5665, 126.9780)
koreasouth (Korea South) INSERT into system.locations VALUES ('region', 'koreasouth', 35.1796, 129.0756)
francecentral (France Central) INSERT into system.locations VALUES ('region', 'francecentral', 46.3772, 2.3730)
francesouth (France South) INSERT into system.locations VALUES ('region', 'francesouth', 43.8345, 2.1972)

Google云

地域 SQL语句
us-east1 (South Carolina) INSERT into system.locations VALUES ('region', 'us-east1', 33.836082, -81.163727)
us-east4 (N. Virginia) INSERT into system.locations VALUES ('region', 'us-east4', 37.478397, -76.453077)
us-central1 (Iowa) INSERT into system.locations VALUES ('region', 'us-central1', 42.032974, -93.581543)
us-west1 (Oregon) INSERT into system.locations VALUES ('region', 'us-west1', 43.804133, -120.554201)
northamerica-northeast1 (Montreal) INSERT into system.locations VALUES ('region', 'northamerica-northeast1', 56.130366, -106.346771)
europe-west1 (Belgium) INSERT into system.locations VALUES ('region', 'europe-west1', 50.44816, 3.81886)
europe-west3 (Frankfurt) INSERT into system.locations VALUES ('region', 'europe-west3', 50.110922, 8.682127)
europe-west4 (Netherlands) INSERT into system.locations VALUES ('region', 'europe-west4', 53.4386, 6.8355)
europe-west2 (London) INSERT into system.locations VALUES ('region', 'europe-west2', 51.507351, -0.127758)
asia-east1 (Taiwan) INSERT into system.locations VALUES ('region', 'asia-east1', 24.0717, 120.5624)
asia-northeast1 (Tokyo) INSERT into system.locations VALUES ('region', 'asia-northeast1', 35.689487, 139.691706)
asia-southeast1 (Singapore) INSERT into system.locations VALUES ('region', 'asia-southeast1', 1.352083, 103.819836)
australia-southeast1 (Sydney) INSERT into system.locations VALUES ('region', 'australia-southeast1', -33.86882, 151.209296)
asia-south1 (Mumbai) INSERT into system.locations VALUES ('region', 'asia-south1', 19.075984, 72.877656)
southamerica-east1 (São Paulo) INSERT into system.locations VALUES ('region', 'southamerica-east1', -23.55052, -46.633309)