Docker 部署 Sentry
-
- 启动redis容器
docker run -d --name sentry-redis redis
- 启动Postgres容器
docker run -d --name sentry-postgres -e POSTGRES_PASSWORD=密码 -e POSTGRES_USER=用户名 postgres
- 生成秘钥 key 供所有 sentry 容器共享 #该值作用于环境变量:SENTRY_SECRET_KEY
docker run --rm sentry config generate-secret-key
- 数据库更新
docker run -it --rm -e SENTRY_SECRET_KEY='秘钥' --link sentry-postgres:postgres --link sentry-redis:redis sentry upgrade
*#-it 参数很重要,它会指引我们创建一个初始用户。 #在这里会让您设置初始账号密码,假设是账号密码是: root@http://qq.com root123456*
- 启动sentry服务
docker run -d --name sentry-luffy -p 8888:9000 -e SENTRY_SECRET_KEY='秘钥' -v /home/sentry/config.yml:/etc/sentry/config.yml --link sentry-redis:redis --link sentry-postgres:postgres sentry
- 额外需要启动 celery beat 和 celery worker
docker run -d --name sentry-cron -e SENTRY_SECRET_KEY='秘钥' -v /home/sentry/config.yml:/etc/sentry/config.yml --link sentry-postgres:postgres --link sentry-redis:redis sentry run cron
docker run -d --name sentry-worker-1 -e SENTRY_SECRET_KEY='秘钥' -v /home/sentry/config.yml:/etc/sentry/config.yml --link sentry-postgres:postgres --link sentry-redis:redis sentry run worker
- 创建用户
docker run -it --rm -e SENTRY_SECRET_KEY='秘钥' --link sentry-redis:redis --link sentry-postgres:postgres sentry createuser
- 登陆
地址: http://localhost:8888
在启动sentry、celery beat 和 celery worker服务注意事项
在启动sentry、celery beat 和 celery worker服务时候需要修改服务的相关配置,正确且方便的做法是将这三个服务的config.yml配置文件挂载到宿主机上。
- 新增config.yml文件到宿主机/home目录下,文件内容如下
# While a lot of configuration in Sentry can be changed via the UI, for all # new-style config (as of 8.0) you can also declare values here in this file # to enforce defaults or to ensure they cannot be changed via the UI. For more # information see the Sentry documentation. ############### # Mail Server # ############### # mail.backend: 'smtp' # Use dummy if you want to disable email entirely # mail.host: 'localhost' # mail.port: 25 # mail.username: '' # mail.password: '' # mail.use-tls: false # The email address to send on behalf of # mail.from: 'root@localhost' mail.backend: 'smtp' # Use dummy if you want to disable email entirely mail.host: 'smtp.163.com' mail.port: 25 mail.username: 'dahuasurvey_sentry@163.com' mail.password: 'IPBQSNSUJNYAYTWH' mail.use-tls: true # The email address to send on behalf of mail.from: 'dahuasurvey_sentry@163.com' # If you'd like to configure email replies, enable this. # mail.enable-replies: false # When email-replies are enabled, this value is used in the Reply-To header # mail.reply-hostname: '' # If you're using mailgun for inbound mail, set your API key and configure a # route to forward to /api/hooks/mailgun/inbound/ # mail.mailgun-api-key: '' ################### # System Settings # ################### # If this file ever becomes compromised, it's important to regenerate your a new key # Changing this value will result in all current sessions being invalidated. # A new key can be generated with `$ sentry config generate-secret-key` # system.secret-key: 'changeme' # The ``redis.clusters`` setting is used, unsurprisingly, to configure Redis # clusters. These clusters can be then referred to by name when configuring # backends such as the cache, digests, or TSDB backend. # redis.clusters: # default: # hosts: # 0: # host: 127.0.0.1 # port: 6379 ################ # File storage # ################ # Uploaded media uses these `filestore` settings. The available # backends are either `filesystem` or `s3`. # filestore.backend: 'filesystem' # filestore.options: # location: '/tmp/sentry-files' # filestore.backend: 's3' # filestore.options: # access_key: 'AKIXXXXXX' # secret_key: 'XXXXXXX' # bucket_name: 's3-bucket-name'
- 分别启动这三个服务的时候加入如下命令
-v /home/config.yml:/etc/sentry/config.yml