TiDB-OPS

TiDB Cluster 使用域名部署测试

场景&问题

部署架构

域名 服务 初始IP 修改后
pd.p.cc PD 127.0.0.1 172.16.10.64
kv.p.cc PD 127.0.0.1 172.16.10.64
db.p.cc PD 127.0.0.1 172.16.10.64

PD 启动参数调整

exec bin/pd-server \
    --name="pd1" \
    --client-urls="http://0.0.0.0:2379" \
    --advertise-client-urls="http://pd.p.cc:2379" \
    --peer-urls="http://0.0.0.0:2380" \
    --advertise-peer-urls="http://pd.p.cc:2380" \
    --data-dir="/data1/domain/data.pd" \
    --initial-cluster="pd1=http://pd.p.cc:2380" \
    --config=conf/pd.toml \
    --log-file="/data1/domain/log/pd.log" 2> "/data1/domain/log/pd_stderr.log"

TiKV 参数启动示例

exec bin/tikv-server \
    --addr "0.0.0.0:20160" \
    --advertise-addr "tikv.p.cc:20160" \
    --pd "http://pd.p.cc:2379" \
    --data-dir "/data1/domain/data" \
    --config conf/tikv.toml \
    --log-file "/data1/domain/log/tikv.log" 2> "/data1/domain/log/tikv_stderr.log"

测试结果

测试修改 IP

Etcdctl 工具获取 PD 注册信息

[root@DB etcd-v3.1.11-linux-amd64]# ./etcdctl  --endpoints=0.0.0.0:2379 get --prefix --keys-only /

/pd/6545739204143641259/leader

/pd/6545739204143641259/timestamp

/pd/cluster_id
[root@DB etcd-v3.1.11-linux-amd64]# ./etcdctl  --endpoints=0.0.0.0:22379 get --prefix /pd

/pd/6545739204143641259/leader

pd1ȴ¦䇃͗http://pd.p.cc:2380"http://pd.p.cc:2379

/pd/6545739204143641259/timestamp
&»WI7

/pd/cluster_id
Zգ Tr«
[root@DB etcd-v3.1.11-linux-amd64]# ./etcdctl  --endpoints=0.0.0.0:2379 get --prefix=true /pd --write-out="json"

{
    "header": {
        "cluster_id": 8216837081137490000, 
        "member_id": 6313215679864995000, 
        "revision": 366, 
        "raft_term": 2
    }, 
    "kvs": [
        {
            "key": "L3BkLzY1NDU3MzkyMDQxNDM2NDEyNTkvbGVhZGVy", 
            "create_revision": 3, 
            "mod_revision": 3, 
            "version": 1, 
            "value": "CgNwZDEQx/SdpuSGw85XGhRodHRwOi8vcGQucC5jYzoyMjM4MCIUaHR0cDovL3BkLnAuY2M6MjIzNzk=", 
            "lease": 8811119877456664000
        }, 
        {
            "key": "L3BkLzY1NDU3MzkyMDQxNDM2NDEyNTkvdGltZXN0YW1w", 
            "create_revision": 4, 
            "mod_revision": 366, 
            "version": 363, 
            "value": "FSaDMWkxK6c="
        }, 
        {
            "key": "L3BkL2NsdXN0ZXJfaWQ=", 
            "create_revision": 2, 
            "mod_revision": 2, 
            "version": 1, 
            "value": "WtcjIBdUcqs="
        }
    ], 
    "count": 3
}
[root@DB etcd-v3.1.11-linux-amd64]# ./etcdctl  --endpoints=0.0.0.0:2379 get --prefix=true  /pd --write-out="json"

