ZABBIX 4.0 安装

1.安装zabbix-release 4.0版

https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm

[root@myserver zabbix]# ls
zabbix-release-4.0-2.el8.noarch.rpm
[root@myserver zabbix]# rpm -ivh zabbix-release-4.0-2.el8.noarch.rpm 
warning: zabbix-release-4.0-2.el8.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID a14
fe591: NOKEYVerifying...              ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-4.0-2.el8         ################################# [100%]
[root@myserver zabbix]# rpm -ivh zabbix-release-4.0-2.el8.noarch.rpm 
warning: zabbix-release-4.0-2.el8.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID a14
fe591: NOKEYVerifying...              ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-4.0-2.el8         ################################# [100%]
[root@myserver zabbix]# 

2. 查看包里有哪些文件

[root@myserver zabbix]# rpm -ql  zabbix-release
/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
/etc/yum.repos.d/zabbix.repo
/usr/share/doc/zabbix-release
/usr/share/doc/zabbix-release/GPL

3.查看zabbix下载地址配置文件 (将镜像源地址换成国内源和gpgcheck=0)      :%s#http://repo.zabbix.com#https://mirrors.tuna.tsinghua.edu.cn/zabbix#g

[root@myserver yum.repos.d]# vim zabbix.repo 
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/8/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/8/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0

4. 安装zabbix组件( zabbix-server zabbix-web都支持mysql和pgsql )要用那个包可对应的加上(zabbix-server-mysql zabbix-web-mysql)

[root@myserver yum.repos.d]# yum install -y zabbix-server-mysql
Zabbix Official Repository - x86_64                     1.1 MB/s | 169 kB     00:00    
Zabbix Official Repository non-supported - x86_64        11 kB/s | 1.2 kB     00:00    
Dependencies resolved.
========================================================================================
 Package                          Architecture Version            Repository       Size
========================================================================================
Installing:
 zabbix-server-mysql              x86_64       4.0.27-1.el8       zabbix          2.2 M
Installing dependencies:
 OpenIPMI-libs                    x86_64       2.0.27-1.el8       baseos          507 k
 fping                            x86_64       4.2-2.el8          epel             43 k
 mariadb-connector-c              x86_64       3.0.7-1.el8        appstream       148 k
 mariadb-connector-c-config       noarch       3.0.7-1.el8        appstream        13 k
 unixODBC                         x86_64       2.3.7-1.el8        appstream       458 k

Transaction Summary
========================================================================================
Install  6 Packages

Total download size: 3.3 M
Installed size: 9.2 M
Downloading Packages:
(1/6): mariadb-connector-c-config-3.0.7-1.el8.noarch.rp  53 kB/s |  13 kB     00:00    
(2/6): mariadb-connector-c-3.0.7-1.el8.x86_64.rpm       565 kB/s | 148 kB     00:00    
(3/6): fping-4.2-2.el8.x86_64.rpm                       746 kB/s |  43 kB     00:00    
(4/6): unixODBC-2.3.7-1.el8.x86_64.rpm                  952 kB/s | 458 kB     00:00    
(5/6): OpenIPMI-libs-2.0.27-1.el8.x86_64.rpm            1.9 MB/s | 507 kB     00:00    
(6/6): zabbix-server-mysql-4.0.27-1.el8.x86_64.rpm      7.6 MB/s | 2.2 MB     00:00    
----------------------------------------------------------------------------------------
Total                                                   321 kB/s | 3.3 MB     00:10     
warning: /var/cache/dnf/zabbix-a623d74d59cbb557/packages/zabbix-server-mysql-4.0.27-1.el
8.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEYZabbix Official Repository - x86_64                     1.6 MB/s | 1.7 kB     00:00    
Importing GPG key 0xA14FE591:
 Userid     : "Zabbix LLC <packager@zabbix.com>"
 Fingerprint: A184 8F53 52D0 22B9 471D 83D0 082A B56B A14F E591
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Running scriptlet: mariadb-connector-c-3.0.7-1.el8.x86_64                         1/1 
  Preparing        :                                                                1/1 
  Installing       : fping-4.2-2.el8.x86_64                                         1/6 
  Installing       : OpenIPMI-libs-2.0.27-1.el8.x86_64                              2/6 
  Installing       : unixODBC-2.3.7-1.el8.x86_64                                    3/6 
  Running scriptlet: unixODBC-2.3.7-1.el8.x86_64                                    3/6 
  Installing       : mariadb-connector-c-config-3.0.7-1.el8.noarch                  4/6 
  Installing       : mariadb-connector-c-3.0.7-1.el8.x86_64                         5/6 
  Running scriptlet: zabbix-server-mysql-4.0.27-1.el8.x86_64                        6/6 
  Installing       : zabbix-server-mysql-4.0.27-1.el8.x86_64                        6/6 
  Running scriptlet: zabbix-server-mysql-4.0.27-1.el8.x86_64                        6/6 
  Verifying        : mariadb-connector-c-3.0.7-1.el8.x86_64                         1/6 
  Verifying        : mariadb-connector-c-config-3.0.7-1.el8.noarch                  2/6 
  Verifying        : unixODBC-2.3.7-1.el8.x86_64                                    3/6 
  Verifying        : OpenIPMI-libs-2.0.27-1.el8.x86_64                              4/6 
  Verifying        : fping-4.2-2.el8.x86_64                                         5/6 
  Verifying        : zabbix-server-mysql-4.0.27-1.el8.x86_64                        6/6 
