centos7下部署sentry日志管理服务

Docker安装

1.卸载旧版本

1
2
3
4
sudo yum remove docker \
docker-common \
docker-selinux \
docker-engine

2.安装依赖包

1
sudo yum install -y yum-utils device-mapper-persistent-data lvm2

3.添加稳定的源

1
2
3
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

安装docker ce

1.更新yum包

1
sudo yum makecache fast

2.安装docker ce

1
sudo yum install docker-ce

3.启动docker

1
sudo systemctl start docker

4.测试docker

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
sudo docker run hello-world

输出:

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.
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

Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/

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

安装docker-compose

1
2
3
1. sudo yum install epel-release
2. sudo yum install -y python-pip
3. sudo pip install docker-compose

2.sentry安装

sentry 依赖的组件比较多 包括 redis、 postgresql、 outbound email

在安装sentry前请确保 docker 版本大于1.10

1.安装git

1
sudo yum install git

2.下载docker镜像并构建容器

cd进入到要安装的目录,创建一个程序目录

1
mkdir -p data/{sentry,postgres}

3.下载onpremise-master项目,放在与刚才创建的data目录同级

两者选一即可

下载地址:https://github.com/getsentry/onpremise

也可以不用下载进行克隆

1
sudo yum install git
1
2
$ git clone  https://github.com/getsentry/onpremise.git
$ cd onpremise

4.cd onpremise,进入到onpremise-master项目,执行命令生成key

注意:以下所有的目录,都是要在onpremise下执行的

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

复制生成的key写入到docker-compose.yml文件

1
vim docker-compose.yml

5.生成数据表

1
docker-compose run --rm web upgrade

6.启动项目,在9000端口,如果是阿里云服务器记得开放端口

1
docker-compose up -d

访问服务器ip加9000端口

可以看到是英文的

首先要改成中文

1

2

以后启动项目

首先启动docker

1
sudo systemctl start docker

然后cd进入到onpremise下执行

1
docker-compose up -d

错误日志监控配置

python脚本监控

选择监控类型

python监控

1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/env python
# -*- coding:utf8 -*-
from raven import Client

# 设置dns的key
client = Client('http://f77284e1694144319ff6e27cf1cf9ae3:dd866ea1b3c34604ad9717deca56c320@47.52.39.160:9000/14')

try:
1 / 0
except ZeroDivisionError:
# 获取错误推送到错误监控
client.captureException()[![复制代码](http://common.cnblogs.com/images/copycode.gif)](javascript:void(0);)

监控

Docker监控

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app1',
'social_django',
'raven.contrib.django.raven_compat', # 配置监控APP
]

# 配置监控配置
RAVEN_CONFIG = {
'dsn': 'http://5def24308c64410fab2f8f4dda116195:619079b681ee4fb599ab62db4da8524f@47.52.39.160:9000/15',
}
🐶 ~怕是要给老板下跪了哦~ 🐶