Differences

This shows you the differences between two versions of the page.

Link to this comparison view

installing_and_configuring_zabbix_server_3.2_on_debian_jessie_with_postgresql_en [2017/09/05 12:18] (current)
Line 1: Line 1:
 +====== Installing and Configuring Zabbix Server 3.2 on Debian Jessie with PostgreSQL ======
 +
 +WORKING ON IT
 +
 +Here I'll show you how to install and configure the Zabbix Server 3.2 and client, the Zabbix server will installed on Debian Jessie.
 +
 +Let's roll up our sleeves and start to work.
 +
 +  * Debian Jessie Zabbix Server ip: 10.0.0.136
 +
 +Here I will use the following repositories,​ use the ones that fits better you.
 +<sxh bash>
 +vim /​etc/​apt/​sources.list
 +# /​etc/​apt/​sources.list
 +deb http://​ftp.br.debian.org/​debian/​ jessie main
 +deb-src http://​ftp.br.debian.org/​debian/​ jessie main
 +
 +deb http://​security.debian.org/​ jessie/​updates main
 +deb-src http://​security.debian.org/​ jessie/​updates main
 +
 +# jessie-updates,​ previously known as '​volatile'​
 +deb http://​ftp.br.debian.org/​debian/​ jessie-updates main
 +deb-src http://​ftp.br.debian.org/​debian/​ jessie-updates main
 +</​sxh>​
 +
 +Let's start installing the Database
 +<sxh bash>
 +aptitude install postgresql postgresql-client postgresql-common postgresql-contrib postgresql-doc \
 +postgresql-server-dev-all -y
 +</​sxh>​
 +
 +Now let's change the postgres password into the database
 +
 +Let's change the user to postgres
 +<sxh bash>
 +su - postgres
 +</​sxh>​
 +
 +Now let's access the psql
 +<sxh bash>
 +psql
 +</​sxh>​
 +
 +Now let's set the password.
 +<sxh bash>
 +ALTER USER postgres WITH PASSWORD '​McW1k8v020E9VqA';​
 +</​sxh>​
 +
 +Now to exit from the psql 
 +<sxh bash>
 +\q
 +</​sxh>​
 +
 +If you don't have a way to create a good password use the following web link to create a good one: [[http://​strongpasswordgenerator.com/​|Strong Password Generator]]
 +
 +Now we can login again with the new password
 +<sxh bash>
 +psql -h localhost -U postgres -W
 +Password for user postgres:
 +psql (9.4.7)
 +SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384,​ bits: 256, compression:​ off)
 +Type "​help"​ for help.
 +
 +postgres=# \q
 +</​sxh>​
 +
 +Now let's create a new user into postgresql, the zabbix user will use the following password: **AwX2O0k83mU40TS**
 +<sxh bash>
 +psql -h localhost -U postgres -W
 +CREATE USER zabbix WITH PASSWORD '​AwX2O0k83mU40TS';​
 +</​sxh>​
 +
 +Now we need to create the database that will be used by the Zabbix
 +<sxh bash>
 +CREATE DATABASE zabbix WITH OWNER zabbix;
 +</​sxh>​
 +
 +Now we can exit from psql
 +<sxh bash>
 +\q
 +</​sxh>​
 +
 +We need to get the repository to install Zabbix with the lastest version is always the best way to install the Zabbix because we always will have more features and new resources to work.
 +
 +<sxh bash>
 +cd /tmp && wget -c http://​repo.zabbix.com/​zabbix/​3.2/​debian/​pool/​main/​z/​zabbix-release/​zabbix-release_3.2-1+jessie_all.deb
 +</​sxh>​
 +
 +Now we need to install the repository like this
 +<sxh bash>
 +dpkg -i zabbix-release_3.2-1+jessie_all.deb
 +</​sxh>​
 +
 +Now we need to update the repositories cache with the follow command
 +<sxh bash>
 +aptitude update
 +</​sxh>​
 +
 +Now let's install the Zabbix Server with PostgreSQL support and its dependencies.
 +<sxh bash>
 +aptitude install zabbix-server-pgsql zabbix-sender snmp -y
 +</​sxh>​
 +
 +Now we need to access the directory that store the database structure
 +<sxh bash>
 +cd /​usr/​share/​doc/​zabbix-server-pgsql
 +</​sxh>​
 +
 +Now we need to decompress the file
 +<sxh bash>
 +gunzip create.sql.gz
 +</​sxh>​
 +
 +Now we need to export a variable to the environment to avoid getting warnings about the password
 +<sxh bash>
 +export PGPASSWORD="​AwX2O0k83mU40TS"​
 +</​sxh>​
 +
 +Now we can import the database structure
 +<sxh bash>
 +psql -h localhost -U zabbix -d zabbix -f create.sql
 +</​sxh>​
 +
 +Now we need to configure the zabbix server configuration file
 +<sxh bash>
 +vim /​etc/​zabbix/​zabbix_server.conf
 +[...]
 +DBName=zabbix
 +[...]
 +DBUser=zabbix
 +[...]
 +DBPassword=AwX2O0k83mU40TS
 +</​sxh>​
 +
 +Now we need to restart the Zabbix Server like this
 +<sxh bash>
 +systemctl status zabbix-server
 +</​sxh>​
 +
 +Now we're able to see the logs with the follow command
 +<sxh bash>
 +tail -f /​var/​log/​zabbix/​zabbix_server.log
 +  7425:​20150316:​103253.365 server #3 started [poller #1]
 +  7424:​20150316:​103253.367 server #2 started [db watchdog #1]
 +  7423:​20150316:​103253.368 server #1 started [configuration syncer #1]
 +  7459:​20150316:​103253.376 server #20 started [history syncer #1]
 +  7462:​20150316:​103253.376 server #23 started [history syncer #4]
 +  7461:​20150316:​103253.377 server #22 started [history syncer #3]
 +  7464:​20150316:​103253.377 server #25 started [proxy poller #1]
 +  7465:​20150316:​103253.377 server #26 started [self-monitoring #1]
 +  7463:​20150316:​103253.377 server #24 started [escalator #1]
 +  7460:​20150316:​103253.377 server #21 started [history syncer #2]
 +</​sxh>​
 +
 +
 +We can double check to see if the zabbix_serer is running
 +<sxh bash>
 +ps -C zabbix_server
 +  PID TTY          TIME CMD
 + 7420 ?        00:00:00 zabbix_server
 + 7423 ?        00:00:00 zabbix_server
 + 7424 ?        00:00:00 zabbix_server
 + 7425 ?        00:00:00 zabbix_server
 + 7426 ?        00:00:00 zabbix_server
 + 7427 ?        00:00:00 zabbix_server
 + 7428 ?        00:00:00 zabbix_server
 + 7429 ?        00:00:00 zabbix_server
 + 7430 ?        00:00:00 zabbix_server
 + 7431 ?        00:00:00 zabbix_server
 + 7432 ?        00:00:00 zabbix_server
 + 7433 ?        00:00:00 zabbix_server
 + 7434 ?        00:00:00 zabbix_server
 + 7435 ?        00:00:00 zabbix_server
 + 7436 ?        00:00:00 zabbix_server
 + 7437 ?        00:00:00 zabbix_server
 + 7438 ?        00:00:00 zabbix_server
 + 7439 ?        00:00:00 zabbix_server
 + 7440 ?        00:00:00 zabbix_server
 + 7441 ?        00:00:00 zabbix_server
 + 7459 ?        00:00:00 zabbix_server
 + 7460 ?        00:00:00 zabbix_server
 + 7461 ?        00:00:00 zabbix_server
 + 7462 ?        00:00:00 zabbix_server
 + 7463 ?        00:00:00 zabbix_server
 + 7464 ?        00:00:00 zabbix_server
 + 7465 ?        00:00:00 zabbix_server
 +</​sxh>​
 +
 +===== Installing and Configuring Zabbix Frontend =====
 +
 +We need to install the Zabbix frontend that will be used to manager the zabbix and their clients
 +<sxh bash>
 +aptitude install zabbix-frontend-php php5-pgsql -y
 +</​sxh>​
 +
 +Now we need to create the Virtualhost that will be used by the Zabbix Frontend
 +<sxh apache>
 +vim /​etc/​apache2/​sites-available/​zabbix.conf
 +<​VirtualHost *:80>
 +    ServerAdmin webmaster@douglasqsantos.com.br
 +    ServerName zabbix.douglasqsantos.com.br
 +    DocumentRoot /​usr/​share/​zabbix
 +
 +<​Directory "/​usr/​share/​zabbix">​
 +    Options FollowSymLinks
 +    AllowOverride None
 +    Require all granted
 +
 +    <​IfModule mod_php5.c>​
 +     php_value max_execution_time 300
 +     php_value memory_limit 128M
 +     php_value post_max_size 16M
 +     php_value upload_max_filesize 2M
 +     php_value max_input_time 300
 +     php_value always_populate_raw_post_data -1
 +     php_value date.timezone America/​Sao_Paulo
 +    </​IfModule>​
 +</​Directory>​
 +
 +<​Directory "/​usr/​share/​zabbix/​conf">​
 +    Require all denied
 +    <files *.php>
 +      Require all denied
 +    </​files>​
 +</​Directory>​
 +
 +<​Directory "/​usr/​share/​zabbix/​app">​
 +    Require all denied
 +    <files *.php>
 +      Require all denied
 +    </​files>​
 +</​Directory>​
 +
 +<​Directory "/​usr/​share/​zabbix/​include">​
 +    Require all denied
 +    <files *.php>
 +      Require all denied
 +    </​files>​
 +</​Directory>​
 +
 +<​Directory "/​usr/​share/​zabbix/​local">​
 +    Require all denied
 +    <files *.php>
 +     ​Require all denied
 +    </​files>​
 +</​Directory>​
 +   ​ErrorLog /​var/​log/​apache2/​zabbix.douglasqsantos.com.br-error.log
 +   ​LogLevel warn
 +   ​CustomLog /​var/​log/​apache2/​zabbix.douglasqsantos.com.br-access.log combined
 +</​VirtualHost>​
 +</​sxh>​
 +
 +Now we need to disable the default virtual host, the default zabbix configuration and enable the zabbix'​s virtual host
 +<sxh bash>
 +a2dissite 000-default.conf
 +a2disconf zabbix.conf
 +a2ensite zabbix.conf
 +</​sxh>​
 +
 +Now restart the apache server like this
 +<sxh bash>
 +systemctl restart apache2
 +</​sxh>​
 +
 +Now we need to configure the frontend access http://​192.168.25.150 or http://​zabbix.douglasqsantos.com.br
 +  * In the first page click on **Next**
 +  * If the all prerequisites is ok click on **Next** or configure the ones that need to be fixed
 +  * Here we need to configure the Database:
 +    * Database type: **PostgreSQL**
 +    * Database host: **localhost**
 +    * Database port: **0**
 +    * Database name: **zabbix**
 +    * User: **zabbix**
 +    * Password: ** AwX2O0k83mU40TS **
 +    * Click in **Next**
 +  * Now we need to only to click on **Next** because the default configuration is ok
 +  * Now click on **Next** again
 +  * Now click on **Finish** ​
 +
 +Now we can login as user: **Admin** password: **zabbix**
 +
 +===== Installing and Configuring Zabbix Server as Zabbix Client ​ =====
 +
 +Let's install the packets to enable the Zabbix Client, here needs to install the zabbix-get too to get information about the clients and to troubleshooting the problems.
 +
 +<sxh bash>
 +aptitude install zabbix-agent zabbix-get ​ -y
 +</​sxh>​
 +
 +Now let's create the PSK agent key.
 +<sxh bash>
 +openssl rand -hex 32 > /​etc/​zabbix/​zabbix_agentd.psk
 +</​sxh>​
 +
 +Now needs to configure the client the configuration is very simple we need to change only two lines
 +<sxh bash>
 +vim /​etc/​zabbix/​zabbix_agentd.conf
 +[...]
 +Server=127.0.0.1
 +[...]
 +Hostname=Zabbix server
 +[...]
 +TLSConnect=psk
 +[...]
 +TLSAccept=psk
 +[...]
 +TLSPSKIdentity=PSK_Zabbix_Server
 +[...]
 +TLSPSKFile=/​etc/​zabbix/​zabbix_agentd.psk
 +</​sxh>​
 +
 +Now we need to remove the current file on the zabbix_agentd.d
 +<sxh bash>
 +rm -rf /​etc/​zabbix/​zabbix_agentd.d/​userparameter_mysql.conf
 +</​sxh>​
 +
 +Now needs to restart the Zabbix client service like this
 +<sxh bash>
 +systemctl restart zabbix-agent
 +</​sxh>​
 +
 +Let's double check if the zabbix-agent is working properly as we need
 +<sxh bash>
 +ps -C zabbix_agentd
 +  PID TTY          TIME CMD
 + 9930 ?        00:00:00 zabbix_agentd
 + 9932 ?        00:00:00 zabbix_agentd
 + 9933 ?        00:00:00 zabbix_agentd
 + 9934 ?        00:00:00 zabbix_agentd
 + 9935 ?        00:00:00 zabbix_agentd
 + 9936 ?        00:00:00 zabbix_agentd
 +</​sxh>​
 +
 +Let's get the kernel version from the client
 +<sxh bash>
 +zabbix_get -s127.0.0.1 -p10050 -ksystem.uname --tls-connect psk --tls-psk-identity "​PSK_Zabbix_Server"​ --tls-psk-file /​etc/​zabbix/​zabbix_agentd.psk
 +Linux noc01 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) x86_64
 +</​sxh>​
 +
 +Now getting the agent version like this
 +<sxh bash>
 +zabbix_get -s127.0.0.1 -p10050 -kagent.version --tls-connect psk --tls-psk-identity "​PSK_Zabbix_Server"​ --tls-psk-file /​etc/​zabbix/​zabbix_agentd.psk
 +3.2.4
 +</​sxh>​
 +
 +Now we can access http://​10.0.0.136 or http://​zabbix.douglasqsantos.com.br inform the user and password
 +
 +After log in into zabbix webinterface we ned to configure the Zabbix Server as Zabbix Client.
 +  * Configuration/​Hosts
 +  * Click on Zabbix Server
 +  * Select Encryption
 +    * Select in Connetions to hosts: **PSK**
 +    * Select in Connections from host: **PSK**
 +      * PSK Identity: PSK_Zabbix_Server
 +      * PSK: Here we need to put the value of (cat /​etc/​zabbix/​zabbix_agentd.psk) it will be something like: 0582bd62e1cc1a257260ea6b99d0cfc4cfd20d3f6a794c9ad830efe8b56a9c30
 +    * Now Click in Host Inventory
 +      * Select Automatic
 +    * Now click Host and Select Enabled
 +  * Now select Update
 +
 +Now we need to restart the Zabbix client service like this
 +<sxh bash>
 +systemctl restart zabbix-agent
 +</​sxh>​
 +
 +===== Installing and Configuring Zabbix Proxy  =====
 +
 +Let's configure the Zabbix Proxy, sometimes we need to have monitoring inside large organizations and we do not have all the access that we need, so we can configure the Zabbix Proxy inside the organization to send information to Zabbix Server.
 +
 +Note: The Zabbix Proxy is configured in another host rather than Zabbix Server.
 +
 +Now we need to install the necessary packages, let's start installing the database, we need the database to get all the information from the client store it and send to Zabbix server.
 +<sxh bash>
 +aptitude install postgresql postgresql-client postgresql-common postgresql-contrib postgresql-doc postgresql-server-dev-all -y
 +</​sxh>​
 +
 +Now we need to configure the password of postgres
 +<sxh bash>
 +su - postgres
 +</​sxh>​
 +
 +Now we need to access the psql
 +<sxh bash>
 +psql
 +</​sxh>​
 +
 +Changing the password
 +<sxh bash>
 +ALTER USER postgres WITH PASSWORD '​McW1k8v020E9VqA';​
 +\q
 +</​sxh>​
 +
 +Now we need to login into postgresql with the new password
 +<sxh bash>
 +psql -h localhost -U postgres -W
 +CREATE USER zabbix WITH PASSWORD '​AwX2O0k83mU40TS';​
 +</​sxh>​
 +
 +Now let's create the database that will be used by the Zabbix Proxy
 +<sxh bash>
 +CREATE DATABASE zabbix WITH OWNER zabbix;
 +</​sxh>​
 +
 +Let's configure the Zabbix Proxy.
 +
 +Let's install the repo
 +<sxh bash>
 +cd /tmp
 +wget -c http://​repo.zabbix.com/​zabbix/​3.2/​debian/​pool/​main/​z/​zabbix-release/​zabbix-release_3.2-1+jessie_all.deb
 +dpkg -i zabbix-release_3.2-1+jessie_all.deb
 +</​sxh>​
 +
 +Now let's install the Zabbix Proxy and the agent
 +<sxh bash>
 +aptitude update && aptitude install zabbix-agent zabbix-get zabbix-sender zabbix-proxy-pgsql snmp -y
 +</​sxh>​
 +
 +Now we need to unzip the database schema
 +<sxh bash>
 +cd /​usr/​share/​doc/​zabbix-proxy-pgsql/​
 +gunzip ​ schema.sql.gz
 +</​sxh>​
 +
 +Now we need to export the password to the environment so we can import the schema without any prompt about the password
 +<sxh bash>
 +export PGPASSWORD="​AwX2O0k83mU40TS"​
 +</​sxh>​
 +
 +Now let's import the schema
 +<sxh bash>
 +psql -h localhost -U zabbix -d zabbix -f schema.sql
 +</​sxh>​
 +
 +Now let's create the psk that will be used by the Zabbix Proxy
 +<sxh bash>
 +openssl rand -hex 32 > /​etc/​zabbix/​zabbix_proxy.psk
 +</​sxh>​
 +
 +Let's configure the zabbix_proxy.conf
 +<sxh bash>
 +vim /​etc/​zabbix/​zabbix_proxy.conf
 +[...]
 +ProxyMode=0
 +[...]
 +# Zabbix Server
 +Server=10.0.0.136
 +[...]
 +# This name will be used into the Zabbix server to get information about the Clients
 +Hostname=zabbix-proxy
 +[...]
 +# Database
 +DBName=zabbix
 +[...]
 +# User of Database
 +DBUser=zabbix
 +[...]
 +# Password of database
 +DBPassword=AwX2O0k83mU40TS
 +[...]
 +# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for '​unencrypted'​ connection)
 +# Default:
 +TLSConnect=psk
 +[...]
 +# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for '​unencrypted'​ connection)
 +# Default:
 +TLSAccept=psk
 +[...]
 +### Option: TLSPSKIdentity
 +#       ​Unique,​ case sensitive string used to identify the pre-shared key.
 +#
 +# Mandatory: no
 +# Default:
 +TLSPSKIdentity=PSK_Zabbix_Proxy_Server
 +[...]
 +### Option: TLSPSKFile
 +#       Full pathname of a file containing the pre-shared key.
 +#
 +# Mandatory: no
 +# Default:
 +TLSPSKFile=/​etc/​zabbix/​zabbix_proxy.psk
 +</​sxh>​
 +
 +Now we need to restart the Zabbix Proxy
 +<sxh bash>
 +systemctl restart zabbix-proxy
 +</​sxh>​
 +
 +Now log into the Zabbix Server WebInterface
 +  * Administration/​Proxies
 +    * Create Proxy
 +      * Proxy name: zabbix-proxy
 +      * Proxy mode: Active
 +    * Encryption
 +      * Connections from proxy: PSK
 +      * PSK identity: PSK_Zabbix_Proxy_Server
 +      * PSK: the value will be the result of (cat /​etc/​zabbix/​zabbix_agentd.psk) will be something like: cafdb6c73f6a63b15ffa65d2e07c23639c5c53c2a860451172402912238b65c2
 +      * Now Click Update