环境搭建
1.查看docker版本信息:docker --version
Docker version 17.09.1-ce, build 19e2cf6
2.安装docker-compose
pip install docker-compose
查看docker-compose版本信息
docker-compose --version
docker-compose version 1.24.0, build 0aa5906
3.克隆仓库:git clone https://github.com/getsentry/onpremise.git
进入仓库:cd onpremise
,然后执行以下命令:
docker volume create --name=sentry-data && docker volume create --name=sentry-postgres
- Make our local database and sentry volumes
Docker volumes have to be created manually, as they are declared as external to be more durable.cp -n .env.example .env
- create env config filedocker-compose build
- Build and tag the Docker servicesdocker-compose run --rm web config generate-secret-key
- 生成SECRET_KEY,注意最后一行.
Add it to.env
asSENTRY_SECRET_KEY
.docker-compose run --rm web upgrade
- Build the database.
Use the interactive prompts to create a user account.docker-compose up -d
- Lift all services (detached/background mode).关闭:docker-compose down- Access your instance at
localhost:9000
!
4.浏览器打开 http://localhost:9000,并设置:查看DSN,发现内容为空:
查看文档:The DSN can be found in Sentry by navigating to [Project Name] -> Project Settings -> Client Keys (DSN).
'{PROTOCOL}://{PUBLIC_KEY}@{HOST}/{PROJECT_ID}'
,组合后的dsn=“http://f397b976ce2b407e9772e5a7cd845570:eb5d1f317d0b47cfa71c0b3b85e76bf8@127.0.0.1:9000/3”
具体的django使用很简单,采用的是sentry-sdk,看官方文档即可,但不推荐使用raven,原因是:This SDK has been superseded by a new unified one. The documentation here is preserved for customers using the old client.
项目迁移
1.在旧机器上的操作
登录正在运行的容器
docker exec -it 容器ID /bin/bash
导出用户与项目等数据,导出的内容为json格式,需要检查下,确保能正常导入
sentry export --exclude savedsearch,rule,permission,migrationhistory,contenttype,option,site,userip,useroption,projectoption,counter,organizationmemberteam,organizationmember,team,organizationoption,projectteam,authenticator,organization,projectbookmark > sentry.json
拷贝数据到本地环境
docker cp 容器ID:/usr/src/sentry/sentry.json .
2.在新机器上的操作
使用scp将旧机器的sentry.json传输到新机器上
拷贝本地数据到docker环境
docker cp sentry.json 容器ID:/usr/src/sentry/sentry.json
导入数据
sentry import sentry.json
参考
https://docs.sentry.io/platforms/python/django/
https://github.com/getsentry/onpremise