Advertising:

Instalación Zabbix 4.4 + PostgreSQL + TimescaleDB en CentOS 8: Difference between revisions

From Zabbix-ES
Jump to navigation Jump to search
(Created page with "==Seccion== ===Sub 1=== $ dnf check-update $ dnf -y update '''Titulo en Negrita:''' Hola ''Mundo''. ===Sub 2=== ====Sub 2.1==== ====Sub 2.2==== ===Sub 3=== ==Seccion 2== =...")
 
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Seccion==
==Update systemc after install==
===Sub 1===
  $ dnf check-update
  $ dnf check-update
  $ dnf -y update
  $ dnf -y update


  '''Titulo en Negrita:''' Hola ''Mundo''.
==Stop and disable FirewallD==
===Sub 2===
$ systemctl stop firewalld
====Sub 2.1====
$ systemctl disable firewalld
====Sub 2.2====
 
===Sub 3===
==Configure SELinux==
==Seccion 2==
  '''Nota:''' SELINUX=disabled in the /etc/selinux/config file
===Sub 1===
 
  $ dnf check-update
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#      enforcing - SELinux security policy is enforced.
#      permissive - SELinux prints warnings instead of enforcing.
#      disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of these two values:
#      targeted - Targeted processes are protected,
#      mls - Multi Level Security protection.
SELINUXTYPE=targeted
                       
'''Nota:''' Reboot your system. After reboot, confirm that the getenforce command returns Disabled
$getenforce
Disabled
 
==Install and update Webmin via RPM==
'''Nota:''' Create the /etc/yum.repos.d/webmin.repo file containing: (Optional)
 
[Webmin]
name=Webmin Distribution Neutral
#baseurl=https://download.webmin.com/download/yum
mirrorlist=https://download.webmin.com/download/yum/mirrorlist
enabled=1
 
===You should also fetch and install my GPG key with which the packages are signed, with the commands===
$ dnf -y install wget
$ cd /tmp
$ wget http://www.webmin.com/jcameron-key.asc
$ rpm --import jcameron-key.asc
 
===You will now be able to install with the command===
$ dnf -y install webmin
 
==All dependencies should be resolved automatically==
# To modify my listen port:
$ dnf -y install perl-Socket6
 
==To use the PostgreSQL Yum Repository, follow these steps==
'''Nota:''' Disable the AppStream modules You will probably never want to use if You use pgdg build (dnf -y module disable postgresql).
$ dnf -y module disable postgresql
 
==Instalacion de PostgreSQL==
===Install the repository RPM===
$ dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
 
===Install the client packages===
$ dnf install postgresql11
 
===Optionally install the server packages===
$ dnf install postgresql11-server
 
===Optionally initialize the database and enable automatic start===  
  $ /usr/pgsql-11/bin/postgresql-11-setup initdb
  $ systemctl enable postgresql-11
  $ systemctl start postgresql-11
 
===Modify  pg_hba.conf in /var/lib/pgsql/11/data/, ident by md5===
# TYPE  DATABASE        USER            ADDRESS                METHOD
# "local" is for Unix domain socket connections only
local  all            all                                    peer
# IPv4 local connections:
host    all            all            127.0.0.1/32            ident --> md5
# IPv6 local connections:
host    all            all            ::1/128                ident --> md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local  replication    all                                    peer
host    replication    all            127.0.0.1/32            ident --> md5
host    replication    all            ::1/128                ident --> md5
 
==Install Zabbix repository==
$ rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm
  $ dnf clean all
 
==Install Zabbix server, frontend, agent==
$ dnf -y install zabbix-server-pgsql zabbix-web-pgsql zabbix-apache-conf zabbix-agent
 
==Create initial database==
$ sudo -u postgres createuser --pwprompt zabbix
$ sudo -u postgres createdb -O zabbix zabbix
 
==Import initial schema and data. You will be prompted to enter your newly created password==
$ zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix
 
==Configure the database for Zabbix server==
# Edit file /etc/zabbix/zabbix_server.conf
DBPassword=password
 
==Configure PHP for Zabbix frontend==
# Edit file /etc/php-fpm.d/zabbix.conf, uncomment and set the right timezone for you.
php_value[date.timezone] = America/Argentina/Buenos_Aires
 
==Start Zabbix server and agent processes and make it start at system boot==
$ systemctl restart zabbix-server zabbix-agent httpd php-fpm
$ systemctl enable zabbix-server zabbix-agent httpd php-fpm
 
==Connect to your newly installed Zabbix frontend==
'''Nota:''' http://server_ip_or_name/zabbix
 
==Install TimescaleDB extension and Configure==
'''Nota: ''' Add TimescaleDB's third party repository and install TimescaleDB, which will download any dependencies it needs from the PostgreSQL repo.
 
$ tee /etc/yum.repos.d/timescale_timescaledb.repo <<EOL
[timescale_timescaledb]
name=timescale_timescaledb
baseurl=https://packagecloud.io/timescale/timescaledb/el/8/\$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/timescale/timescaledb/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOL
 
  $ dnf -y update
  $ dnf -y update
