macOS ◆ xterm-256color ◆ zsh 5713 views

# 首先,检查 OpenTSDB 和 TSDB 是否正常运行
curl http://localhost:4242/api/version
curl http://localhost:8242/api/version

# 确认版本是否支持
# OpenTSDB 只保证 2.3.x 是兼容的
# TSDB 只保证 2.4.x 及以上版本是兼容的

# 配置任务
cd /tmp/datax
cp datax/job/job.json opentsdb2tsdb.json

{
  "job": {
    "content": [
      {
        "reader": {
          "name": "opentsdbreader",
          "parameter": {
            "endpoint": "http://localhost:4242",
            "column": [
              "m"
            ],
            "beginDateTime": "2019-01-01 00:00:00",
            "endDateTime": "2019-01-01 01:00:00"
          }
        },
        "writer": {
          "name": "tsdbwriter",
          "parameter": {
            "endpoint": "http://localhost:8242"
          }
        }
      }
    ],
    "setting": {
      "speed": {
        "channel": 1
      }
    }
  }
}

# 启动之前,确认 OpenTSDB 存在数据,而 TSDB 不存在数据
# OpenTSDB
time curl -X POST -H "Content-Type: application/json " localhost:4242/api/query -d '{"start":1546272000,"end":1546272300,"queries":[{"aggregator":"count","metric":"m","tags":{"ip":"i1"}}]}'

# TSDB
time curl -X POST -H "Content-Type: application/json " localhost:8242/api/query -d '{"start":1546272000,"end":1546272300,"queries":[{"aggregator":"count","metric":"m","tags":{"ip":"i1"}}]}'



# 通过 datax.py 脚本启动任务
python datax/bin/datax.py opentsdb2tsdb.json
# 任务已完成
# 现在,我们来检查是否写入成功
# OpenTSDB
time curl -X POST -H "Content-Type: application/json " localhost:4242/api/query -d '{"start":1546272000,"end":1546272300,"queries":[{"aggregator":"count","metric":"m","tags":{"ip":"i1"}}]}'

# TSDB
time curl -X POST -H "Content-Type: application/json " localhost:8242/api/query -d '{"start":1546272000,"end":1546272300,"queries":[{"aggregator":"count","metric":"m","tags":{"ip":"i1"}}]}'

# 恭喜!
# 数据已成功迁移!