前期準備 [root@Aaron ~]# uname -r 3.10.0-327.el7.x86_64 [root@Aaron ~]# uname -a Linux Aaron 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86 ...
前期準備
[root@Aaron ~]# uname -r
3.10.0-327.el7.x86_64
[root@Aaron ~]# uname -a
Linux Aaron 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@Aaron ~]# python -V
Python 2.7.5
[root@Aaron ~]# pip -V
pip 9.0.1 from /usr/lib/python2.7/site-packages (python 2.7)
創建虛擬環境
[root@Aaron ~]# pip install -U virtualenv
[root@Aaron ~]# virtualenv /www/sentry/
[root@Aaron ~]# source /www/sentry/bin/activate
(sentry) [root@Aaron ~]#
安裝sentry
這裡sentry官網推薦postgres,因為我之前沒使用過postgres,折騰了一會,感覺非常難受,所以最終選擇mysql5.7,用哪個資料庫都一樣,只要在sentry.conf.py文件配置好就行。
安裝redis
(sentry) [root@Aaron ~]# yum install redis
(sentry) [root@Aaron sentry]# systemctl start redis
(sentry) [root@Aaron sentry]# systemctl status redis
安裝mysql
(sentry) [root@Aaron sentry]# yum install mysql-devel
(sentry) [root@Aaron sentry]# pip install mysqlclient
(sentry) [root@Aaron sentry]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
(sentry) [root@Aaron sentry]# yum -y install mysql57-community-release-el7-10.noarch.rpm
(sentry) [root@Aaron sentry]# yum -y install mysql-community-server
(sentry) [root@Aaron sentry]# systemctl start mysqld.service
(sentry) [root@Aaron sentry]# systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 二 2018-11-06 10:47:51 CST; 6s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 4775 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 4698 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 4779 (mysqld)
CGroup: /system.slice/mysqld.service
└─4779 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
11月 06 10:47:47 Aaron systemd[1]: Starting MySQL Server...
11月 06 10:47:51 Aaron systemd[1]: Started MySQL Server.
(sentry) [root@Aaron sentry]# grep "password" /var/log/mysqld.log
2018-11-06T02:47:48.394158Z 1 [Note] A temporary password is generated for root@localhost: wbP&Wms*p0y9
(sentry) [root@Aaron sentry]# mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY ‘Root.123456';
這裡我就順便把sentry資料庫給創建了
mysql> create database sentry;
Query OK, 1 row affected (0.00 sec)
我這裡圖方便,直接yum安裝了
沒有安裝redis執行pip install -U sentry會報錯
redis-py-cluster 1.3.5 has requirement redis>=2.10.6, but you'll have redis 2.10.5 which is incompatible.
一定要先安裝好redis和mysql,並且啟動redis和mysql
(sentry) [root@Aaron ~]# yum install -y python-devel
(sentry) [root@Aaron ~]# pip install -U sentry
如果覺得慢,使用豆瓣源
pip install -i https://pypi.douban.com/simple/ sentry
(sentry) [root@Aaron ~]# mkdir $HOME/sentry/
(sentry) [root@Aaron ~]# echo "export SENTRY_CONF=$HOME/sentry/" >> ~/.bash_profile
(sentry) [root@Aaron ~]# source ~/.bash_profile
(sentry) [root@Aaron ~]# sentry init $HOME/sentry/
(sentry) [root@Aaron ~]# cd ~/sentry/
(sentry) [root@Aaron sentry]# ls
config.yml sentry.conf.py
修改config.yml
[root@Aaron sentry]# cat config.yml|grep -v "^#"| grep -v "^$"
mail.backend: 'dummy' # Use dummy if you want to disable email entirely
system.secret-key: '(tn%ksnk&(%uxcsh_=3(wf%0upe)w(b0o02morvw)nvoj@6e#0'
redis.clusters:
default:
hosts:
0:
host: 127.0.0.1
port: 6379
filestore.backend: 'filesystem'
filestore.options:
location: '/tmp/sentry-files'
修改sentry.conf.py
[root@Aaron sentry]# cat sentry.conf.py|grep -v "^#"| grep -v "^$"
from sentry.conf.server import *
import os.path
CONF_ROOT = os.path.dirname(__file__)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'sentry',
'USER': 'root',
'PASSWORD': 'Root.123456',
'HOST': 'localhost',
'PORT': '3306',
'AUTOCOMMIT': True,
'ATOMIC_REQUESTS': False,
}
}
SENTRY_USE_BIG_INTS = True
SENTRY_SINGLE_ORGANIZATION = True
DEBUG = False
SENTRY_CACHE = 'sentry.cache.redis.RedisCache'
BROKER_URL = 'redis://localhost:6379'
SENTRY_RATELIMITER = 'sentry.ratelimits.redis.RedisRateLimiter'
SENTRY_BUFFER = 'sentry.buffer.redis.RedisBuffer'
SENTRY_QUOTAS = 'sentry.quotas.redis.RedisQuota'
SENTRY_TSDB = 'sentry.tsdb.redis.RedisTSDB'
SENTRY_DIGESTS = 'sentry.digests.backends.redis.RedisBackend'
SENTRY_WEB_HOST = '0.0.0.0'
SENTRY_WEB_PORT = 9000
SENTRY_WEB_OPTIONS = {
# 'workers': 3, # the number of web workers
# 'protocol': 'uwsgi', # Enable uwsgi protocol instead of http
}
(sentry) [root@Aaron sentry]# sentry upgrade
(sentry) [root@Aaron sentry]# sentry run web
然後訪問ip:9000