Advertising:

Instalacion desde 0 - Zabbix Server 7.X + PostgreSQL 16 con TimeScaleDB 2

From Zabbix-ES
Jump to navigation Jump to search

Pre requisitos para instalar Zabbix 7.X en RHEL9 o OL9

Requerimientos             : https://www.zabbix.com/documentation/7.0/en/manual/installation/requirements
PostgreSQL                 : 13.0-16.X
TimescaleDB for PostgreSQL : 2.13.0-2.15.X
Apache                     : 2.4 or later o Nginx: 1.20 or later
PHP                        : 8.0.0 - 8.3.X

Despliegue de la infraestructura

[Infraestructura via Vagrant - Laboratorio]

Instalacion de Zabbix Server, Zabbix Frontend y Zabbix Agent2

-- SI instalamos EPEL tenemos que desahabilitar la paqueteria de Zabbix y php que nos trae EPEL
[root@zbxserver01 ~]# echo excludepkgs=php* zabbix* >>/etc/yum.repos.d/oracle-epel-ol9.repo 
[root@zbxserver01 ~]# dnf config-manager --set-disabled ol9_developer_EPEL
[root@zbxserver01 ~]# rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rhel/9/x86_64/zabbix-release-7.0-3.el9.noarch.rpm
[root@zbxserver01 ~]# dnf clean all 
[root@zbxserver01 ~]# dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-java-gateway zabbix-agent2 zabbix-agent2-plugin-*
[root@zbxserver01 ~]# dnf install httpd httpd-devel
[root@zbxserver01 ~]# dnf install php php-*
[root@zbxserver01 ~]# dnf install gd gettext openssl curl libevent libpq libssh libcurl libxml2 net-snmp fping

Instalacion y configuracion de Postgres 16

[root@zbxserver01 ~]# dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
[root@zbxserver01 ~]# dnf -qy module disable postgresql
[root@zbxserver01 ~]# dnf install -y postgresql16-server
[root@zbxserver01 ~]# /usr/pgsql-16/bin/postgresql-16-setup initdb
[root@zbxserver01 ~]# systemctl enable postgresql-16
[root@zbxserver01 ~]# systemctl start postgresql-16
[root@zbxserver01 ~]# dnf config-manager --set-disabled pgdg12 pgdg13 pgdg14 pgdg15
[root@zbxserver01 ~]# su - postgres
[postgres@zbxserver01 ~]$ createuser --pwprompt zabbix
[postgres@zbxserver01 ~]$ createdb -O zabbix zabbix
[postgres@zbxserver01 ~]$ exit
[root@zbxserver01 ~]# zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix 
[root@zbxserver01 ~]# vi /etc/zabbix/zabbix_server.conf
DBPassword=Z4bb1x

Instalacion de TimeScaleDB

[root@zbxserver01 ~]# tee /etc/yum.repos.d/timescale_timescaledb.repo <<EOL
[timescale_timescaledb]
name=timescale_timescaledb
baseurl=https://packagecloud.io/timescale/timescaledb/el/$(rpm -E %{rhel})/\$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

[root@zbxserver01 ~]# dnf update
[root@zbxserver01 ~]# dnf install timescaledb-2-postgresql-16

Configuracion de TimeScaleDB 2.15 + PostgreSQL 16

Notas: https://www.zabbix.com/documentation/7.0/en/manual/appendix/install/timescaledb?hl=usr%2Fshare%2Fzabbix%2Csql%2Cscripts%2Fpostgresql%2Ftimescaledb

[root@zbxserver01 postgresql]# echo "shared_preload_libraries = 'timescaledb'" >> /var/lib/pgsql/16/data/postgresql.conf
[root@zbxserver01 postgresql]# systemctl restart postgresql-16.service 
[root@zbxserver01 postgresql]# echo "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" | sudo -u postgres psql zabbix
CREATE EXTENSION

-- Creación de Hipertablas
[root@zbxserver01 postgresql]# cat /usr/share/zabbix-sql-scripts/postgresql/timescaledb/schema.sql | sudo -u zabbix psql zabbix
--- Verificamos las Hipertablas creadas 
[root@zbxserver01 postgresql]# echo "SELECT * FROM timescaledb_information.hypertables;" | sudo -u postgres psql zabbix


Configuracion Zabbix Frontend

[root@zbxserver01 ~]# systemctl restart zabbix-server zabbix-agent2 httpd php-fpm
[root@zbxserver01 ~]# systemctl enable zabbix-server zabbix-agent2 httpd php-fpm

[root@zbxserver01 ~]# vi /etc/php.ini
date.timezone = "Europe/Madrid"