Installed products updated.

Installed:
  OpenIPMI-libs-2.0.27-1.el8.x86_64       fping-4.2-2.el8.x86_64                        
  mariadb-connector-c-3.0.7-1.el8.x86_64  mariadb-connector-c-config-3.0.7-1.el8.noarch 
  unixODBC-2.3.7-1.el8.x86_64             zabbix-server-mysql-4.0.27-1.el8.x86_64       

Complete!
[root@myserver yum.repos.d]# yum install -y zabbix-web-mysql
Last metadata expiration check: 0:00:28 ago on Tue 22 Dec 2020 12:20:11 AM CST.
Dependencies resolved.
========================================================================================
 Package            Arch     Version                                  Repository   Size
========================================================================================
Installing:
 zabbix-web-mysql   noarch   4.0.27-1.el8                             zabbix       15 k
Installing dependencies:
 httpd              x86_64   2.4.37-30.module_el8.3.0+561+97fdbbcc    appstream   1.7 M
 mod_http2          x86_64   1.15.7-2.module_el8.3.0+477+498bb568     appstream   154 k
 nginx-filesystem   noarch   1:1.14.1-9.module_el8.0.0+184+e34fea82   appstream    24 k
 php                x86_64   7.2.24-1.module_el8.2.0+313+b04d0a66     appstream   1.5 M
 php-bcmath         x86_64   7.2.24-1.module_el8.2.0+313+b04d0a66     appstream    79 k
 php-cli            x86_64   7.2.24-1.module_el8.2.0+313+b04d0a66     appstream   3.1 M
 php-common         x86_64   7.2.24-1.module_el8.2.0+313+b04d0a66     appstream   661 k
 php-gd             x86_64   7.2.24-1.module_el8.2.0+313+b04d0a66     appstream    84 k
 php-json           x86_64   7.2.24-1.module_el8.2.0+313+b04d0a66     appstream    73 k
 php-ldap           x86_64   7.2.24-1.module_el8.2.0+313+b04d0a66     appstream    79 k
 php-mbstring       x86_64   7.2.24-1.module_el8.2.0+313+b04d0a66     appstream   580 k
 php-mysqlnd        x86_64   7.2.24-1.module_el8.2.0+313+b04d0a66     appstream   190 k
 php-pdo            x86_64   7.2.24-1.module_el8.2.0+313+b04d0a66     appstream   122 k
 php-xml            x86_64   7.2.24-1.module_el8.2.0+313+b04d0a66     appstream   188 k
 zabbix-web         noarch   4.0.27-1.el8                             zabbix      2.9 M
Installing weak dependencies:
 php-fpm            x86_64   7.2.24-1.module_el8.2.0+313+b04d0a66     appstream   1.6 M
Enabling module streams:
 php                         7.2                                                       

Transaction Summary
========================================================================================
Install  17 Packages

