CentOS6.8搭建Sentry環境

安裝第三方依賴包(redis依賴包,python依賴包,pip依賴包等必須提早安裝):css

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不能有很好的支持html

下載地址:https://www.python.org/downloads/  下載sentry2.7中推薦版本html5

 

並上傳服務器,並解壓、配置、編譯、安裝:python

[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中mysql

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

 

Sentry安裝依賴pip安裝,而pip安裝依賴setuptools接下來進行setuptools安裝:linux

setuptools安裝

https://pypi.python.org/pypi/setuptoolsc++

下載最新的支持py二、py3的setuptools安裝包,並上傳linux: 進入python安裝目錄,並解壓setuptools-*.zipgit

[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目錄並安裝github

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

此時python安裝目錄bin目錄下有安裝後的sasy_install文件及其軟鏈接文件web

 

下載及安裝pip

pip github下載pip源碼

咱們下載7.1.2版本支持python2,

pip 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

相關文章
相關標籤/搜索