自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

OpenObserve HA模式安裝配置

運(yùn)維
OpenObserve 可以在裸機(jī)服務(wù)器、虛擬機(jī)、Kubernetes 和其他平臺(tái)上以 HA 模式安裝和運(yùn)行,但目前官方提供的使用 Helm Chart 的安裝方式,所以需要提前準(zhǔn)備一個(gè)可用的 Kubernetes 集群。

前面我們了解到 OpenObserve 的架構(gòu)支持單節(jié)點(diǎn)和 HA 兩種模式,接下來我們來了解下 OpenObserve 的 HA 模式是如何使用的。

OpenObserve 可以在裸機(jī)服務(wù)器、虛擬機(jī)、Kubernetes 和其他平臺(tái)上以 HA 模式安裝和運(yùn)行,但目前官方提供的使用 Helm Chart 的安裝方式,所以需要提前準(zhǔn)備一個(gè)可用的 Kubernetes 集群。

由于 HA 模式不支持本地磁盤存儲(chǔ),因此必須配置對(duì)象存儲(chǔ)(例如 s3、minio、gcs 等等),這里我們就以 minio 為例進(jìn)行說明。

首先添加 openobserve 的 helm 倉庫:

$ helm repo add openobserve https://charts.openobserve.ai
$ helm repo update
# 或者直接 clone chart 倉庫
$ git clone https://github.com/openobserve/openobserve-helm-chart.git

然后可以使用下面的命令來獲取 helm chat 包:

$ tree openobserve-helm-chart
openobserve-helm-chart
├── Chart.lock
├── Chart.yaml
├── LICENSE
├── README.md
├── charts
│   ├── etcd-8.10.1.tgz
│   ├── etcd-8.11.4.tgz
│   └── minio-5.0.7.tgz
├── index.yaml
├── publish.sh
├── templates
│   ├── NOTES.txt
│   ├── _helpers.tpl
│   ├── alertmanager-deployment.yaml
│   ├── alertmanager-service.yaml
│   ├── compactor-deployment.yaml
│   ├── compactor-hpa.yaml
│   ├── compactor-service.yaml
│   ├── configmap.yaml
│   ├── ingester-hpa.yaml
│   ├── ingester-service.yaml
│   ├── ingester-statefulset.yaml
│   ├── ingress.yaml
│   ├── issuer.yaml
│   ├── querier-deployment.yaml
│   ├── querier-hpa.yaml
│   ├── querier-service.yaml
│   ├── router-deployment.yaml
│   ├── router-hpa.yaml
│   ├── router-service.yaml
│   ├── secret.yaml
│   ├── serviceaccount.yaml
│   ├── zplane-deployment.yaml
│   ├── zplane-ingress.yaml
│   └── zplane-service.yaml
└── values.yaml

2 directories, 34 files

整個(gè)包里面還包括 etcd 和 minio 兩個(gè)依賴的 helm chart 包,創(chuàng)建一個(gè) oo-values.yaml 文件,然后添加如下內(nèi)容:

auth:
  ZO_ROOT_USER_EMAIL: "root@example.com"
  ZO_ROOT_USER_PASSWORD: "root321"

  # 啟用了 minio 不用設(shè)置這個(gè)
  # ZO_S3_ACCESS_KEY: "console"
  # ZO_S3_SECRET_KEY: "console123"

