天天看點

prometheus thanos搭建

thanos叢集介紹完畢,現在開始搭建叢集。

下載下傳位址:

wget https://github.com/thanos-io/thanos/releases/download/v0.20.1/thanos-0.20.1.linux-amd64.tar.gz
           

再開始搭建之前必須準備好一個桶(bucket),在minio管理頁面建立一個prometheus-bucket,如圖:

prometheus thanos搭建

再在prometheus上建立 bucket_config.yaml

type: s3

config:

  bucket: prometheus-bucket

  endpoint: ***************   ###minio的位址加端口

  access_key: ***********

  secret_key: **********

  insecure: true

啟動sidecar

nohup ./thanos sidecar --tsdb.path "/usr/local/thanos/data" --prometheus.url "http://localhost:9090" --http-address 0.0.0.0:19191 --grpc-address 0.0.0.0:19091 --objstore.config-file /usr/local/thanos/bucket_config.yaml --shipper.upload-compacted &
           

建立store目錄

mkdir /usr/local/thanos/store
           

啟動store

nohup ./thanos store --data-dir /usr/local/thanos/data --objstore.config-file bucket_config.yaml --http-address 0.0.0.0:39191 --grpc-address 0.0.0.0:39090 &
           

啟動query

nohup ./thanos query --http-address "0.0.0.0:29090" --grpc-address "0.0.0.0:29091" --query.replica-label replica --store "172.21.231.103:19091" --store "172.21.231.104:19091" --store "172.21.231.105:19091" --store "172.21.231.103:39090" --store "172.21.231.104:39090" --store "172.21.231.105:39090" &
           

啟動compact

nohup ./thanos compact --data-dir /usr/local/thanos/compact --http-address 0.0.0.0:19192 --objstore.config-file bucket_config.yaml &
           

啟動ruler

nohup ./thanos rule --data-dir  "/usr/local/thanos/ruler_data" --eval-interval "30s" --rule-file  "/usr/local/prometheus/rules/*.yml" --alert.query-url "http://0.0.0.0:29090" --alertmanagers.url "http://172.21.231.103:9093" --query "172.21.231.103:29090" --query "172.21.231.104:29090" --objstore.config-file "bucket_config.yaml"  --label 'region="sz"' --label 'replica="A"' &
           

thanos搭建完畢

prometheus thanos搭建

繼續閱讀