§2024-05-22

  1. install postgresql
$ sudo apt update && sudo apt -y upgrade
alexlai@orangepi5plus:/$ sudo apt install postgresql postgresql-contrib
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libjson-perl libllvm14 postgresql-15 postgresql-client-15 postgresql-client-common postgresql-common
Suggested packages:
  postgresql-doc postgresql-doc-15
Recommended packages:
  libjson-xs-perl
The following NEW packages will be installed:
  libjson-perl libllvm14 postgresql postgresql-15 postgresql-client-15 postgresql-client-common postgresql-common postgresql-contrib
0 upgraded, 8 newly installed, 0 to remove and 61 not upgraded.
Need to get 37.6 MB of archives.
After this operation, 170 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

alexlai@orangepi5plus:/$ systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; preset: enabled)
     Active: active (exited) since Wed 2024-05-22 10:02:56 CST; 52s ago
   Main PID: 9082 (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     15+248       all          object-relational SQL database (supported version)

alexlai@orangepi5plus:/$ dpkg -L postgresql-15|less

alexlai@orangepi5plus:/$ /usr/lib/postgresql/15/bin/postgres --version
postgres (PostgreSQL) 15.5 (Debian 15.5-0+deb12u1)

  1. After having Postgres up and running, I can start installing Zabbix.

Zabbix-01.png Zabbix-02.png Zabbix-03.png

2.1. Install Zabbix repository;

--2024-05-22 10:14:09--  https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian12_all.deb

# dpkg -i zabbix-release_6.4-1+debian12_all.deb

alexlai@orangepi5plus:~/Download$ sudo apt update
Hit:1 http://repo.huaweicloud.com/debian bookworm InRelease
Hit:2 http://repo.huaweicloud.com/debian bookworm-updates InRelease                                         
Hit:3 http://repo.huaweicloud.com/debian bookworm-backports InRelease                                       
Get:4 https://repo.zabbix.com/zabbix/6.4/debian bookworm InRelease [2,874 B]
Get:5 https://repo.zabbix.com/zabbix/6.4/debian bookworm/main Sources [15.1 kB]
Get:6 https://repo.zabbix.com/zabbix/6.4/debian bookworm/main all Packages [8,657 B]
Hit:7 https://repo.huaweicloud.com/docker-ce/linux/debian bookworm InRelease
Fetched 26.6 kB in 6s (4,588 B/s)      
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
61 packages can be upgraded. Run 'apt list --upgradable' to see them.
N: Skipping acquire of configured file 'main/binary-arm64/Packages' as repository 'https://repo.zabbix.com/zabbix/6.4/debian bookworm InRelease' doesn't support architecture 'arm64'
N: Skipping acquire of configured file 'main/binary-armhf/Packages' as repository 'https://repo.zabbix.com/zabbix/6.4/debian bookworm InRelease' doesn't support architecture 'armhf'
W: https://repo.huaweicloud.com/docker-ce/linux/debian/dists/bookworm/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
alexlai@orangepi5plus:~/Download$ 

2.2. Install Zabbix server, frontend, agent;

alexlai@hc4nas02:~/Downloads$ sudo apt install zabbix-server-pgsql zabbix-frontend-php php7.4-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  fonts-dejavu fonts-dejavu-extra fping libblas3 libiksemel3 liblinear4 libodbc1 libonig5 libopenipmi0 libssh2-1 lua-lpeg nmap nmap-common php-bcmath
  php-common php-fpm php-gd php-ldap php-mbstring php-xml php7.4-bcmath php7.4-cli php7.4-common php7.4-fpm php7.4-gd php7.4-json php7.4-ldap
  php7.4-mbstring php7.4-opcache php7.4-readline php7.4-xml snmpd traceroute
Suggested packages:
  liblinear-tools liblinear-dev libmyodbc odbc-postgresql tdsodbc unixodbc-bin ncat ndiff zenmap php-pear snmptrapd zabbix-apache-conf snmp-mibs-downloader
The following NEW packages will be installed:
  fonts-dejavu fonts-dejavu-extra fping libblas3 libiksemel3 liblinear4 libodbc1 libonig5 libopenipmi0 libssh2-1 lua-lpeg nmap nmap-common php-bcmath
  php-common php-fpm php-gd php-ldap php-mbstring php-xml php7.4-bcmath php7.4-cli php7.4-common php7.4-fpm php7.4-gd php7.4-json php7.4-ldap
  php7.4-mbstring php7.4-opcache php7.4-pgsql php7.4-readline php7.4-xml snmpd traceroute zabbix-agent zabbix-frontend-php zabbix-nginx-conf
  zabbix-server-pgsql zabbix-sql-scripts
0 upgraded, 39 newly installed, 0 to remove and 1 not upgraded.
Need to get 30.2 MB of archives.
After this operation, 111 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
....
  1. Initialize Database
alexlai@hc4nas02:~$ sudo -u postgres createuser --pwprompt zabbix
[sudo] password for alexlai: 
Enter password for new role: b2nnnnnnn
Enter it again: b2nnnnnn5

alexlai@hc4nas02:~$ sudo -u postgres createdb -O zabbix zabbix

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
---
> # DBPassword=

3.3. Configure PHP for Zabbix frontend;

$ sudo cp -v /etc/zabbix/nginx.conf /etc/zabbix/nginx.conf.backup

$ sudo nano /etc/zabbix/nginx.conf

alexlai@hc4nas02:~$ sudo diff  /etc/zabbix/nginx.conf /etc/zabbix/nginx.conf.backup 
2,3c2,3
<          listen          8088;
<          server_name     hc4nas02.yushei.net;
---
> #        listen          8080;
> #        server_name     example.com;
  1. Start Zabbix server and agent processes;
alexlai@hc4nas02:~$ sudo systemctl restart zabbix-server zabbix-agent nginx php7.4-fpm
alexlai@hc4nas02:~$ sudo systemctl status  zabbix-server zabbix-agent nginx php7.4-fpm
● zabbix-server.service - Zabbix Server (PostgreSQL)
     Loaded: loaded (/lib/systemd/system/zabbix-server.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-05-21 10:12:36 CST; 8s ago
       Docs: man:zabbix_server
    Process: 300451 ExecStart=/usr/sbin/zabbix_server --foreground (code=exited, status=1/FAILURE)
   Main PID: 300451 (code=exited, status=1/FAILURE)

May 21 10:12:36 hc4nas02 systemd[1]: Started Zabbix Server (PostgreSQL).
May 21 10:12:36 hc4nas02 zabbix_server[300451]: Starting Zabbix Server. Zabbix 4.0.17 (revision a528a0a4bc).
May 21 10:12:36 hc4nas02 zabbix_server[300451]: Press Ctrl+C to exit.
May 21 10:12:36 hc4nas02 systemd[1]: zabbix-server.service: Main process exited, code=exited, status=1/FAILURE
May 21 10:12:36 hc4nas02 systemd[1]: zabbix-server.service: Failed with result 'exit-code'.

● zabbix-agent.service - Zabbix Agent
     Loaded: loaded (/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2024-05-21 10:12:36 CST; 9s ago
       Docs: man:zabbix_agentd
   Main PID: 300453 (zabbix_agentd)
      Tasks: 6 (limit: 3462)
     Memory: 2.8M
     CGroup: /system.slice/zabbix-agent.service
             ├─300453 /usr/sbin/zabbix_agentd --foreground
             ├─300454 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
             ├─300455 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
             ├─300456 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
             ├─300458 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
             └─300459 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

May 21 10:12:36 hc4nas02 systemd[1]: Started Zabbix Agent.
May 21 10:12:36 hc4nas02 zabbix_agentd[300453]: Starting Zabbix Agent [hc4nas02]. Zabbix 4.0.17 (revision a528a0a4bc).
May 21 10:12:36 hc4nas02 zabbix_agentd[300453]: Press Ctrl+C to exit.

● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
     Active: active (running) since Tue 2024-05-21 10:12:36 CST; 9s ago
       Docs: man:nginx(8)
    Process: 300457 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 300465 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 300467 (nginx)
      Tasks: 5 (limit: 3462)
     Memory: 4.3M
     CGroup: /system.slice/nginx.service
             ├─300467 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ├─300468 nginx: worker process
             ├─300469 nginx: worker process
             ├─300470 nginx: worker process
             └─300471 nginx: worker process

May 21 10:12:36 hc4nas02 systemd[1]: Starting A high performance web server and a reverse proxy server...
May 21 10:12:36 hc4nas02 systemd[1]: Started A high performance web server and a reverse proxy server.

● php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2024-05-21 10:12:36 CST; 9s ago
       Docs: man:php-fpm7.4(8)
    Process: 300479 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/7.4/fpm/pool.d/www.conf 74 (code=exited, status=>
   Main PID: 300464 (php-fpm7.4)
     Status: "Ready to handle connections"
      Tasks: 8 (limit: 3462)
     Memory: 12.9M
     CGroup: /system.slice/php7.4-fpm.service
             ├─300464 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
             ├─300472 php-fpm: pool www
             ├─300473 php-fpm: pool www
             ├─300474 php-fpm: pool zabbix
             ├─300475 php-fpm: pool zabbix
             ├─300476 php-fpm: pool zabbix
             ├─300477 php-fpm: pool zabbix
             └─300478 php-fpm: pool zabbix

May 21 10:12:36 hc4nas02 systemd[1]: Starting The PHP 7.4 FastCGI Process Manager...
May 21 10:12:36 hc4nas02 systemd[1]: Started The PHP 7.4 FastCGI Process Manager.

If everything goes we will connect to the frontend by http://hc4nas02.yushei.net:8088/setup.php

Zabbix-02.png

Zabbix-03.png

Zabbix-04.png

Zabbix-05.png

Zabbix-06.png

Zabbix-07.png

Zabbix-08.png