config:
  # ZO_S3_SERVER_URL: "http://minio:9000"  # 啟用了 minio 不用設(shè)置這個(gè)
  ZO_S3_BUCKET_NAME: "openobserve"
  ZO_S3_REGION_NAME: "us-east-1"
  ZO_S3_PROVIDER: "minio" # 只有在使用 minio 進(jìn)行對(duì)象存儲(chǔ)時(shí)才需要設(shè)置這個(gè),如果啟用了minio,將會(huì)自動(dòng)設(shè)置。
  ZO_TELEMETRY: "false" # 發(fā)送匿名遙測(cè)信息以改進(jìn)OpenObserve,您可以將其設(shè)置為false來禁用。
  # ZO_ETCD_ADDR: "openobserve-etcd-headless.openobserve.svc.cluster.local:2379" # etcd endpoint,啟用 etcd 會(huì)自動(dòng)配置
  ZO_DATA_DIR: "./data/" # 指定數(shù)據(jù)目錄,主要是 WAL 日志
  ZO_WAL_MEMORY_MODE_ENABLED: "false" # 開啟內(nèi)存模式,開啟后不再寫入本地文件,wal的數(shù)據(jù)直接在內(nèi)存中,然后從內(nèi)存轉(zhuǎn)存到對(duì)象存儲(chǔ),為了解決某些云服務(wù)器,本地磁盤性能很差的問題,但是需要大內(nèi)存。
  ZO_WAL_LINE_MODE_ENABLED: "true" # wal的寫入模式,一般寫入數(shù)據(jù)的時(shí)候都會(huì)批量寫入,但是這有個(gè)潛在的風(fēng)險(xiǎn)。比如你一次寫入了10k數(shù)據(jù),如果我一次性寫入wal,有可能遇到系統(tǒng)崩潰,掉電,這一批數(shù)據(jù)不知道斷在哪兒,wal文件會(huì)出錯(cuò)??赡軐懭肓艘话?。如果開啟line模式,就是雖然你是一次給了我10k數(shù)據(jù),我寫入wal的時(shí)候,一行行的調(diào)用write接口,這樣wal損壞的可能性小一些,但是性能稍微差一些。

replicaCount: # 可以根據(jù)需要調(diào)整副本數(shù)
  ingester: 1
  querier: 1
  router: 1
  alertmanager: 1
  compactor: 1

ingester:
  persistence: # 持久化 data 目錄,主要是 WAL 日志
    enabled: true
    size: 10Gi
    storageClass: "cfsauto" # 指定可用的 storage class
    accessModes:
      - ReadWriteOnce

ingress:
  enabled: true
  className: "nginx"
  annotations:
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/connection-proxy-header: keep-alive
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
    nginx.ingress.kubernetes.io/proxy-body-size: 32m
  hosts:
    - host: oo.k8s.local
      paths:
        - path: /
          pathType: ImplementationSpecific

etcd:
  enabled: true # 指定 etcd 是否啟用
  replicaCount: 1 # 奇數(shù)
  persistence:
    size: 20Gi
    storageClass: "cfsauto" # 指定可用的 storage class
    accessModes:
      - ReadWriteOnce

minio:
  enabled: true # 指定 minio 是否啟用
  region: "us-east-1"
  rootUser: rootuser
  rootPassword: rootpass123
  drivesPerNode: 1
  replicas: 2
  mode: distributed # or standalone
  buckets:
    - name: openobserve
      policy: none
      purge: false
  persistence:
    enabled: true
    size: 10Gi
    storageClass: "cfsauto" # 指定可用的 storage class
    accessModes:
      - ReadWriteOnce
  consoleIngress:
    enabled: true
    ingressClassName: "nginx"
    annotations:
      kubernetes.io/ingress.allow-http: "true"
      nginx.ingress.kubernetes.io/secure-backends: "true"
      nginx.ingress.kubernetes.io/whitelist-source-range: 0.0.0.0/0
    path: /
    hosts:
      - minio.k8s.local

在這個(gè)文件中我們指定了管理員的郵箱和密碼,還有對(duì)象存儲(chǔ)的相關(guān)配置,然后指定了 etcd 和 minio 的相關(guān)配置,要注意 auth 和 config 部分的配置,如果啟用了 minio,那么 ZO_S3_ACCESS_KEY、ZO_S3_SECRET_KEY、ZO_S3_SERVER_URL 這些配置都可以省略,因?yàn)檫@些配置項(xiàng)會(huì)自動(dòng)設(shè)置,包括如果啟用了 etcd,ZO_ETCD_ADDR 參數(shù)也會(huì)自動(dòng)配置。