Total size: 13 M
Total download size: 11 M
Installed size: 50 M
Downloading Packages:
[SKIPPED] httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64.rpm: Already downloaded   
[SKIPPED] mod_http2-1.15.7-2.module_el8.3.0+477+498bb568.x86_64.rpm: Already downloaded
(3/17): nginx-filesystem-1.14.1-9.module_el8.0.0+184+e3 206 kB/s |  24 kB     00:00    
(4/17): php-bcmath-7.2.24-1.module_el8.2.0+313+b04d0a66 439 kB/s |  79 kB     00:00    
(5/17): php-common-7.2.24-1.module_el8.2.0+313+b04d0a66 2.9 MB/s | 661 kB     00:00    
(6/17): php-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 3.3 MB/s | 1.5 MB     00:00    
(7/17): php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86 1.1 MB/s |  84 kB     00:00    
(8/17): php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x 808 kB/s |  73 kB     00:00    
(9/17): php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x8 5.0 MB/s | 1.6 MB     00:00    
(10/17): php-ldap-7.2.24-1.module_el8.2.0+313+b04d0a66. 804 kB/s |  79 kB     00:00    
(11/17): php-mbstring-7.2.24-1.module_el8.2.0+313+b04d0 4.7 MB/s | 580 kB     00:00    
(12/17): php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a 1.6 MB/s | 190 kB     00:00    
(13/17): php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x 4.0 MB/s | 3.1 MB     00:00    
(14/17): php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x 1.9 MB/s | 122 kB     00:00    
(15/17): php-xml-7.2.24-1.module_el8.2.0+313+b04d0a66.x 2.4 MB/s | 188 kB     00:00    
(16/17): zabbix-web-mysql-4.0.27-1.el8.noarch.rpm       330 kB/s |  15 kB     00:00    
(17/17): zabbix-web-4.0.27-1.el8.noarch.rpm             8.9 MB/s | 2.9 MB     00:00    
----------------------------------------------------------------------------------------
Total                                                   6.0 MB/s |  11 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                1/1 
  Installing       : php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64        1/17 
  Installing       : mod_http2-1.15.7-2.module_el8.3.0+477+498bb568.x86_64         2/17 
  Installing       : httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64            3/17 
  Running scriptlet: httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64            3/17 
  Installing       : php-bcmath-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64        4/17 
  Installing       : php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64           5/17 
  Installing       : php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64            6/17 
  Installing       : php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64          7/17 
  Installing       : php-ldap-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64          8/17 
  Installing       : php-mbstring-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64      9/17 
  Installing       : php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64          10/17 
  Installing       : php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64      11/17 
  Installing       : php-xml-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64          12/17 
  Running scriptlet: nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.no   13/17 
  Installing       : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.no   13/17 
  Installing       : php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64          14/17 
  Running scriptlet: php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64          14/17 
  Installing       : php-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64              15/17 
  Installing       : zabbix-web-mysql-4.0.27-1.el8.noarch                         16/17 
  Installing       : zabbix-web-4.0.27-1.el8.noarch                               17/17 
  Running scriptlet: zabbix-web-4.0.27-1.el8.noarch                               17/17 
  Running scriptlet: httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64           17/17 
  Running scriptlet: zabbix-web-4.0.27-1.el8.noarch                               17/17 
  Running scriptlet: php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64          17/17 
  Verifying        : httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64            1/17 
  Verifying        : mod_http2-1.15.7-2.module_el8.3.0+477+498bb568.x86_64         2/17 
  Verifying        : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.no    3/17 
  Verifying        : php-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64               4/17 
  Verifying        : php-bcmath-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64        5/17 
  Verifying        : php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64           6/17 
  Verifying        : php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64        7/17 
  Verifying        : php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64           8/17 
  Verifying        : php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64            9/17 
  Verifying        : php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64         10/17 
  Verifying        : php-ldap-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64         11/17 
  Verifying        : php-mbstring-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64     12/17 
  Verifying        : php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64      13/17 
  Verifying        : php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64          14/17 
  Verifying        : php-xml-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64          15/17 
  Verifying        : zabbix-web-4.0.27-1.el8.noarch                               16/17 
  Verifying        : zabbix-web-mysql-4.0.27-1.el8.noarch                         17/17 
Installed products updated.

Installed:
  httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64                                    
  mod_http2-1.15.7-2.module_el8.3.0+477+498bb568.x86_64                                 
  nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                        
  php-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                       
  php-bcmath-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                
  php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                   
  php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                
  php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                   
  php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                    
  php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                  
  php-ldap-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                  
  php-mbstring-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                              
  php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                               
  php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                   
  php-xml-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                   
  zabbix-web-4.0.27-1.el8.noarch                                                        
  zabbix-web-mysql-4.0.27-1.el8.noarch                                                  
Complete!
[root@myserver yum.repos.d]# 

5.安装 mariadb-server

