日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
使用Loki微服務模式部署生產集群

前面我們提到了 Loki 部署的單體模式和??讀寫分離兩種模式??,當你的每天日志規(guī)模超過了 TB 的量級,那么可能我們就需要使用到微服務模式來部署 Loki 了。

專注于為中小企業(yè)提供成都做網(wǎng)站、成都網(wǎng)站制作服務,電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)寧化免費做網(wǎng)站提供優(yōu)質的服務。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了上1000家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設實現(xiàn)規(guī)模擴充和轉變。

微服務部署模式將 Loki 的組件實例化為不同的進程,每個進程都被調用并指定其目標,每個組件都會產生一個用于內部請求的 gRPC 服務器和一個用于外部 API 請求的 HTTP 服務。

  • ingester
  • distributor
  • query-frontend
  • query-scheduler
  • querier
  • index-gateway
  • ruler
  • compactor

將組件作為單獨的微服務運行允許通過增加微服務的數(shù)量來進行擴展,定制的集群對各個組件具有更好的可觀察性。微服務模式部署是最高效的 Loki 安裝,但是,它們的設置和維護也是最復雜的。

對于超大的 Loki 集群或需要對擴展和集群操作進行更多控制的集群,建議使用微服務模式。

微服務模式最適合在 Kubernetes 集群中部署,提供了 Jsonnet 和 Helm Chart 兩種安裝方式。

Helm Chart

同樣這里我們還是使用 Helm Chart 的方式來安裝微服務模式的 Loki,在安裝之前記得將前面章節(jié)安裝的 Loki 相關服務刪除。

首先獲取微服務模式的 Chart 包:

$ helm repo add grafana https://grafana.github.io/helm-charts
$ helm pull grafana/loki-distributed --untar --version 0.48.4
$ cd loki-simple-scalable

該 Chart 包支持下表中顯示的組件,Ingester、distributor、querier 和 query-frontend 組件是始終安裝的,其他組件是可選的。

組件

可選

默認開啟?

gateway

ingester

n/a

distributor

n/a

querier

n/a

query-frontend

n/a

table-manager

compactor

ruler

index-gateway

memcached-chunks

memcached-frontend

memcached-index-queries

memcached-index-writes

該 Chart 包在微服務模式下配置 Loki,已經(jīng)過測試,可以與 boltdb-shipper? 和 memberlist? 一起使用,而其他存儲和發(fā)現(xiàn)選項也可以使用,但是,該圖表不支持設置 Consul 或 Etcd 以進行發(fā)現(xiàn),它們需要進行單獨配置,相反,可以使用不需要單獨的鍵/值存儲的 memberlist。默認情況下該 Chart 包會為成員列表創(chuàng)建了一個 Headless Service,ingester、distributor、querier 和 ruler 是其中的一部分。

安裝minio

比如我們這里使用 memberlist、boltdb-shipper 和 minio 來作存儲,由于這個 Chart 包沒有包含 minio,所以需要我們先單獨安裝 minio:

$ helm repo add minio https://helm.min.io/
$ helm pull minio/minio --untar --version 8.0.10
$ cd minio

創(chuàng)建一個如下所示的 values 文件:

# ci/loki-values.yaml
accessKey: "myaccessKey"
secretKey: "mysecretKey"
persistence:
enabled: true
storageClass: "local-path"
accessMode: ReadWriteOnce
size: 5Gi
service:
type: NodePort
port: 9000
nodePort: 32000
resources:
requests:
memory: 1Gi

直接使用上面配置的 values 文件安裝 minio:

$ helm upgrade --install minio -n logging -f ci/loki-values.yaml .
Release "minio" does not exist. Installing it now.
NAME: minio
LAST DEPLOYED: Sun Jun 19 16:56:28 2022
NAMESPACE: logging
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Minio can be accessed via port 9000 on the following DNS name from within your cluster:
minio.logging.svc.cluster.local
To access Minio from localhost, run the below commands:
1. export POD_NAME=$(kubectl get pods --namespace logging -l "release=minio" -o jsonpath="{.items[0].metadata.name}")
2. kubectl port-forward $POD_NAME 9000 --namespace logging
Read more about port forwarding here: http://kubernetes.io/docs/user-guide/kubectl/kubectl_port-forward/
You can now access Minio server on http://localhost:9000. Follow the below steps to connect to Minio server with mc client:
1. Download the Minio mc client - https://docs.minio.io/docs/minio-client-quickstart-guide
2. Get the ACCESS_KEY=$(kubectl get secret minio -o jsonpath="{.data.accesskey}" | base64 --decode) and the SECRET_KEY=$(kubectl get secret minio -o jsonpath="{.data.secretkey}" | base64 --decode)
3. mc alias set minio-local http://localhost:9000 "$ACCESS_KEY" "$SECRET_KEY" --api s3v4
4. mc ls minio-local
Alternately, you can use your browser or the Minio SDK to access the server - https://docs.minio.io/categories/17

安裝完成后查看對應的 Pod 狀態(tài):

$ kubectl get pods -n logging
NAME READY STATUS RESTARTS AGE
minio-548656f786-gctk9 1/1 Running 0 2m45s
$ kubectl get svc -n logging
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
minio NodePort 10.111.58.196 9000:32000/TCP 3h16m

可以通過指定的 32000 端口來訪問 minio:

然后記得創(chuàng)建一個名為 loki-data 的 bucket。

安裝Loki

現(xiàn)在將我們的對象存儲準備好后,接下來我們來安裝微服務模式的 Loki,首先創(chuàng)建一個如下所示的 values 文件:

# ci/minio-values.yaml
loki:
structuredConfig:
ingester:
max_transfer_retries: 0
chunk_idle_period: 1h
chunk_target_size: 1536000
max_chunk_age: 1h
storage_config:
aws:
endpoint: minio.logging.svc.cluster.local:9000
insecure: true
bucketnames: loki-data
access_key_id: myaccessKey
secret_access_key: mysecretKey
s3forcepathstyle: true
boltdb_shipper:
shared_store: s3
schema_config:
configs:
- from: 2022-06-21
store: boltdb-shipper
object_store: s3
schema: v12
index:
prefix: loki_index_
period: 24h
distributor:
replicas: 2
ingester:
replicas: 2
persistence:
enabled: true
size: 1Gi
storageClass: local-path
querier:
replicas: 2
persistence:
enabled: true
size: 1Gi
storageClass: local-path
queryFrontend:
replicas: 2
gateway:
nginxConfig:
httpSnippet: |-
client_max_body_size 100M; serverSnippet: |-
client_max_body_size 100M;

上述配置會選擇性地覆蓋 loki.config 模板文件中的默認值,使用 loki.structuredConfig 可以在外部設置大多數(shù)配置參數(shù)。loki.config、loki.schemaConfig 和 loki.storageConfig 也可以與 loki.structuredConfig 結合使用。loki.structuredConfig 中的值優(yōu)先級更高。

這里我們通過 loki.structuredConfig.storage_config.aws 指定了用于保存數(shù)據(jù)的 minio 配置,為了高可用,核心的幾個組件我們配置了2個副本,ingester 和 querier 配置了持久化存儲。

現(xiàn)在使用上面的 values 文件進行一鍵安裝:

$ helm upgrade --install loki -n logging -f ci/minio-values.yaml .
Release "loki" does not exist. Installing it now.
NAME: loki
LAST DEPLOYED: Tue Jun 21 16:20:10 2022
NAMESPACE: logging
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
***********************************************************************
Welcome to Grafana Loki
Chart version: 0.48.4
Loki version: 2.5.0
***********************************************************************
Installed components:
* gateway
* ingester
* distributor
* querier
* query-frontend

上面會分別安裝幾個組件:gateway、ingester、distributor、querier、query-frontend,對應的 Pod 狀態(tài)如下所示:

$ kubectl get pods -n logging
NAME READY STATUS RESTARTS AGE
loki-loki-distributed-distributor-5dfdd5bd78-nxdq8 1/1 Running 0 2m40s
loki-loki-distributed-distributor-5dfdd5bd78-rh4gz 1/1 Running 0 116s
loki-loki-distributed-gateway-6f4cfd898c-hpszv 1/1 Running 0 21m
loki-loki-distributed-ingester-0 1/1 Running 0 96s
loki-loki-distributed-ingester-1 1/1 Running 0 2m38s
loki-loki-distributed-querier-0 1/1 Running 0 2m2s
loki-loki-distributed-querier-1 1/1 Running 0 2m33s
loki-loki-distributed-query-frontend-6d9845cb5b-p4vns 1/1 Running 0 4s
loki-loki-distributed-query-frontend-6d9845cb5b-sq5hr 1/1 Running 0 2m40s
minio-548656f786-gctk9 1/1 Running 1 (123m ago) 47h
$ kubectl get svc -n logging
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
loki-loki-distributed-distributor ClusterIP 10.102.156.127 3100/TCP,9095/TCP 22m
loki-loki-distributed-gateway ClusterIP 10.111.73.138 80/TCP 22m
loki-loki-distributed-ingester ClusterIP 10.98.238.236 3100/TCP,9095/TCP 22m
loki-loki-distributed-ingester-headless ClusterIP None 3100/TCP,9095/TCP 22m
loki-loki-distributed-memberlist ClusterIP None 7946/TCP 22m
loki-loki-distributed-querier ClusterIP 10.101.117.137 3100/TCP,9095/TCP 22m
loki-loki-distributed-querier-headless ClusterIP None 3100/TCP,9095/TCP 22m
loki-loki-distributed-query-frontend ClusterIP None 3100/TCP,9095/TCP,9096/TCP 22m
minio NodePort 10.111.58.196 9000:32000/TCP 47h

Loki 對應的配置文件如下所示:

$ kubectl get cm -n logging loki-loki-distributed -o yaml
apiVersion: v1
data:
config.yaml: |
auth_enabled: false
chunk_store_config:
max_look_back_period: 0s
compactor:
shared_store: filesystem
distributor:
ring:
kvstore:
store: memberlist
frontend:
compress_responses: true
log_queries_longer_than: 5s
tail_proxy_url: http://loki-loki-distributed-querier:3100
frontend_worker:
frontend_address: loki-loki-distributed-query-frontend:9095
ingester:
chunk_block_size: 262144
chunk_encoding: snappy
chunk_idle_period: 1h
chunk_retain_period: 1m
chunk_target_size: 1536000
lifecycler:
ring:
kvstore:
store: memberlist
replication_factor: 1
max_chunk_age: 1h
max_transfer_retries: 0
wal:
dir: /var/loki/wal
limits_config:
enforce_metric_name: false
max_cache_freshness_per_query: 10m
reject_old_samples: true
reject_old_samples_max_age: 168h
split_queries_by_interval: 15m
memberlist:
join_members:
- loki-loki-distributed-memberlist
query_range:
align_queries_with_step: true
cache_results: true
http://www.5511xx.com/article/djoogog.html