centos7 安裝和配置sentry

本文主要介紹在centos7 下通過(guò)docker安裝sentry

1. docker

安裝(方法一)

1.確保yum packages 是最新的

$ sudo yum update

2.添加yum repo

$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

3.安裝docker

$ sudo yuminstalldocker-engine

4.啟動(dòng)docker

$ sudo service dockerstart

5.驗(yàn)證docker已經(jīng)啟動(dòng)

$ sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from hello-world
a8219747be10: Pull complete
91c95931e552: Already exists
hello-world:latest: The image you are pulling has been verified.      Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:aa03e5d0d5553b4c3473e89c8619cf79df368babd1.7.1cf5daeb82aab55838d
Status: Downloaded newer image for hello-world:latest
Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (Assuming it was not already locally available.)
 3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

For more examples and ideas, visit:
 http://docs.docker.com/userguide/

安裝(方法二)

1.確保yum packages 是最新的

$ sudo yum update

2.運(yùn)行docker 安裝腳本

$ curl -fsSL https://get.docker.com/ | sh

3.啟動(dòng)docker服務(wù)器

$ sudo service docker start

4.驗(yàn)證docker已經(jīng)啟動(dòng)

$ sudo docker run hello-world

2. sentry

sentry 依賴的組件比較多 包括 redis、 postgresql、 outbound email

在安裝sentry前請(qǐng)確保 docker 版本大于1.10

1.安裝git

$ sudo yum install git

2.下載docker鏡像并構(gòu)建容器

$ git clone  https://github.com/getsentry/onpremise.git
$ cd onpremise
$ sudo make build

注: 所有命令都要以sudo權(quán)限運(yùn)行 否則會(huì)報(bào)錯(cuò)docker 未啟動(dòng)

3.用docker安裝sentry依賴的組件

Redis
docker run \
--detach \
--name sentry-redis \
redis:3.2-alpine
PostgreSQL
docker run \
--detach \
--name sentry-postgres \
--env POSTGRES_PASSWORD=secret \
--env POSTGRES_USER=sentry \
postgres:9.5
Outbound Email
docker run \
--detach \
--name sentry-smtp \
tianon/exim4

注意:接下來(lái)所有命令都需要用到 Redis、 PostgreSQL、 Outbound Email中的環(huán)境變量,所有命令中需要將將三個(gè)鏡像連接起來(lái)

$ sudo docker run \
--detach \
--rm \
--link sentry-redis:redis \
--link sentry-postgres:postgres \
--link sentry-smtp:smtp \
--env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} \
${REPOSITORY} \
<command>

其中 SENTRY_SECRET_KEY 可以自己生成

4.在PostgreSQL中生成sentry需要的表

$ sudo docker run \
--detach \
--rm \
--link sentry-redis:redis \
--link sentry-postgres:postgres \
--link sentry-smtp:smtp \
--env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} \
-it sentry-onpremise upgrade

在創(chuàng)建過(guò)程中會(huì)提示創(chuàng)建一個(gè)superuser, 根據(jù)提示自動(dòng)輸入郵箱和密碼,該賬戶和密碼很重要, 在sentry部署好以后需要用該賬號(hào)登錄, 請(qǐng)必須記住賬號(hào)和密碼

5.拉起sentry需要的后臺(tái)服務(wù)

$ sudo docker run \
--detach \
--rm \
--link sentry-redis:redis \
--link sentry-postgres:postgres \
--link sentry-smtp:smtp \
--env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} \
--name sentry-worker-01 \
sentry-onpremise run worker

6.拉起sentry需要的cron后臺(tái)服務(wù)

$ sudo docker run \
--detach \
--rm \
--link sentry-redis:redis \
--link sentry-postgres:postgres \
--link sentry-smtp:smtp \
--env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} \
--name sentry-cron \
sentry-onpremise run cron

7.最后拉起sentry的web服務(wù)

$ sudo docker run \
--detach \
--rm \
--link sentry-redis:redis \
--link sentry-postgres:postgres \
--link sentry-smtp:smtp \
--env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} \
--name sentry-web-01 \
--port 9000:9000 \
sentry-onpremise \
run web

注:不同版本的docker可能會(huì)在--port 參數(shù)上有報(bào)錯(cuò),如果出錯(cuò)可以嘗試-p 或者--p 同時(shí)有些會(huì)提示 --d和-rm沖突,去掉--detach即可

最后在瀏覽器中訪問(wèn) http://localhost:9000/

注意啟動(dòng)順序 woker->cron->web, 如果不啟動(dòng)worker和cron可能會(huì)遇到報(bào)錯(cuò)如下:


error.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 簡(jiǎn)介 sentry是一個(gè)人性化收集&定位&定格程序錯(cuò)誤的工具。說(shuō)白了就是在網(wǎng)頁(yè)上就能看到你的錯(cuò)誤棧信息,和各種當(dāng)時(shí)...
    weidwonder閱讀 2,628評(píng)論 0 1
  • Docker 是一個(gè)開(kāi)源的應(yīng)用容器引擎,讓開(kāi)發(fā)者可以打包他們的應(yīng)用以及依賴包到一個(gè)可移植的容器中,然后發(fā)布到任何流...
    ProteanBear閱讀 1,451評(píng)論 0 3
  • 簡(jiǎn)介 在上一篇中, 我們已經(jīng)較為詳細(xì)的描述如何基于docker,搭建一套全棧式應(yīng)用。web端采用Django,并使...
    keysaim閱讀 929評(píng)論 0 1
  • 1****、前言進(jìn)入云計(jì)算的時(shí)代,各大云提供商AWS,阿里云紛紛推出針對(duì)Docker的服務(wù),現(xiàn)在Docker是十分...
    燕京博士閱讀 1,081評(píng)論 0 0
  • 轉(zhuǎn)載自 http://blog.opskumu.com/docker.html 一、Docker 簡(jiǎn)介 Docke...
    極客圈閱讀 10,753評(píng)論 0 120

友情鏈接更多精彩內(nèi)容