Sentry 高可用部署,部署分析基于Sentry 10.1.0.dev 05e720a7
對應dockerhub鏡像版本分别為:
getsentry/snuba:31c967e774759c0548652d986645fdff844e0a39
getsentry/sentry:8549f2a492c803bab77af26e7417272975b9369a
getsentry/symbolicator:94cdbb7b543ebe53744144305db21a56b6a0d5a8
Sentry官方對于自托管推薦的部署方式是Docker Compose,但這種方式有以下幾個缺點:
- 所有服務都部署在一台機器上
- 所有的元件都不是高可用的
對于生産環境來說,元件高可用是一個必備的條件,是以有了下面的高可用部署,高可用部署分為兩部分:
- Sentry依賴中間件的高可用
- Sentry本身元件的高可用
Sentry 服務
Sentry具體的服務關系及依賴,具體見下圖:
[外鍊圖檔轉存失敗,源站可能有防盜鍊機制,建議将圖檔儲存下來直接上傳(img-bRwycccO-1647422427770)(/images/sentry-high-availability-deploy/Sentry.png)]
需要注意以下幾點:
- symbolicator、symbolicator-cleanup 依賴挂載卷sentry-symbolicator:/data
- web、cron、worker、post-process-forwarder、sentry-cleanup 也依賴挂載卷,具體可以可見:https://docs.sentry.io/server/filestore/
為什麼需要關注挂載卷?
因為挂載卷依賴存儲服務,如果沒用高可用的存儲服務,Sentry自身元件就難以做到全部高可用。
部署
Sentry依賴中間件
- Sentry依賴中間件的高可用,可以通過購買雲服務商的服務來實作或者自己搭建。
- 通過修改sentry onpremise将Sentry依賴的服務替換為相關的ip或者域名,具體代碼可以參考:jiankunking/onpremise。
Sentry自身服務
将Sentry服務拆分,部署到kubernetes叢集中,具體設定參考onpremise中docker-compose.yml中的啟動指令、端口、環境變量來設定。
其中有以下幾點需要注意:
- Sentry各個服務的啟動指令,相比docker-compose.yml中command,不太一緻,簡單列一下:
- snuba api
- snuba consumer --auto-offset-reset=latest --max-batch-time-ms 750
- snuba replacer --auto-offset-reset=latest --max-batch-size 3
- symbolicator run
- sentry run web --loglevel DEBUG
- sentry run cron
- sentry run worker
- …
-
snuba api預設監聽的是127.0.0.1,修改為0.0.0.0,具體修改位置參見:
https://github.com/jiankunking/snuba/commit/69fee6253c6a78e7c2668bf6c86692e4df8fe012
-
sentry sentry/conf/server.py中KAFKA_CLUSTERS預設是localhost:9092,修改方式參見:
https://github.com/jiankunking/onpremise/blob/master/sentry/cover/server.py#L1640
-
建構sentry鏡像,當啟動指令為post-process-forwarder時,需要将自定義後的config.yml、sentry.conf.py拷貝到鏡像/etc/sentry目錄下,具體參見:
https://github.com/jiankunking/onpremise/blob/master/sentry/Dockerfile#L10
- sentry 環境變量中添加C_FORCE_ROOT=true,可以強制以root身份運作
- install.sh腳本
- 初始化clickhouse資料庫結構
- 添加初始使用者
- sentry worker依賴于sentry cron,是以不能隻部署worker,否則會有下面的錯誤提示:Background workers haven’t checked in recently. This is likely an issue with your configuration or the workers aren’t running.
小結
總的來說,将sentry部署到kubernetes中,需要注意的點還是挺多的,很多細節需要看代碼來排查。
2020-06-17 更新
Distributed tables are not officially supported.
DATASET_MODE would switch to distributed table names, but bootstrap won't work.
You would have to manage your tables (create and all DDL operations) manually.
This is not a support process, I can give you some hints, but you would be doing it at your own risk.
On the other hand, we are working on this support though we cannot commit to a timeline at this time.