另外我們可以看到 ingester 組件我們配置了數(shù)據(jù)持久化,這主要是為了對(duì) WAL 日志數(shù)據(jù)的持久化,關(guān)于 WAL 主要有兩種模式:

  • ZO_WAL_MEMORY_MODE_ENABLED: 內(nèi)存模式,開啟后不再寫入本地文件,wal 的數(shù)據(jù)直接在內(nèi)存中,然后從內(nèi)存轉(zhuǎn)存到對(duì)象存儲(chǔ),為了解決某些云服務(wù)器,本地磁盤性能很差的問題,但是需要大內(nèi)存。
  • ZO_WAL_LINE_MODE_ENABLED: WAL 的寫入模式,默認(rèn)開啟,一般寫入數(shù)據(jù)的時(shí)候都會(huì)批量寫入,但是這有個(gè)潛在的風(fēng)險(xiǎn)。比如你一次寫入了 10k 數(shù)據(jù),如果我一次性寫入 wal,有可能遇到系統(tǒng)崩潰,掉電,這一批數(shù)據(jù)不知道斷在哪兒,wal 文件會(huì)出錯(cuò)??赡軐懭肓艘话?。如果開啟 line 模式,就是雖然你是一次給了我 10k 數(shù)據(jù),我寫入 wal 的時(shí)候,一行行的調(diào)用 write 接口,這樣 wal 損壞的可能性小一些,但是性能稍微差一些。

所以如果我們使用內(nèi)存模式的話理論上可以不用持久化數(shù)據(jù)目錄,但有一種情況會(huì)落盤,就是當(dāng)內(nèi)存中還有數(shù)據(jù)的時(shí)候程序接收到關(guān)閉指令,會(huì)把內(nèi)存中的數(shù)據(jù) dump 到磁盤,下次啟動(dòng)的時(shí)候再轉(zhuǎn)移到對(duì)象存儲(chǔ)中去。

更多配置可以參考官方文檔關(guān)于環(huán)境變量的說明:https://openobserve.ai/docs/environment-variables/。

然后使用如下命令即可一件安裝 OpenObserve:

$ helm upgrade --install openobserve -f oo-values.yaml --namespace openobserve ./openobserve-helm-chart
Release "openobserve" does not exist. Installing it now.
NAME: openobserve
LAST DEPLOYED: Thu Aug 10 15:31:37 2023
NAMESPACE: openobserve
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. Get the application URL by running these commands:
  http://oo.k8s.local/

安裝后我們可以查看一下 OpenObserve 的 Pod 狀態(tài):

$ kubectl get pods -n openobserve
NAME                                        READY   STATUS    RESTARTS      AGE
openobserve-alertmanager-7957d8fb79-xzh8z   1/1     Running   4 (31m ago)   32m
openobserve-compactor-d679d4765-gpkgk       1/1     Running   4 (31m ago)   32m
openobserve-etcd-0                          1/1     Running   0             32m
openobserve-ingester-0                      1/1     Running   0             4m31s
openobserve-minio-0                         1/1     Running   0             32m
openobserve-minio-1                         1/1     Running   0             32m
openobserve-querier-56456d48c5-dth52        1/1     Running   4 (31m ago)   32m
openobserve-router-7bd4fcbc6c-nrmbs         1/1     Running   3 (32m ago)   32m
prometheus-756c8c78f5-gkwl8                 1/1     Running   0             2d
$ kubectl get svc -n openobserve
NAME                        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE
openobserve-alertmanager    ClusterIP   10.102.247.215   <none>        5080/TCP            71m
openobserve-compactor       ClusterIP   10.96.24.228     <none>        5080/TCP            71m
openobserve-etcd            ClusterIP   10.103.96.225    <none>        2379/TCP,2380/TCP   71m
openobserve-etcd-headless   ClusterIP   None             <none>        2379/TCP,2380/TCP   71m
openobserve-ingester        ClusterIP   10.108.17.186    <none>        5080/TCP            71m
openobserve-minio           ClusterIP   10.108.196.221   <none>        9000/TCP            71m
openobserve-minio-console   ClusterIP   10.103.65.90     <none>        9001/TCP            71m
openobserve-minio-svc       ClusterIP   None             <none>        9000/TCP            71m
openobserve-querier         ClusterIP   10.99.221.44     <none>        5080/TCP            71m
openobserve-router          ClusterIP   10.101.230.112   <none>        5080/TCP            71m
$ kubectl get ingress -n openobserve
NAME                        CLASS   HOSTS             ADDRESS       PORTS   AGE
openobserve                 nginx   oo.k8s.local      10.98.12.94   80      53m
openobserve-minio-console   nginx   minio.k8s.local   10.98.12.94   80      53m

