天天看點

sentry部署安裝及資料清理

文章目錄

      • 全部服務都使用docker 運作部署
      • 使用已部署好的redis 和postgresql 安裝方式

全部服務都使用docker 運作部署

  1. 安裝git docker-ce docker-compose

    yum install docker-ce git -y

    pip install docker-compose

    systemctl start docker

  2. 建立資料卷

    docker volume create --name=sentry-data && docker volume create --name=sentry-postgres

  3. 克隆sentry 倉庫

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

    建立配置檔案

    cd onpremise && cp -n .env.example .env

    Dockerfile 中 FROM ${SENTRY_IMAGE}-onbuild ${SENTRY_IMAGE}改為sentry:9.0

  4. docker-compose build
  5. 擷取項目的 key

    docker-compose run --rm web config generate-secret-key

  6. 初始資料

    docker-compose run --rm web upgrade

  7. 啟動服務

    docker-compose up -d

  8. 建立賬号

    docker-compose run --rm web createuser

  9. sentry 資料清理

    docker exec -it sentry_web sentry cleanup --days 7

    docker exec -it onpremise_postgres_1 vacuumdb -U postgres -d sentry -t nodestore_node -v -f --analyze

使用已部署好的redis 和postgresql 安裝方式

  • 準備需要的redis、postgresql 、郵箱等資訊直接寫入 docker-compose.yml 檔案即可
cat  > docker-compose.yml  <<EOF
version: '2'
services:
  sentry:
    image: library/sentry:9.0
    command: sentry run web
    ports:
    - 9000:9000
    volumes:
    - /data/sentry/files:/var/lib/sentry/files
    environment:
      SENTRY_SECRET_KEY: 82xp1vgoen2hzhv2g!twdcyi%f#9y0zn)ax36--b=!ao=7j_%e
      SENTRY_POSTGRES_HOST: 172.16.1.234
      SENTRY_POSTGRES_PORT: 5432
      SENTRY_DB_NAME: sentry
      SENTRY_DB_USER: sentry
      SENTRY_DB_PASSWORD: *****
      SENTRY_REDIS_HOST: r-bp16614804c35c24.redis.rds.aliyuncs.com
      SENTRY_REDIS_DB: 14
      SENTRY_SERVER_EMAIL: [email protected]
      SENTRY_EMAIL_HOST: smtp.exmail.qq.com
      SENTRY_EMAIL_PORT: 587
      SENTRY_EMAIL_USER: [email protected]
      SENTRY_EMAIL_PASSWORD: ********
      SENTRY_EMAIL_USE_TLS: 1
  cron:
    image: library/sentry:9.0
    command: sentry run cron
    environment:
      SENTRY_SECRET_KEY: 82xp1vgoen2hzhv2g!twdcyi%f#9y0zn)ax36--b=!ao=7j_%e
      SENTRY_POSTGRES_HOST: 172.16.1.234
      SENTRY_POSTGRES_PORT: 5432
      SENTRY_DB_NAME: sentry
      SENTRY_DB_USER: sentry
      SENTRY_DB_PASSWORD: *****
      SENTRY_REDIS_HOST: r-bp16614804c35c24.redis.rds.aliyuncs.com
      SENTRY_REDIS_DB: 14
      SENTRY_SERVER_EMAIL: [email protected]
      SENTRY_EMAIL_HOST: smtp.exmail.qq.com
      SENTRY_EMAIL_PORT: 587
      SENTRY_EMAIL_USER: [email protected]
      SENTRY_EMAIL_PASSWORD: *******
      SENTRY_EMAIL_USE_TLS: 1
  worker:
    image: library/sentry:9.0
    command: sentry run worker
    environment:
      SENTRY_SECRET_KEY: 82xp1vgoen2hzhv2g!twdcyi%f#9y0zn)ax36--b=!ao=7j_%e
      SENTRY_POSTGRES_HOST: 172.16.1.234
      SENTRY_POSTGRES_PORT: 5432
      SENTRY_DB_NAME: sentry
      SENTRY_DB_USER: sentry
      SENTRY_DB_PASSWORD: *****
      SENTRY_REDIS_HOST: r-bp16614804c35c24.redis.rds.aliyuncs.com
      SENTRY_REDIS_DB: 14
      SENTRY_SERVER_EMAIL: [email protected]
      SENTRY_EMAIL_HOST: smtp.exmail.qq.com
      SENTRY_EMAIL_PORT: 587
      SENTRY_EMAIL_USER: [email protected]
      SENTRY_EMAIL_PASSWORD: *******
      SENTRY_EMAIL_USE_TLS: 1
  EOF
           
  • 運作

    docker-compose -f ./docker-compose.yml up -d