CentOS6.8搭建Sentry环境

安装第三方依赖包(redis依赖包,python依赖包,pip依赖包等必须提前安装):

yum install -y zlib zlib-devel
yum install -y cpp  binutils glibc-kernheaders glibc-common glibc-devel gcc gcc-c++ make wget libstdc++-devel tcl  tcl-devel
yum install -y openssl openssl-devel
yum install postgresql-devel*

下载Python2.7.14 :

下载2.7.*版本 3.*版本在使用pip安装sentry时会出现python库与sentry依赖库兼容性问题 , 2.6.*版本太低,对sentry不能有很好的支持

下载地址:https://www.python.org/downloads/ 下载sentry2.7中推荐版本

上传服务器,并解压、配置、编译、安装:

[root@centos1 py]# tar -xzvf Python-2.7.14.tgz 
[root@centos1 py]# cd Python-2.7.14
[root@centos1 Python-2.7.14]# ./configure --prefix=/usr/local/python2.7/
[root@centos1 Python-2.7.14]# make && make install

进入安装目录:创建安装python的软连接到用户资源库/usr/bin中

[root@centos1 bin]# ln -s /usr/local/python2.7/bin/python /usr/bin/python2.7

Sentry安装依赖pip安装,而pip安装依赖setuptools接下来进行setuptools安装:

setuptools安装

https://pypi.python.org/pypi/setuptools

下载最新的支持py2、py3的setuptools安装包,并上传linux: 进入python安装目录,并解压setuptools-*.zip

[root@centos1 python2.7]# pwd
/usr/local/python2.7
[root@centos1 python2.7]# unzip /root/py/setuptools-38.2.4.zip 
[root@centos1 python2.7]# ls
bin  include  lib selenium  setuptools-38.2.4  share

安装setuptools工具:进入setuptools目录并安装

[root@centos1 python2.7]# cd setuptools-38.2.4/
[root@centos1 setuptools-38.2.4]# python2.7 setup.py install

此时python安装目录bin目录下有安装后的sasy_install文件及其软连接文件

下载及安装pip

pip github下载pip源码

我们下载7.1.2版本支持python2,8.*支持python3 ,python2下载的话安装过程中有兼容性问题

下载pip 并上传服务器,并解压到python安转目录:

[root@centos1 python2.7]# pwd
/usr/local/python2.7
[root@centos1 python2.7]# tar -xzvf /root/py/pip-7.1.2.tar.gz 
[root@centos1 python2.7]# ls
bin  include  lib  pip-7.1.2  selenium  setuptools-38.2.4  share

进入pip目录并安装pip

[root@centos1 python2.7]# cd pip-7.1.2/              
[root@centos1 pip-7.1.2]# python2.7 setup.py install
....
[root@centos1 pip-7.1.2]# cd /usr/local/python2.7/bin/
[root@centos1 bin]# ls
2to3                     cssparse          explode.py    petname         pilprint.pyc  python2           rst2html5.pyc           rst2odt.pyc        rstpep2html.pyc
celery                   cygdb             explode.pyc   pilconvert.py   pip           python2.7         rst2html.py             rst2pseudoxml.py   sentry
celerybeat               cython            gifmaker.py   pilconvert.pyc  pip2          python2.7-config  rst2html.pyc            rst2pseudoxml.pyc  smtpd.py
celeryd                  cythonize         gifmaker.pyc  pildriver.py    pip2.7        python2-config    rst2latex.py            rst2s5.py          sqlformat
celeryd-multi            django-admin.py   honcho        pildriver.pyc   player.py     python-config     rst2latex.pyc           rst2s5.pyc         thresholder.py
chardetect               django-admin.pyc  idle          pilfile.py      player.pyc    qr                rst2man.py              rst2xetex.py       thresholder.pyc
createfontdatachunk.py   easy_install      jp.py         pilfile.pyc     pydoc         raven             rst2man.pyc             rst2xetex.pyc      uwsgi
createfontdatachunk.pyc  easy_install-2.7  jp.pyc        pilfont.py      pytest        rst2html4.py      rst2odt_prepstyles.py   rst2xml.py         viewer.py
csscapture               enhancer.py       painter.py    pilfont.pyc     py.test       rst2html4.pyc     rst2odt_prepstyles.pyc  rst2xml.pyc        viewer.pyc
csscombine               enhancer.pyc      painter.pyc   pilprint.py     python        rst2html5.py      rst2odt.py              rstpep2html.py     virtualenv
[root@centos1 bin]#

此时python安装目录bin目录下有pip可执行文件

easy_install 和 pip文件创建软连接:

[root@centos1 bin]# ln -s /usr/local/python2.7/bin/easy_install /usr/bin/easy_install 
[root@centos1 bin]# ln -s /usr/local/python2.7/bin/pip /usr/bin/pip

