sentry部署
docker部署
GitHub:https://github.com/getsentry/self-hosted
安装环境要求
- Docker 19.03.6+
- Compose 1.28.0+
- 4 CPU Cores
- 8 GB RAM
- 20 GB Free Disk Space
环境确认
[root@localhost ~]# docker -v
Docker version 20.10.18, build b40c2f6
[root@localhost ~]# docker-compose -v
docker-compose version 1.28.6, build 5db8d86f
开始安装
拉取代码,执行安装脚本
[root@localhost ~]# git clone https://github.com/getsentry/self-hosted.git
[root@localhost ~]# cd self-hosted
[root@localhost self-hosted]# ls
certificates cloudbuild.yaml docker-compose.yml install.sh LICENSE README.md scripts test.sh
CHANGELOG.md CONTRIBUTING.md geoip _integration-test nginx relay sentry zookeeper
clickhouse cron install integration-test.sh postgres reset.sh symbolicator
[root@localhost self-hosted]# ./install.sh
按提示输入确认,创建账户
Created internal Sentry project (slug=internal, id=1)
Would you like to create a user account now? [Y/n]: y # 输入”y“确认
Email: admin@sentry.local # 输入邮箱
Password: 123456 # 输入密码
Repeat for confirmation: 123456 # 再次输入密码
Added to organization: sentry
User created: admin@sentry.local
Creating missing DSNs
Correcting Group.num_comments counter
▶ Migrating file storage ...
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
59bf1c3509f3: Pulling fs layer
59bf1c3509f3: Verifying Checksum
59bf1c3509f3: Download complete
59bf1c3509f3: Pull complete
Digest: sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300
Status: Downloaded newer image for alpine:latest
▶ Setting up GeoIP integration ...
Setting up IP address geolocation ...
Installing (empty) IP address geolocation database ... done.
IP address geolocation is not configured for updates.
See https://develop.sentry.dev/self-hosted/geolocation/ for instructions.
Error setting up IP address geolocation.
-----------------------------------------------------------------
You're all done! Run the following command to get Sentry running:
docker-compose up -d
-----------------------------------------------------------------
[root@localhost self-hosted]#
docker-compose 启动服务
[root@localhost self-hosted]# docker-compose up -d
Starting sentry-self-hosted_symbolicator_1 ... done
Starting sentry-self-hosted_zookeeper_1 ... done
Starting sentry-self-hosted_memcached_1 ... done
Recreating sentry-self-hosted_clickhouse_1 ... done
Starting sentry-self-hosted_smtp_1 ... done
Starting sentry-self-hosted_postgres_1 ... done
Starting sentry-self-hosted_redis_1 ... done
Creating sentry-self-hosted_symbolicator-cleanup_1 ... done
Creating sentry-self-hosted_geoipupdate_1 ... done
Starting sentry-self-hosted_kafka_1 ... done
Creating sentry-self-hosted_snuba-cleanup_1 ... done
Recreating sentry-self-hosted_snuba-transactions-consumer_1 ... done
Recreating sentry-self-hosted_snuba-subscription-consumer-transactions_1 ... done
Recreating sentry-self-hosted_snuba-consumer_1 ... done
Recreating sentry-self-hosted_snuba-outcomes-consumer_1 ... done
Recreating sentry-self-hosted_snuba-api_1 ... done
Creating sentry-self-hosted_snuba-transactions-cleanup_1 ... done
Recreating sentry-self-hosted_snuba-replacer_1 ... done
Recreating sentry-self-hosted_snuba-subscription-consumer-events_1 ... done
Recreating sentry-self-hosted_snuba-sessions-consumer_1 ... done
Creating sentry-self-hosted_cron_1 ... done
Creating sentry-self-hosted_worker_1 ... done
Creating sentry-self-hosted_subscription-consumer-events_1 ... done
Creating sentry-self-hosted_sentry-cleanup_1 ... done
Creating sentry-self-hosted_subscription-consumer-transactions_1 ... done
Creating sentry-self-hosted_post-process-forwarder_1 ... done
Creating sentry-self-hosted_ingest-consumer_1 ... done
Creating sentry-self-hosted_web_1 ... done
Creating sentry-self-hosted_relay_1 ... done
Creating sentry-self-hosted_nginx_1 ... done
浏览器访问:http://IP:9000,使用上面创建的用户登录
k8s部署
GitHub:https://github.com/sentry-kubernetes/charts/
测试环境说明
- Kubernetes v1.21.5
- helm v3.6.3
[root@mytest ~]# kubelet --version
Kubernetes v1.21.5
[root@mytest ~]# helm version
version.BuildInfo{Version:"v3.6.3", GitCommit:"d506314abfb5d21419df8c7e7e68012379db2354", GitTreeState:"clean", GoVersion:"go1.16.5"}
开始安装
[root@mytest ~]# kubectl create ns sentry
namespace/sentry created
[root@mytest ~]# helm repo add sentry https://sentry-kubernetes.github.io/charts
"sentry" has been added to your repositories
[root@mytest ~]# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "sentry" chart repository
Update Complete. ⎈Happy Helming!⎈
[root@mytest ~]# helm search repo sentry
NAME CHART VERSION APP VERSION DESCRIPTION
sentry/sentry 15.2.1 22.8.0 A Helm chart for Kubernetes
sentry/sentry-db 0.9.4 10.0.0 A Helm chart for Kubernetes
sentry/sentry-kubernetes 0.3.2 latest A Helm chart for sentry-kubernetes (https://git...
sentry/clickhouse 3.1.3 19.14 ClickHouse is an open source column-oriented da...
[root@mytest ~]# helm install sentry sentry/sentry --version 15.2.1 -n sentry
coalesce.go:163: warning: skipped value for config: Not a table.
Error: failed post-install: job failed: DeadlineExceeded
## warnings忽略即可
修改配置
等待pod都起来
[root@mytest ~]# kubectl get po -n sentry
NAME READY STATUS RESTARTS AGE
sentry-clickhouse-0 1/1 Running 0 3m30s
sentry-clickhouse-1 1/1 Running 0 3m30s
sentry-clickhouse-2 1/1 Running 0 3m29s
sentry-cron-dcd468579-9s8nx 1/1 Running 3 3m30s
sentry-kafka-0 1/1 Running 3 3m30s
sentry-kafka-1 1/1 Running 3 3m30s
sentry-kafka-2 1/1 Running 2 3m30s
sentry-nginx-6d668df4c5-nw7x5 1/1 Running 0 3m30s
sentry-rabbitmq-0 1/1 Running 0 3m30s
sentry-rabbitmq-1 1/1 Running 0 87s
sentry-rabbitmq-2 0/1 Running 0 21s
sentry-sentry-postgresql-0 1/1 Running 0 3m30s
sentry-sentry-redis-master-0 1/1 Running 0 3m29s
sentry-sentry-redis-replicas-0 1/1 Running 2 3m30s
sentry-sentry-redis-replicas-1 1/1 Running 0 84s
sentry-sentry-redis-replicas-2 1/1 Running 0 54s
sentry-snuba-api-84b4b74f6f-xzrpf 1/1 Running 0 3m30s
sentry-web-ddcff7558-p5hz8 1/1 Running 3 3m30s
sentry-worker-867747d7cc-8jpfv 1/1 Running 3 3m30s
sentry-worker-867747d7cc-fdfnl 1/1 Running 3 3m30s
sentry-worker-867747d7cc-ffmsc 1/1 Running 3 3m30s
sentry-zookeeper-0 1/1 Running 0 3m29s
sentry-zookeeper-clickhouse-0 1/1 Running 0 3m30s
sentry-zookeeper-clickhouse-1 1/1 Running 0 3m30s
sentry-zookeeper-clickhouse-2 1/1 Running 0 3m29s
[root@mytest ~]# kubectl get po -n sentry |wc -l
26
默认所有的service类型都是ClusterIP
[root@mytest ~]# kubectl get svc -n sentry
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
sentry-clickhouse ClusterIP 10.233.60.236 <none> 9000/TCP,8123/TCP,9009/TCP 6m20s
sentry-clickhouse-headless ClusterIP None <none> 9000/TCP,8123/TCP,9009/TCP 6m20s
sentry-kafka ClusterIP 10.233.31.221 <none> 9092/TCP 6m20s
sentry-kafka-headless ClusterIP None <none> 9092/TCP,9093/TCP 6m20s
sentry-nginx ClusterIP 10.233.0.231 <none> 80/TCP 6m20s
sentry-rabbitmq ClusterIP 10.233.5.19 <none> 5672/TCP,4369/TCP,25672/TCP,15672/TCP 6m20s
sentry-rabbitmq-headless ClusterIP None <none> 4369/TCP,5672/TCP,25672/TCP,15672/TCP 6m20s
sentry-relay ClusterIP 10.233.10.196 <none> 3000/TCP 6m20s
sentry-sentry-postgresql ClusterIP 10.233.9.145 <none> 5432/TCP 6m20s
sentry-sentry-postgresql-headless ClusterIP None <none> 5432/TCP 6m20s
sentry-sentry-redis-headless ClusterIP None <none> 6379/TCP 6m20s
sentry-sentry-redis-master ClusterIP 10.233.14.93 <none> 6379/TCP 6m20s
sentry-sentry-redis-replicas ClusterIP 10.233.33.109 <none> 6379/TCP 6m20s
sentry-snuba ClusterIP 10.233.28.164 <none> 1218/TCP 6m20s
sentry-web ClusterIP 10.233.37.228 <none> 9000/TCP 6m20s
sentry-zookeeper ClusterIP 10.233.8.116 <none> 2181/TCP,2888/TCP,3888/TCP 6m20s
sentry-zookeeper-clickhouse ClusterIP 10.233.48.88 <none> 2181/TCP,2888/TCP,3888/TCP 6m20s
sentry-zookeeper-clickhouse-headless ClusterIP None <none> 2181/TCP,2888/TCP,3888/TCP 6m20s
sentry-zookeeper-headless ClusterIP None <none> 2181/TCP,2888/TCP,3888/TCP 6m20s
编辑sentry-web的service
[root@mytest ~]# kubectl edit svc -n sentry sentry-web
将ClusterIP修改为NodePort
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
kind: Service
metadata:
annotations:
meta.helm.sh/release-name: sentry
meta.helm.sh/release-namespace: sentry
creationTimestamp: "2022-09-15T03:17:01Z"
labels:
app: sentry
app.kubernetes.io/managed-by: Helm
chart: sentry-15.2.1
heritage: Helm
release: sentry
name: sentry-web
namespace: sentry
resourceVersion: "162316"
uid: e71130a1-5fd3-4838-98a7-0e7c93ca92b3
spec:
clusterIP: 10.233.37.228
clusterIPs:
- 10.233.37.228
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: sentry
port: 9000
protocol: TCP
targetPort: 9000
selector:
app: sentry
role: web
sessionAffinity: None
type: NodePort #将原来的 ClusterIP 修改为 NodePort,然后保存退出
status:
loadBalancer: {}
查看对外暴露的端口
[root@mytest ~]# kubectl get svc -n sentry |grep sentry-web
sentry-web NodePort 10.233.37.228 <none> 9000:30579/TCP 21m
浏览器访问测试:http://IP:30579,页面无法找到,但地址栏中可以可能到,此时请求已经跳转到:http://IP:30579/auth/login/
经过一番资料搜索,这里需要进入容器内手动执行初始化和创建用户
[root@mytest ~]# kubectl get pod -n sentry |grep sentry-web
sentry-web-ddcff7558-p5hz8 1/1 Running 3 39m
[root@mytest ~]# kubectl exec -it -n sentry sentry-web-ddcff7558-p5hz8 /bin/bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
root@sentry-web-ddcff7558-p5hz8:/# sentry upgrade # 执行初始化
03:57:46 [WARNING] sentry.utils.geo: settings.GEOIP_PATH_MMDB not configured.
03:57:50 [INFO] sentry.plugins.github: apps-not-configured
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/sentry_sdk/integrations/redis.py", line 123, in setup_once
_patch_rediscluster()
File "/usr/local/lib/python3.8/site-packages/sentry_sdk/integrations/redis.py", line 88, in _patch_rediscluster
pipeline_cls = rediscluster.ClusterPipeline
AttributeError: module 'rediscluster' has no attribute 'ClusterPipeline'
03:57:51 [ERROR] sentry_sdk.errors: Error occurred while patching `rediscluster` library
Running migrations for default
Operations to perform:
Apply all migrations: admin, auth, contenttypes, nodestore, replays, sentry, sessions, sites, social_auth
Running migrations:
Applying sentry.0001_squashed_0200_release_indices... OK
Applying contenttypes.0001_initial... OK
...中间输出信息...
Applying sites.0002_alter_domain_unique... OK
Applying social_auth.0001_initial... OK
03:59:07 [WARNING] sentry: Cannot initiate onboarding for organization (1) due to missing owners
Created internal Sentry project (slug=internal, id=1)
Would you like to create a user account now? [Y/n]: y # 输入”y“确认
Email: admin@sentry.local # 输入邮箱
Password: 123456 # 输入密码
Repeat for confirmation: 123456 # 再次输入密码
--staff/--no-staff not specified, matching superuser value.
Added to organization: sentry
User created: admin@sentry.local
Creating missing DSNs
Correcting Group.num_comments counter
root@sentry-web-ddcff7558-p5hz8:/# exit
exit
[root@mytest ~]#
再次访问:http://IP:30579,使用上面创建的用户登录
卸载sentry
helm uninstall -n sentry sentry
kubectl delete ns sentry