[root@zbxserver01 ~]# vi /etc/php-fpm.d/zabbix.conf
php_value[date.timezone] = Europe/Madrid

[root@zbxserver01 ~]# cat <<"EOF" >/var/www/html/index.html
<html>
<head>
<title>Zabbix Server</title>
<meta http-equiv="refresh" content="0; URL=http://10.1.100.100/zabbix">
<meta name="keywords" content="automatic redirection">
</head>
<body>
</body>
</html>
EOF

[root@zbxserver01 ~]# systemctl restart httpd php-fpm zabbix-server

[Zabbix Server]


Errores y Soluciones post instalaicon

ERROR: Unsupported DB! timescaledb version 21503 is newer than 21499
SOLUCION: Actualizar a version 7.0.2 o superior
ERROR: for a discovery process with 5 workers, the user limit of 1024 file descriptors is insufficient. The maximum number of concurrent checks per worker has been reduced to 122
SOLUCION:
### Solo para Zabbix
# mkdir -p /etc/systemd/system/zabbix-server.service.d
# cat <<'EOF' >/etc/systemd/system/zabbix-server.service.d/filelimit.conf 
[Service]
LimitNOFILE=500000
EOF
# systemctl daemon-reload
# sudo -u zabbix ulimit -Sn

### Para todo el sistema
# mkdir -p /etc/systemd/system.conf.d/
# cat >/etc/systemd/system.conf.d/10-filelimit.conf <<EOF
[Manager]
DefaultLimitNOFILE=500000
EOF
ERROR: query failed: [0] PGRES_FATAL_ERROR:ERROR:  table "history_bin" is not a hypertable
       [select set_integer_now_func('history_bin', 'zbx_ts_unix_now', true)]
       Table "history_bin" is not a hypertable. Execute TimescaleDB configuration step as described in Zabbix documentation to upgrade schema.

SOLUCION: Volver a ejecutar el script de timescaledb.
[root@zbxserver01 ~]# cd /usr/share/zabbix-sql-scripts/postgresql/timescaledb/
[root@zbxserver01 ~]# cat /usr/share/zabbix-sql-scripts/postgresql/timescaledb/schema.sql | sudo -u zabbix psql zabbix
[root@zbxserver01 ~]# sudo -u zabbix psql zabbix
zabbix=> select * from _timescaledb_catalog.hypertable;
 id |      schema_name      |        table_name         | associated_schema_name | associated_table_prefix | num_dimensions | chunk_sizing_func_schema |  chunk_sizing_func_name  | chunk_target_size | compression_state | compressed_hypertable_id | status 
----+-----------------------+---------------------------+------------------------+-------------------------+----------------+--------------------------+--------------------------+-------------------+-------------------+--------------------------+--------
  1 | public                | history                   | _timescaledb_internal  | _hyper_1                |              1 | _timescaledb_functions   | calculate_chunk_interval |                 0 |                 1 |                        9 |      0
  2 | public                | history_uint              | _timescaledb_internal  | _hyper_2                |              1 | _timescaledb_functions   | calculate_chunk_interval |                 0 |                 1 |                       10 |      0
  5 | public                | history_str               | _timescaledb_internal  | _hyper_5                |              1 | _timescaledb_functions   | calculate_chunk_interval |                 0 |                 1 |                       11 |      0
  4 | public                | history_text              | _timescaledb_internal  | _hyper_4                |              1 | _timescaledb_functions   | calculate_chunk_interval |                 0 |                 1 |                       12 |      0
  3 | public                | history_log               | _timescaledb_internal  | _hyper_3                |              1 | _timescaledb_functions   | calculate_chunk_interval |                 0 |                 1 |                       13 |      0
  7 | public                | trends                    | _timescaledb_internal  | _hyper_7                |              1 | _timescaledb_functions   | calculate_chunk_interval |                 0 |                 1 |                       14 |      0
  8 | public                | trends_uint               | _timescaledb_internal  | _hyper_8                |              1 | _timescaledb_functions   | calculate_chunk_interval |                 0 |                 1 |                       15 |      0
  6 | public                | auditlog                  | _timescaledb_internal  | _hyper_6                |              1 | _timescaledb_functions   | calculate_chunk_interval |                 0 |                 1 |                       16 |      0
 17 | public                | history_bin    <------ Hipertabla creada
(17 rows)

zabbix=> quit
Nota: Ver si se ejecuto el tune de TSDB sino aplicarlo y ajustar parametros como max_connections que los baja a 25.
[postgres@zbxserver01 ~]$ timescaledb-tune --pg-config=/usr/pgsql-16/bin/pg_config