How to install Sentry on Centos 7
In this manual we will tell you how to install Sentry on Centos 7, and do it quickly, correctly and reliably. In addition, we will prepare the configuration for Supervisor, with which we will manage the main Sentry services.
In this manual we will tell you how to install Sentry on Centos 7, and do it quickly, correctly and reliably. In addition, we will prepare the configuration for Supervisor, with which we will manage the main Sentry services.
So, first of all, we will install all the necessary dependencies:yum install epel-release -y yum install wget python-setuptools.noarch python2-pip.noarch python-devel.x86_64 libxslt.x86_64 libxslt-devel.x86_64 libxml2 libxml2-devel.x86_64 libzip libzip-devel libffi.x86_64 libffi-devel.x86_64 openssl-libs.x86_64 libpqxx libpqxx-devel libyaml libyaml-devel libjpeg libjpeg-devel libpng libpng12 libpng12-devel libpng-devel net-tools gcc gcc-c++ -y
Sentry uses PostgreSQL as the database, so install the postgresql package with the command:
yum install postgresql-server.x86_64 postgresql-contrib -y postgresql-setup initdb systemctl enable postgresql.service systemctl start postgresql.service
Sentry also needs Redis to work, so we can also install it using the command:
yum install redis -y systemctl enable redis.service systemctl start redis.service
And of course, we need to install Supervisor, with which we will control the operation of Sentry:
yum install supervisor -y systemctl enable supervisord.service
Now update pip:
pip install --upgrade pip
Next, install virtualenv to create an isolated Python environment:
pip install -U virtualenv
In order to ensure the necessary level of security, we will run Sentry under a user created separately for it, which we will create with the command:
useradd sentry
All the necessary packages are installed, so now let's get started and create a sentrydb database and a sentry database user first:
su - postgres psql template1 create user sentry with password 'your_strong_password'; alter user sentry with superuser; create database sentrydb with owner sentry; \q exit
The user and the database are ready, now log in as the user of the centry command:
su - sentry
Create a virtual environment in the sentry user’s home directory:
virtualenv /home/sentry/sentry_app
We activate the shell inside the environment:
source /home/sentry/sentry_app/bin/activate
Now we proceed to install Sentry itself, for this we execute the command:
pip install -U sentry
After the installation process is completed, we will initialize Sentry:
/home/sentry/sentry_app/bin/sentry init
Next, we need to configure the Sentry configuration files, so open the first config file:
nano /home/sentry/.sentry/sentry.conf.py
and change the following lines, specifying the data from the db user and the db name that we created above:
… DATABASES = { 'default': { 'ENGINE': 'sentry.db.postgres', 'NAME': 'sentrydb', 'USER': 'sentry', 'PASSWORD': 'your_strong_password', 'HOST': '127.0.0.1', 'PORT': '5432', 'AUTOCOMMIT': True, 'ATOMIC_REQUESTS': False, } } …
also edit the second config file:
nano /home/sentry/.sentry/config.yml
specifying the data to connect to redis:
… redis.clusters: default: hosts: 0: host: 127.0.0.1 port: 6379 …
Now we need to configure PostgreSQL permissions so that the Sentry user can connect to the database without any problems. Edit the file with the command:
nano /var/lib/pgsql/data/pg_hba.conf
we bring it to the following form:
# TYPE DATABASE USER ADDRESS METHOD local all postgres peer # "local" is for Unix domain socket connections only local all all peer # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 # Allow replication connections from localhost, by a user with the # replication privilege. #local replication postgres peer #host replication postgres 127.0.0.1/32 ident #host replication postgres ::1/128 ident
Restart PostgreSQL with the command:
systemctl restart postgresql.service
Now execute the command:
/home/sentry/sentry_app/bin/sentry upgrade
in the process you will need to enter an email for the super user.
Next, we need to configure the supervisor that will manage the Sentry services. To do this, edit the supervisr config file with the command:
nano /etc/supervisord.conf
and at the very bottom we indicate the following:
files = supervisord.d/*.conf
Thus, we indicate that in the /etc/supervisord.d/ folder there will be configuration files that must be taken into account when the service is running.
Create a configuration file for managing Sentry services with the command
nano /etc/supervisord.d/sentry.conf
and paste the following contents into it:
[program:sentry-web] directory=/home/sentry/sentry_app/ environment=SENTRY_CONF="/home/sentry/.sentry" command=/home/sentry/sentry_app/bin/sentry --config=/home/sentry/.sentry run web autostart=true autorestart=true redirect_stderr=true user=sentry stdout_logfile=syslog stderr_logfile=syslog [program:sentry-worker] directory=/home/sentry/sentry_app/ environment=SENTRY_CONF="/home/sentry/.sentry" command=/home/sentry/sentry_app/bin/sentry --config=/home/sentry/.sentry run worker autostart=true autorestart=true redirect_stderr=true user=sentry stdout_logfile=syslog stderr_logfile=syslog startsecs=1 startretries=3 stopsignal=TERM stopwaitsecs=10 stopasgroup=false killasgroup=true [program:sentry-cron] directory=/home/sentry/sentry_app/ environment=SENTRY_CONF="/home/sentry/.sentry" command=/home/sentry/sentry_app/bin/sentry --config=/home/sentry/.sentry run cron autostart=true autorestart=true redirect_stderr=true user=sentry stdout_logfile=syslog stderr_logfile=syslog
Restart the supervisor and update its configuration with the commands:
service supervisord restart supervisorctl reread supervisorctl update
Sentry installation and configuration is complete. Now we can using the url of the form:
http://server_ip_address:9000
Log in to the Sentry web control panel and connect your application to collect errors.