官方文檔參考:http://kylin.apache.org/cn/docs21/howto/howto_build_cube_with_restapi.html (寫的不詳細)html
帳戶:咱們使用的默認帳戶:ADMIN/KYLIN的basic認證碼爲:QURNSU46S1lMSU4=apache
格式以下:
curl -X PUT -H "Authorization: Basic QURNSU46S1lMSU4=" -H 'Content-Type: application/json' -d '{"endTime":'$endTime', "buildType":"BUILD"}' http:/$host:7070/kylin/api/cubes/$(cube_name)/rebuildjson
個人腳本:
···
‘’#!/bin/bashapi
kylinMinusTime=$((8 60 60 1000)) #8小時對應的毫秒時間,這裏是utc時間,須要+8小時
today=date -d now +%Y-%m-%d
todayTimeStamp=date -d "$today 00:00:00" +%s
todayTimeStampMs=$(($todayTimeStamp1000 + date "+%N"
/1000000)) #將current轉換爲時間戳,精確到毫秒
endTime=$(($todayTimeStampMs+$kylinMinusTime))bash
curl -X PUT -H "Authorization: Basic QURNSU46S1lMSU4=" -H 'Content-Type: application/json' -d '{"endTime":'$endTime', "buildType":"BUILD"}' http://stream5:7070/kylin/api/cubes/campaignCube/rebuild
curl -X PUT -H "Authorization: Basic QURNSU46S1lMSU4=" -H 'Content-Type: application/json' -d '{"endTime":'$endTime', "buildType":"BUILD"}' http://stream5:7070/kylin/api/cubes/salesCube/rebuild
curl -X PUT -H "Authorization: Basic QURNSU46S1lMSU4=" -H 'Content-Type: application/json' -d '{"endTime":'$endTime', "buildType":"BUILD"}' http://stream5:7070/kylin/api/cubes/marketingCube/rebuild
···app