zabbix

Version 5.0 seems to have recently updated not long ago, we deployed to see what changes have not, then again. From 2.0 to 3.0 does look a lot better, today to see what 5.0 looks like, without further ado, start the installation!

5.0 new features reference https://www.zabbix.com/cn/whats_new_5_0

Prepare the environment

  • Centos 7.8
  • PHP 7.2 +
  • Apache 1.3.12 +
  • Mysql or MariaDB 5.7+

Refer to the link https://www.zabbix.com/documentation/current/manual/installation/requirements for specific requirements

Hardware conditions refer to the following table

Hardware conditions

Installation

Turn off selinux

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
[root@localhost ~]# systemctl disable --now firewalld
[root@localhost ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
[root@localhost ~]#

Installing zabbix sources

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.vw5pXe: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-5.0-1.el7         ################################# [100%]
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates zabbix zabbix-non-supported
Cleaning up list of fastest mirrors
[root@localhost ~]#

Install server and agnet

1
[root@localhost ~]# yum -y install zabbix-server-mysql zabbix-agent

If you are in China, the installation may fail due to GFW

1
2
3
4
5
6
http://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-server-mysql-5.0.3-1.el7.x86_64.rpm: [Errno 14] curl#18 - "transfer closed with 1461988 bytes remaining to read"
Trying other mirror.


Error downloading packages:
  zabbix-server-mysql-5.0.3-1.el7.x86_64: [Errno 256] No more mirrors to try.

Solution, switch to aliyun

1
2
3
4
5
[root@localhost ~]# sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates zabbix zabbix-non-supported
Cleaning up list of fastest mirrors

Execute the installation again

Installation of front-end components

1
[root@localhost ~]# yum install centos-release-scl -y

Enable zabbix front end source, edit the configuration file /etc/yum.repos.d/zabbix.repo and change enabled to 1

1
2
3
4
5
6
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

Software package installation, including httpd php web components, etc.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
[root@localhost ~]# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y 
...
Installing:
 zabbix-apache-conf-scl                        noarch                       5.0.3-1.el7                                  zabbix-frontend                        13 k
 zabbix-web-mysql-scl                          noarch                       5.0.3-1.el7                                  zabbix-frontend                        12 k
Installing for dependencies:
 apr                                           x86_64                       1.4.8-5.el7                                  base                                  103 k
 apr-util                                      x86_64                       1.5.2-6.el7                                  base                                   92 k
 audit-libs-python                             x86_64                       2.8.5-4.el7                                  base                                   76 k
 checkpolicy                                   x86_64                       2.5-8.el7                                    base                                  295 k
 dejavu-fonts-common                           noarch                       2.33-6.el7                                   base                                   64 k
 dejavu-sans-fonts                             noarch                       2.33-6.el7                                   base                                  1.4 M
 fontpackages-filesystem                       noarch                       1.44-8.el7                                   base                                  9.9 k
 httpd                                         x86_64                       2.4.6-93.el7.centos                          base                                  2.7 M
 httpd-tools                                   x86_64                       2.4.6-93.el7.centos                          base                                   92 k
 libX11                                        x86_64                       1.6.7-2.el7                                  base                                  607 k
 libX11-common                                 noarch                       1.6.7-2.el7                                  base                                  164 k
 libXau                                        x86_64                       1.0.8-2.1.el7                                base                                   29 k
 libXpm                                        x86_64                       3.5.12-1.el7                                 base                                   55 k
 libcgroup                                     x86_64                       0.41-21.el7                                  base                                   66 k
 libjpeg-turbo                                 x86_64                       1.2.90-8.el7                                 base                                  135 k
 libsemanage-python                            x86_64                       2.5-14.el7                                   base                                  113 k
 libwebp                                       x86_64                       0.3.0-7.el7                                  base                                  170 k
 libxcb                                        x86_64                       1.13-1.el7                                   base                                  214 k
 libxslt                                       x86_64                       1.1.28-5.el7                                 base                                  242 k
 mailcap                                       noarch                       2.1.41-2.el7                                 base                                   31 k
 policycoreutils-python                        x86_64                       2.5-34.el7                                   base                                  457 k
 python-IPy                                    noarch                       0.75-6.el7                                   base                                   32 k
 rh-php72                                      x86_64                       1-2.el7                                      centos-sclo-rh                        4.3 k
 rh-php72-php-bcmath                           x86_64                       7.2.24-1.el7                                 centos-sclo-rh                         60 k
 rh-php72-php-cli                              x86_64                       7.2.24-1.el7                                 centos-sclo-rh                        2.9 M
 rh-php72-php-common                           x86_64                       7.2.24-1.el7                                 centos-sclo-rh                        680 k
 rh-php72-php-fpm                              x86_64                       7.2.24-1.el7                                 centos-sclo-rh                        1.5 M
 rh-php72-php-gd                               x86_64                       7.2.24-1.el7                                 centos-sclo-rh                        151 k
 rh-php72-php-json                             x86_64                       7.2.24-1.el7                                 centos-sclo-rh                         54 k
 rh-php72-php-ldap                             x86_64                       7.2.24-1.el7                                 centos-sclo-rh                         59 k
 rh-php72-php-mbstring                         x86_64                       7.2.24-1.el7                                 centos-sclo-rh                        553 k
 rh-php72-php-mysqlnd                          x86_64                       7.2.24-1.el7                                 centos-sclo-rh                        166 k
 rh-php72-php-pdo                              x86_64                       7.2.24-1.el7                                 centos-sclo-rh                        101 k
 rh-php72-php-pear                             noarch                       1:1.10.5-1.el7                               centos-sclo-rh                        357 k
 rh-php72-php-process                          x86_64                       7.2.24-1.el7                                 centos-sclo-rh                         62 k
 rh-php72-php-xml                              x86_64                       7.2.24-1.el7                                 centos-sclo-rh                        160 k
 rh-php72-php-zip                              x86_64                       7.2.24-1.el7                                 centos-sclo-rh                         90 k
 rh-php72-runtime                              x86_64                       1-2.el7                                      centos-sclo-rh                        1.1 M
 scl-utils                                     x86_64                       20130529-19.el7                              base                                   24 k
 setools-libs                                  x86_64                       3.3.8-4.el7                                  base                                  620 k
 zabbix-web                                    noarch                       5.0.3-1.el7                                  zabbix-frontend                       3.1 M
 zabbix-web-deps-scl                           noarch                       5.0.3-1.el7                                  zabbix-frontend                        13 k

Installing the database

Install and set up boot-up

1
2
[root@localhost ~]# yum install mariadb-server -y
[root@localhost ~]# systemctl enable --now mariadb

Initializing the database

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
[root@localhost ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):   #Enter, no password by default
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y。#Whether to set a password
New password:               #New Password
Re-enter new password:      #New password confirmation
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]   #Remove Anonymous Users
 ... skipping.

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n    #Disable root remote connection
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y #Delete test database
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y  #Refresh Permissions
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Create the database and users needed for zabbix and set the password zabbix123

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 5.5.65-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
MariaDB [(none)]> 
MariaDB [(none)]> 
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create user zabbix@localhost identified by 'zabbix123';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit
Bye