[root@myserver zabbix]# yum install -y mariadb-server
Last metadata expiration check: 0:07:32 ago on Tue 22 Dec 2020 12:20:11 AM CST.
Dependencies resolved.
========================================================================================
 Package               Arch   Version                                   Repo       Size
========================================================================================
Installing:
 mariadb-server        x86_64 3:10.3.17-1.module_el8.1.0+257+48736ea6   appstream  16 M
Installing dependencies:
 mariadb               x86_64 3:10.3.17-1.module_el8.1.0+257+48736ea6   appstream 6.1 M
 mariadb-common        x86_64 3:10.3.17-1.module_el8.1.0+257+48736ea6   appstream  62 k
 mariadb-errmsg        x86_64 3:10.3.17-1.module_el8.1.0+257+48736ea6   appstream 232 k
 perl-DBD-MySQL        x86_64 4.046-3.module_el8.1.0+203+e45423dc       appstream 156 k
Installing weak dependencies:
 mariadb-backup        x86_64 3:10.3.17-1.module_el8.1.0+257+48736ea6   appstream 6.0 M
 mariadb-gssapi-server x86_64 3:10.3.17-1.module_el8.1.0+257+48736ea6   appstream  49 k
 mariadb-server-utils  x86_64 3:10.3.17-1.module_el8.1.0+257+48736ea6   appstream 1.6 M
Enabling module streams:
 mariadb                      10.3                                                     
 perl                         5.26                                                     
 perl-DBD-MySQL               4.046                                                    

Transaction Summary
========================================================================================
Install  8 Packages

Total download size: 30 M
Installed size: 170 M
Downloading Packages:
(1/8): mariadb-common-10.3.17-1.module_el8.1.0+257+4873 384 kB/s |  62 kB     00:00    
(2/8): mariadb-errmsg-10.3.17-1.module_el8.1.0+257+4873 1.7 MB/s | 232 kB     00:00    
(3/8): mariadb-gssapi-server-10.3.17-1.module_el8.1.0+2 497 kB/s |  49 kB     00:00    
(4/8): mariadb-10.3.17-1.module_el8.1.0+257+48736ea6.x8 4.8 MB/s | 6.1 MB     00:01    
(5/8): mariadb-backup-10.3.17-1.module_el8.1.0+257+4873 3.6 MB/s | 6.0 MB     00:01    
(6/8): mariadb-server-utils-10.3.17-1.module_el8.1.0+25 3.8 MB/s | 1.6 MB     00:00    
(7/8): perl-DBD-MySQL-4.046-3.module_el8.1.0+203+e45423 2.8 MB/s | 156 kB     00:00    
(8/8): mariadb-server-10.3.17-1.module_el8.1.0+257+4873 6.3 MB/s |  16 MB     00:02    
----------------------------------------------------------------------------------------
Total                                                   3.5 MB/s |  30 MB     00:08     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                1/1 
  Installing       : mariadb-common-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_6   1/8 
  Installing       : mariadb-errmsg-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_6   2/8 
  Installing       : perl-DBD-MySQL-4.046-3.module_el8.1.0+203+e45423dc.x86_64      3/8 
  Installing       : mariadb-backup-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_6   4/8 
  Installing       : mariadb-gssapi-server-3:10.3.17-1.module_el8.1.0+257+48736ea   5/8 
  Installing       : mariadb-server-utils-3:10.3.17-1.module_el8.1.0+257+48736ea6   6/8 
  Running scriptlet: mariadb-server-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_6   7/8 
  Installing       : mariadb-server-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_6   7/8 
  Running scriptlet: mariadb-server-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_6   7/8 
  Installing       : mariadb-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64         8/8 
  Running scriptlet: mariadb-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64         8/8 
  Verifying        : mariadb-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64         1/8 
  Verifying        : mariadb-backup-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_6   2/8 
  Verifying        : mariadb-common-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_6   3/8 
  Verifying        : mariadb-errmsg-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_6   4/8 
  Verifying        : mariadb-gssapi-server-3:10.3.17-1.module_el8.1.0+257+48736ea   5/8 
  Verifying        : mariadb-server-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_6   6/8 
  Verifying        : mariadb-server-utils-3:10.3.17-1.module_el8.1.0+257+48736ea6   7/8 
  Verifying        : perl-DBD-MySQL-4.046-3.module_el8.1.0+203+e45423dc.x86_64      8/8 
Installed products updated.

