鹏叔(https://pengtech.net)

导航

如何在Ubuntu 22.04上安装Sentry

Sentry 是一个免费和开源的错误跟踪平台,可以实时监控和修复崩溃。它使软件开发人员能够看到重要的东西,更快地解决问题,并不断了解他们的应用程序。这个平台提供了对生产部署的实时洞察力,并提供了重现和修复崩溃的信息。Sentry 支持所有主要的语言和框架,并与你喜欢的应用程序和服务集成。

前提条件

  • 一台运行 Ubuntu 22.04 的服务器。
  • 一个有效的域名被指向你的服务器 IP。
  • 在你的服务器上配置了一个根密码。

环境

本教程实验环境

Ubuntu 22.04.1
Docker 24.0.5
Docker-Compose 2.22.0
Sentry 23.11.0

安装所需的依赖项

在开始之前,建议将你的软件包更新到最新版本。你可以用以下命令来更新它们:

sudo apt update -y
sudo apt upgrade -y

一旦你的系统被更新,用下面的命令安装所有需要的软件包:

sudo apt-get install curl git build-essential apt-transport-https ca-certificates software-properties-common -y

安装 Docker 和 Docker Compose

默认情况下,最新版本的 Docker 和 Docker Compose 包在 Ubuntu 22.04 的默认软件库中是不可用的。所以你需要在 APT 中添加 Docker 官方仓库。

首先,用以下命令下载并添加 Docker GPG 密钥:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

接下来,用下面的命令添加 Docker 存储库:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

一旦版本库被添加,用以下命令更新版本库缓存。

sudo apt update -y

接下来,用下面的命令安装 Docker 和 Docker Compose。

sudo apt install docker -y
sudo curl -L https://github.com/docker/compose/releases/download/v2.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/bin/docker-compose

安装好这两个软件包后,用以下命令启动 Docker 服务并使其在系统重启时启动:

sudo systemctl start docker
sudo systemctl enable docker

现在你可以用下面的命令来验证 Docker 的状态:

sudo systemctl status docker

你应该得到以下输出:

? docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-01-10 04:37:27 UTC; 5s ago
TriggeredBy: ? docker.socket
       Docs: https://docs.docker.com
   Main PID: 45847 (dockerd)
      Tasks: 8
     Memory: 29.1M
        CPU: 220ms
     CGroup: /system.slice/docker.service
             ??45847 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Jan 10 04:37:26 vultr dockerd[45847]: time="2023-01-10T04:37:26.903435377Z" level=info msg="scheme \"unix\" not registered, fallback to defau>
Jan 10 04:37:26 vultr dockerd[45847]: time="2023-01-10T04:37:26.903453803Z" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:>
Jan 10 04:37:26 vultr dockerd[45847]: time="2023-01-10T04:37:26.903464761Z" level=info msg="ClientConn switching balancer to \"pick_first\"" >
Jan 10 04:37:26 vultr dockerd[45847]: time="2023-01-10T04:37:26.916581613Z" level=info msg="Loading containers: start."
Jan 10 04:37:26 vultr dockerd[45847]: time="2023-01-10T04:37:26.997807510Z" level=info msg="Default bridge (docker0) is assigned with an IP a>
Jan 10 04:37:27 vultr dockerd[45847]: time="2023-01-10T04:37:27.060381720Z" level=info msg="Loading containers: done."
Jan 10 04:37:27 vultr dockerd[45847]: time="2023-01-10T04:37:27.074467014Z" level=info msg="Docker daemon" commit=20.10.12-0ubuntu4 graphdriv>
Jan 10 04:37:27 vultr dockerd[45847]: time="2023-01-10T04:37:27.074649813Z" level=info msg="Daemon has completed initialization"
Jan 10 04:37:27 vultr systemd[1]: Started Docker Application Container Engine.
Jan 10 04:37:27 vultr dockerd[45847]: time="2023-01-10T04:37:27.092699576Z" level=info msg="API listen on /run/docker.sock"

要检查 Docker 的版本,请运行以下命令:

docker --version

你应该看到以下输出:

Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1

你也可以用以下命令检查 Docker compose 的版本:

docker-compose --version

你应该看到以下输出:

Docker Compose version v2.22.0

安装 Sentry

首先,使用以下命令从 Git 仓库下载最新版本的 Sentry:

git clone https://github.com/getsentry/onpremise

下载完成后,将目录改为下载的目录,并运行 Sentry 安装脚本,开始安装。

cd onpremise
sudo bash install.sh

自托管监控

当运行./install.sh 时,您可以选择加入或退出 sentry 官方的监控。此监控用于开发和调试目的,以便我们能够掌握您面临的问题,从而使我们能够提供更加无缝的安装过程。

请注意,从 22.11.0 版本开始,选择是否发送错误将成为强制要求。

在安装过程中,你会被要求创建一个管理员账户,如下图所示:

Here's the info we may collect:

  - OS username
  - IP address
  - install log
  - runtime errors
  - performance data

Thirty (30) day retention. No marketing. Privacy policy at sentry.io/privacy.

Would you like to create a user account now? [Y/n]: y

Email: Email: your_email@xxx.com
Password:
Repeat for confirmation:
Added to organization: sentry
User created: your_email@xxx.com
Creating missing DSNs
Correcting Group.num_comments counter

-----------------------------------------------------------------

You're all done! Run the following command to get Sentry running:

  docker-compose up -d

-----------------------------------------------------------------

接下来,使用以下命令验证所有下载的镜像。

docker images

你应该看到以下输出。

REPOSITORY                               TAG             IMAGE ID       CREATED         SIZE
vroom-cleanup-self-hosted-local          latest          ea9a97a173e4   8 hours ago     119MB
symbolicator-cleanup-self-hosted-local   latest          ddf3f91711b9   8 hours ago     139MB
sentry-cleanup-self-hosted-local         latest          3f649c2adb51   8 hours ago     1.04GB
<none>                                   <none>          e6275ee189a4   8 hours ago     1.04GB
<none>                                   <none>          ffb03d72b02c   8 hours ago     1.04GB
sentry-self-hosted-local                 latest          7e021f899f9d   8 hours ago     1.04GB
<none>                                   <none>          7e93f5ff254c   8 hours ago     1.04GB
<none>                                   <none>          cfb9b6b7e493   8 hours ago     1.04GB
<none>                                   <none>          b25501401a89   8 hours ago     1.04GB
<none>                                   <none>          83f5784ea774   8 hours ago     1.04GB
<none>                                   <none>          a25a2fe8d5dd   8 hours ago     1.04GB
<none>                                   <none>          247203428a29   8 hours ago     1.04GB
<none>                                   <none>          b317e37159df   8 hours ago     1.04GB
<none>                                   <none>          acb9c8ac94a4   8 hours ago     1.04GB
<none>                                   <none>          8798646a9a6e   8 hours ago     1.04GB
<none>                                   <none>          eeb84b793191   8 hours ago     1.04GB
<none>                                   <none>          33786daa04f9   8 hours ago     1.04GB
<none>                                   <none>          e9207519f5ea   8 hours ago     1.04GB
<none>                                   <none>          5a6bc83fb1d5   8 hours ago     1.04GB
<none>                                   <none>          284a0389a802   8 hours ago     1.04GB
<none>                                   <none>          01822573c6da   8 hours ago     1.04GB
<none>                                   <none>          863ad8d9962c   8 hours ago     1.04GB
sentry-self-hosted-jq-local              latest          802ce2121fdc   9 hours ago     76.8MB
getsentry/sentry                         nightly         fab0bb9cf072   17 hours ago    1.04GB
getsentry/relay                          nightly         da690b7dffe9   2 days ago      277MB
getsentry/snuba                          nightly         58aa2f0ddbd0   2 days ago      1.08GB
getsentry/vroom                          nightly         4248c1746c67   2 days ago      118MB
debian                                   bookworm-slim   8edcf5b83723   11 days ago     74.8MB
getsentry/symbolicator                   nightly         29b78918bd5a   2 weeks ago     137MB
nginx                                    1.25.2-alpine   661daf9bcac8   3 weeks ago     42.6MB
getsentry/sentry-cli                     latest          329fdf92d508   2 months ago    27.3MB
busybox                                  latest          a416a98b71e2   3 months ago    4.26MB
ghcr.io/maxmind/geoipupdate              v6.0.0          3fdbd1ffd226   4 months ago    15.5MB
redis                                    6.2.13-alpine   529fcf955ad4   4 months ago    28MB
memcached                                1.6.21-alpine   2db2248e0a53   4 months ago    10.3MB
postgres                                 14.5            cefd1c9e490c   12 months ago   376MB
tianon/exim4                             latest          a56a3348ddb1   21 months ago   158MB
clickhouse-self-hosted-local             latest          79441da6ab2b   22 months ago   706MB
confluentinc/cp-kafka                    5.5.7           b362671f2bc0   22 months ago   737MB
confluentinc/cp-zookeeper                5.5.7           22b646e1afd0   22 months ago   737MB
curlimages/curl                          7.77.0          e062233fb4a9   2 years ago     8.26MB

启动 Sentry 容器

在这一点上,Sentry 已经安装完毕。现在你可以使用以下命令启动 Sentry 容器:

docker-compose up -d

这将启动 Sentry 的所有容器,如下所示:

Starting sentry_onpremise_memcached_1            ... done
Starting sentry_onpremise_redis_1                ... done
Starting sentry_onpremise_symbolicator_1         ... done
Creating sentry_onpremise_symbolicator-cleanup_1 ... done
Starting sentry_onpremise_zookeeper_1            ... done
Starting sentry_onpremise_clickhouse_1           ... done
Starting sentry_onpremise_smtp_1                 ... done
Starting sentry_onpremise_postgres_1             ... done
Starting sentry_onpremise_kafka_1                ... done
Starting sentry_onpremise_snuba-consumer_1          ... done
Starting sentry_onpremise_snuba-outcomes-consumer_1 ... done
Starting sentry_onpremise_snuba-api_1               ... done
Starting sentry_onpremise_snuba-sessions-consumer_1 ... done
Starting sentry_onpremise_snuba-replacer_1          ... done
Creating sentry_onpremise_snuba-cleanup_1           ... done
Creating sentry_onpremise_relay_1                   ... done
Creating sentry_onpremise_web_1                     ... done
Creating sentry_onpremise_post-process-forwarder_1  ... done
Creating sentry_onpremise_cron_1                    ... done
Creating sentry_onpremise_sentry-cleanup_1          ... done
Creating sentry_onpremise_worker_1                  ... done
Creating sentry_onpremise_ingest-consumer_1         ... done
Creating sentry_onpremise_nginx_1                   ... done

你可以使用下面的命令验证所有容器的状态。

docker-compose ps

访问 Sentry Web UI

此时,Sentry 已经启动,并在 9000 端口上监听。现在,打开你的网页浏览器,输入网址http://your-server-ip:9000,访问 Sentry 仪表板。你将会被转到 Sentry 的登录页面.

参考文档

如何在 Ubuntu 22.04 上用 Docker 安装 Sentry

posted on 2023-11-15 05:43  eagle.supper  阅读(425)  评论(0编辑  收藏  举报