纯净centOs 安装sentry
扫描二维码
随时随地手机看文章
本文是在centOs 7 上安装sentry的全过程,亲测可行
1. 关掉CentOs防火墙,允许服务器联网
1.1 su 更换root用户
1.2 sudo chmod 0777 /etc/sudoers
1.3 vi /etc/sudoers
1.4 在root ALL=(ALL) ALL下添加一行
john ALL=(ALL) ALL
1.5 sudo chmod 0440 /etc/sudoers 更换为原来的权限
1.6 关闭防火墙
sudo service firewalld stop
2. 编辑网卡驱动文件
2.1 vi /etc/sysconfig/network-scripts/ifcfg-ens33
将 ONBOOT设置为yes
2.2 重启网络服务
sudo service network restart
3. 安装wget
3.1 yum install wget
4. 安装ssh
4.1 yum install openssh-server
5. 安装 gcc
5.1 yum install gcc
6. CentOs换源
6.1 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
6.2 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
6.3 yum clean all
6.4 yum makecache
7. 更新tcl 8.5
7.1 wget http://downloads.sourceforge.net/tcl/tcl8.6.0-src.tar.gz
7.2 sudo tar xzvf tcl8.6.0-src.tar.gz -C /usr/local/
7.3 cd /usr/local/tcl8.6.0/unix/
7.4 sudo ./configure
7.5 sudo make
7.6 sudo make install
8. 安装redis
8.1 wget http://download.redis.io/releases/redis-2.8.0.tar.gz
8.2 tar zxvf redis-2.8.0.tar.gz
8.3 cd redis-2.8.0.tar.gz/src
8.4 make
8.5 make install
8.6 ./redis-server &
9. 安装deltarpm
9.1 yum provides '*/applydeltarpm'
9.2 yum install deltarpm
10. 安装rabbitMq
10.1 rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
10.2 sudo rpm -Uvh http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
10.1 wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server-3.6.1-1.noarch.rpm
10.2 rpm --import https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
10.5 yum install rabbitmq-server-3.6.1-1.noarch.rpm
网速太慢 先跳过
11 安装postgresql
11.1 yum install -y postgresql-server;
11.2 service postgresql initdb
11.3 vi /var/lib/pgsql/data/pg_hba.conf 修改 local 的 peer为trust
11.4 service postgresql start; 启动psql
11.5 su postgres; 更换postgres 用户
11.6 psql -U postgres postgres
11.7 password 设置新密码
11.8 create database "sentry"; 新建数据库
11.9 q ; 退出
11.10 exit
12 安装python环境设置
12.1 yum install -y gcc bzip2-devel.x86_64 sqlite-devel.x86_64 readline-devel.x86_64 libxslt-devel libffi-devel redis python-devel postgresql-devel*
12.2 wget http://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz;
12.3 tar -zxf Python-2.7.9.tgz;
12.4 cd Python-2.7.9;
12.5 ./configure --prefix=/usr/local/python2.7.9;
12.6 make
12.7 make install
12.8 cd
12.9 wget https://pypi.python.org/packages/source/d/distribute/distribute-0.6.49.tar.gz --no-check-certificate;
12.10 tar zxvf distribute-0.6.49.tar.gz;
12.11 cd distribute-0.6.49
12.12 /usr/local/python2.7.9/bin/python setup.py install;
12.13 yum install python-setuptools
12.14 easy_install virtualenv
12.14 easy_install virtualenvwrapper
12.15 mkdir -p /data/server/python-envs
12.16 vi ~/.bashrc
后面添加内容
export WORKON_HOME=/data/server/python-envs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/python2.7.9/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/bin/virtualenv
source /usr/bin/virtualenvwrapper.sh
12.16 source ~/.bashrc
12.17 mkvirtualenv sentry;
12.18 yum install libjpeg-turbo-devel
12.19 yum install openssl-devel
12.20 workon sentry
13 pip换源
13.1 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gevent
14 安装sentry
14.1 pip install sentry
14.2 pip install sentry[postgres];
14.3 pip install sentry[postgres] --upgrade;
14.4 pip install gevent;
14.5 pip install eventlet;
15 环境设置
15.1 mkdir -p /data/server/sentry/etc;
15.2 sentry init /data/server/sentry/etc;
15.3 useradd sentry -s /sbin/nologin;
15.4 chown -Rf sentry:sentry /data/server/sentry/etc;
15.5 vi /data/server/sentry/etc/sentry.conf.py 修改postgres的用户名和密码
修正
/data/server/python-envs/sentry/lib/python2.7/site-packages/sentry/runner/initializer.py 的403 后面3行注释掉
16 sentry启动
16.1 sentry --config=/data/server/sentry/etc/sentry.conf.py upgrade; 创建 sentry用户名密码
16.2 export C_FORCE_ROOT="true"
16.3 sentry --config=/data/server/sentry/etc/sentry.conf.py run worker
16.4 遇到错误 UnicodeError
/data/server/python-envs/sentry/lib/python2.7/site-packages/sentry/db/postgres/helpers.py 引入代码
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
16.5 sentry init
16.6 修改配置文件 /data/server/sentry/etc/sentry.conf.py 设置EMAIL(在最后添加)
设置postgres的数据库密码
EMAIL_HOST = 'smtp.qq.com'
EMAIL_HOST_PASSWORD = 'x162728'
EMAIL_HOST_USER = '674026565@qq.com'
EMAIL_PORT = 25
EMAIL_USE_TLS = True
16.6 sentry start
17 sentry 添加用户
17.1 sentry --config=~/.sentry/sentry.conf.py createuser
部署成功之后的开启过程
1 切换到root用户
1.1 su
1.2 service postgresql start;
1.3 启动redis redis-server &
1.4 workon sentry
1.5 source /data/server/python-envs/sentry/bin/activate
1.6 export C_FORCE_ROOT="true"
1.7 sentry run worker //开启另外一个窗口
1.8 sentry start //正式启动完成
额,还有一个1.9 别忘了关闭防火墙
1.9 sudo service firewalld stop