Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:monitoring:zabbix:install [2019/10/22 11:44]
jlucas [Install Zabbix frontend]
linux:monitoring:zabbix:install [2019/11/06 12:43] (current)
jlucas
Line 7: Line 7:
 For this install, I have setup an OpenBSD vmm instace with a fresh install of OpenBSD 6.6 (amd64).  I will be installing the latest (v4.4.0) release of Zabbix server and frontend.  For all additional packages I will be using what comes packaged with the OpenBSD 6.6 release.  Unless I find a reason for installing something different. For this install, I have setup an OpenBSD vmm instace with a fresh install of OpenBSD 6.6 (amd64).  I will be installing the latest (v4.4.0) release of Zabbix server and frontend.  For all additional packages I will be using what comes packaged with the OpenBSD 6.6 release.  Unless I find a reason for installing something different.
  
-====Update /etc/sysctl.conf====+====OpenBSD updates==== 
 + 
 +===Increase some limits===
  
 By default, a few of the system semephore and shared memory limits are too low. By default, a few of the system semephore and shared memory limits are too low.
Line 13: Line 15:
   doas vi /etc/sysctl.conf   doas vi /etc/sysctl.conf
      
-  kern.seminfo.semmsl=100 +  kern.pool_debug=0 
-  kern.seminfo.semmns=200 +  ddb.panic=0 
-  kern.shminfo.shmall=32769 +  kern.maxproc=16384 
- +  kern.maxthread=16384 
- +  kern.maxfiles=262144 
-====Install Zabbix Server====+  kern.shminfo.shmall=999999999 
 +  kern.shminfo.shmmax=1999999999 
 +  kern.seminfo.semmni=256 
 +  kern.seminfo.semmns=2048 
 +  kern.somaxconn=1024
  
 ===Setup the package management=== ===Setup the package management===
Line 26: Line 32:
   PKG_PATH="ftp://mirrors.syringanetworks.net/pub/OpenBSD/6.6/packages/amd64/"   PKG_PATH="ftp://mirrors.syringanetworks.net/pub/OpenBSD/6.6/packages/amd64/"
   export PKG_PATH   export PKG_PATH
 +
 +===Install packages====
  
 Install utilities needed to configure and install Zabbix Install utilities needed to configure and install Zabbix
  
-  doas pkg_add wget net-snmp curl libssh2 pcre+  doas pkg_add curl htop libssh2 net-snmp pcre wget
  
 ===Install PostgreSQL=== ===Install PostgreSQL===
Line 49: Line 57:
 You will see something like the following: You will see something like the following:
  
-  openbsd$ initdb -D /var/postgresql/data/ -U postgres --auth=md5 --pwprompt --encoding=UTF-8 --locale=en_US.UTF-8 
   The files belonging to this database system will be owned by user "_postgresql".   The files belonging to this database system will be owned by user "_postgresql".
   This user must also own the server process.   This user must also own the server process.
Line 80: Line 87:
 Enable and start the PostgreSQL server Enable and start the PostgreSQL server
  
-  openbsd$ doas rcctl enable postgresql +  doas rcctl enable postgresql
-  doas (jlucas@openbsd.cmsws.com) password:  +
-  openbsd$ doas rcctl start postgresql +
-  postgresql(ok)+
  
-Confirm you can connect+Populate the Zabbix DB within PostgreSQL
  
-  openbsd$ psql -U postgres  +Create Zabbix PostgreSQL user 
-  Password for user postgres + 
-  psql (11.5) +  doas -u _postgresql createuser -U postgres --pwprompt zabbix 
-  Type "help" for help+  Enter password for new role:  
-   +  Enter it again:  
-  postgres=#+  Password:  
 + 
 +Setup the database for Zabbix with the just create Zabbix user 
 + 
 +  doas -u _postgresql createdb -U postgres -O zabbix -E Unicode -T template0 zabbix 
 + 
 +Configure the database for Zabbix server.  Edit file /etc/zabbix/zabbix_server.conf 
 + 
 +  DBPassword=password 
 + 
 +====Zabbix Server from packages==== 
 + 
 +Install Zabbix server and agent from the package tree 
 + 
 +  doas pkg_add zabbix-server-4.0.11-pgsql zabbix-agent-4.0.11 
 + 
 +Import the initial schema and data 
 + 
 +  cat /usr/local/share/zabbix/schema/postgresql/schema.sql | doas psql -U zabbix zabbix 
 +  # stop here if you are creating database for Zabbix proxy 
 +  cat /usr/local/share/zabbix/schema/postgresql/images.sql | doas psql -U zabbix zabbix 
 +  cat /usr/local/share/zabbix/schema/postgresql/data.sql | doas psql -U zabbix zabbix 
 + 
 +Enable and start daemons 
 + 
 +  doas rcctl enable zabbix_server 
 +  doas rcctl start zabbix_server 
 +  doas rcctl enable zabbix_agentd 
 +  doas rcctl start zabbix_agentd 
 + 
 +Tail log file to make sure zabbix is running and working as expected 
 + 
 +  tail -f /tmp/zabbix_server.log
  
