使用Ubuntu系统编译安装Zabbix企业级监控系统

      使用Ubuntu系统编译安装Zabbix企业级监控系统  

                          作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

  Ubuntu系统部署笔记:https://www.cnblogs.com/yinzhengjie/p/12180899.html.

一.从zabbix官网下载相应版本软件包步骤详解

1>.如下图所示,点击"产品手册"(官网地址:https://www.zabbix.com/cn/manuals)

使用Ubuntu系统编译安装Zabbix企业级监控系统

2>.如下图所示,点击"阅读中文版"

使用Ubuntu系统编译安装Zabbix企业级监控系统

3>.查看官方中文手册,如下图所示,点击"从源代码安装"

使用Ubuntu系统编译安装Zabbix企业级监控系统

4>.打开zabbix的软件包下载页面(https://www.zabbix.com/cn/download_sources)

使用Ubuntu系统编译安装Zabbix企业级监控系统

5>.下载zabbix软件包,如下图所示,选择zabbix版本后,点击"下载"

使用Ubuntu系统编译安装Zabbix企业级监控系统

6>.如上图所示,点击"下载"后会跳转到一个广告页面,下载速度非常快,基本上10秒左右就能搞定

使用Ubuntu系统编译安装Zabbix企业级监控系统

二.编译安装zabbix

1>.将默认软件源仓库更换为阿里云的(目的是为例提速,因为官网默认配置的服务器在国外,当安装一些常用软件时速度会很慢)

[root@zabbix203.yinzhengjie.org.cn ~]# cp /etc/apt/sources.list /etc/apt/sources.list-`date +%F`          #修改文件前需要做备份
[root@zabbix203.yinzhengjie.org.cn ~]# vim /etc/apt/sources.list
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# cat /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# vim /etc/apt/sources.list                             #修改默认的软件源为阿里的仓库

[root@zabbix203.yinzhengjie.org.cn ~]# apt update
Get: http://mirrors.aliyun.com/ubuntu bionic InRelease [242 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security InRelease [88.7 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates InRelease [88.7 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease [242 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports InRelease [74.6 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/restricted Sources [5,324 B]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe Sources [9,051 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/multiverse Sources [181 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main Sources [829 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 Packages [1,019 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main Translation-en [516 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/restricted amd64 Packages [9,184 B]
Get: http://mirrors.aliyun.com/ubuntu bionic/restricted Translation-en [3,584 B]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe amd64 Packages [8,570 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe Translation-en [4,941 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/multiverse amd64 Packages [151 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/multiverse Translation-en [108 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/restricted Sources [4,548 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe Sources [166 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/multiverse Sources [3,180 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/main Sources [142 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 Packages [636 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/main Translation-en [208 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/restricted amd64 Packages [21.2 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/restricted Translation-en [5,984 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 Packages [644 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe Translation-en [217 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/multiverse amd64 Packages [6,340 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/multiverse Translation-en [2,640 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/restricted Sources [6,540 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/universe Sources [277 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/multiverse Sources [5,840 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/main Sources [307 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 Packages [853 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/main Translation-en [298 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/restricted amd64 Packages [30.2 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/restricted Translation-en [7,928 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/universe amd64 Packages [1,048 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/universe Translation-en [324 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/multiverse amd64 Packages [9,700 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/multiverse Translation-en [4,576 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/main Sources [71.2 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/multiverse Sources [1,796 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/restricted Sources [5,564 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/universe Sources [20.8 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 Packages [124 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/main Translation-en [43.9 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/restricted amd64 Packages [16.8 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/restricted Translation-en [5,716 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/universe amd64 Packages [145 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/universe Translation-en [32.2 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/multiverse amd64 Packages [7,372 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/multiverse Translation-en [2,796 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/universe Sources [2,496 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/main Sources [2,532 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/main amd64 Packages [2,512 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/main Translation-en [1,644 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/universe amd64 Packages [4,028 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/universe Translation-en [1,900 B]
Fetched 31.8 MB in 5s (, kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
packages can be upgraded. Run 'apt list --upgradable' to see them.
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# apt update

使用Ubuntu系统编译安装Zabbix企业级监控系统

2>.在ubuntu系统环境安装zabbix编译时依赖的库

[root@zabbix203.yinzhengjie.org.cn ~]# apt-get -y install libmysqlclient-dev libxml2-dev libxml2 libsnmp-dev libevent-dev libcurl4-openssl-dev openjdk--jdk

温馨提示:
  如果缺少任意一个库均可以能会编译报错,参考笔记:https://www.cnblogs.com/yinzhengjie2020/p/12306882.html

3>.将下载的zabbix软件包上传到服务器

[root@zabbix203.yinzhengjie.org.cn ~]# apt-get -y install lrzsz
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
minicom
The following NEW packages will be installed:
lrzsz
0 upgraded, 1 newly installed, 0 to remove and 136 not upgraded.
Need to get 74.8 kB of archives.
After this operation, 531 kB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 lrzsz amd64 0.12.21-10~build0.18.04.1 [74.8 kB]
Fetched 74.8 kB in 0s (330 kB/s)
Selecting previously unselected package lrzsz.
(Reading database ... 67267 files and directories currently installed.)
Preparing to unpack .../lrzsz_0.12.21-10~build0.18.04.1_amd64.deb ...
Unpacking lrzsz (0.12.21-10~build0.18.04.1) ...
Setting up lrzsz (0.12.21-10~build0.18.04.1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# apt-get -y install lrzsz              #小于4G的文件都可以使用该命令行工具进行上传哟~

使用Ubuntu系统编译安装Zabbix企业级监控系统

3>.解压zabbix的软件包

[root@zabbix203.yinzhengjie.org.cn /usr/local/src]# ll
total
drwxr-xr-x root root Feb : ./
drwxr-xr-x root root Aug ../
-rw-r--r-- root root Feb : zabbix-4.0..tar.gz
[root@zabbix203.yinzhengjie.org.cn /usr/local/src]#
[root@zabbix203.yinzhengjie.org.cn /usr/local/src]#
[root@zabbix203.yinzhengjie.org.cn /usr/local/src]# tar -zxf zabbix-4.0..tar.gz
[root@zabbix203.yinzhengjie.org.cn /usr/local/src]#
[root@zabbix203.yinzhengjie.org.cn /usr/local/src]# ll
total
drwxr-xr-x root root Feb : ./
drwxr-xr-x root root Aug ../
drwxr-xr-x Jan : zabbix-4.0./
-rw-r--r-- root root Feb : zabbix-4.0..tar.gz
[root@zabbix203.yinzhengjie.org.cn /usr/local/src]#
[root@zabbix203.yinzhengjie.org.cn /usr/local/src]# ll zabbix-4.0.
total
drwxr-xr-x Jan : ./
drwxr-xr-x root root Feb : ../
-rw-r--r-- Jan : aclocal.m4
-rw-r--r-- Jan : AUTHORS
drwxr-xr-x Jan : bin/
drwxr-xr-x Jan : build/
-rw-r--r-- Jan : ChangeLog
-rwxr-xr-x Jan compile*
drwxr-xr-x Jan : conf/
-rwxr-xr-x Nov config.guess*
-rwxr-xr-x Nov config.sub*
-rwxr-xr-x Jan : configure*
-rw-r--r-- Jan : configure.ac
-rw-r--r-- Jan : COPYING
drwxr-xr-x Jan : database/
-rwxr-xr-x Jan depcomp*
drwxr-xr-x Jan : frontends/
drwxr-xr-x Jan : include/
-rw-r--r-- Jan : INSTALL
-rwxr-xr-x Jan install-sh*
drwxr-xr-x Jan : m4/
-rw-r--r-- Jan : Makefile.am
-rw-r--r-- Jan : Makefile.in
drwxr-xr-x Jan : man/
drwxr-xr-x Jan : misc/
-rwxr-xr-x Jan missing*
-rw-r--r-- Jan : NEWS
-rw-r--r-- Jan : README
drwxr-xr-x Jan : sass/
drwxr-xr-x Jan : src/
[root@zabbix203.yinzhengjie.org.cn /usr/local/src]#
[root@zabbix203.yinzhengjie.org.cn /usr/local/src]#

[root@zabbix203.yinzhengjie.org.cn /usr/local/src]# tar -zxf zabbix-4.0.17.tar.gz

4>.配置zabbix需要安装的软件包

[root@zabbix203.yinzhengjie.org.cn /usr/local/src/zabbix-4.0.]# ./configure --help
`configure' configures Zabbix 4.0.17 to adapt to many kinds of systems. Usage: ./configure [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..'] Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX] By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'. For better control, use the options below. Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/zabbix]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR] Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD] Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-silent-rules less verbose build output (undo: "make V=1")
--disable-silent-rules verbose build output (undo: "make V=0")
--enable-dependency-tracking
do not reject slow dependency extractors
--disable-dependency-tracking
speeds up one-time build
--disable-largefile omit support for large files
--enable-static Build statically linked binaries
--enable-server Turn on build of Zabbix server
--enable-proxy Turn on build of Zabbix proxy
--enable-agent Turn on build of Zabbix agent and client utilities
--enable-java Turn on build of Zabbix Java gateway
--enable-ipv6 Turn on support of IPv6 Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-ibm-db2[=ARG] use IBM DB2 CLI from given sqllib directory
(ARG=path); use /home/db2inst1/sqllib (ARG=yes);
disable IBM DB2 support (ARG=no)
--with-ibm-db2-include[=DIR]
use IBM DB2 CLI headers from given path
--with-ibm-db2-lib[=DIR]
use IBM DB2 CLI libraries from given path
--with-mysql[=ARG] use MySQL client library [default=no], optionally
specify path to mysql_config
--with-oracle[=ARG] use Oracle OCI API from given Oracle home
(ARG=path); use existing ORACLE_HOME (ARG=yes);
disable Oracle OCI support (ARG=no)
--with-oracle-include[=DIR]
use Oracle OCI API headers from given path
--with-oracle-lib[=DIR] use Oracle OCI API libraries from given path
--with-postgresql[=ARG] use PostgreSQL library [default=no], optionally
specify path to pg_config
--with-sqlite3[=ARG] use SQLite library [default=no], optionally
specify the prefix for sqlite3 library If you want to use Jabber protocol for messaging:
--with-jabber[=DIR] Include Jabber support [default=no]. DIR is the
iksemel library install directory. If you want to use XML library:
--with-libxml2[=ARG] use libxml2 client library [default=no], optionally
specify path to xml2-config If you want to use unixODBC library:
--with-unixodbc[=ARG] use ODBC driver against unixODBC package
[default=no], optionally specify full path to
odbc_config binary. If you want to use Net-SNMP library:
--with-net-snmp[=ARG] use Net-SNMP package [default=no], optionally
specify path to net-snmp-config If you want to use SSH2 based checks:
--with-ssh2[=DIR] use SSH2 package [default=no], DIR is the SSH2
library install directory. If you want to check IPMI devices:
--with-openipmi[=DIR] Include OPENIPMI support [default=no]. DIR is the
OPENIPMI base install directory, default is to
search through a number of common places for the
OPENIPMI files. If you want to specify zlib installation directories:
--with-zlib=DIR use zlib from given base install directory (DIR),
default is to search through a number of common
places for the zlib files.
--with-zlib-include=DIR use zlib include headers from given path.
--with-zlib-lib=DIR use zlib libraries from given path. If you want to specify pthread installation directories:
--with-libpthread[=DIR] use libpthread from given base install directory
(DIR), default is to search through a number of
common places for the libpthread files.
--with-libpthread-include[=DIR]
use libpthread include headers from given path.
--with-libpthread-lib[=DIR]
use libpthread libraries from given path. If you want to specify libevent installation directories:
--with-libevent[=DIR] use libevent from given base install directory
(DIR), default is to search through a number of
common places for the libevent files.
--with-libevent-include[=DIR]
use libevent include headers from given path.
--with-libevent-lib[=DIR]
use libevent libraries from given path. If you want to use encryption provided by mbed TLS (PolarSSL) library:
--with-mbedtls[=DIR] use mbed TLS (PolarSSL) package [default=no], DIR is
the libpolarssl install directory. If you want to use encryption provided by GnuTLS library:
--with-gnutls[=DIR] use GnuTLS package [default=no], DIR is the
libgnutls install directory. If you want to use encryption provided by OpenSSL library:
--with-openssl[=DIR] use OpenSSL package [default=no], DIR is the libssl
and libcrypto install directory. If you want to check LDAP servers:
--with-ldap[=DIR] Include LDAP support [default=no]. DIR is the LDAP
base install directory, default is to search through
a number of common places for the LDAP files. If you want to use cURL library:
--with-libcurl[=DIR] use cURL package [default=no], optionally specify
path to curl-config If you want to specify libpcre installation directories:
--with-libpcre[=DIR] use libpcre from given base install directory (DIR),
default is to search through a number of common
places for the libpcre files.
--with-libpcre-include[=DIR]
use libpcre include headers from given path.
--with-libpcre-lib[=DIR]
use libpcre libraries from given path. If you want to specify iconv installation directories:
--with-iconv[=DIR] use iconv from given base install directory (DIR),
default is to search through a number of common
places for the iconv files.
--with-iconv-include[=DIR]
use iconv include headers from given path.
--with-iconv-lib[=DIR] use iconv libraries from given path. Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
PKG_CONFIG path to pkg-config utility
PKG_CONFIG_PATH
directories to add to pkg-config's search path
PKG_CONFIG_LIBDIR
path overriding pkg-config's built-in search path
IKSEMEL_CFLAGS
C compiler flags for IKSEMEL, overriding pkg-config
IKSEMEL_LIBS
linker flags for IKSEMEL, overriding pkg-config Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider.
[root@zabbix203.yinzhengjie.org.cn /usr/local/src/zabbix-4.0.]#
[root@zabbix203.yinzhengjie.org.cn /usr/local/src/zabbix-4.0.]#

[root@zabbix203.yinzhengjie.org.cn /usr/local/src/zabbix-4.0.17]# ./configure --help

[root@zabbix203.yinzhengjie.org.cn /usr/local/src/zabbix-4.0.]# ./configure --prefix=/yinzhengjie/softwares/zabbix --enable-server --enable-agent --enable-java --with-mysql --with-net-snmp --with-libcurl --with-libxml2

温馨提示:    
    --prefix=/yinzhengjie/softwares/zabbix:
      指定安装的路径     --enable-server:
      表示编译zabbix server服务。
    
    --enable-agent:
      表示编译zabbix agent客户端应用程序。     --enable-java:
      表示编译Zabbix Java gateway,该组件用于监控Java程序。     --with-mysql:
      使用MySQL客户端库[default=no],可以选择指定MySQL配置的路径。
    
    --with-net-snmp:
      使用Net SNMP包[default=no],可以选择指定netsnmp配置的路径。     --with-libcurl:
      使用cURL包[default=no],可以选择指定cURL配置的路径。     --with-libxml2:
      使用libxml2客户端库[default=no],可以选择指定xml2配置的路径。

使用Ubuntu系统编译安装Zabbix企业级监控系统

5>.编译并安装zabbix软件

[root@zabbix203.yinzhengjie.org.cn ~]# lscpu
Architecture: x86_64
CPU op-mode(s): -bit, -bit
Byte Order: Little Endian
CPU(s):
On-line CPU(s) list: ,
Thread(s) per core:
Core(s) per socket:
Socket(s):
NUMA node(s):
Vendor ID: GenuineIntel
CPU family:
Model:
Model name: Intel(R) Core(TM) i7-8750H CPU @ .20GHz
Stepping:
CPU MHz: 2207.998
BogoMIPS: 4415.99
Hypervisor vendor: VMware
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 9216K
NUMA node0 CPU(s): ,
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht sysca
ll nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xsaves arat md_clear flush_l1d arch_capabilities[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# lscpu | grep "^CPU(s)"
CPU(s):
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# lscpu | grep "^CPU(s)"

[root@zabbix203.yinzhengjie.org.cn /usr/local/src/zabbix-4.0.]# make -j  && make install

使用Ubuntu系统编译安装Zabbix企业级监控系统

6>.zabbix编译安装成功会生成相应的目录

[root@zabbix203.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares
total
drwxr-xr-x root root Feb : ./
drwxr-xr-x root root Feb : ../
drwxr-xr-x root root Feb : zabbix/
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zabbix/
total
drwxr-xr-x root root Feb : ./
drwxr-xr-x root root Feb : ../
drwxr-xr-x root root Feb : bin/
drwxr-xr-x root root Feb : etc/
drwxr-xr-x root root Feb : lib/
drwxr-xr-x root root Feb : sbin/
drwxr-xr-x root root Feb : share/
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zabbix/

使用Ubuntu系统编译安装Zabbix企业级监控系统

 

三.安装数据库并授权

1>.将默认软件源仓库更换为阿里云的(目的是为例提速,因为官网默认配置的服务器在国外,当安装一些常用软件时速度会很慢)

[root@yinzhengjie.org.cn ~]# cp /etc/apt/sources.list /etc/apt/sources.list-`date +%F`          #修改文件前一定要先做好备份。
[root@yinzhengjie.org.cn ~]# vim /etc/apt/sources.list
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]# cat /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
[root@yinzhengjie.org.cn ~]#

[root@yinzhengjie.org.cn ~]# vim /etc/apt/sources.list

[root@yinzhengjie.org.cn ~]# apt update
Get: http://mirrors.aliyun.com/ubuntu bionic InRelease [242 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security InRelease [88.7 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates InRelease [88.7 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease [242 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports InRelease [74.6 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main Sources [829 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe Sources [9,051 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/multiverse Sources [181 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/restricted Sources [5,324 B]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 Packages [1,019 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main Translation-en [516 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/restricted amd64 Packages [9,184 B]
Get: http://mirrors.aliyun.com/ubuntu bionic/restricted Translation-en [3,584 B]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe amd64 Packages [8,570 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe Translation-en [4,941 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/multiverse amd64 Packages [151 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/multiverse Translation-en [108 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/multiverse Sources [3,180 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe Sources [166 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/restricted Sources [4,548 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/main Sources [142 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 Packages [636 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/main Translation-en [208 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/restricted amd64 Packages [21.2 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/restricted Translation-en [5,984 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 Packages [644 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe Translation-en [217 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/multiverse amd64 Packages [6,340 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/multiverse Translation-en [2,640 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/main Sources [307 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/universe Sources [277 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/restricted Sources [6,540 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/multiverse Sources [5,840 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 Packages [853 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/main Translation-en [298 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/restricted amd64 Packages [30.2 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/restricted Translation-en [7,928 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/universe amd64 Packages [1,048 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/universe Translation-en [324 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/multiverse amd64 Packages [9,700 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/multiverse Translation-en [4,576 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/universe Sources [20.8 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/main Sources [71.2 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/restricted Sources [5,564 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/multiverse Sources [1,796 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 Packages [124 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/main Translation-en [43.9 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/restricted amd64 Packages [16.8 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/restricted Translation-en [5,716 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/universe amd64 Packages [145 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/universe Translation-en [32.2 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/multiverse amd64 Packages [7,372 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/multiverse Translation-en [2,796 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/main Sources [2,532 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/universe Sources [2,496 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/main amd64 Packages [2,512 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/main Translation-en [1,644 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/universe amd64 Packages [4,028 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/universe Translation-en [1,900 B]
Fetched 31.8 MB in 6s (, kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
packages can be upgraded. Run 'apt list --upgradable' to see them.
[root@yinzhengjie.org.cn ~]#

[root@yinzhengjie.org.cn ~]# apt update

2>.安装MariaDB数据库并修改数据库的默认监听地址

[root@yinzhengjie.org.cn ~]# apt-get -y install mariadb-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
galera- libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl
libjemalloc1 liblwp-mediatypes-perl libmysqlclient20 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.1 mariadb-client-core-10.1 mariadb-common mariadb-server-10.1 mariadb-server-core-10.1 mysql-common socat
Suggested packages:
libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx mariadb-test tinyca
The following NEW packages will be installed:
galera- libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl
libjemalloc1 liblwp-mediatypes-perl libmysqlclient20 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.1 mariadb-client-core-10.1 mariadb-common mariadb-server mariadb-server-10.1 mariadb-server-core-10.1 mysql-common socat
upgraded, newly installed, to remove and not upgraded.
Need to get 24.1 MB of archives.
After this operation, MB of additional disk space will be used.
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 mysql-common all 5.8+1.0.4 [7,308 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 mariadb-common all 1:10.1.44-0ubuntu0.18.04.1 [16.1 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe amd64 galera-3 amd64 25.3.20-1 [947 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 libdbi-perl amd64 1.640-1 [724 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 libconfig-inifiles-perl all 2.94-1 [40.4 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 libaio1 amd64 0.3.110-5ubuntu0.1 [6,476 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 mariadb-client-core-10.1 amd64 1:10.1.44-0ubuntu0.18.04.1 [4,772 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe amd64 libjemalloc1 amd64 3.6.0-11 [82.4 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 mariadb-client-10.1 amd64 1:10.1.44-0ubuntu0.18.04.1 [5,641 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 mariadb-server-core-10.1 amd64 1:10.1.44-0ubuntu0.18.04.1 [4,952 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 socat amd64 1.7.3.2-2ubuntu2 [342 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 mariadb-server-10.1 amd64 1:10.1.44-0ubuntu0.18.04.1 [5,099 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 libhtml-tagset-perl all 3.20-3 [12.1 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 liburi-perl all 1.73-1 [77.2 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 libhtml-parser-perl amd64 3.72-3build1 [85.9 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 libcgi-pm-perl all 4.38-1 [185 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 libfcgi-perl amd64 0.78-2build1 [32.8 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 libcgi-fast-perl all 1:2.13-1 [9,940 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 libmysqlclient20 amd64 5.7.29-0ubuntu0.18.04.1 [690 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe amd64 libdbd-mysql-perl amd64 4.046-1 [82.0 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 libencode-locale-perl all 1.05-1 [12.3 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 libhtml-template-perl all 2.97-1 [59.0 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 libtimedate-perl all 2.3000-2 [37.5 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 libhttp-date-perl all 6.02-1 [10.4 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 libio-html-perl all 1.001-1 [14.9 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 liblwp-mediatypes-perl all 6.02-1 [21.7 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 libhttp-message-perl all 6.14-1 [72.1 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe amd64 libterm-readkey-perl amd64 2.37-1build1 [24.4 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 mariadb-server all 1:10.1.44-0ubuntu0.18.04.1 [12.9 kB]
Fetched 24.1 MB in 4s (, kB/s)
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... files and directories currently installed.)
Preparing to unpack .../-mysql-common_5.+1.0.4_all.deb ...
Unpacking mysql-common (5.8+1.0.) ...
Selecting previously unselected package mariadb-common.
Preparing to unpack .../-mariadb-common_1%3a10.1.44-0ubuntu0.18.04.1_all.deb ...
Unpacking mariadb-common (:10.1.-0ubuntu0.18.04.) ...
Selecting previously unselected package galera-.
Preparing to unpack .../-galera-3_25.3.20-1_amd64.deb ...
Unpacking galera- (25.3.-) ...
Selecting previously unselected package libdbi-perl.
Preparing to unpack .../-libdbi-perl_1.-1_amd64.deb ...
Unpacking libdbi-perl (1.640-) ...
Selecting previously unselected package libconfig-inifiles-perl.
Preparing to unpack .../-libconfig-inifiles-perl_2.-1_all.deb ...
Unpacking libconfig-inifiles-perl (2.94-) ...
Selecting previously unselected package libaio1:amd64.
Preparing to unpack .../-libaio1_0.3.110-5ubuntu0.1_amd64.deb ...
Unpacking libaio1:amd64 (0.3.-5ubuntu0.) ...
Selecting previously unselected package mariadb-client-core-10.1.
Preparing to unpack .../-mariadb-client-core-.1_1%3a10.1.44-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mariadb-client-core-10.1 (:10.1.-0ubuntu0.18.04.) ...
Selecting previously unselected package libjemalloc1.
Preparing to unpack .../-libjemalloc1_3.6.0-11_amd64.deb ...
Unpacking libjemalloc1 (3.6.-) ...
Selecting previously unselected package mariadb-client-10.1.
Preparing to unpack .../-mariadb-client-.1_1%3a10.1.44-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mariadb-client-10.1 (:10.1.-0ubuntu0.18.04.) ...
Selecting previously unselected package mariadb-server-core-10.1.
Preparing to unpack .../-mariadb-server-core-.1_1%3a10.1.44-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mariadb-server-core-10.1 (:10.1.-0ubuntu0.18.04.) ...
Selecting previously unselected package socat.
Preparing to unpack .../-socat_1.7.3.-2ubuntu2_amd64.deb ...
Unpacking socat (1.7.3.2-2ubuntu2) ...
Setting up mysql-common (5.8+1.0.) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Setting up mariadb-common (:10.1.-0ubuntu0.18.04.) ...
update-alternatives: using /etc/mysql/mariadb.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mariadb-server-10.1.
(Reading database ... files and directories currently installed.)
Preparing to unpack .../-mariadb-server-.1_1%3a10.1.44-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mariadb-server-10.1 (:10.1.-0ubuntu0.18.04.) ...
Selecting previously unselected package libhtml-tagset-perl.
Preparing to unpack .../-libhtml-tagset-perl_3.-3_all.deb ...
Unpacking libhtml-tagset-perl (3.20-) ...
Selecting previously unselected package liburi-perl.
Preparing to unpack .../-liburi-perl_1.-1_all.deb ...
Unpacking liburi-perl (1.73-) ...
Selecting previously unselected package libhtml-parser-perl.
Preparing to unpack .../-libhtml-parser-perl_3.-3build1_amd64.deb ...
Unpacking libhtml-parser-perl (3.72-3build1) ...
Selecting previously unselected package libcgi-pm-perl.
Preparing to unpack .../-libcgi-pm-perl_4.-1_all.deb ...
Unpacking libcgi-pm-perl (4.38-) ...
Selecting previously unselected package libfcgi-perl.
Preparing to unpack .../-libfcgi-perl_0.-2build1_amd64.deb ...
Unpacking libfcgi-perl (0.78-2build1) ...
Selecting previously unselected package libcgi-fast-perl.
Preparing to unpack .../-libcgi-fast-perl_1%3a2.-1_all.deb ...
Unpacking libcgi-fast-perl (:2.13-) ...
Selecting previously unselected package libmysqlclient20:amd64.
Preparing to unpack .../-libmysqlclient20_5.7.29-0ubuntu0.18.04.1_amd64.deb ...
Unpacking libmysqlclient20:amd64 (5.7.-0ubuntu0.18.04.) ...
Selecting previously unselected package libdbd-mysql-perl.
Preparing to unpack .../-libdbd-mysql-perl_4.-1_amd64.deb ...
Unpacking libdbd-mysql-perl (4.046-) ...
Selecting previously unselected package libencode-locale-perl.
Preparing to unpack .../-libencode-locale-perl_1.-1_all.deb ...
Unpacking libencode-locale-perl (1.05-) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../-libhtml-template-perl_2.-1_all.deb ...
Unpacking libhtml-template-perl (2.97-) ...
Selecting previously unselected package libtimedate-perl.
Preparing to unpack .../-libtimedate-perl_2.-2_all.deb ...
Unpacking libtimedate-perl (2.3000-) ...
Selecting previously unselected package libhttp-date-perl.
Preparing to unpack .../-libhttp-date-perl_6.-1_all.deb ...
Unpacking libhttp-date-perl (6.02-) ...
Selecting previously unselected package libio-html-perl.
Preparing to unpack .../-libio-html-perl_1.-1_all.deb ...
Unpacking libio-html-perl (1.001-) ...
Selecting previously unselected package liblwp-mediatypes-perl.
Preparing to unpack .../-liblwp-mediatypes-perl_6.-1_all.deb ...
Unpacking liblwp-mediatypes-perl (6.02-) ...
Selecting previously unselected package libhttp-message-perl.
Preparing to unpack .../-libhttp-message-perl_6.-1_all.deb ...
Unpacking libhttp-message-perl (6.14-) ...
Selecting previously unselected package libterm-readkey-perl.
Preparing to unpack .../-libterm-readkey-perl_2.-1build1_amd64.deb ...
Unpacking libterm-readkey-perl (2.37-1build1) ...
Selecting previously unselected package mariadb-server.
Preparing to unpack .../-mariadb-server_1%3a10.1.44-0ubuntu0.18.04.1_all.deb ...
Unpacking mariadb-server (:10.1.-0ubuntu0.18.04.) ...
Setting up libhtml-tagset-perl (3.20-) ...
Setting up libconfig-inifiles-perl (2.94-) ...
Processing triggers for ureadahead (0.100.-) ...
Setting up libencode-locale-perl (1.05-) ...
Setting up libjemalloc1 (3.6.-) ...
Setting up libtimedate-perl (2.3000-) ...
Setting up socat (1.7.3.2-2ubuntu2) ...
Setting up libio-html-perl (1.001-) ...
Setting up libterm-readkey-perl (2.37-1build1) ...
Setting up liblwp-mediatypes-perl (6.02-) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up libaio1:amd64 (0.3.-5ubuntu0.) ...
Setting up galera- (25.3.-) ...
Setting up liburi-perl (1.73-) ...
Processing triggers for systemd (-3ubuntu10.) ...
Setting up libhtml-parser-perl (3.72-3build1) ...
Setting up libcgi-pm-perl (4.38-) ...
Processing triggers for man-db (2.8.-2ubuntu0.) ...
Setting up libmysqlclient20:amd64 (5.7.-0ubuntu0.18.04.) ...
Setting up libfcgi-perl (0.78-2build1) ...
Setting up libdbi-perl (1.640-) ...
Setting up libhttp-date-perl (6.02-) ...
Setting up mariadb-server-core-10.1 (:10.1.-0ubuntu0.18.04.) ...
Setting up libhtml-template-perl (2.97-) ...
Setting up mariadb-client-core-10.1 (:10.1.-0ubuntu0.18.04.) ...
Setting up libcgi-fast-perl (:2.13-) ...
Setting up libhttp-message-perl (6.14-) ...
Setting up libdbd-mysql-perl (4.046-) ...
Setting up mariadb-client-10.1 (:10.1.-0ubuntu0.18.04.) ...
Setting up mariadb-server-10.1 (:10.1.-0ubuntu0.18.04.) ...
Created symlink /etc/systemd/system/mysql.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/mariadb.service.
Setting up mariadb-server (:10.1.-0ubuntu0.18.04.) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for ureadahead (0.100.-) ...
Processing triggers for systemd (-3ubuntu10.) ...
[root@yinzhengjie.org.cn ~]#

[root@yinzhengjie.org.cn ~]# apt-get -y install mariadb-server

[root@yinzhengjie.org.cn ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 127.0.0.53%lo: 0.0.0.0:*
LISTEN 0.0.0.0: 0.0.0.0:*
LISTEN 127.0.0.1: 0.0.0.0:*
LISTEN [::]: [::]:*
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]# grep bind-address /etc/mysql/ -R
/etc/mysql/mariadb.conf.d/-server.cnf:bind-address = 127.0.0.1
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]# grep 127.0.0.1 /etc/mysql/ -R
/etc/mysql/mariadb.conf.d/-server.cnf:bind-address = 127.0.0.1
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]# ifconfig ens33 | sed -nr '2s/^[^0-9]+([0-9.]+).*/\1/p'
172.200.5.202
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]# sed -i 's#127.0.0.1#172.200.5.202#' /etc/mysql/mariadb.conf.d/-server.cnf
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]# grep bind-address /etc/mysql/ -R
/etc/mysql/mariadb.conf.d/-server.cnf:bind-address = 172.200.5.202
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]# systemctl restart mariadb
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]# systemctl enable mariadb
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]# systemctl list-unit-files | grep mariadb
mariadb.service enabled
mariadb@.service disabled
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 127.0.0.53%lo: 0.0.0.0:*
LISTEN 0.0.0.0: 0.0.0.0:*
LISTEN 172.200.5.202: 0.0.0.0:*
LISTEN [::]: [::]:*
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]#

[root@yinzhengjie.org.cn ~]# sed -i 's#127.0.0.1#172.200.5.202#' /etc/mysql/mariadb.conf.d/50-server.cnf

[root@yinzhengjie.org.cn ~]# cat /etc/mysql/my.cnf
# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# . "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# . "/etc/mysql/conf.d/*.cnf" to set global options.
# . "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# . "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use. #
# This group is read both both by the client and the server
# use it for options that affect everything
#
# #Add by yinzhengjie
[mysqld]
innodb_file_format=BARRACUDA
innodb_large_prefix=true
innodb_default_row_format=DYNAMIC
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci [client-server] # Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
[root@yinzhengjie.org.cn ~]#

[root@yinzhengjie.org.cn ~]# cat /etc/mysql/my.cnf  #修改MySQL的配置文件,这一步骤千万别忘记,否则你可能会遇到"ERROR 1709 (HY000) at line 89: Index column size too large. The maximum column size is 767 bytes."的报错信息

使用Ubuntu系统编译安装Zabbix企业级监控系统

3>.配置MariaDB数据库授权

[root@yinzhengjie.org.cn ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 31
Server version: 10.1.44-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04 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)]> CREATE DATABASE zabbix_server DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Query OK, 1 row affected (0.00 sec) MariaDB [(none)]>
MariaDB [(none)]> GRANT ALL PRIVILEGES ON zabbix_server.* to zabbix@'172.200.5.%' IDENTIFIED BY 'yinzhengjie';
Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]>
MariaDB [(none)]> QUIT
Bye
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]#
MariaDB [(none)]> SELECT user,host,password FROM mysql.user;
+--------+-------------+-------------------------------------------+
| user | host | password |
+--------+-------------+-------------------------------------------+
| root | localhost | |
| zabbix | 172.200.5.% | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 |
+--------+-------------+-------------------------------------------+
rows in set (0.00 sec) MariaDB [(none)]>
MariaDB [(none)]>

MariaDB [(none)]> SELECT user,host,password FROM mysql.user;

MariaDB [(none)]> SHOW GRANTS FOR zabbix@'172.200.5.%';
+-----------------------------------------------------------------------------------------------------------------+
| Grants for zabbix@172.200.5.% |
+-----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'zabbix'@'172.200.5.%' IDENTIFIED BY PASSWORD '*BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7' |
| GRANT ALL PRIVILEGES ON `zabbix_server`.* TO 'zabbix'@'172.200.5.%' |
+-----------------------------------------------------------------------------------------------------------------+
rows in set (0.01 sec) MariaDB [(none)]>

MariaDB [(none)]> SHOW GRANTS FOR zabbix@'172.200.5.%';

四.配置zabbix server服务器 

1>.zabbix server的服务器测试

[root@zabbix203.yinzhengjie.org.cn ~]# apt-get -y install mariadb-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libaio1 libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libjemalloc1 libmysqlclient20 libterm-readkey-perl mariadb-client-10.1 mariadb-client-core-10.1 mariadb-common mysql-common
Suggested packages:
libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl
The following NEW packages will be installed:
libaio1 libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libjemalloc1 libmysqlclient20 libterm-readkey-perl mariadb-client mariadb-client-10.1 mariadb-client-core-10.1 mariadb-common mysql-common
upgraded, 12 newly installed, 0 to remove and 136 not upgraded.
Need to get 12.1 MB of archives.
After this operation, 76.2 MB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 libaio1 amd64 0.3.110-5ubuntu0.1 [6,476 B]
Get:2 http://mirrors.aliyun.com/ubuntu bionic/main amd64 libdbi-perl amd64 1.640-1 [724 kB]
Get:3 http://mirrors.aliyun.com/ubuntu bionic/main amd64 mysql-common all 5.8+1.0.4 [7,308 B]
Get:4 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 libmysqlclient20 amd64 5.7.29-0ubuntu0.18.04.1 [690 kB]
Get:5 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 libdbd-mysql-perl amd64 4.046-1 [82.0 kB]
Get:6 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 libterm-readkey-perl amd64 2.37-1build1 [24.4 kB]
Get:7 http://mirrors.aliyun.com/ubuntu bionic/main amd64 libconfig-inifiles-perl all 2.94-1 [40.4 kB]
Get:8 http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 mariadb-common all 1:10.1.44-0ubuntu0.18.04.1 [16.1 kB]
Get:9 http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 mariadb-client-core-10.1 amd64 1:10.1.44-0ubuntu0.18.04.1 [4,772 kB]
Get:10 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 libjemalloc1 amd64 3.6.0-11 [82.4 kB]
Get:11 http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 mariadb-client-10.1 amd64 1:10.1.44-0ubuntu0.18.04.1 [5,641 kB]
Get:12 http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 mariadb-client all 1:10.1.44-0ubuntu0.18.04.1 [12.8 kB]
Fetched 12.1 MB in 2s (6,216 kB/s)
Selecting previously unselected package libaio1:amd64.
(Reading database ... 66992 files and directories currently installed.)
Preparing to unpack .../00-libaio1_0.3.110-5ubuntu0.1_amd64.deb ...
Unpacking libaio1:amd64 (0.3.110-5ubuntu0.1) ...
Selecting previously unselected package libdbi-perl.
Preparing to unpack .../01-libdbi-perl_1.640-1_amd64.deb ...
Unpacking libdbi-perl (1.640-1) ...
Selecting previously unselected package mysql-common.
Preparing to unpack .../02-mysql-common_5.8+1.0.4_all.deb ...
Unpacking mysql-common (5.8+1.0.4) ...
Selecting previously unselected package libmysqlclient20:amd64.
Preparing to unpack .../03-libmysqlclient20_5.7.29-0ubuntu0.18.04.1_amd64.deb ...
Unpacking libmysqlclient20:amd64 (5.7.29-0ubuntu0.18.04.1) ...
Selecting previously unselected package libdbd-mysql-perl.
Preparing to unpack .../04-libdbd-mysql-perl_4.046-1_amd64.deb ...
Unpacking libdbd-mysql-perl (4.046-1) ...
Selecting previously unselected package libterm-readkey-perl.
Preparing to unpack .../05-libterm-readkey-perl_2.37-1build1_amd64.deb ...
Unpacking libterm-readkey-perl (2.37-1build1) ...
Selecting previously unselected package libconfig-inifiles-perl.
Preparing to unpack .../06-libconfig-inifiles-perl_2.94-1_all.deb ...
Unpacking libconfig-inifiles-perl (2.94-1) ...
Selecting previously unselected package mariadb-common.
Preparing to unpack .../07-mariadb-common_1%3a10.1.44-0ubuntu0.18.04.1_all.deb ...
Unpacking mariadb-common (1:10.1.44-0ubuntu0.18.04.1) ...
Selecting previously unselected package mariadb-client-core-10.1.
Preparing to unpack .../08-mariadb-client-core-10.1_1%3a10.1.44-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mariadb-client-core-10.1 (1:10.1.44-0ubuntu0.18.04.1) ...
Selecting previously unselected package libjemalloc1.
Preparing to unpack .../09-libjemalloc1_3.6.0-11_amd64.deb ...
Unpacking libjemalloc1 (3.6.0-11) ...
Selecting previously unselected package mariadb-client-10.1.
Preparing to unpack .../10-mariadb-client-10.1_1%3a10.1.44-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mariadb-client-10.1 (1:10.1.44-0ubuntu0.18.04.1) ...
Selecting previously unselected package mariadb-client.
Preparing to unpack .../11-mariadb-client_1%3a10.1.44-0ubuntu0.18.04.1_all.deb ...
Unpacking mariadb-client (1:10.1.44-0ubuntu0.18.04.1) ...
Setting up libconfig-inifiles-perl (2.94-1) ...
Setting up libjemalloc1 (3.6.0-11) ...
Setting up mysql-common (5.8+1.0.4) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Setting up libterm-readkey-perl (2.37-1build1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up libaio1:amd64 (0.3.110-5ubuntu0.1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up libmysqlclient20:amd64 (5.7.29-0ubuntu0.18.04.1) ...
Setting up libdbi-perl (1.640-1) ...
Setting up mariadb-common (1:10.1.44-0ubuntu0.18.04.1) ...
update-alternatives: using /etc/mysql/mariadb.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Setting up mariadb-client-core-10.1 (1:10.1.44-0ubuntu0.18.04.1) ...
Setting up libdbd-mysql-perl (4.046-1) ...
Setting up mariadb-client-10.1 (1:10.1.44-0ubuntu0.18.04.1) ...
Setting up mariadb-client (1:10.1.44-0ubuntu0.18.04.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# apt-get -y install mariadb-client        #需要单独安装MariaDB的客户端

[root@zabbix203.yinzhengjie.org.cn ~]# ifconfig ens33 | sed -nr '2s/^[^0-9]+([0-9.]+).*/\1/p'
172.200.5.203
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# mysql -u zabbix -pyinzhengjie -h 172.200.5.202
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 51
Server version: 10.1.44-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04 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)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| zabbix_server |
+--------------------+
2 rows in set (0.00 sec) MariaDB [(none)]>
MariaDB [(none)]> USE zabbix_server
Database changed
MariaDB [zabbix_server]>
MariaDB [zabbix_server]> SHOW TABLES;
Empty set (0.00 sec) MariaDB [zabbix_server]>
MariaDB [zabbix_server]> QUIT
Bye
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# mysql -u zabbix -pyinzhengjie -h 172.200.5.202

使用Ubuntu系统编译安装Zabbix企业级监控系统

2>.初始化zabbix server的数据库信息

[root@zabbix203.yinzhengjie.org.cn ~]# ll /usr/local/src/zabbix-4.0.17/database/
total 84
drwxr-xr-x 8 1001 1001 4096 Feb 14 06:20 ./
drwxr-xr-x 13 1001 1001 4096 Feb 14 06:20 ../
drwxr-xr-x 2 1001 1001 4096 Jan 28 14:36 elasticsearch/
drwxr-xr-x 2 1001 1001 4096 Feb 14 06:20 ibm_db2/
-rw-r--r-- 1 root root 21640 Feb 14 06:20 Makefile
-rw-r--r-- 1 1001 1001 155 Jan 28 14:36 Makefile.am
-rw-r--r-- 1 1001 1001 21722 Jan 28 14:36 Makefile.in
drwxr-xr-x 2 1001 1001 4096 Feb 14 06:20 mysql/
drwxr-xr-x 2 1001 1001 4096 Feb 14 06:20 oracle/
drwxr-xr-x 2 1001 1001 4096 Feb 14 06:20 postgresql/
drwxr-xr-x 2 1001 1001 4096 Feb 14 06:20 sqlite3/
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# ll /usr/local/src/zabbix-4.0.17/database/

[root@zabbix203.yinzhengjie.org.cn ~]# ll /usr/local/src/zabbix-4.0.17/database/mysql/
total 6100
drwxr-xr-x 2 1001 1001 4096 Feb 14 06:20 ./
drwxr-xr-x 8 1001 1001 4096 Feb 14 06:20 ../
-rw-r--r-- 1 1001 1001 4079333 Jan 28 14:36 data.sql
-rw-r--r-- 1 1001 1001 1978341 Jan 28 14:36 images.sql
-rw-r--r-- 1 root root 15586 Feb 14 06:20 Makefile
-rw-r--r-- 1 1001 1001 392 Jan 28 14:36 Makefile.am
-rw-r--r-- 1 1001 1001 15711 Jan 28 14:36 Makefile.in
-rw-r--r-- 1 1001 1001 140265 Jan 28 14:36 schema.sql
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# ll /usr/local/src/zabbix-4.0.17/database/mysql/

[root@zabbix203.yinzhengjie.org.cn ~]# ifconfig ens33 | sed -nr '2s/^[^0-9]+([0-9.]+).*/\1/p'
172.200.5.203
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# mysql -u zabbix -pyinzhengjie -h 172.200.5.202 zabbix_server < /usr/local/src/zabbix-4.0./database/mysql/schema.sql
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# mysql -u zabbix -pyinzhengjie -h 172.200.5.202 zabbix_server < /usr/local/src/zabbix-4.0./database/mysql/images.sql
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# mysql -u zabbix -pyinzhengjie -h 172.200.5.202 zabbix_server < /usr/local/src/zabbix-4.0./database/mysql/data.sql
[root@zabbix203.yinzhengjie.org.cn ~]#

使用Ubuntu系统编译安装Zabbix企业级监控系统

3>.修改zabbix的配置文件

[root@zabbix203.yinzhengjie.org.cn ~]# grep DBHost= /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf
# DBHost=localhost
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (DBHost=)localhost@\1172.200.5.202@' /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# grep DBHost= /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf
DBHost=172.200.5.202
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (DBHost=)localhost@\1172.200.5.202@' /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf

[root@zabbix203.yinzhengjie.org.cn ~]# grep DBPort= /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf
# DBPort=
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (DBPort=)@\13306@' /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# grep DBPort= /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf
DBPort=
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (DBPort=)@\13306@' /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf

[root@zabbix203.yinzhengjie.org.cn ~]# grep ^DBName= /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf
DBName=zabbix
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's#(DBName=)zabbix#\1zabbix_server#' /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# grep ^DBName= /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf
DBName=zabbix_server
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's#(DBName=)zabbix#\1zabbix_server#' /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf

[root@zabbix203.yinzhengjie.org.cn ~]# grep DBPassword= /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf
# DBPassword=
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (DBPassword=)@\1yinzhengjie@' /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# grep DBPassword= /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf
DBPassword=yinzhengjie
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (DBPassword=)@\1yinzhengjie@' /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf

[root@zabbix203.yinzhengjie.org.cn ~]# grep "^D" /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf
DBHost=172.200.5.202
DBName=zabbix_server
DBUser=zabbix
DBPassword=yinzhengjie
DBPort=
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# grep "^D" /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf

使用Ubuntu系统编译安装Zabbix企业级监控系统

4>.创建zabbix用户用来运行zabbix server的守护进程

[root@zabbix203.yinzhengjie.org.cn ~]# groupadd zabbix
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# useradd zabbix -s /sbin/nologin -M -g zabbix
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# chown zabbix:zabbix /yinzhengjie/softwares/zabbix/ -R
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zabbix/ -d
drwxr-xr-x zabbix zabbix Feb : /yinzhengjie/softwares/zabbix//
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zabbix/
total
drwxr-xr-x zabbix zabbix Feb : ./
drwxr-xr-x root root Feb : ../
drwxr-xr-x zabbix zabbix Feb : bin/
drwxr-xr-x zabbix zabbix Feb : etc/
drwxr-xr-x zabbix zabbix Feb : lib/
drwxr-xr-x zabbix zabbix Feb : sbin/
drwxr-xr-x zabbix zabbix Feb : share/
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#

5>.启动zabbix server服务器

[root@zabbix203.yinzhengjie.org.cn ~]# /yinzhengjie/softwares/zabbix/sbin/zabbix_server  -h
usage:
zabbix_server [-c config-file]
zabbix_server [-c config-file] -R runtime-option
zabbix_server -h
zabbix_server -V The core daemon of Zabbix software. Options:
-c --config config-file Path to the configuration file
(default: "/yinzhengjie/softwares/zabbix/etc/zabbix_server.conf")
-f --foreground Run Zabbix server in foreground
-R --runtime-control runtime-option Perform administrative functions Runtime control options:
config_cache_reload Reload configuration cache
housekeeper_execute Execute the housekeeper
log_level_increase=target Increase log level, affects all processes if
target is not specified
log_level_decrease=target Decrease log level, affects all processes if
target is not specified Log level control targets:
process-type All processes of specified type
(alerter, alert manager, configuration syncer,
discoverer, escalator, history syncer,
housekeeper, http poller, icmp pinger,
ipmi manager, ipmi poller, java poller,
poller, preprocessing manager,
preprocessing worker, proxy poller,
self-monitoring, snmp trapper, task manager,
timer, trapper, unreachable poller,
vmware collector)
process-type,N Process type and number (e.g., poller,)
pid Process identifier, up to . For larger
values specify target as "process-type,N" -h --help Display this help message
-V --version Display version number Some configuration parameter default locations:
AlertScriptsPath "/yinzhengjie/softwares/zabbix/share/zabbix/alertscripts"
ExternalScripts "/yinzhengjie/softwares/zabbix/share/zabbix/externalscripts"
SSLCertLocation "/yinzhengjie/softwares/zabbix/share/zabbix/ssl/certs"
SSLKeyLocation "/yinzhengjie/softwares/zabbix/share/zabbix/ssl/keys"
LoadModulePath "/yinzhengjie/softwares/zabbix/lib/modules" Report bugs to: <https://support.zabbix.com>
Zabbix home page: <http://www.zabbix.com>
Documentation: <https://www.zabbix.com/documentation>
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# /yinzhengjie/softwares/zabbix/sbin/zabbix_server -h

[root@zabbix203.yinzhengjie.org.cn ~]# /yinzhengjie/softwares/zabbix/sbin/zabbix_server -c /yinzhengjie/softwares/zabbix/etc/zabbix_server.conf

使用Ubuntu系统编译安装Zabbix企业级监控系统

五.配置zabbix web

1>.安装apache及php环境

[root@zabbix203.yinzhengjie.org.cn ~]# apt -y install apache2 apache2-bin apache2-data apache2-utils fontconfig-config fonts-dejavu-core fping javascript-common libapache2-mod-php7. libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libblas3 libfontconfig1 libgd3 libiksemel3 libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs-jquery-ui libjs-prototype liblinear3 libltdl7 liblua5.- liblua5.- libodbc1 libopenipmi0 libpq5 libsensors4 libsnmp-base libsnmp30 libsodium23 libssh2- libtiff5 libwebp6 libxpm4 nmap php php-bcmath php-common php-gd php-ldap php-mbstring php-pgsql php-xml php7. php7.-bcmath php7.-cli php7.-common php7.-gd php7.-json php7.-ldap php7.-mbstring php7.-opcache php7.-pgsql php7.-readline php7.-xml snmpd ssl-cert traceroute ttf-dejavu-core 

使用Ubuntu系统编译安装Zabbix企业级监控系统

2>.将前端的PHP代码拷贝到apache的根目录(当然,你也可以在根目录下创建一个"zabbix"目录,并将代码放在里面)

使用Ubuntu系统编译安装Zabbix企业级监控系统

3>.访问zabbix web界面(http://zabbix203.yinzhengjie.org.cn/setup.php)

使用Ubuntu系统编译安装Zabbix企业级监控系统

4>.如果不修改php的默认配置文件,则会检测参数异常,如下图所示

使用Ubuntu系统编译安装Zabbix企业级监控系统

5>.修改php的配置文件并重启web服务器使得配置生效

[root@zabbix203.yinzhengjie.org.cn ~]# find / -name php.ini
/etc/php/7.2/cli/php.ini
/etc/php/7.2/apache2/php.ini
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# cp /etc/php/7.2/apache2/php.ini /etc/php/7.2/apache2/php.ini-`date +%F`          #修改前记得备份配置文件哈~
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# grep post_max_size /etc/php/7.2/apache2/php.ini
post_max_size = 8M
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's#(post_max_size =) 8#\1 16#' /etc/php/7.2/apache2/php.ini
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# grep post_max_size /etc/php/7.2/apache2/php.ini
post_max_size = 16M
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's#(post_max_size =) 8#\1 16#' /etc/php/7.2/apache2/php.ini

[root@zabbix203.yinzhengjie.org.cn ~]# grep max_execution_time /etc/php/7.2/apache2/php.ini
max_execution_time =
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's#(max_execution_time =) 30#\1 300#' /etc/php/7.2/apache2/php.ini
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# grep max_execution_time /etc/php/7.2/apache2/php.ini
max_execution_time =
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's#(max_execution_time =) 30#\1 300#' /etc/php/7.2/apache2/php.ini

[root@zabbix203.yinzhengjie.org.cn ~]# grep "max_input_time =" /etc/php/7.2/apache2/php.ini
max_input_time =
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's#(max_input_time =) 60#\1 300#' /etc/php/7.2/apache2/php.ini
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# grep "max_input_time =" /etc/php/7.2/apache2/php.ini
max_input_time =
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's#(max_input_time =) 60#\1 300#' /etc/php/7.2/apache2/php.ini

[root@zabbix203.yinzhengjie.org.cn ~]# grep "date.timezone =" /etc/php/7.2/apache2/php.ini
;date.timezone =
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's#;(date.timezone =)#\1 Asia/Shanghai#' /etc/php/7.2/apache2/php.ini
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# grep "date.timezone =" /etc/php/7.2/apache2/php.ini
date.timezone = Asia/Shanghai
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's#;(date.timezone =)#\1 Asia/Shanghai#' /etc/php/7.2/apache2/php.ini

使用Ubuntu系统编译安装Zabbix企业级监控系统

6>.配置数据库信息

  如果没有安装mysql驱动的话,默认是不支持MySQL数据库类型的,如下图所示。

使用Ubuntu系统编译安装Zabbix企业级监控系统

[root@zabbix203.yinzhengjie.org.cn ~]# apt -y install  php-gettext php-xml php-net-socket php-gd php-mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
php-gd is already the newest version (:7.2+60ubuntu1).
php-xml is already the newest version (:7.2+60ubuntu1).
The following additional packages will be installed:
php-pear php-php-gettext php7.-mysql
The following NEW packages will be installed:
php-gettext php-mysql php-net-socket php-pear php-php-gettext php7.-mysql
upgraded, newly installed, to remove and not upgraded.
Need to get kB of archives.
After this operation, , kB of additional disk space will be used.
Get: http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 php-pear all 1:1.10.5+submodules+notgz-1ubuntu1.18.04.1 [284 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe amd64 php-php-gettext all 1.0.12-0.1 [16.2 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe amd64 php-gettext all 1.0.12-0.1 [1,508 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 php7.2-mysql amd64 7.2.24-0ubuntu0.18.04.2 [117 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 php-mysql all 1:7.2+60ubuntu1 [2,004 B]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe amd64 php-net-socket all 1.0.14-2 [10.2 kB]
Fetched kB in 1s ( kB/s)
Selecting previously unselected package php-pear.
(Reading database ... files and directories currently installed.)
Preparing to unpack .../-php-pear_1%3a1.10.5+submodules+notgz-1ubuntu1.18.04.1_all.deb ...
Unpacking php-pear (:1.10.+submodules+notgz-1ubuntu1.18.04.) ..........................................................................................................................................................................................................]
Selecting previously unselected package php-php-gettext...................................................................................................................................................................................................................]
Preparing to unpack .../-php-php-gettext_1.0.12-.1_all.deb ...
Unpacking php-php-gettext (1.0.-0.1) ...########........................................................................................................................................................................................................................]
Selecting previously unselected package php-gettext.##############........................................................................................................................................................................................................]
Preparing to unpack .../-php-gettext_1.0.12-.1_all.deb ...
Unpacking php-gettext (1.0.-0.1) ...####################################................................................................................................................................................................................................]
Selecting previously unselected package php7.-mysql.#####################################................................................................................................................................................................................]
Preparing to unpack .../-php7.-mysql_7.2.24-0ubuntu0.18.04.2_amd64.deb ...
Unpacking php7.-mysql (7.2.-0ubuntu0.18.04.) ...##############################################........................................................................................................................................................................]
Selecting previously unselected package php-mysql.################################################################........................................................................................................................................................]
Preparing to unpack .../-php-mysql_1%3a7.+60ubuntu1_all.deb ...
Unpacking php-mysql (:7.2+60ubuntu1) ...#################################################################################................................................................................................................................................]
Selecting previously unselected package php-net-socket.###################################################################################................................................................................................................................]
Preparing to unpack .../-php-net-socket_1.0.14-2_all.deb ...
Unpacking php-net-socket (1.0.-) ...###########################################################################################################........................................................................................................................]
Setting up php7.-mysql (7.2.-0ubuntu0.18.04.) ...#############################################################################################################........................................................................................................]
Progress: [ %] [########################################################################################################################################################................................................................................................]
Creating config file /etc/php/7.2/mods-available/mysqlnd.ini with new version Creating config file /etc/php/7.2/mods-available/mysqli.ini with new version Creating config file /etc/php/7.2/mods-available/pdo_mysql.ini with new version
Setting up php-net-socket (1.0.-) ...##########################################################################################################################################........................................................................................]
Setting up php-pear (:1.10.+submodules+notgz-1ubuntu1.18.04.) ...##############################################################################################################################........................................................................]
Processing triggers for man-db (2.8.-2ubuntu0.) ...#############################################################################################################################################################........................................................]
Processing triggers for libapache2-mod-php7. (7.2.-0ubuntu0.18.04.) ...
Setting up php-mysql (:7.2+60ubuntu1) ...
Setting up php-php-gettext (1.0.-0.1) ...#######################################################################################################################################################################################........................................]
Setting up php-gettext (1.0.-0.1) ...###########################################################################################################################################################################################################........................]
[root@zabbix203.yinzhengjie.org.cn ~]#

[root@zabbix203.yinzhengjie.org.cn ~]# apt -y install php-gettext php-xml php-net-socket php-gd php-mysql

[root@zabbix203.yinzhengjie.org.cn ~]# systemctl restart apache2            #安装上述的php相关程序包后,别忘记重启apache2服务哟~重启后刷新页面就可以选择MySQL类型了,填写对应的参数即可,如下图所示。

使用Ubuntu系统编译安装Zabbix企业级监控系统

7>.填写zabbix的信息

使用Ubuntu系统编译安装Zabbix企业级监控系统

8>.安装zabbix web前的最后确认

使用Ubuntu系统编译安装Zabbix企业级监控系统

9>.创建zabbix web的配置文件失败,我们需要手动上传

使用Ubuntu系统编译安装Zabbix企业级监控系统

10>.根据上一步的提示信息将文件下载后上传到服务器指定位置并修改相应的权限

[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]# cat zabbix.conf.php
<?php
// Zabbix GUI configuration file.
global $DB; $DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = '172.200.5.202';
$DB['PORT'] = '';
$DB['DATABASE'] = 'zabbix_server';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'yinzhengjie'; // Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = 'za'; $ZBX_SERVER = '172.200.5.203';
$ZBX_SERVER_PORT = '';
$ZBX_SERVER_NAME = 'Yinzhengjie\'s Zabbix Server'; $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]#

[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]# cat zabbix.conf.php

[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]# ll
total
drwxr-xr-x zabbix zabbix Feb : ./
drwxr-xr-x root root Feb : ../
-rw-r--r-- zabbix zabbix Jan : .htaccess
-rw-r--r-- zabbix zabbix Jan : maintenance.inc.php
-rw-r--r-- root root Feb : zabbix.conf.php
-rw-r--r-- zabbix zabbix Jan : zabbix.conf.php.example
[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]#
[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]# cat zabbix.conf.php
<?php
// Zabbix GUI configuration file.
global $DB; $DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = '172.200.5.202';
$DB['PORT'] = '';
$DB['DATABASE'] = 'zabbix_server';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'yinzhengjie'; // Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = 'za'; $ZBX_SERVER = '172.200.5.203';
$ZBX_SERVER_PORT = '';
$ZBX_SERVER_NAME = 'Yinzhengjie\'s Zabbix Server'; $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]#
[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]# chown zabbix:zabbix zabbix.conf.php
[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]#
[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]#
[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]# ll
total
drwxr-xr-x zabbix zabbix Feb : ./
drwxr-xr-x root root Feb : ../
-rw-r--r-- zabbix zabbix Jan : .htaccess
-rw-r--r-- zabbix zabbix Jan : maintenance.inc.php
-rw-r--r-- zabbix zabbix Feb : zabbix.conf.php
-rw-r--r-- zabbix zabbix Jan : zabbix.conf.php.example
[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]#
[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]#

[root@zabbix203.yinzhengjie.org.cn /var/www/html/conf]# chown zabbix:zabbix zabbix.conf.php

使用Ubuntu系统编译安装Zabbix企业级监控系统

11>.zabbix前端安装完成

使用Ubuntu系统编译安装Zabbix企业级监控系统

12>.登录zabbix的WebUI页面

使用Ubuntu系统编译安装Zabbix企业级监控系统

13>.配置zabbix web对中文支持

  博主推荐阅读:
    https://www.cnblogs.com/yinzhengjie2020/p/12305904.html

使用Ubuntu系统编译安装Zabbix企业级监控系统

 14>.解决中文乱码问题

[root@zabbix203.yinzhengjie.org.cn ~]# ll /var/www/html/assets/fonts/
total
drwxr-xr-x zabbix zabbix Jan : ./
drwxr-xr-x zabbix zabbix Jan : ../
-rw-r--r-- zabbix zabbix Jan : DejaVuSans.ttf
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# cd /var/www/html/assets/fonts/
[root@zabbix203.yinzhengjie.org.cn /var/www/html/assets/fonts]#
[root@zabbix203.yinzhengjie.org.cn /var/www/html/assets/fonts]# rz [root@zabbix203.yinzhengjie.org.cn /var/www/html/assets/fonts]#
[root@zabbix203.yinzhengjie.org.cn /var/www/html/assets/fonts]# ll
total
drwxr-xr-x zabbix zabbix Feb : ./
drwxr-xr-x zabbix zabbix Jan : ../
-rw-r--r-- zabbix zabbix Jan : DejaVuSans.ttf
-rw-r--r-- root root Mar simkai.ttf
[root@zabbix203.yinzhengjie.org.cn /var/www/html/assets/fonts]#
[root@zabbix203.yinzhengjie.org.cn /var/www/html/assets/fonts]# cd
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# grep -i DejaVuSans /var/www/html/include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans'); // font file name
define('ZBX_FONT_NAME', 'DejaVuSans');
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's#DejaVuSans#simkai#' /var/www/html/include/defines.inc.php
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# grep -i simkai /var/www/html/include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME', 'simkai'); // font file name
define('ZBX_FONT_NAME', 'simkai');
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#

使用Ubuntu系统编译安装Zabbix企业级监控系统

六.启动zabbix agent服务

1>.查看zabbix的主界面

使用Ubuntu系统编译安装Zabbix企业级监控系统

2>.点击"配置" ---> "主机",查看主机的状态

使用Ubuntu系统编译安装Zabbix企业级监控系统

3>.手动启动zabbix agent

使用Ubuntu系统编译安装Zabbix企业级监控系统

4>.再次查看zabbix WebUI

使用Ubuntu系统编译安装Zabbix企业级监控系统

5>.查看zabbix的主界面

使用Ubuntu系统编译安装Zabbix企业级监控系统

6>.编写zabbix的启动管理脚本

  博主推荐阅读:
    https://www.cnblogs.com/yinzhengjie2020/p/12306215.html
上一篇:Zabbix监控平台搭建部署与概述


下一篇:zabbix分布式监控的部署与win被控端