{
    "header": {
        "cluster_id": 8216837081137490000, 
        "member_id": 6313215679864995000, 
        "revision": 934, 
        "raft_term": 2
    }, 
    "kvs": [
        {
            "key": "L3BkLzY1NDU3MzkyMDQxNDM2NDEyNTkvYWxsb2NfaWQ=", 
            "create_revision": 693, 
            "mod_revision": 693, 
            "version": 1, 
            "value": "AAAAAAAAA+g="
        }, 
        {
            "key": "L3BkLzY1NDU3MzkyMDQxNDM2NDEyNTkvY29uZmln", 
            "create_revision": 697, 
            "mod_revision": 697, 
            "version": 1, 
            "value": "eyJjbGllbnQtdXJscyI6IiIsInBlZXItdXJscyI6IiIsImFkdmVydGlzZS1jbGllbnQtdXJscyI6IiIsImFkdmVydGlzZS1wZWVyLXVybHMiOiIiLCJuYW1lIjoiIiwiZGF0YS1kaXIiOiIiLCJpbml0aWFsLWNsdXN0ZXIiOiIiLCJpbml0aWFsLWNsdXN0ZXItc3RhdGUiOiIiLCJqb2luIjoiIiwibGVhc2UiOjAsImxvZyI6eyJsZXZlbCI6IiIsImZvcm1hdCI6IiIsImRpc2FibGUtdGltZXN0YW1wIjpmYWxzZSwiZmlsZSI6eyJmaWxlbmFtZSI6IiIsImxvZy1yb3RhdGUiOmZh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JlbC1wcm9wZXJ0eSI6bnVsbCwiV2FybmluZ01zZ3MiOm51bGwsIm5hbWVzcGFjZS1jbGFzc2lmaWVyIjoiIn0="
        }, 
        {
            "key": "L3BkLzY1NDU3MzkyMDQxNDM2NDEyNTkvbGVhZGVy", 
            "create_revision": 3, 
            "mod_revision": 3, 
            "version": 1, 
            "value": "CgNwZDEQx/SdpuSGw85XGhRodHRwOi8vcGQucC5jYzoyMjM4MCIUaHR0cDovL3BkLnAuY2M6MjIzNzk=", 
            "lease": 8811119877456664000
        }, 
        {
            "key": "L3BkLzY1NDU3MzkyMDQxNDM2NDEyNTkvcmFmdA==", 
            "create_revision": 694, 
            "mod_revision": 694, 
            "version": 1, 
            "value": "CKvl0bqB5MjrWhAB"
        }, 
        {
            "key": "L3BkLzY1NDU3MzkyMDQxNDM2NDEyNTkvcmFmdC9yLzAwMDAwMDAwMDAwMDAwMDAwMDAy", 
            "create_revision": 694, 
            "mod_revision": 694, 
            "version": 1, 
            "value": "CAIiBAgBEAEqBAgDEAE="
        }, 
        {
            "key": "L3BkLzY1NDU3MzkyMDQxNDM2NDEyNTkvcmFmdC9zLzAwMDAwMDAwMDAwMDAwMDAwMDAx", 
            "create_revision": 694, 
            "mod_revision": 695, 
            "version": 2, 
            "value": "CAESEjE3Mi4xNi4xMC42NToyMjE2MA=="
        }, 
        {
            "key": "L3BkLzY1NDU3MzkyMDQxNDM2NDEyNTkvcmFmdC9zLzAwMDAwMDAwMDAwMDAwMDAwMDA0", 
            "create_revision": 856, 
            "mod_revision": 856, 
            "version": 1, 
            "value": "CAQSDWt2LnAuY2M6MjIxNjA="
        }, 
        {
            "key": "L3BkLzY1NDU3MzkyMDQxNDM2NDEyNTkvcmFmdC9zdGF0dXMvcmFmdF9ib290c3RyYXBfdGltZQ==", 
            "create_revision": 694, 
            "mod_revision": 694, 
            "version": 1, 
            "value": "FSaEFqfEqcU="
        }, 
        {
            "key": "L3BkLzY1NDU3MzkyMDQxNDM2NDEyNTkvdGltZXN0YW1w", 
            "create_revision": 4, 
            "mod_revision": 934, 
            "version": 926, 
            "value": "FSaEvjZofRE="
        }, 
        {
            "key": "L3BkL2NsdXN0ZXJfaWQ=", 
            "create_revision": 2, 
            "mod_revision": 2, 
            "version": 1, 
            "value": "WtcjIBdUcqs="
        }
    ], 
    "count": 10
}
[root@DB etcd-v3.1.11-linux-amd64]# curl http://pd.p.cc:2379/pd/api/v1/stores
{
  "count": 2,
  "stores": [
    {
      "store": {
        "id": 1,
        "address": "172.16.10.65:20160", # IP 注册
        "state_name": "Down"
      },
      "status": {
        "leader_weight": 1,
        "region_weight": 1
      }
    },
    {
      "store": {
        "id": 4,
        "address": "kv.p.cc:20160", # 域名注册
        "state_name": "Up"
      },
      "status": {
        "capacity": "118 GiB",
        "available": "23 GiB",
        "leader_weight": 1,
        "region_weight": 1,
        "start_ts": "2018-04-18T19:44:51+08:00",
        "last_heartbeat_ts": "2018-04-18T19:45:51.567575991+08:00",
        "uptime": "1m0.567575991s"
      }
    }
  ]
}