编译安装Zabbix 5.0 LTS

编译安装Zabbix 5.0 LTS

编译安装Zabbix 5.0 LTSZ0UKUN编译安装ZABBIX 5.0 LTS有4条评论

文章目录 [点击隐藏]

Zabbix 5.0 LTS新增功能

新版本附带了可用性,安全性和完整性方面的重大改进列表。Zabbix团队遵循的主要策略是使Zabbix尽可能可用。Zabbix是一种开源,免费的监视解决方案,现在可以在内部和云中部署。在RedHat / IBM,SuSE,Ubuntu的最新版本的平台,容器和Linux发行版中可用。现在,一键式Zabbix部署也可以在Azure,AWS,Google Cloud,IBM / RedHat Cloud,Oracle和Digital Ocean上使用。现在,在Red Hat和Azure市场上提供Zabbix技术支持服务。

此外,Zabbix监视工具还提供了与Messenger,票务和警报系统的大量现成集成。新版本扩展了可以轻松监控的受支持服务和应用程序的列表。

满足一些新功能:

  • 自动化和发现:新的Zabbix版本具有改进的自动化功能。新版本增加了自动发现硬件组件,与Windows相关的资源以及Java度量的高级发现的功能。
  • 可扩展性:Zabbix UI已经过优化,可以简化对数百万个设备的监视。
  • 新的Zabbix监视代理程序具有“官方支持”状态。新的可扩展代理为最苛刻的客户和复杂的用例提供了高级功能。它基于插件体系结构,具有使用各种方法和技术收集度量标准数据的能力。我们相信它是市场上最先进的监控代理。
  • 安全性方面的重大改进:新的改进确保所有Zabbix组件以安全的方式进行通信,并且还使用安全协议进行出站通信,而不会以任何方式影响性能。对于在高度敏感的环境中使用Zabbix的用户而言,可配置的密码以及为度量定义黑名单和白名单的能力至关重要。
  • TimescaleDB的压缩:时间序列数据压缩有助于提高性能和效率,同时降低运营成本。
  • 可用性改进:新版本针对宽屏进行了优化,除了Zabbix UI的其他增强功能之外,还引入了对第三方UI模块的支持。

Zabbix 5.0是具有5年官方支持的LTS(长期支持)版本。它结合了创新和稳定性,并包括经过时间检验的功能,这些功能已在Zabbix 4.2和4.4的非LTS版本中引入,这使其成为大型企业环境的理想选择。

注:Zabbix 5.0 版本对基础环境的要求有大的变化,最大的就是对 php 版本的要求,最低要求 7.2.0 版本,对 php 扩展组件版本也有要求,详见官网文档https://www.zabbix.com/documentation/current/manual/installation/requirements

系统初始化

# 配置主机名称
hostnamectl --static --transient  set-hostname ZabbixServer

# 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
iptables -F && iptables -X && iptables -F -t nat && iptables -X -t nat
iptables -P FORWARD ACCEPT

# 关闭swap分区
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

# 关闭SELinux
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config

# 配置时钟同步
# 配置时区
timedatectl set-timezone Asia/Shanghai
# 查看同步状态
timedatectl status
# 注:System clock synchronized: yes,表示时钟已同步; NTP service: active,表示开启了时钟同步服务。

# 将当前的 UTC 时间写入硬件时钟
timedatectl set-local-rtc 0

# 重启依赖于系统时间的服务
systemctl restart rsyslog 
systemctl restart crond

# 关闭无关服务
systemctl stop postfix && systemctl disable postfix

# 重启主机
sync
reboot
Bash

编译安装LNMP

编译安装Nginx v1.18.0

Nginx官方网站:http://nginx.org/en/download.html

Nginx v1.18.0下载地址:http://nginx.org/download/nginx-1.18.0.tar.gz

我们直接去上面的地址下载 Nginx v1.18.0 版本、下载完成以后采用下面的命令解压并编译安装Nginx:

# 下载Nginx
wget http://nginx.org/download/nginx-1.18.0.tar.gz

# 解压Nginx
tar -zxvf nginx-1.18.0.tar.gz

# 编译安装Nginx
cd nginx-1.18.0
mkdir -p /usr/local/nginx/
./configure --prefix=/usr/local/nginx/ --without-http_rewrite_module --without-http_gzip_module --with-pcre && make && make install
Bash

注:如果需要安装特定模块也可以自行添加、Nginx支持模块详情可以查看Nginx官方文档:http://nginx.org/en/docs/

然后我们将Nginx注册为Centos7系统服务,将下面的内容插入到 /etc/init.d/nginx 文件中:

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig:   - 85 15
# description:  NGINX is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /usr/local/nginx/conf/nginx.conf
# pidfile:     /usr/local/nginx/logs/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
# :set ff=unix

