当前位置: 移动技术网 > IT编程>脚本编程>Python > Sentry部署

Sentry部署

2018年11月07日  | 移动技术网IT编程  | 我要评论

湖南女子学院是几本,湖北大学知行学院,cafe janky

前期准备

 

[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

 

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

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网