Sentry 是一個使用 python 寫的異常監控服務,並有支持不少語言的 SDK。python
這裏有官方部署文檔和 compose file: github.com/getsentry/o…nginx
在當前部署 sentry 時 (2019/06/20),文檔處於這個 commit 的位置 github.com/getsentry/o…git
雖然每次部署服務時的首選是看看有沒有官方以及社區 star 較多的 compose file,可是他們的 compose file 也是要大體看一看的github
本文連接: shanyue.tech/post/sentry…web
雖然這篇文章介紹 Sentry 的部署,但仍是推薦 Saas 版,省了運維麻煩,並且功能也更加齊全redis
因爲我使用了 traefik
做爲方向代理,直接修改 docker-compose.yml
,添加 label
,並把端口映射給隱去docker
你須要把 sentry.hostname.com
替換爲你將要設置的域名shell
web:
<<: *defaults
expose:
- 9000
labels:
- "traefik.frontend.rule=Host:sentry.hostname.com"
複製代碼
若是使用 nginx
做爲反向代理,設置 proxy-pass
便可,不細講。數據庫
這裏有官方部署文檔和 compose file: github.com/getsentry/o…,如下是個人部署命令bash
# 安裝以前,先看一下內存使用狀況
$ free -h
total used free shared buff/cache available
Mem: 3.7G 1.0G 204M 140M 2.5G 2.2G
Swap: 0B 0B 0B
$ git clone git@github.com:getsentry/onpremise.git
$ cd onpremise
# 建立 name volume,方便持久化,其實掛載的時候指定目錄也是同樣的。
$ docker volume create --name=sentry-data && docker volume create --name=sentry-postgres
sentry-data
sentry-postgres
# `-n` 表明不覆蓋文件,能夠理解爲 `redis` 的 `setnx` 命令
$ cp -n .env.example .env
# 生成 key 放到 .env 文件中
$ docker-compose run --rm web config generate-secret-key
# 生成數據庫,並在這一步設置超級用戶
$ docker-compose run --rm web upgrade
# 啓動服務
$ docker-compose up -d
# docker ps 查看,啓動成功,若是你沒有設置 traefik,PORTS 那一列會把端口號映射到 Host
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0acc4dedf59f onpremise_web "/entrypoint.sh run …" 4 seconds ago Up 3 seconds 9000/tcp onpremise_web_1
8eebadc9e2ff onpremise_worker "/entrypoint.sh run …" 2 minutes ago Up 2 minutes 9000/tcp onpremise_worker_1
9cce91ae40d3 onpremise_cron "/entrypoint.sh run …" 2 minutes ago Up 2 minutes 9000/tcp onpremise_cron_1
# 查看 Host 的內存消耗,與剛開始大約 600MB
$ free -h
total used free shared buff/cache available
Mem: 3.7G 1.6G 1.0G 165M 1.1G 1.6G
Swap: 0B 0B 0B
# 單獨查看 sentry 的內存消耗,大約加起來 600MB,與剛纔的數據相一致
$ docker stats | head -7
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
0acc4dedf59f onpremise_web_1 0.00% 331MiB / 3.702GiB 8.73% 328kB / 4.99MB 7.68MB / 0B 19
8eebadc9e2ff onpremise_worker_1 0.00% 138.3MiB / 3.702GiB 3.65% 2.69MB / 9.54MB 34.5MB / 0B 7
9cce91ae40d3 onpremise_cron_1 0.00% 97.52MiB / 3.702GiB 2.57% 869kB / 1.24MB 37.8MB / 156kB 3
01788eef014f onpremise_memcached_1 0.00% 8.871MiB / 3.702GiB 0.23% 261kB / 154kB 11.2MB / 0B 10
66a27f681af3 onpremise_postgres_1 0.00% 5.297MiB / 3.702GiB 0.14% 1.94MB / 1.45MB 83MB / 96.8MB 8
645fd1e25d78 onpremise_smtp_1 0.00% 800KiB / 3.702GiB 0.02% 672B / 0B 5.27MB / 57.3kB 2
複製代碼
從十五分鐘的內存使用圖表中能夠看出部署完成後有一個尖峯,後逐漸平穩了下來。
進入反向代理設置的域名 sentry.hostname.com,部署成功
歡迎關注個人公衆號山月行,在這裏記錄着個人技術成長,歡迎交流