帮助中心
如何在Ubuntu 22.04上用Docker安装Sentry



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

前提条件

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

安装所需的依赖项


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

apt update -y
apt upgrade -y

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

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 | 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" | tee /etc/apt/sources.list.d/docker.list > /dev/null

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

apt update -y

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

apt install docker docker-compose -y

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

systemctl start docker
systemctl enable docker

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

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 20.10.12, build 20.10.12-0ubuntu4

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

docker-compose --version

你应该看到以下输出:

docker-compose version 1.29.2, build unknown


安装Sentry


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

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

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

cd onpremise
bash install.sh

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

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: hitjethva81@gmail.com
Password: 
Repeat for confirmation: 
Added to organization: sentry
User created: hitjethva81@gmail.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
sentry-cleanup-self-hosted-local         latest          04fa0fce18f0   4 minutes ago       908MB
symbolicator-cleanup-self-hosted-local   latest          6837f5f48e6c   5 minutes ago       180MB
snuba-cleanup-self-hosted-local          latest          242b7b248e1c   5 minutes ago       486MB
sentry-self-hosted-local                 latest          101b00356aa6   5 minutes ago       907MB
sentry-self-hosted-jq-local              latest          83c66fd3f78f   6 minutes ago       82.5MB
getsentry/sentry                         nightly         cf0f404d102e   About an hour ago   907MB
getsentry/snuba                          nightly         fc6c2d286bf8   8 hours ago         484MB
getsentry/relay                          nightly         43cd2ba5497c   5 days ago          242MB
busybox                                  latest          66ba00ad3de8   6 days ago          4.87MB
tianon/exim4                             latest          12842ac621c1   2 weeks ago         158MB
debian                                   bullseye-slim   dd94cb611937   2 weeks ago         80.5MB
getsentry/sentry-cli                     latest          a585383ff864   2 weeks ago         26.3MB
getsentry/symbolicator                   nightly         80d9b41cd195   3 weeks ago         178MB
nginx                                    1.22.0-alpine   5685937b6bc1   3 months ago        23.5MB
postgres                                 9.6             027ccf656dc1   11 months ago       200MB
confluentinc/cp-kafka                    5.5.0           efc480c1c89c   15 months ago       598MB
confluentinc/cp-zookeeper                5.5.0           ddeb961d8e80   15 months ago       598MB
redis                                    6.2.4-alpine    500703a12fa4   18 months ago       32.3MB
memcached                                1.6.9-alpine    a0132b3398e4   18 months ago       8.09MB
curlimages/curl                          7.77.0          e062233fb4a9   19 months ago       8.26MB
maxmindinc/geoipupdate                   v4.7.1          8ec32cc727c7   21 months ago       10.6MB
clickhouse-self-hosted-local             latest          abe55fc6544d   2 years ago         497MB
yandex/clickhouse-server                 20.3.9.70       abe55fc6544d   2 years ago         497MB


启动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

你应该看到下面的输出:

                        Name                                        Command                  State                      Ports                