Installed:
  mariadb-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64                                
  mariadb-backup-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64                         
  mariadb-common-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64                         
  mariadb-errmsg-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64                         
  mariadb-gssapi-server-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64                  
  mariadb-server-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64                         
  mariadb-server-utils-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64                   
  perl-DBD-MySQL-4.046-3.module_el8.1.0+203+e45423dc.x86_64                             

Complete!

6. 启动数据库(并设置开机自启)

[root@myserver zabbix]# systemctl start mariadb.service
[root@myserver zabbix]# systemctl enable mariadb.service
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.ser
vice.Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.se
rvice.Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/
systemd/system/mariadb.service.

7.数据库初始化优化设置

[root@myserver zabbix]# 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):         ---直接回车
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] n           ----可不设置root密码
 ... skipping.

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] y         ----移除匿名用户
 ... Success!

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] y    -------- 拒绝root远程登录
 ... Success!

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      ---删除测试库
 - 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                   -----刷新权限
 ... 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!

8.登上数据库测试

[root@myserver zabbix]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 10.3.17-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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.000 sec)

MariaDB [(none)]> select user,host from mysql.user;
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1       |
| root | localhost |
+------+-----------+
3 rows in set (0.000 sec)

MariaDB [(none)]> 

9.创建zabbix库并授权

MariaDB [(none)]> drop database zabbix;
Query OK, 97 rows affected (0.165 sec)

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

MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by '123456';
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> set innodb_strict_mode=0;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> exit
Bye
 

10.将zabbix的数据导到数据库里面

查看文件的内容有哪些(rpm -ql zabbix-server-mysql)

[root@myserver zabbix]# rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/.build-id
/usr/lib/.build-id/58
/usr/lib/.build-id/58/b1c983f60fa3eed962759cab143ca4db290bd1
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql
/usr/share/doc/zabbix-server-mysql/AUTHORS
/usr/share/doc/zabbix-server-mysql/COPYING
/usr/share/doc/zabbix-server-mysql/ChangeLog
/usr/share/doc/zabbix-server-mysql/NEWS
/usr/share/doc/zabbix-server-mysql/README
/usr/share/doc/zabbix-server-mysql/create.sql.gz
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix
[root@myserver zabbix]# 

11.导入表数据

[root@myserver my.cnf.d]# systemctl restart mariadb.service
[root@myserver my.cnf.d]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz|mysql -uzabbix -p123456 zabbix
 [root@myserver my.cnf.d]#

12检查导入是否成功(mysql zabbix -e 'show tables;')  114张

13 配置zabbix-server,使其能连上数据库

[root@myserver zabbix]# egrep -v '#|^$' /etc/zabbix/zabbix_server.conf 
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

14.设置开启自启并查看监听端口10051

[root@myserver zabbix]# systemctl start zabbix-server
[root@myserver zabbix]# systemctl enable zabbix-server
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /us
r/lib/systemd/system/zabbix-server.service.
[root@myserver ~]# netstat -anlpt|grep 10051
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      35217/zabbix_server 
tcp6       0      0 :::10051                :::*                    LISTEN      35217/zabbix_server 

15 启动httpd服务,前台页面验证

[root@myserver ~]# systemctl start httpd
[root@myserver ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/s
ystem/httpd.service.

16 web页面访问

17编辑配置文件/etc/httpd/conf.d/zabbix.conf 修改时区

    <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 Asia/Shanghai
    </IfModule>

18 点击下一步,填写相关配置信息

19 zabbix有报警信息,未安装zabbix-agent

 

20  安装zabbix-agent

[root@myserver_1 test]# yum install -y zabbix-agent
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.tuna.tsinghua.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package zabbix-agent.x86_64 0:4.0.27-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================
 Package               Arch            Version                  Repository       Size
======================================================================================
Installing:
 zabbix-agent          x86_64          4.0.27-1.el7             zabbix          427 k

Transaction Summary
======================================================================================
Install  1 Package

Total download size: 427 k
Installed size: 1.6 M
Downloading packages:
zabbix-agent-4.0.27-1.el7.x86_64.rpm                           | 427 kB  00:00:05     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : zabbix-agent-4.0.27-1.el7.x86_64                                   1/1 
  Verifying  : zabbix-agent-4.0.27-1.el7.x86_64                                   1/1 

Installed:
  zabbix-agent.x86_64 0:4.0.27-1.el7                                                  

Complete!
[root@myserver_1 test]# systemctl start zabbix-agent.service
[root@myserver_1 test]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@myserver_1 test]# 

21.等待一会自动会检测

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值