tmcc多地域切换

最近更新时间: 2026-06-30 15:06:00

操作描述

通过命令查询tmcc组件的主备状态,并执行主备地域切换。

处理步骤

tcs master 执行:

# TCE 1 执行 TMCC API,查询当前主备状态
curl -s -XPOST -H "Content-Type: application/json" -d '{"Action":"ListCloudMetadata"}' http://$(kubectl get svc -n tce product-tcs-tmcc --no-headers  | awk '{print $3}')/apis/v1  

# API 返回样例,Role 表示主备状态
{
 "Response": {
  "CloudMetadatas": [
   {
    "CloudId": "0521d725-16f0-4c13-9e4c-379a74c07994",
    "Domain": "tce31011test.fsphere.cn",
    "Region": "ap-shenzhen-hqtest-ops",
    "Role": "master"
   },
   {
    "CloudId": "6cc28c64-3ae1-4608-80df-ad066b46ef59",
    "Domain": "tce2az31011.fsphere.cn",
    "Region": "mr-50000001",
    "Role": "slave"
   }
  ],
  "RequestId": ""
 }
}

TCE 2 执行 TMCC API,切换为主


curl -XPOST -H "Content-Type: application/json" -d '{
    "Action":"SwitchTmccMaster"
}' http://$(kubectl get svc -n tce product-tcs-tmcc --no-headers | awk '{print $3}')/apis/v1 

TCE 2 执行 TMCC API,查询当前主备状态


curl -s -XPOST -H "Content-Type: application/json" -d '{"Action":"ListCloudMetadata"}' http://$(kubectl get svc -n tce product-tcs-tmcc --no-headers  | awk '{print $3}')/apis/v1  

# API 返回样例,Role 表示主备状态
{
 "Response": {
  "CloudMetadatas": [
   {
    "CloudId": "0521d725-16f0-4c13-9e4c-379a74c07994",
    "Domain": "tce31011test.fsphere.cn",
    "Region": "ap-shenzhen-hqtest-ops",
    "Role": "master"
   },
   {
    "CloudId": "6cc28c64-3ae1-4608-80df-ad066b46ef59",
    "Domain": "tce2az31011.fsphere.cn",
    "Region": "mr-50000001",
    "Role": "slave"
   }
  ],
  "RequestId": ""
 }
}