----------------------------------------------------------------------------------------------------------------------------------------------
sentry-self-hosted_clickhouse_1                           /entrypoint.sh                   Up (healthy)   8123/tcp, 9000/tcp, 9009/tcp        
sentry-self-hosted_cron_1                                 /etc/sentry/entrypoint.sh  ...   Up             9000/tcp                            
sentry-self-hosted_geoipupdate_1                          /usr/bin/geoipupdate -d /s ...   Exit 1                                             
sentry-self-hosted_ingest-consumer_1                      /etc/sentry/entrypoint.sh  ...   Up             9000/tcp                            
sentry-self-hosted_kafka_1                                /etc/confluent/docker/run        Up (healthy)   9092/tcp                            
sentry-self-hosted_memcached_1                            docker-entrypoint.sh memcached   Up (healthy)   11211/tcp                           
sentry-self-hosted_nginx_1                                /docker-entrypoint.sh ngin ...   Up             0.0.0.0:9000->80/tcp,:::9000->80/tcp
sentry-self-hosted_post-process-forwarder-errors_1        /etc/sentry/entrypoint.sh  ...   Up             9000/tcp                            
sentry-self-hosted_post-process-forwarder-                /etc/sentry/entrypoint.sh  ...   Up             9000/tcp                            
transactions_1                                                                                                                                
sentry-self-hosted_postgres_1                             /opt/sentry/postgres-entry ...   Up (healthy)   5432/tcp                            
sentry-self-hosted_redis_1                                docker-entrypoint.sh redis ...   Up (healthy)   6379/tcp                            
sentry-self-hosted_relay_1                                /bin/bash /docker-entrypoi ...   Up             3000/tcp                            
sentry-self-hosted_sentry-cleanup_1                       /entrypoint.sh 0 0 * * * g ...   Up             9000/tcp                            
sentry-self-hosted_smtp_1                                 docker-entrypoint.sh exim  ...   Up             25/tcp                              
sentry-self-hosted_snuba-api_1                            ./docker_entrypoint.sh api       Up             1218/tcp                            
sentry-self-hosted_snuba-cleanup_1                        /entrypoint.sh */5 * * * * ...   Up             1218/tcp                            
sentry-self-hosted_snuba-consumer_1                       ./docker_entrypoint.sh con ...   Up             1218/tcp                            
sentry-self-hosted_snuba-outcomes-consumer_1              ./docker_entrypoint.sh con ...   Up             1218/tcp                            
sentry-self-hosted_snuba-replacer_1                       ./docker_entrypoint.sh rep ...   Up             1218/tcp                            
sentry-self-hosted_snuba-sessions-consumer_1              ./docker_entrypoint.sh con ...   Up             1218/tcp                            
sentry-self-hosted_snuba-subscription-consumer-events_1   ./docker_entrypoint.sh sub ...   Up             1218/tcp                            
sentry-self-hosted_snuba-subscription-consumer-           ./docker_entrypoint.sh sub ...   Up             1218/tcp                            
transactions_1                                                                                                                                
sentry-self-hosted_snuba-transactions-cleanup_1           /entrypoint.sh */5 * * * * ...   Up             1218/tcp                            
sentry-self-hosted_snuba-transactions-consumer_1          ./docker_entrypoint.sh con ...   Up             1218/tcp                            
sentry-self-hosted_subscription-consumer-events_1         /etc/sentry/entrypoint.sh  ...   Up             9000/tcp                            
sentry-self-hosted_subscription-consumer-transactions_1   /etc/sentry/entrypoint.sh  ...   Up             9000/tcp                            
sentry-self-hosted_symbolicator-cleanup_1                 /entrypoint.sh 55 23 * * * ...   Up             3021/tcp                            
sentry-self-hosted_symbolicator_1                         /bin/bash /docker-entrypoi ...   Up             3021/tcp                            
sentry-self-hosted_web_1                                  /etc/sentry/entrypoint.sh  ...   Up (healthy)   9000/tcp                            
sentry-self-hosted_worker_1                               /etc/sentry/entrypoint.sh  ...   Up             9000/tcp                            
sentry-self-hosted_zookeeper_1                            /etc/confluent/docker/run        Up (healthy)   2181/tcp, 2888/tcp, 3888/tcp        

完成后,你可以进入下一步。


访问Sentry Web UI


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



提供你的管理员用户名和密码,然后点击登录按钮。你应该看到以下页面:




提供你的Sentry URL、电子邮件地址和SMTP详细信息,并点击继续按钮。你应该在下面的页面中看到Sentry的默认仪表盘:



总结


在本指南中,我们解释了如何在Ubuntu 22.04上安装Sentry。现在,你可以在你的组织中实施Sentry,实时跟踪整个堆栈中的应用程序。

文章相关标签: Docker Sentry Ubuntu 22.04
购物车