sentry的安裝和使用以及各種問題處理


官方的git地址:https://github.com/getsentry/onpremise

 

需要先安裝docker 1.10版本以上

假設你已經安裝完docker,那么接下來

安裝docker-compose

sudo yum install epel-release
sudo yum install -y python-pip
sudo pip install docker-compose

安裝git

sudo yum install git

 

制作本地數據庫和sentry的目錄配置,用來綁定掛載

sudo mkdir -p data/{sentry,postgres}

 

克隆sentry項目

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

以下是根據官網給的步驟

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

 

創建配置文件

cp -n .env.example .env

 

執行

docker-compose build

 

生成key

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

 

添加到.env的SENTRY_SECRET_KEY里面

創建數據庫 並且根據提示創建賬號

docker-compose run --rm web upgrade

 

啟動

docker-compose up -d

 

啟動成功后可以訪問http://localhost:9001

如果創建賬號失敗:

(1)使用docker命令進入postgres數據庫

# docker exec -it onpremise_postgres_1 bash

(2)進入postgres數據庫

# psql -h 127.0.0.1 -d postgres -U postgres

(3)查看這兩個表是否有數據sentry_project,sentry_organization

postgres=#  select * from sentry_project;

postgres=# select * from sentry_organization ;

 

如果沒有數據,進行創建

(4)新開一個終端,進入sentry的web的shell里面,其實就是一個python端

# docker-compose run --rm web shell 

 

(5)輸入以下命令進行初始化數據

 

from sentry.models import Project

from sentry.receivers.core import create_default_projects

create_default_projects([Project])

(6)退出第五步的shell,創建自己的用戶

# docker-compose run --rm web createuser

 

根據提示輸入郵箱和密碼

 

如果是發送成功,但是sentry里面看不到日志:

從docker日志查詢

docker stop onpremise_worker

docker logs -f --tail 100 onpremise_worker

 

 

如果發現是類似這樣的錯誤

 

 

1.運行命令進入postgres docker

docker exec -it onpremise_postgres_1 bash

 

2.進入postgre數據庫

psql -h 127.0.0.1 -d postgres -U postgres

 

3.執行:

create or replace function sentry_increment_project_counter( project bigint, delta int) returns int as $$ declare new_val int; begin loop update sentry_projectcounter set value = value + delta where project_id = project returning value into new_val; if found then return new_val; end if; begin insert into sentry_projectcounter(project_id, value) values (project, delta) returning value into new_val; return new_val; exception when unique_violation then end; end loop; end $$ language plpgsql;

4.ctrl + D退出數據庫,exit退出bash

5.重新運行onpremise_worker

 

安裝好以后我們可以用python的raven進行測試:

安裝

pip install raven

 

我們假設DSN是http://2b104bab64a447dab5ade5fbd8cac7b8:bad2a34018ce48ea9437f204384ffd54@192.168.187.134:9000/5

raven test http://2b104bab64a447dab5ade5fbd8cac7b8:bad2a34018ce48ea9437f204384ffd54@192.168.187.134:9000/5

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM