ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
[TOC] `thanos store` 命令(也称为 Store Gateway)在对象存储桶中的历史数据之上实现 Store API。 它主要充当 API 网关,因此不需要大量的本地磁盘空间。 它在启动时加入一个 `thanos` 集群,并公布它可以访问的数据。 它在本地磁盘上保留有关所有远程块的少量信息,并使其与存储桶保持同步。 这些数据通常可以安全地在重新启动时删除,但会增加启动时间。 `thanos store` 是多副本形成高可用。多个副本的安装步骤都是一样 ## 前置环境 这里使用 `minion` 提供 S3 存储,安装minion集群,请参考 https://www.cnblogs.com/jiaxzeng/p/16206474.html 创建 Serice Accounts ![](https://img.kancloud.cn/bf/06/bf06c17135a1a1bb126ca067836ad109_1608x437.png) ![](https://img.kancloud.cn/a2/90/a290a57ae6d9ad7cffe6756b30e6d2ff_1055x499.png) 创建 thanos 桶 ![](https://img.kancloud.cn/cb/59/cb59fabc409c5cc041a4169eb8f9a501_1532x352.png) ![](https://img.kancloud.cn/81/d3/81d36733db46527bebc6be94a3cd4457_792x443.png) ## 下载thanos ```shell wget https://github.com/thanos-io/thanos/releases/download/v0.28.0/thanos-0.28.0.linux-amd64.tar.gz tar xf thanos-0.28.0.linux-amd64.tar.gz -C /opt/ cp /opt/thanos-0.28.0.linux-amd64/thanos /usr/local/bin ``` ## 创建数据目录 ```shell mkdir -p /data/thanos/store ``` ## 修改配置文件 ```shell cat <<-EOF | sudo tee /data/thanos/thanos-minio.yml > /dev/null type: s3 config: bucket: "thanos" endpoint: "192.168.31.177:9000" access_key: "voV6fk04dK40x8qx" insecure: true secret_key: "jOqC75LNJIN9hIgDyr1M0O9Pe35k7Dlk" http_config: idle_conn_timeout: 5m response_header_timeout: 10m insecure_skip_verify: true EOF chown -R ops. /data/thanos/ ``` > 注意:`access_key` 和 `secret_key` 是前置环境创建 `Serice Accounts` 保存的 ## 创建systemd服务 ```shell cat <<-EOF | sudo tee /usr/lib/systemd/system/thanos-store.service > /dev/null [Unit] Description=thanos-store Documentation=https://thanos.io/ After=network.target [Service] Type=simple User=ops Group=ops ExecStart=/usr/local/bin/thanos store \\ --grpc-address=0.0.0.0:10903 --http-address=127.0.0.1:10904 \\ --data-dir=/data/thanos/store --chunk-pool-size=8GB --max-time=30d \\ --block-sync-concurrency=200 --store.grpc.series-max-concurrency=200 \\ --objstore.config-file=/data/thanos/thanos-minio.yml ExecReload=/usr/bin/kill -HUP TimeoutStartSec=20s Restart=always LimitNOFILE=20480000 [Install] WantedBy=multi-user.target EOF ``` ## 启动服务 ```shell systemctl daemon-reload systemctl enable --now thanos-store.service systemctl is-active thanos-store.service ``` ## 验证 ```shell $ curl localhost:10904/-/healthy && echo OK ``` ## sidecar配置连接store服务 ```shell vim /usr/lib/systemd/system/thanos-sidecar.service # 启动参数添加下面的参数(文件内容,和store的objstore.config-file参数值一样) --objstore.config-file=/data/thanos/thanos-minio.yml systemctl daemon-reload systemctl restart thanos-sidecar.service curl localhost:10902/-/healthy && echo ``` ## 参考文档 https://thanos.io/tip/components/store.md/