升级pip版本:

pip install --upgrade pip

下载sentry运行环境

pip install -U virtualenv

运行virtualenv 初始化sentry资源:

virtualenv /www/sentry/

切换sentry环境:

source /www/sentry/bin/activate

安装sentry:为了防止下载过程中超时,适当调整timeout

pip --default-timeout=50000 install -U sentry

下载、安装修改配置(修改密码,绑定ip ,后台启动配置修改)及启动redis:

略...

测试redis连接:

MysqL服务安装:

略...

致命错误 : python.h 没有那个文件或目录,这是因为我们安装的python不是开发版,在CentOS6.8中

yum install python-devel

Building without Cython. ERROR: /bin/sh: xslt-config:未找到命令,致命错误:libxml/xpath.h:没有那个文件或目录以及致命错误:libxml/xmlversion.h:没有那个文件或目录,解决方法是:

easy_install Cython
yum install libxslt-devel libxml2-devel

解决了上述问题,继续安装sentry[MysqL]

pip install sentry[MysqL]

遇到的问题 sh: MysqL_config: 未找到命令,需要安装MysqL-devel

yum install MysqL-devel

升级sentry[MysqL]

pip install sentry[MysqL] --upgrade

安装相关的Python库:

pip install redis hiredis nydus                                    
pip install redis hiredis nydus --upgrade                                 
pip install gevent                                
pip install eventlet

Sentry AttributeError: 'nonetype' object has no attribute 'connection_pool' , 下载redis插件

pip install redis==2.10.5

初始化sentry配置并生成配置文件

sentry init

配置文件会出现在~/.sentry目录下:

[root@centos1 .sentry]# cd ~/.sentry/
[root@centos1 .sentry]# ls
config.yml  sentry.conf.py
[root@centos1 .sentry]#

config.xml配置email配置,sentry.conf.py配置MysqL 及redis链接文件配置如下:

[root@centos1 redis-2.8.23]# cat /root/.sentry/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','HOST': '192.168.1.109','PORT': '3306','AUTOCOMMIT': True,'ATOMIC_REQUESTS': False,}
}
SENTRY_USE_BIG_INTS = True
SENTRY_SINGLE_ORGANIZATION = True
DEBUG = False
ENTRY_REdis_OPTIONS = {
    'hosts': {
        0: {
            'host': '127.0.0.1','port': 6379,'timeout': 3,'password': '123456'
        }
    }
}
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
}
SECRET_KEY='eyleyqvbv_ox)l9qufyh*tii@l(ryj=259_zh(d-w4+h@j3khz'
[root@centos1 redis-2.8.23]#

根据自己环境配置,SECRET_KEY利用

sentry config generate-secret-key

生成并配置,否则启动会报错。更加详细的配置可以参考:sentry.conf.py

利用配置文件初始化MysqL数据库

(sentry) [root@centos1 bin]# sentry /root/.sentry/sentry.conf.py upgrade

会出现 django Error loading MysqLdb module:No module named MysqLdb,因为python并未下载下载并引入MysqL-python模块

安装MysqL-python

easy_install MysqL-python

MysqL模块引入python中

>>>python
>>>import MysqLdb

然后就可以进行数据库初始化工作了,初始化过程中提示要不要创建用户,创建用户并设置为超级用户。建议创建。

启动sentry服务

(sentry) [root@centos1 bin]# sentry --config=/root/.sentry/sentry.conf.py start

命令使用详情使用 sentry --help查看

我们可以通过服务监听的9000端口来访问服务。

参考文章

https://www.tianmaying.com/tutorial/sentry

http://blog.csdn.net/u011630575/article/details/51209117

http://blog.csdn.net/u013896646/article/details/77869506

https://github.com/pypa/pip/releases

http://blog.csdn.net/u011630575/article/details/51209117
http://www.landui.com/help/show-3671.html

https://www.cnblogs.com/yangxia-test/p/4160022.html

https://www.python.org/downloads/release/python-2714/

https://blog.lerzen.com/articles/dbe34500-14b5-11e7-8747-eff4a27017c0

https://www.cnblogs.com/shansongxian/p/6256428.html

https://pypi.python.org/pypi/setuptools#downloads

https://www.cnblogs.com/xiaoduc-org/p/5958973.html

http://blog.csdn.net/longyinyushi/article/details/51851336

https://www.tianmaying.com/tutorial/sentry

http://blog.csdn.net/u011630575/article/details/51209117

http://blog.csdn.net/zheng0518/article/details/50421265

http://san-yun.iteye.com/blog/2109258

http://www.landui.com/help/show-3671.html

https://pypi.python.org/pypi/setuptools

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native