§2024-05-19
- Install Zabbix Server on Ubuntu 20.04 VM with Postgres and NginxMustafa Altunok, Nov 2, 2022
機器: orgpi516G.yushei.net, ubuntu arm64, 22.04
- 機器: hc4Jamjmy.yushei.com.tw
- ubuntu 22.04, /dev/sda
$ sudo apt update && sudo apt -y upgrade
$ sudo apt install postgresql postgresql-contrib
alexlai@hc4Jammy:~$ /usr/lib/postgresql/14/bin/postgres --version
postgres (PostgreSQL) 14.11 (Ubuntu 14.11-0ubuntu0.22.04.1)
$ /usr/lib/postgresql/14/bin/postgres --version
postgres (PostgreSQL) 14.11 (Ubuntu 14.11-0ubuntu0.22.04.1)
alexlai@orangepi5plus:~$ systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Wed 2024-05-22 10:56:27 CST; 49s ago
Process: 4739 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 4739 (code=exited, status=0/SUCCESS)
CPU: 5ms
alexlai@orangepi5plus:~$ dpkg -l postgresql
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-==================================================
ii postgresql 14+238 all object-relational SQL database (supported version)
$ dpkg -l postgresql-contrib
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==================-============-============-========================================================
ii postgresql-contrib 14+238 all additional facilities for PostgreSQL (supported version)
- After having Postgres up and running, I can start installing Zabbix.
2.1. Install Zabbix repository;
alexlai@orangepi5plus:~/Downloads$ wget https://repo.zabbix.com/zabbix/6.4/ubuntu-arm64/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb
alexlai@opi58G:~/Downloads$ sudo dpkg -i zabbix-release_6.4-1+ubuntu22.04_all.deb
[sudo] password for alexlai:
Selecting previously unselected package zabbix-release.
(Reading database ... 239097 files and directories currently installed.)
Preparing to unpack zabbix-release_6.4-1+ubuntu22.04_all.deb ...
Unpacking zabbix-release (1:6.4-1+ubuntu22.04) ...
Setting up zabbix-release (1:6.4-1+ubuntu22.04) ...
alexlai@orangepi5plus:~/Downloads$ sudo apt update
....
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
43 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: https://repo.huaweicloud.com/docker-ce/linux/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
N: Skipping acquire of configured file 'main/binary-armhf/Packages' as repository 'https://repo.zabbix.com/zabbix/6.4/ubuntu-arm64 jammy InRelease' doesn't support architecture 'armhf'
alexlai@orangepi5plus:~/Downloads$
$ sudo apt -y upgrade
2.2. Install Zabbix server, frontend, agent;
alexlai@orangepi5plus:~/Downloads$ sudo apt install zabbix-server-pgsql zabbix-frontend-php php8.1-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent
- Initialize Database
alexlai@orangepi5plus:~/Downloads$ sudo -u postgres createuser --pwprompt zabbix
could not change directory to "/home/alexlai/Downloads": Permission denied
Enter password for new role: b2nnnnnn5
Enter it again:
alexlai@orangepi
$ sudo -u postgres createdb -O zabbix zabbix
alexlai@orangepi5plus:~/Downloads$ sudo -u postgres createuser --pwprompt zabbix
could not change directory to "/home/alexlai/Downloads": Permission denied
Enter password for new role:
Enter it again:
alexlai@orangepi5plus:~/Downloads$ sudo -u postgres psql -c "\l"
could not change directory to "/home/alexlai/Downloads": Permission denied
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
3.1. On Zabbix server host import initial schema and data;
$ sudo zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix
....
INSERT 0 1
INSERT 0 1
INSERT 0 1
DELETE 98754
COMMIT
3.2. Configure the database for Zabbix server
alexlai@hc4nas02:~$ sudo cp -v /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.backup
'/etc/zabbix/zabbix_server.conf' -> '/etc/zabbix/zabbix_server.conf.backup'
alexlai@hc4nas02:~$ sudo nano /etc/zabbix/zabbix_server.conf
alexlai@hc4nas02:~$ sudo diff /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.backup
119c119
< DBPassword=b2nnnnnn5
---
> # DBPassw
3.2.1
alexlai@hc4Jammy:/tmp$ sudo cp -v /etc/zabbix/nginx.conf /etc/zabbix/nginx.conf.backup
'/etc/zabbix/nginx.conf' -> '/etc/zabbix/nginx.conf.backup'
alexlai@hc4Jammy:/tmp$ sudo nano /etc/zabbix/nginx.conf
alexlai@hc4Jammy:/tmp$ sudo diff /etc/zabbix/nginx.conf /etc/zabbix/nginx.conf.backup
2,3c2,3
< listen 8088;
< server_name hc4Jammy.yushei.com.tw;
---
> # listen 8080;
> # server_name example.com;
3.3. Configure PHP for Zabbix frontend;
alexlai@orangepi5plus:~$ sudo systemctl status zabbix-server zabbix-agent nginx php8.1-fpm
● zabbix-server.service - Zabbix Server
Loaded: loaded (/lib/systemd/system/zabbix-server.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2024-05-22 11:22:12 CST; 12s ago
Process: 17431 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 17433 (zabbix_server)
Tasks: 48 (limit: 18675)
Memory: 54.4M
CPU: 1.181s
CGroup: /system.slice/zabbix-server.service
├─17433 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
├─17443 "/usr/sbin/zabbix_server: ha manager" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17445 "/usr/sbin/zabbix_server: service manager #1 [processed 0 events, updated 0 event tags, deleted 0 problems, synced 0 service updates, idle 5.019070 sec during 5.019301 sec]"
├─17446 "/usr/sbin/zabbix_server: configuration syncer [synced configuration in 0.067451 sec, idle 10 sec]"
├─17450 "/usr/sbin/zabbix_server: alert manager #1 [sent 0, failed 0 alerts, idle 5.022190 sec during 5.022375 sec]"
├─17451 "/usr/sbin/zabbix_server: alerter #1 started" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17452 "/usr/sbin/zabbix_server: alerter #2 started" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17453 "/usr/sbin/zabbix_server: alerter #3 started" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17454 "/usr/sbin/zabbix_server: preprocessing manager #1 [queued 2, processed 2 values, idle 5.017320 sec during 5.018219 sec]"
├─17456 "/usr/sbin/zabbix_server: lld manager #1 [processed 0 LLD rules, idle 5.016536sec during 5.016673 sec]"
├─17457 "/usr/sbin/zabbix_server: lld worker #1 started" "" "" "" "" "" "" "" "" "" "" ""
├─17458 "/usr/sbin/zabbix_server: lld worker #2 started" "" "" "" "" "" "" "" "" "" "" ""
├─17459 "/usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes]"
├─17460 "/usr/sbin/zabbix_server: timer #1 [updated 0 hosts, suppressed 0 events in 0.005362 sec, idle 46 sec]"
├─17461 "/usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.000047 sec, idle 5 sec]"
├─17462 "/usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000050 sec, idle 60 sec]"
├─17465 "/usr/sbin/zabbix_server: history syncer #1 [processed 0 values, 0 triggers in 0.000042 sec, idle 1 sec]"
├─17467 "/usr/sbin/zabbix_server: history syncer #2 [processed 4 values, 2 triggers in 0.014859 sec, idle 1 sec]"
├─17469 "/usr/sbin/zabbix_server: history syncer #3 [processed 0 values, 0 triggers in 0.000037 sec, idle 1 sec]"
├─17470 "/usr/sbin/zabbix_server: history syncer #4 [processed 0 values, 0 triggers in 0.000038 sec, idle 1 sec]"
├─17471 "/usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.005016 sec, idle 3 sec]"
├─17472 "/usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000103 sec, idle 5 sec]"
├─17474 "/usr/sbin/zabbix_server: self-monitoring [processed data in 0.000041 sec, idle 1 sec]"
├─17475 "/usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.001443 sec, idle 5 sec]"
├─17476 "/usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000050 sec, idle 1 sec]"
├─17478 "/usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000079 sec, idle 1 sec]"
├─17479 "/usr/sbin/zabbix_server: poller #3 [got 3 values in 0.001880 sec, idle 1 sec]"
├─17480 "/usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000051 sec, idle 1 sec]"
├─17482 "/usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000049 sec, idle 1 sec]"
├─17483 "/usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000032 sec, idle 5 sec]"
├─17484 "/usr/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection]"
├─17486 "/usr/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection]"
├─17487 "/usr/sbin/zabbix_server: trapper #3 [processed data in 0.000355 sec, waiting for connection]"
├─17488 "/usr/sbin/zabbix_server: trapper #4 [processed data in 0.000288 sec, waiting for connection]"
├─17490 "/usr/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection]"
├─17491 "/usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000072 sec, idle 5 sec]"
├─17492 "/usr/sbin/zabbix_server: alert syncer [queued 0 alerts(s), flushed 0 result(s) in 0.005955 sec, idle 1 sec]"
├─17503 "/usr/sbin/zabbix_server: history poller #1 [got 0 values in 0.000050 sec, idle 5 sec]"
├─17504 "/usr/sbin/zabbix_server: history poller #2 [got 0 values in 0.000034 sec, idle 5 sec]"
├─17505 "/usr/sbin/zabbix_server: history poller #3 [got 0 values in 0.000051 sec, idle 5 sec]"
├─17506 "/usr/sbin/zabbix_server: history poller #4 [got 0 values in 0.000076 sec, idle 5 sec]"
├─17507 "/usr/sbin/zabbix_server: history poller #5 [got 0 values in 0.000077 sec, idle 5 sec]"
├─17508 "/usr/sbin/zabbix_server: availability manager #1 [queued 0, processed 0 values, idle 5.017337 sec during 5.017464 sec]"
├─17509 "/usr/sbin/zabbix_server: trigger housekeeper [startup idle for 60 second(s)]"
└─17510 "/usr/sbin/zabbix_server: odbc poller #1 [got 0 values in 0.000045 sec, idle 5 sec]"
May 22 11:22:12 orangepi5plus systemd[1]: Starting Zabbix Server...
May 22 11:22:12 orangepi5plus systemd[1]: Started Zabbix Server.
● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-05-22 11:22:10 CST; 14s ago
Process: 17398 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 17400 (zabbix_agentd)
Tasks: 6 (limit: 18675)
Memory: 5.9M
CPU: 126ms
CGroup: /system.slice/zabbix-agent.service
├─17400 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
├─17401 "/usr/sbin/zabbix_agentd: collector [idle 1 sec]" "" "" "" "" "" "" "" "" "" ""
├─17402 "/usr/sbin/zabbix_agentd: listener #1 [waiting for connection]"
├─17403 "/usr/sbin/zabbix_agentd: listener #2 [waiting for connection]"
├─17404 "/usr/sbin/zabbix_agentd: listener #3 [waiting for connection]"
└─17406 "/usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]" "" "" ""
May 22 11:22:10 orangepi5plus systemd[1]: Starting Zabbix Agent...
May 22 11:22:10 orangepi5plus systemd[1]: Started Zabbix Agent.
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-05-22 11:22:10 CST; 14s ago
Docs: man:nginx(8)
Process: 17409 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 17410 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 17419 (nginx)
Tasks: 9 (limit: 18675)
Memory: 6.8M
CPU: 68ms
CGroup: /system.slice/nginx.service
├─17419 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
├─17420 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17421 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17422 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17423 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17424 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17425 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17426 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
└─17427 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
May 22 11:22:10 orangepi5plus systemd[1]: Starting A high performance web server and a reverse proxy server...
May 22 11:22:10 orangepi5plus systemd[1]: Started A high performance web server and a reverse proxy server.
● php8.1-fpm.service - The PHP 8.1 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php8.1-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-05-22 11:22:10 CST; 14s ago
Docs: man:php-fpm8.1(8)
Process: 17418 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.1/fpm/pool.d/www.conf 81 (code=exited, status=0/SUCCESS)
Main PID: 17408 (php-fpm8.1)
Status: "Processes active: 0, idle: 7, Requests: 0, slow: 0, Traffic: 0req/sec"
Tasks: 8 (limit: 18675)
Memory: 10.9M
CPU: 77ms
CGroup: /system.slice/php8.1-fpm.service
├─17408 "php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17411 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17412 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17413 "php-fpm: pool zabbix" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17414 "php-fpm: pool zabbix" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17415 "php-fpm: pool zabbix" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─17416 "php-fpm: pool zabbix" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
└─17417 "php-fpm: pool zabbix" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
May 22 11:22:10 orangepi5plus systemd[1]: Starting The PHP 8.1 FastCGI Process Manager...
May 22 11:22:10 orangepi5plus systemd[1]: Started The PHP 8.1 FastCGI Process Manager.
lines 91-123/123 (END)
If everything goes we will connect to the frontend by http://hc4nas02.yushei.net:8088/setup.php
- Here choose Postgresql as Database type and enter our DB password
- Username: Admin, Password: zabbix
- Start using Zabbix
Read in documentation: Quickstart guide