可以看到 OpenObserve 的幾個(gè)組件 Router、Querier、Ingester、Alertmanager、Compactor、Minio、Etcd 都已經(jīng)正常運(yùn)行了,此外我們?yōu)?MinIO 和 OpenObserve 都添加了 Ingress,只需要將 oo.k8s.local 和 minio.k8s.local 映射到 Ingress 控制器即可訪問。

比如現(xiàn)在我們可以通過 minio.k8s.local 來訪問 MINIO 的 UI 界面:

使用用戶名 rootuser 和密碼 rootpass123 即可登錄成功。

可以看到指定的 openobserve bucket 也已經(jīng)創(chuàng)建成功了:

同樣我們也可以通過 oo.k8s.local 來訪問 OpenObserve 的 UI 界面:

只是現(xiàn)在還沒有任何數(shù)據(jù):

接下來我們只需要將前面日志、指標(biāo)、鏈路追蹤的數(shù)據(jù)發(fā)送到新的 OpenObserve 地址 http://openobserve-router.openobserve.svc.cluster.local:5080 即可,比如前面我們已經(jīng)部署的 Fluentd,只需要將日志輸出地址修改即可:

# fluentd.yaml
# ...... 省略部分配置
output.conf: |-
  <match **>
    @type http # 使用http插件
    endpoint http://openobserve-router.openobserve:5080/api/default/K8sLogs/_json # 指定接收日志的地址
    content_type json
    json_array true
    <auth>
      method basic
      username root@example.com
      password root321
    </auth>
    <buffer>
      flush_interval 2s   # 每2秒發(fā)送一次
    </buffer>
  </match>

然后重啟 fluentd 即可,隔一會(huì)兒就可以在 OpenObserve 的 UI 界面中看到日志數(shù)據(jù)了:

同樣對(duì)于 Prometheus 也是一樣的,只需要修改 Prometheus 的配置文件中的遠(yuǎn)程寫入地址即可:

remote_write: # 寫入到遠(yuǎn)程 OO,url 是遠(yuǎn)程寫入接口地址
  - url: http://openobserve-router.openobserve:5080/api/default/prometheus/api/v1/write
    basic_auth:
      username: root@example.com
      password: root321

對(duì)于鏈路追蹤數(shù)據(jù)也是一樣的,只需要修改 OpenTelemetry Collector 的配置文件中的遠(yuǎn)程寫入地址即可。

最后我們可以去 MINIO 中驗(yàn)證下數(shù)據(jù)是否已經(jīng)寫入到對(duì)象存儲(chǔ)中了:

不過需要注意的是數(shù)據(jù)并不是實(shí)時(shí)上傳到對(duì)象存儲(chǔ)中的,默認(rèn) 10 分鐘或者 WAL 達(dá)到 32MB 后會(huì)上傳一次。

到這里 OpenObserve 的 HA 模式就部署完成了,我們可以根據(jù)需要設(shè)置各個(gè)組件的副本數(shù)量進(jìn)行橫向擴(kuò)展,也可以啟用 HPA 來自動(dòng)擴(kuò)縮容。

其他更多功能請(qǐng)參考官方文檔 https://openobserve.ai/docs/ 以了解更多相關(guān)信息。

責(zé)任編輯:姜華 來源: k8s技術(shù)圈
相關(guān)推薦

2021-06-01 08:08:47

Harbor Traefik 開源

2011-02-23 10:43:17

2011-03-02 10:41:41

Vsftpd安裝

2011-04-01 15:00:35

2011-04-02 14:21:46

MRTG安裝

2011-02-25 17:48:52

2010-06-07 11:22:28

2011-02-25 17:19:09

Pureftpd安裝

2011-03-25 15:01:44

Cacti安裝

2011-03-30 15:05:40

MRTG安裝

2011-04-02 15:26:51

Cacti安裝

2011-11-08 21:55:58

MRTG 配置

2011-03-25 13:40:28

Cacti安裝配置

2011-03-11 16:42:38

Ubuntu安裝LAMP

2013-11-28 09:44:00

2011-04-02 15:26:58

Cacti安裝

2011-04-02 15:17:59

2009-06-04 20:48:15

Eclipse中安裝VEclipse中配置V

2009-07-09 15:58:40

Ubuntu JDK安

2010-09-10 20:19:34

tftp server
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)