一、前提条件
准备一台 Linux 服务器,先把 Docker Engine 和 Docker Compose 装好二、部署sentry
git clone https://github.com/getsentry/self-hosted.git
cd self-hosted
git checkout 26.3.0
./install.sh
#./install.sh 需要很久需要拉取很多镜像和初始化准备,提前给docker配置镜像加速
docker compose up --waitvi sentry/config.yml
添加下面内容 把网址改成你自己的
system.url-prefix: 'http://192.168.169.18:9000'#报错
▶ Ensuring proper PostgreSQL version ...
▶ Ensuring correct permissions on profiles directory ...
Container sentry-self-hosted-vroom-run-15b4504ed5f7 Creating
Container sentry-self-hosted-vroom-run-15b4504ed5f7 Created
▶ Bootstrapping seaweedfs (profiles)...
Container sentry-self-hosted-seaweedfs-1 Running
Container sentry-self-hosted-seaweedfs-1 Waiting
Container sentry-self-hosted-seaweedfs-1 Healthy
OK: 64.1 MiB in 55 packages
Bucket 's3://profiles/' created
Container sentry-self-hosted-kafka-1 Running
Container sentry-self-hosted-vroom-1 Creating
Container sentry-self-hosted-vroom-1 Created
Container sentry-self-hosted-kafka-1 Waiting
Container sentry-self-hosted-kafka-1 Healthy
Container sentry-self-hosted-vroom-1 Starting
Container sentry-self-hosted-vroom-1 Started
Container sentry-self-hosted-vroom-1 Waiting
Container sentry-self-hosted-kafka-1 Waiting
Container sentry-self-hosted-kafka-1 Healthy
Container sentry-self-hosted-vroom-1 Healthy
No files found in 'sentry-vroom' volume. Skipping files migration.
s3://profiles/: Lifecycle Policy updated
Making sure the bucket lifecycle policy is all set up correctly...
<?xml version="1.0" ?>
<LifecycleConfiguration>
<Rule>
<Status>Enabled</Status>
<Prefix/>
<Expiration>
<Days>90</Days>
</Expiration>
</Rule>
</LifecycleConfiguration>
▶ Setting up / migrating database ...
Container sentry-self-hosted-postgres-1 Running
Container sentry-self-hosted-postgres-1 Waiting
Container sentry-self-hosted-postgres-1 Healthy
Container sentry-self-hosted-postgres-1 Running
Container sentry-self-hosted-pgbouncer-1 Creating
Container sentry-self-hosted-pgbouncer-1 Created
Container sentry-self-hosted-postgres-1 Waiting
Container sentry-self-hosted-postgres-1 Healthy
Container sentry-self-hosted-pgbouncer-1 Starting
Container sentry-self-hosted-pgbouncer-1 Started
Container sentry-self-hosted-pgbouncer-1 Waiting
Container sentry-self-hosted-postgres-1 Waiting
Container sentry-self-hosted-postgres-1 Healthy
Container sentry-self-hosted-pgbouncer-1 Healthy
Container sentry-self-hosted-memcached-1 Creating
Container sentry-self-hosted-smtp-1 Creating
Container sentry-self-hosted-seaweedfs-1 Running
Container sentry-self-hosted-symbolicator-1 Creating
Container sentry-self-hosted-redis-1 Running
Container sentry-self-hosted-clickhouse-1 Running
Container sentry-self-hosted-kafka-1 Running
Container sentry-self-hosted-postgres-1 Running
Container sentry-self-hosted-pgbouncer-1 Running
Container sentry-self-hosted-snuba-api-1 Creating
Container sentry-self-hosted-smtp-1 Created
Container sentry-self-hosted-memcached-1 Created
Container sentry-self-hosted-snuba-api-1 Created
Container sentry-self-hosted-symbolicator-1 Created
Container sentry-self-hosted-symbolicator-1 Starting
Container sentry-self-hosted-memcached-1 Starting
Container sentry-self-hosted-clickhouse-1 Waiting
Container sentry-self-hosted-kafka-1 Waiting
Container sentry-self-hosted-redis-1 Waiting
Container sentry-self-hosted-smtp-1 Starting
Container sentry-self-hosted-postgres-1 Waiting
Container sentry-self-hosted-clickhouse-1 Healthy
Container sentry-self-hosted-postgres-1 Healthy
Container sentry-self-hosted-redis-1 Healthy
Container sentry-self-hosted-kafka-1 Healthy
Container sentry-self-hosted-snuba-api-1 Starting
Container sentry-self-hosted-symbolicator-1 Started
Container sentry-self-hosted-smtp-1 Started
Container sentry-self-hosted-memcached-1 Started
Container sentry-self-hosted-snuba-api-1 Started
Container sentry-self-hosted-redis-1 Waiting
Container sentry-self-hosted-kafka-1 Waiting
Container sentry-self-hosted-pgbouncer-1 Waiting
Container sentry-self-hosted-pgbouncer-1 Healthy
Container sentry-self-hosted-redis-1 Healthy
Container sentry-self-hosted-kafka-1 Healthy
Container sentry-self-hosted-web-run-fd8a6ea88424 Creating
Container sentry-self-hosted-web-run-fd8a6ea88424 Created
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Error opening GeoIP database: /geoip/GeoLite2-City.mmdb
Error opening GeoIP database in Rust: /geoip/GeoLite2-City.mmdb
Traceback (most recent call last):
File "/.venv/bin/sentry", line 4, in <module>
raise SystemExit(main())
~~~~^^
File "/usr/src/sentry/src/sentry/runner/main.py", line 143, in main
func(**kwargs)
~~~~^^^^^^^^^^
File "/.venv/lib/python3.13/site-packages/click/core.py", line 1442, in __call__
return self.main(*args, **kwargs)
~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.13/site-packages/click/core.py", line 1363, in main
rv = self.invoke(ctx)
File "/.venv/lib/python3.13/site-packages/click/core.py", line 1830, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/.venv/lib/python3.13/site-packages/click/core.py", line 1226, in invoke
return ctx.invoke(self.callback, **ctx.params)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.13/site-packages/click/core.py", line 794, in invoke
return callback(*args, **kwargs)
File "/.venv/lib/python3.13/site-packages/click/decorators.py", line 34, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/src/sentry/src/sentry/runner/decorators.py", line 33, in inner
configure()
~~~~~~~~~^^
File "/usr/src/sentry/src/sentry/runner/__init__.py", line 33, in configure
_configure(ctx, py, yaml, skip_service_validation)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/runner/settings.py", line 118, in configure
initialize_app(
~~~~~~~~~~~~~~^
{"config_path": py, "settings": settings, "options": yaml},
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
skip_service_validation=skip_service_validation,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/sentry/src/sentry/runner/initializer.py", line 366, in initialize_app
setup_services(validate=not skip_service_validation)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/runner/initializer.py", line 418, in setup_services
service.validate()
~~~~~~~~~~~~~~~~^^
File "/usr/src/sentry/src/sentry/utils/lazy_service_wrapper.py", line 118, in <lambda>
context[key] = (lambda f: lambda *a, **k: getattr(self, f)(*a, **k))(key)
~~~~~~~^^^^^^^^^
File "/usr/src/sentry/src/sentry/utils/lazy_service_wrapper.py", line 88, in __getattr__
self._setup()
~~~~~~~~~~~^^
File "/usr/src/sentry/src/sentry/utils/lazy_service_wrapper.py", line 72, in _setup
backend = import_string(self._backend)
File "/usr/src/sentry/src/sentry/utils/imports.py", line 29, in import_string
result = _cache[path]
~~~~~~^^^^^^
File "/usr/src/sentry/src/sentry/utils/imports.py", line 11, in __missing__
module = __import__(module_name, {}, {}, [class_name])
ModuleNotFoundError: No module named 'sentry_nodestore_s3'
Error in install/set-up-and-migrate-database.sh:23.
'$dcr web upgrade --create-kafka-topics' exited with status 1
-> ./install.sh:main:44
--> install/set-up-and-migrate-database.sh:source:23
install/error-handling.sh: line 81: /usr/bin/docker: Argument list too long
root@ubuntu:/woke/self-hosted#
vi /woke/self-hosted/sentry/sentry.conf.py
把下面内容注释或者删除
SENTRY_NODESTORE = "sentry_nodestore_s3.S3PassthroughDjangoNodeStorage"
SENTRY_NODESTORE_OPTIONS = {
...
}root@ubuntu:/woke/self-hosted# docker compose up --wait
[+] up 64/67
[+] up 68/68ntry-self-hosted_sentry-taskbroker Created
[+] up 68/68ntry-self-hosted_sentry-taskbroker Created
[+] up 73/73ntry-self-hosted_sentry-taskbroker Created
✔ Volume sentry-self-hosted_sentry-taskbroker Created
✔ Volume sentry-self-hosted_sentry-nginx-www Created
✔ Volume sentry-self-hosted_sentry-nginx-cache Created
✔ Container sentry-self-hosted-symbolicator-cleanup-1 Healthy
✔ Container sentry-self-hosted-vroom-cleanup-1 Healthy
✔ Container sentry-self-hosted-taskbroker-1 Healthy
✔ Container sentry-self-hosted-snuba-profiling-profiles-consumer-1 Healthy
✔ Container sentry-self-hosted-snuba-subscription-consumer-generic-metrics-distributions-1 Healthy
✔ Container sentry-self-hosted-snuba-eap-items-consumer-1 Healthy
✔ Container sentry-self-hosted-snuba-profiling-profile-chunks-consumer-1 Healthy
✔ Container sentry-self-hosted-snuba-subscription-consumer-generic-metrics-gauges-1 Healthy
✔ Container sentry-self-hosted-snuba-generic-metrics-gauges-consumer-1 Healthy
✔ Container sentry-self-hosted-snuba-subscription-consumer-events-1 Healthy
✔ Container sentry-self-hosted-snuba-generic-metrics-counters-consumer-1 Healthy
✔ Container sentry-self-hosted-snuba-issue-occurrence-consumer-1 Healthy
✔ Container sentry-self-hosted-snuba-replays-consumer-1 Healthy
✔ Container sentry-self-hosted-snuba-errors-consumer-1 Healthy
✔ Container sentry-self-hosted-snuba-subscription-consumer-eap-items-1 Healthy
✔ Container sentry-self-hosted-snuba-subscription-consumer-transactions-1 Healthy
✔ Container sentry-self-hosted-snuba-generic-metrics-sets-consumer-1 Healthy
✔ Container sentry-self-hosted-snuba-transactions-consumer-1 Healthy
✔ Container sentry-self-hosted-snuba-profiling-functions-consumer-1 Healthy
✔ Container sentry-self-hosted-taskworker-1 Healthy
✔ Container sentry-self-hosted-snuba-subscription-consumer-generic-metrics-counters-1 Healthy
✔ Container sentry-self-hosted-snuba-group-attributes-consumer-1 Healthy
✔ Container sentry-self-hosted-vroom-1 Healthy
✔ Container sentry-self-hosted-snuba-outcomes-consumer-1 Healthy
✔ Container sentry-self-hosted-snuba-metrics-consumer-1 Healthy
✔ Container sentry-self-hosted-ingest-occurrences-1 Healthy
✔ Container sentry-self-hosted-process-segments-1 Healthy
✔ Container sentry-self-hosted-subscription-consumer-events-1 Healthy
✔ Container sentry-self-hosted-snuba-replacer-1 Healthy
✔ Container sentry-self-hosted-subscription-consumer-eap-items-1 Healthy
✔ Container sentry-self-hosted-post-process-forwarder-issue-platform-1 Healthy
✔ Container sentry-self-hosted-snuba-outcomes-billing-consumer-1 Healthy
... 38 more 
三、测试
pip install sentry-sdkimport os
import sentry_sdk
print("当前 Python:", os.sys.executable)
print("当前读取到的 SENTRY_DSN:", os.getenv("SENTRY_DSN"))
dsn = os.getenv("SENTRY_DSN")
if not dsn:
raise RuntimeError("请先设置环境变量 SENTRY_DSN")
sentry_sdk.init(
dsn=dsn,
debug=True,
environment="dev",
release="python-test@1.0.0",
)
print("Sentry 已初始化,马上制造一个测试异常...")
division_by_zero = 1 / 0(.venv) PS C:\Users\xing\PycharmProjects\PythonProject2\.venv> python .\sentry_test.py
当前 Python: C:\Users\xing\PycharmProjects\PythonProject2\.venv\Scripts\python.exe
当前读取到的 SENTRY_DSN: http://fbd6b96105352bfd6a0142dd7f118b01@192.168.169.18:9000/1
[sentry] DEBUG: Setting up integrations (with default = True)
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.aiohttp.AioHttpIntegration: AIOHTTP not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.anthropic.AnthropicIntegration: Anthropic not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.ariadne.AriadneIntegration: ariadne is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.arq.ArqIntegration: Arq is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.asyncpg.AsyncPGIntegration: asyncpg not installed.
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.boto3.Boto3Integration: botocore is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.bottle.BottleIntegration: Bottle not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.celery.CeleryIntegration: Celery not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.chalice.ChaliceIntegration: Chalice is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.clickhouse_driver.ClickhouseDriverIntegration: clickhouse-driver not installed.
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.cohere.CohereIntegration: Cohere not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.django.DjangoIntegration: Django not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.falcon.FalconIntegration: Falcon not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.fastapi.FastApiIntegration: Starlette is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.flask.FlaskIntegration: Flask is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.gql.GQLIntegration: gql is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.google_genai.GoogleGenAIIntegration: google-genai not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.graphene.GrapheneIntegration: graphene is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.httpx.HttpxIntegration: httpx is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.huey.HueyIntegration: Huey is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.huggingface_hub.HuggingfaceHubIntegration: Huggingface not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.langchain.LangchainIntegration: langchain not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.langgraph.LanggraphIntegration: langgraph not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.litestar.LitestarIntegration: Litestar is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.loguru.LoguruIntegration: LOGURU is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.mcp.MCPIntegration: MCP SDK not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.openai.OpenAIIntegration: OpenAI not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.openai_agents.OpenAIAgentsIntegration: OpenAI Agents not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.pydantic_ai.PydanticAIIntegration: pydantic-ai not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.pymongo.PyMongoIntegration: Pymongo not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.pyramid.PyramidIntegration: Pyramid not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.quart.QuartIntegration: Quart is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.rq.RqIntegration: RQ not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.sanic.SanicIntegration: Sanic not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.sqlalchemy.SqlalchemyIntegration: SQLAlchemy not installed.
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.starlette.StarletteIntegration: Starlette is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.starlite.StarliteIntegration: Starlite is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.strawberry.StrawberryIntegration: strawberry-graphql is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.tornado.TornadoIntegration: Tornado not installed
[sentry] DEBUG: Setting up previously not enabled integration argv
[sentry] DEBUG: Setting up previously not enabled integration atexit
[sentry] DEBUG: Setting up previously not enabled integration dedupe
[sentry] DEBUG: Setting up previously not enabled integration excepthook
[sentry] DEBUG: Setting up previously not enabled integration logging
[sentry] DEBUG: Setting up previously not enabled integration modules
[sentry] DEBUG: Setting up previously not enabled integration stdlib
[sentry] DEBUG: Setting up previously not enabled integration threading
[sentry] DEBUG: Setting up previously not enabled integration redis
[sentry] DEBUG: Did not enable default integration redis: Redis client not installed
[sentry] DEBUG: Enabling integration argv
[sentry] DEBUG: Enabling integration atexit
[sentry] DEBUG: Enabling integration dedupe
[sentry] DEBUG: Enabling integration excepthook
[sentry] DEBUG: Enabling integration logging
[sentry] DEBUG: Enabling integration modules
[sentry] DEBUG: Enabling integration stdlib
[sentry] DEBUG: Enabling integration threading
[sentry] DEBUG: Setting SDK name to 'sentry.python'
[sentry] DEBUG: [Profiling] Setting up continuous profiler in thread mode
Sentry 已初始化,马上制造一个测试异常...
Traceback (most recent call last):
File "C:\Users\xing\PycharmProjects\PythonProject2\.venv\sentry_test.py", line 20, in <module>
[sentry] DEBUG: Sending envelope [envelope with 1 items (error)] project:1 host:192.168.169.18
division_by_zero = 1 / 0
ZeroDivisionError: division by zero
[sentry] DEBUG: atexit: got shutdown signal
[sentry] DEBUG: atexit: shutting down client
[sentry] DEBUG: Flushing HTTP transport
[sentry] DEBUG: background worker got flush request
[sentry] DEBUG: background worker flushed
[sentry] DEBUG: Killing HTTP transport
[sentry] DEBUG: background worker got kill request
(.venv) PS C:\Users\xing\PycharmProjects\PythonProject2\.venv>


评论 (0)