-===Install Zabbix===+====Zabbix Server from source====
  
 Download the latest release: Download the latest release:
Line 110: Line 146:
   doas useradd -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix   doas useradd -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
   doas chown zabbix:zabbix /usr/lib/zabbix   doas chown zabbix:zabbix /usr/lib/zabbix
- 
-Populate the Zabbix DB within PostgreSQL 
- 
-Create Zabbix PostgreSQL user 
- 
-  doas -u _postgresql createuser -U postgres --pwprompt zabbix 
-  Enter password for new role:  
-  Enter it again:  
-  Password:  
- 
-Setup the database for Zabbix with the just create Zabbix user 
- 
-  doas -u _postgresql createdb -U postgres -O zabbix -E Unicode -T template0 zabbix 
  
 Import the initial schema and data Import the initial schema and data
  
   cd zabbix-4.4.0/database/postgresql   cd zabbix-4.4.0/database/postgresql
-  cat schema.sql | doas -zabbix psql zabbix+  cat schema.sql | doas psql -zabbix zabbix
   # stop here if you are creating database for Zabbix proxy   # stop here if you are creating database for Zabbix proxy
-  cat images.sql | doas -zabbix psql zabbix +  cat images.sql | doas psql -zabbix zabbix 
-  cat data.sql | doas -zabbix psql zabbix+  cat data.sql | doas psql -zabbix zabbix
  
 Configure Zabbix source Configure Zabbix source
Line 142: Line 165:
  
   doas make install   doas make install
-====Install Zabbix frontend==== 
  
-We will use the bundled **//httpd//** OpenBSD web server with PHP enable with PgSQL support.+====Zabbix frontend from packages==== 
 + 
 +Install package(s) 
 + 
 +  doas pkg_add zabbix-web-4.0.11p0 
 + 
 +Update the **//zabbix.conf.php//** with the following 
 + 
 +  $DB['TYPE'                    = 'POSTGRESQL'; 
 +  $DB['PASSWORD'                = '<YOUR_PASSWORD>'; 
 + 
 +====Install PHP-FPM & enable httpd====
  
-===Install Apache and PHP===+===Install PHP===
  
   doas pkg_add php-7.3.10 php-pgsql-7.3.10 php-gd-7.3.10 php-ldap-7.3.10   doas pkg_add php-7.3.10 php-pgsql-7.3.10 php-gd-7.3.10 php-ldap-7.3.10
  
-Enable the PgSQL entension for PHP+Enable PHP extension
  
   doas ln -sf /etc/php-7.3.sample/pgsql.ini /etc/php-7.3/   doas ln -sf /etc/php-7.3.sample/pgsql.ini /etc/php-7.3/
Line 163: Line 196:
   max_execution_time = 300   max_execution_time = 300
   max_input_time = 300   max_input_time = 300
 +  date.timezone = America/Los_Angeles
  
 ===Configure /etc/httpd.conf=== ===Configure /etc/httpd.conf===
Line 171: Line 205:
      
   types {   types {
-  include "/usr/share/misc/mime.types"+    include "/usr/share/misc/mime.types"
   }   }
-   +  server "HOSTNAME" { 
-  server "default" { +    listen on * tls port 443 
-   listen on * port 80 +    tls { 
-   +      certificate "/etc/ssl/HOSTNAME.pem" 
-   root "/htdocs+      key "/etc/ssl/private/HOSTNAME.key" 
-   directory index index.php +    } 
-   +    root "/zabbix
-   location "*.php*"+    directory index index.php } 
-   fastcgi socket "/run/php-fpm.sock" +    # Increase connection limits to extend the lifetime 
-   }+    connection { max requests 500, timeout 3600 } 
 +    connection { max request body 8388608 } 
 +    location "/conf/*"
 +      block return 401 
 +    } 
 +    location "*.php*"
 +      fastcgi socket "/run/php-fpm.sock" 
 +    } 
 +    location "/.well-known/acme-challenge/*"
 +      root "/acme" 
 +      request strip 2 
 +    }
   }   }
  
-Enable and start the bundled httpd daemon+Enable and start both the httpd and php73_fpm daemons:
  
 +  doas rcctl enable php73_fpm
 +  doas rcctl start php73_fpm
   doas rcctl enable httpd   doas rcctl enable httpd
   doas rcctl start httpd   doas rcctl start httpd
 +
 +If you want to have a TLS secured connection, follow these instructions [[https://www.romanzolotarev.com/openbsd/acme-client.html|here]].
 +
 +====Zabbix frontend from source====
 +
 +We will use the bundled **//httpd//** OpenBSD web server with PHP enable with PgSQL support.
  
 Copy Zabbix front-end web files to the correct location for httpd to serve them up. Copy Zabbix front-end web files to the correct location for httpd to serve them up.
  
   doas cp -rp /home/jlucas/zabbix-4.4.0/frontends/php/* /var/www/htdocs/   doas cp -rp /home/jlucas/zabbix-4.4.0/frontends/php/* /var/www/htdocs/
 +
 =====Debian 9===== =====Debian 9=====