$ dnf -y install timescaledb-postgresql-11
===The easiest way to get started is to run timescaledb-tune===
$ timescaledb-tune --pg-config=/usr/pgsql-11/bin/pg_config
===These changes are then written to your postgresql.conf and will take effect on the next (re)start===
$ systemctl restart postgresql-11
===TimescaleDB extension must also be enabled for the specific DB by executing===
$ echo "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" | sudo -u postgres psql zabbix
'''Result:'''
could not change directory to "/root": Permission denied
WARNING:
WELCOME TO
  _____ _                              _    ____________
|_  _(_)                            | |    |  _  \ ___ \
  | |  _ _ __ ___  ___  ___  ___ __ _| | ___| | | | |_/ /
  | | | |  _ ` _ \ / _ \/ __|/ __/ _` | |/ _ \ | | | ___ \
  | | | | | | | | |  __/\__ \ (_| (_| | |  __/ |/ /| |_/ /
  |_| |_|_| |_| |_|\___||___/\___\__,_|_|\___|___/ \____/
                Running version 1.4.2
For more information on TimescaleDB, please visit the following links:
  1. Getting started: https://docs.timescale.com/getting-started
  2. API reference documentation: https://docs.timescale.com/api
  3. How TimescaleDB is designed: https://docs.timescale.com/introduction/architecture
'''Note:''' TimescaleDB collects anonymous reports to better understand and assist our users.
For more information and how to disable, please see our docs https://docs.timescaledb.com/using-timescaledb/telemetry.
CREATE EXTENSION
===Then run the timescaledb.sql script located in database/postgresql===
'''Nota:''' Si la BD es grande, es recomendable ejecutar el particionado desde una sesion con el comando screen par poder dejarla en BG ya que puede tardar mucho tiempo.


  '''Titulo en Negrita:''' Hola Mundo.
  # zcat /usr/share/doc/zabbix-server-pgsql-5.0.0/timescaledb.sql.gz | sudo -u zabbix psql zabbix
===Sub 2===
$ dnf check-update
$ dnf -y update


  '''Titulo en Negrita:''' Hola Mundo.
===timescaledb.sql===
# zcat /usr/share/doc/zabbix-server-pgsql-5.0.0/timescaledb.sql.gz
SELECT create_hypertable('history', 'clock', chunk_time_interval => 86400, migrate_data => true);
SELECT create_hypertable('history_uint', 'clock', chunk_time_interval => 86400, migrate_data => true);
SELECT create_hypertable('history_log', 'clock', chunk_time_interval => 86400, migrate_data => true);
  SELECT create_hypertable('history_text', 'clock', chunk_time_interval => 86400, migrate_data => true);
SELECT create_hypertable('history_str', 'clock', chunk_time_interval => 86400, migrate_data => true);
SELECT create_hypertable('trends', 'clock', chunk_time_interval => 86400, migrate_data => true);
SELECT create_hypertable('trends_uint', 'clock', chunk_time_interval => 86400, migrate_data => true);
UPDATE config SET db_extension='timescaledb',hk_history_global=1,hk_trends_global=1;
UPDATE config SET compression_status=1,compress_older='7d';

Latest revision as of 16:10, 25 May 2020

Update systemc after install

$ dnf check-update
$ dnf -y update

Stop and disable FirewallD

$ systemctl stop firewalld
$ systemctl disable firewalld

Configure SELinux

Nota: SELINUX=disabled in the /etc/selinux/config file
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of these two values:
#       targeted - Targeted processes are protected,
#       mls - Multi Level Security protection.
SELINUXTYPE=targeted
                       
Nota: Reboot your system. After reboot, confirm that the getenforce command returns Disabled
$getenforce
Disabled

Install and update Webmin via RPM

Nota: Create the /etc/yum.repos.d/webmin.repo file containing:	(Optional)
[Webmin]
name=Webmin Distribution Neutral
#baseurl=https://download.webmin.com/download/yum
mirrorlist=https://download.webmin.com/download/yum/mirrorlist
enabled=1

You should also fetch and install my GPG key with which the packages are signed, with the commands

$ dnf -y install wget
$ cd /tmp
$ wget http://www.webmin.com/jcameron-key.asc
$ rpm --import jcameron-key.asc

You will now be able to install with the command

$ dnf -y install webmin

All dependencies should be resolved automatically

# To modify my listen port:
$ dnf -y install perl-Socket6

To use the PostgreSQL Yum Repository, follow these steps

Nota: Disable the AppStream modules You will probably never want to use if You use pgdg build (dnf -y module disable postgresql).
$ dnf -y module disable postgresql

Instalacion de PostgreSQL

Install the repository RPM

$ dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Install the client packages

$ dnf install postgresql11

Optionally install the server packages

$ dnf install postgresql11-server

Optionally initialize the database and enable automatic start

 $ /usr/pgsql-11/bin/postgresql-11-setup initdb
 $ systemctl enable postgresql-11
 $ systemctl start postgresql-11

Modify pg_hba.conf in /var/lib/pgsql/11/data/, ident by md5

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer

# IPv4 local connections:
host    all             all             127.0.0.1/32            ident --> md5

# IPv6 local connections:
host    all             all             ::1/128                 ident --> md5

# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            ident --> md5
host    replication     all             ::1/128                 ident --> md5

Install Zabbix repository

$ rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm
$ dnf clean all

Install Zabbix server, frontend, agent

$ dnf -y install zabbix-server-pgsql zabbix-web-pgsql zabbix-apache-conf zabbix-agent

Create initial database

$ sudo -u postgres createuser --pwprompt zabbix
$ sudo -u postgres createdb -O zabbix zabbix

Import initial schema and data. You will be prompted to enter your newly created password

$ zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix

Configure the database for Zabbix server

# Edit file /etc/zabbix/zabbix_server.conf
DBPassword=password

Configure PHP for Zabbix frontend

#	Edit file /etc/php-fpm.d/zabbix.conf, uncomment and set the right timezone for you.
php_value[date.timezone] = America/Argentina/Buenos_Aires

Start Zabbix server and agent processes and make it start at system boot

$ systemctl restart zabbix-server zabbix-agent httpd php-fpm
$ systemctl enable zabbix-server zabbix-agent httpd php-fpm

Connect to your newly installed Zabbix frontend

Nota: http://server_ip_or_name/zabbix

Install TimescaleDB extension and Configure

Nota:  Add TimescaleDB's third party repository and install TimescaleDB, which will download any dependencies it needs from the PostgreSQL repo.
$ tee /etc/yum.repos.d/timescale_timescaledb.repo <<EOL
[timescale_timescaledb]
name=timescale_timescaledb
baseurl=https://packagecloud.io/timescale/timescaledb/el/8/\$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/timescale/timescaledb/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOL
$ dnf -y update
$ dnf -y install timescaledb-postgresql-11

The easiest way to get started is to run timescaledb-tune

$ timescaledb-tune --pg-config=/usr/pgsql-11/bin/pg_config

These changes are then written to your postgresql.conf and will take effect on the next (re)start

$ systemctl restart postgresql-11

TimescaleDB extension must also be enabled for the specific DB by executing

$ echo "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" | sudo -u postgres psql zabbix
Result:
could not change directory to "/root": Permission denied
WARNING:
WELCOME TO
 _____ _                               _     ____________
|_   _(_)                             | |    |  _  \ ___ \
  | |  _ _ __ ___   ___  ___  ___ __ _| | ___| | | | |_/ /
  | | | |  _ ` _ \ / _ \/ __|/ __/ _` | |/ _ \ | | | ___ \
  | | | | | | | | |  __/\__ \ (_| (_| | |  __/ |/ /| |_/ /
  |_| |_|_| |_| |_|\___||___/\___\__,_|_|\___|___/ \____/
               Running version 1.4.2
For more information on TimescaleDB, please visit the following links:

 1. Getting started: https://docs.timescale.com/getting-started
 2. API reference documentation: https://docs.timescale.com/api
 3. How TimescaleDB is designed: https://docs.timescale.com/introduction/architecture

Note: TimescaleDB collects anonymous reports to better understand and assist our users.
For more information and how to disable, please see our docs https://docs.timescaledb.com/using-timescaledb/telemetry.
CREATE EXTENSION

Then run the timescaledb.sql script located in database/postgresql

Nota: Si la BD es grande, es recomendable ejecutar el particionado desde una sesion con el comando screen par poder dejarla en BG ya que puede tardar mucho tiempo.
# zcat /usr/share/doc/zabbix-server-pgsql-5.0.0/timescaledb.sql.gz | sudo -u zabbix psql zabbix

timescaledb.sql

# zcat /usr/share/doc/zabbix-server-pgsql-5.0.0/timescaledb.sql.gz

SELECT create_hypertable('history', 'clock', chunk_time_interval => 86400, migrate_data => true);
SELECT create_hypertable('history_uint', 'clock', chunk_time_interval => 86400, migrate_data => true);
SELECT create_hypertable('history_log', 'clock', chunk_time_interval => 86400, migrate_data => true);
SELECT create_hypertable('history_text', 'clock', chunk_time_interval => 86400, migrate_data => true);
SELECT create_hypertable('history_str', 'clock', chunk_time_interval => 86400, migrate_data => true);
SELECT create_hypertable('trends', 'clock', chunk_time_interval => 86400, migrate_data => true);
SELECT create_hypertable('trends_uint', 'clock', chunk_time_interval => 86400, migrate_data => true);
UPDATE config SET db_extension='timescaledb',hk_history_global=1,hk_trends_global=1;
UPDATE config SET compression_status=1,compress_older='7d';