# 修改为实际配置文件目录
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
# 修改为实际配置文件目录
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx

make_dirs() {
   # make required directories
   user=`$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
   if [ -n "$user" ]; then
      if [ -z "`grep $user /etc/passwd`" ]; then
         useradd -M -s /bin/nologin $user
      fi
      options=`$nginx -V 2>&1 | grep 'configure arguments:'`
      for opt in $options; do
          if [ `echo $opt | grep '.*-temp-path'` ]; then
              value=`echo $opt | cut -d "=" -f 2`
              if [ ! -d "$value" ]; then
                  # echo "creating" $value
                  mkdir -p $value && chown -R $user $value
              fi
          fi
       done
    fi
}

start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    make_dirs
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
} 

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
} 

restart() {
    configtest || return $?
    stop
    sleep 1
    start
}

reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $prog -HUP
    retval=$?
    echo
} 

force_reload() {
    restart
}

configtest() {
   nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
    status $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo  "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac
Bash

注:上面那个文件里面要修改的地方有,这两处改为自己的nginx 安装位置。保存一定要保存成UNIX格式(notepad++:编辑–文档格式转换–转为UNIX格式),否则会报错的。

然后我们就可以把Nginx注册成服务并设置为开机自动启动了:

# 设置执行权限
chmod +x /etc/init.d/nginx

# 注册成服务
chkconfig --add nginx

# 设置开机启动
chkconfig nginx on

# 然后我们就可以使用下面的命令来管理nginx(使用下面的命令之前先执行/usr/local/nginx/sbin/nginx)
systemctl status nginx
systemctl start nginx
systemctl stop nginx
Bash

然后我们在浏览器中输入主机IP地址就可以看到久违的页面啦。

编译安装PHP v7.2.25

在编译安装PHP之前、我们需要准备安装环境:

# 下载安装编译工具
yum groupinstall 'Development Tools'

# 安装依赖包
yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel
Bash

PHP官方网站:https://www.php.net/

PHP v7.2.25下载地址:https://www.php.net/distributions/php-7.2.25.tar.gz

下载完成以后我们同样采用下面的命令解压并编译安装PHP:

# 下载PHP
wget https://www.php.net/distributions/php-7.2.25.tar.gz

# 解压PHP
tar -zxvf php-7.2.25.tar.gz

# 在编译钱我们需要新增用户组和用户用于编译使用
groupadd www useradd -g www www
useradd www
# 编译PHP(具体模块根据自己情况自行增减)
cd php-7.2.25
./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-fpm-user=www --with-fpm-group=www --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm

# 编译没有问题,我们就可以直接安装PHP了
make && make install
Bash

注:在PHP 7.4版本中编译参数 –with-gd 改成了 –enable-gd

安装完成以后我们就可以来配置PHP的环境变量并把PHP添加到系统服务中:

# 验证PHP版本
/usr/local/php/bin/php -v

# 添加环境变量,把下面的的命令添加到/etc/profile文件的最后
PATH=$PATH:/usr/local/php/bin export PATH
# 更新环境变量
source /etc/profile

# 查看PHP版本
php -v

# 配置PHP-FPM
cd php-7.2.25
cp php.ini-production /etc/php.ini 
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf 
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf 
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 
chmod +x /etc/init.d/php-fpm

# 启动PHP-FPM
/etc/init.d/php-fpm start
注:然后我们就可以通过systemctl命令来管理PHP啦!
Bash

Nginx和PHP都编译安装完成以后、我们需要把Nginx和PHP集成起来;这里我们需要去修改Nginx的配置文件、让Nginx支持PHP,我们去/usr/local/nginx/conf下面修改nginx.conf文件:

[root@localhost conf]# grep -v "#" nginx.conf
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;
        # 添加index.php
        location / {
            root   html;
            index  index.php index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        # 放开有关php的location注释
        location ~ \.php{
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            # 修改路径
            fastcgi_param  SCRIPT_FILENAMEdocument_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}
[root@localhost conf]# 
Bash

修改完成以后我们重启Nginx和PHP并到/usr/local/nginx/html目录下面新建index.php文件并插入下面的内容:

# 重启Nginx
systemctl restart nginx

# 重启PHP
systemctl restart php-fpm
Bash

然后我们刷新浏览器页面,可以得到下面的页面就代表Nginx和PHP已经集成成功了:

编译安装Zabbix 5.0 LTS

安装MySQL 5.6

Nginx和PHP编译安装完成以后我们开始部署数据库;下午我们就可以来安装MySQL数据库了。这里我们安装MySQL5.6.48版本:

MySQL官方网站:https://www.mysql.com/

MySQL 5.6下载地址:https://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.48-1.el7.x86_64.rpm-bundle.tar

这里我们离线安装的方式安装MySQL5.6.48:

# 下载MySQL
wget https://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.48-1.el7.x86_64.rpm-bundle.tar

# 解压MySQL
tar -xf MySQL-5.6.48-1.el7.x86_64.rpm-bundle.tar

# 安装之前需要把系统自带的Mariadb卸载
[root@ZabbixServer ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.64-1.el7.x86_64
[root@ZabbixServer ~]# yum remove mariadb-libs-5.5.64-1.el7.x86_64 -y

# 创建mysql用户组和用户
groupadd mysql && useradd mysql
# 安装MySQL
rpm -ivh MySQL-server-5.6.48-1.el7.x86_64.rpm
rpm -ivh MySQL-client-5.6.48-1.el7.x86_64.rpm
rpm -ivh MySQL-devel-5.6.48-1.el7.x86_64.rpm
rpm -ivh MySQL-embedded-5.6.48-1.el7.x86_64.rpm
rpm -ivh MySQL-shared-5.6.48-1.el7.x86_64.rpm
rpm -ivh MySQL-shared-compat-5.6.48-1.el7.x86_64.rpm

# 验证MySQL是否安装成功
rpm  -qa | grep  MySQL
Bash

安装完成以后MySQL会把默认生成的密码放在 /root/.mysql_secret ,我们可以直接查看该文件并用该密码登录到MySQL数据中;在登录之前我们需要先启动MYSQL数据库:

# 启动MySQL数据库并添加到开机启动项
systemctl start mysql
systemctl enable mysql

# 获取MySQL随机密码
[root@ZabbixServer zabbix-5.0.0]# cat /root/.mysql_secret 
# The random password set for the root user at Mon Jun  8 17:02:46 2020 (local time): aFj3rwYAdEsLQUSN

[root@ZabbixServer zabbix-5.0.0]# 

# 初始化MySQL数据库
[root@ZabbixServer]# mysql_secure_installation

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

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, 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 MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL 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] 
 ... 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] 
 ... Success!

By default, MySQL 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] 
 - 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] 
 ... Success!

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

Thanks for using MySQL!

Cleaning up...
[root@ZabbixServer]# 

# 授权远程访问
[root@ZabbixServer]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.6.48 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# root是登陆数据库的用户,123456是登陆数据库的密码,*就是意味着任何来源任何主机。
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;      
Query OK, 0 rows affected (0.01 sec)

# 刷新生效
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> 
mysql> quit
Bye
[root@ZabbixServer]# 
Bash

然后我们用Navicat Premium看看能否正常连接数据库,如果可以正常连接、就代表数据库已经基本配置完成。

编译安装Zabbix 5.0 LTS

到这里、LNMP基本环境就已经配置完成了;下面我们开始安装Zabbix 5.0 LTS。

安装zabbix

Zabbix官方网站:https://www.zabbix.com/cn/

Zabbix 5.0 下载地址:https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.0.tar.gz

在安装Zabbix 5.0之前我们先把相关依赖包安装好,直接执行下面的命令即可:

yum install gcc gcc-c++ make unixODBC-devel net-snmp-devel libssh2-devel OpenIPMI-devel libevent-devel pcre-devel libcurl-devel curl-* net-snmp* libxml2-* wget tar -y
Bash

然后我们开始安装Zabbix5.0:

# 下载zabbix 5.0
wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.0.tar.gz

# 解压Zabbix
tar -zxvf zabbix-5.0.0.tar.gz
# 配置Zabbix
mkdir -p /usr/local/zabbix
cd zabbix-5.0.0
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

# 编译并安装Zabbix
make && make install
Bash

zabbix编译安装完成以后我们需要创建zabbix所需的用户和组:

groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
Bash

然后我们再次回到zabbix解压目录、复制启动脚本到 /etc/init.d/ 目录并对文件授权:

cd zabbix-5.0.0
cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
ll -d /etc/init.d/zabbix_*
chmod +x /etc/init.d/zabbix_*
Bash

创建zabbix数据库并依次导入数据文件:

# 进入MySQL Cli交互式命令行
mysql -u root -p

# 创建数据库并授权访问
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
grant all privileges on zabbix.* to zabbix@127.0.0.1 identified by '123456';
GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;

# 导入相关数据(切记导入顺序)
[root@ZabbixServer mysql]# mysql -u zabbix -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.6.48 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> source /root/zabbix-5.0.0/database/mysql/schema.sql  //表结构
mysql> source /root/zabbix-5.0.0/database/mysql/image.sql  //图片相关数据
mysql> source /root/zabbix-5.0.0/database/mysql/data.sql  //模版相关数据
Bash

配置zabbix_server.conf相关参数:

[root@ZabbixServer zabbix-5.0.0]# grep -v "#" /usr/local/zabbix/etc/zabbix_server.conf 
LogFile=/var/log/zabbix/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBSocket=/var/lib/mysql/mysql.sock
DBPort=3306
StartPollers=100
StartTrappers=10
StartPingers=10
StartDiscoverers=10
Timeout=4
LogSlowQueries=3000
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
StatsAllowedIP=127.0.0.1
[root@ZabbixServer zabbix-5.0.0]# 
Bash

配置zabbix_agent.conf相关参数:

[root@ZabbixServer zabbix-5.0.0]# grep -v "#" /usr/local/zabbix/etc/zabbix_agentd.conf
PidFile=/tmp/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agent.log
LogFile=/tmp/zabbix_agentd.log
DenyKey=system.run[*]
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
UnsafeUserParameters=1
[root@ZabbixServer zabbix-5.0.0]#  
Bash

上面我们创建日志文件目录,这里必须要对日志文件目录进行授权,否则在启动zabbix的时候会报错的:

chown -R zabbix:zabbix /var/log/zabbix
Bash

注:这里需要特别说明:一定要对日志文件目录授权、不然会报错的。

配置zabbix server启动文件 vi /lib/systemd/system/zabbix-server.service :

[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
After=mysql.service
After=mysqld.service
After=mariadb.service
After=postgresql.service

[Service]
Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_server.conf"
EnvironmentFile=-/etc/sysconfig/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/tmp/zabbix_server.pid
KillMode=control-group
ExecStart=/usr/local/zabbix/sbin/zabbix_server -c CONFFILE
ExecStop=/bin/kill -SIGTERMMAINPID
RestartSec=10s
TimeoutSec=0

[Install]
WantedBy=multi-user.target
Bash

配置 zabbix agent 启动文件 vi /lib/systemd/system/zabbix-agent.service :

[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target

[Service]
Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_agentd.conf"
EnvironmentFile=-/etc/sysconfig/zabbix-agent
Type=forking
Restart=on-failure
PIDFile=/tmp/zabbix_agentd.pid
KillMode=control-group
ExecStart=/usr/local/zabbix/sbin/zabbix_agentd -c CONFFILE
ExecStop=/bin/kill -SIGTERMMAINPID
RestartSec=10s
User=zabbix
Group=zabbix

[Install]
WantedBy=multi-user.target
Bash

启动zabbix server和zabbix agent并添加到系统启动项:

systemctl enable --now zabbix-server
systemctl enable --now zabbix-agent
Bash

启动完成以后我们可以通过netstat -nltp命令验证一下zabbix服务端口是否监听成功:

[root@ZabbixServer zabbix-5.0.0]# systemctl enable --now zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@ZabbixServer zabbix-5.0.0]# systemctl enable --now zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@ZabbixServer zabbix-5.0.0]# netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      873/zabbix_agentd   
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      536/zabbix_server   
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      4267/php-fpm: maste 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      4215/nginx: master  
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1110/sshd           
tcp6       0      0 :::10050                :::*                    LISTEN      873/zabbix_agentd   
tcp6       0      0 :::10051                :::*                    LISTEN      536/zabbix_server   
tcp6       0      0 :::3306                 :::*                    LISTEN      20496/mysqld        
tcp6       0      0 :::22                   :::*                    LISTEN      1110/sshd           
[root@ZabbixServer zabbix-5.0.0]# 
Bash

然后我们拷贝前端文件目录到Nginx服务目录:

cp -r /root/zabbix-5.0.0/ui/* /var/www/html/
chown -R www:www /var/www/html/
Bash

我们把前端文件拷贝到Nginx运行目录之后,就可以通过浏览器来设置前端的配置信息了;依次点击下一步完成配置即可,这里需要注意的是,我们还需要去配置PHP的环境参数以适配Zabbix:

# vi /etc/php.ini 修改内容如下
max_execution_time = 300
max_input_time = 300
post_max_size = 16M
date.timezone = Asia/Shanghai
pdo_mysql.default_socket=/var/lib/mysql/mysql.sock
mysqli.default_socket =/var/lib/mysql/mysql.sock

# 修改完成以后重启PHP
systemctl restart php-fpm
Bash

编译安装Zabbix 5.0 LTS
编译安装Zabbix 5.0 LTS
编译安装Zabbix 5.0 LTS
编译安装Zabbix 5.0 LTS
编译安装Zabbix 5.0 LTS
编译安装Zabbix 5.0 LTS
编译安装Zabbix 5.0 LTS

好了、现在我们已经成功进入Zabbix管理页面;从上图可以看到Zabbix Server和Zabbix Agent已经成功启动;到这里,我们就已经完成了Zabbix 5.0 LTS的编译安装;感兴趣的小伙伴赶紧去试试吧。

上一篇:UBUNTU 16.04 LTS SERVER 手动升级 MariaDB 到最新版 10.2


下一篇:Ubuntu 18.04 LTS 搜狗输入法出现中文乱码,英文-无乱码-英文-乱码交替出现解决方案