Importing initial data

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: 
[root@localhost ~]# mysql -u root -p  #Check if the import was successful
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.65-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use zabbix
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| application_discovery      |
| application_prototype      |
| application_template       |
| applications               |
| auditlog                   |
.......

Modify the configuration file

Configure database password /etc/zabbix/zabbix_server.conf

1
DBPassword=zabbix123

Change the php timezone /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf to your desired timezone and remove the previous comments

1
php_value[date.timezone] = Asia/Shanghai

Set boot up

1
2
[root@localhost ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@localhost ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm

Initialization

Login to the system at http://[host]/zabbix

Start initialization

zabbix initialization

Check the environment

zabbix Check the environment

Configuration Database

zabbix Configuration Database

Confirm server details

zabbix Confirm server details

Installation Confirmation

zabbix Installation Confirmation

Installation completed

zabbix Installation completed

Login system account password Admin ,default password zabbix

zabbix login

System page, the default is English, you can switch the language in the personal center

zabbix system page

zabbix switch language

zabbix chinese language

zabbix garbled code problem

Upload any font from the C:\Windows\Fonts directory of Win10 OS to the fonts directory

1
2
3
4
5
6
7
[root@localhost fonts]# pwd
/usr/share/zabbix/assets/fonts
[root@localhost fonts]# ll
total 11512
lrwxrwxrwx 1 root root       33 Sep 18 16:34 graphfont.ttf -> /etc/alternatives/zabbix-web-font
-r-xr-xr-x 1 root root 11787328 Sep 18 17:05 simkai.ttf
[root@localhost fonts]#

Edit the configuration file /usr/share/zabbix/include/defines.inc.php

1
2
 81 define('ZBX_GRAPH_FONT_NAME',           'simkai'); // font file name
 122 define('ZBX_FONT_NAME', 'simkai');

Reboot

1
[root@localhost fonts]# systemctl restart zabbix-server

zabbix

References


Reference http://roddypy.com/2020/09/18/zabbix-5-0-%E8%AF%A6%E7%BB%86%E5%AE%89%E8%A3%85%E6%AD%A5%E9%AA%A4/