老男孩 安装php5.5,Zabbix 5.0全网监控搭建(LNMP版本)

centos7基于lnmp架构安装zabbix 5.0

zabbix 5.0 版本于2020年 5 月 11 日正式发布,是最新的 LTS(长期支持)版本,5.0 带来很多功能和特性,接下来,我们先把它部署上

1.环境要求

一个软件刚刚更新发布新版本没多久,这时候不要去百度搜索什么的,资料很少的,我们直接去看官方文档,你想要的官方文档里都有,我们先看看官方文档上 zabbix 5.0的安装要求

REQUIRED SOFTWARE

Zabbix is built around modern web servers, leading database engines, and PHP scripting language.

DATABASE MANAGEMENT SYSTEM

Software

Version

Comments

MySQL

5.5.62 - 8.0.x

Required if MySQL is used as Zabbix backend database. InnoDB engine is required. MariaDB (10.0.37 or later) also works with Zabbix. We recommend using the MariaDB Connector/C library for building server/proxy regardless of whether you use a MySQL or MariaDB database server.

Oracle

11.2 or later

Required if Oracle is used as Zabbix backend database.

PostgreSQL

9.2.24 or later

Required if PostgreSQL is used as Zabbix backend database. It is suggested to use at least PostgreSQL 8.3, which introduced much better VACUUM performance.

TimescaleDB

1.0 or later, OSS (free) version

Required if TimescaleDB is used as Zabbix backend database.

SQLite

3.3.5 or later

SQLite is only supported with Zabbix proxies. Required if SQLite is used as Zabbix proxy database.

FRONTEND

The minimum supported screen width for Zabbix frontend is 1200px.

Software

Version

Comments

Apache

1.3.12 or later

PHP

7.2.0 or later

PHP extensions:

gd

2.0.28 or later

PHP GD extension must support PNG images (--with-png-dir), JPEG (--with-jpeg-dir) images and FreeType 2 (--with-freetype-dir).

bcmath

php-bcmath (--enable-bcmath)

ctype

php-ctype (--enable-ctype)

libXML

2.6.15 or later

php-xml, if provided as a separate package by the distributor.

xmlreader

php-xmlreader, if provided as a separate package by the distributor.

xmlwriter

php-xmlwriter, if provided as a separate package by the distributor.

session

php-session, if provided as a separate package by the distributor.

sockets

php-net-socket (--enable-sockets). Required for user script support.

mbstring

php-mbstring (--enable-mbstring)

gettext

php-gettext (--with-gettext). Required for translations to work.

ldap

php-ldap. Required only if LDAP authentication is used in the frontend.

openssl

php-openssl. Required only if SAML authentication is used in the frontend.

mysqli

Required if MySQL is used as Zabbix backend database.

oci8

Required if Oracle is used as Zabbix backend database.

pgsql

Required if PostgreSQL is used as Zabbix backend database.

注意:以上内容来自于zabbix官方文档

从这段资料中可以看出,zabbix 5.0最大的变化,就是php版本要求 7.2以上,而centos7的默认源php版本是5.4,所以这里我们就要使用第三方php的yum源了

2:安装php 7.2以及zabbix 所需的php扩展模块

安装php第三方源

yum install epel-release.noarch -y

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装nginx、php7.2和所需php扩展模块

yum install nginx php72w-cli php72w-fpm php72w-common php72w-mysqlnd php72w-mbstring php72w-gd php72w-bcmath php72w-ldap php72w-xml -y

注意:webtatic源在国外,容易失败

修改php的配置文件

vim /etc/php-fpm.d/www.conf

user = apache

group = apache

修改为

user = nginx

group = nginx

修改nginx的配置文件

vim /etc/nginx/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;

location / {

root /html;

index index.php index.html index.htm;

}

location ~ \.php$ {

root /html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /html$fastcgi_script_name;

include fastcgi_params;

}

}

}

启动nginx和php-fpm

systemctl start nginx

systemctl enable nginx

systemctl start php-fpm

systemctl enable php-fpm

3:安装zabbix-web

cd /opt/

#下载源码包

wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.4.tar.gz

tar xf zabbix-5.0.4.tar.gz

mkdir /html

#拷贝zabbix-web到站点目录

cp -a zabbix-5.0.4/ui/* /html

#修改站点目录属主和属组

chown -R nginx:nginx /html

使用浏览器访问http://

c78757c75c1fa0a47d6a1fdcc892b788.png

发现页面打不开,不要慌,我们看下日志

[root@zabbix-5 opt]# cat /var/log/nginx/error.log

2020/10/08 10:29:01 [error] 12403#0: *1 FastCGI sent in stderr: "PHP message: PHP Warning: session_start(): open(/var/lib/php/session/sess_f8b4d79c68b0ec44a225bd3419783d60, O_RDWR) failed: No such file or directory (2) in /html/include/classes/core/CSession.php on line 45

PHP message: PHP Warning: session_start(): Failed to read session data: files (path: /var/lib/php/session) in /html/include/classes/core/CSession.php on line 45

PHP message: PHP Fatal error: Uncaught Exception: Cannot start session. in /html/include/classes/core/CSession.php:46

Stack trace:

#0 /html/setup.php(66): CSession::start()

#1 {main}

thrown in /html/include/classes/core/CSession.php on line 46" while reading response header from upstream, client: 192.168.2.8, server: localhost, request: "GET /setup.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.2.121"

从这段日志分析来看,php执行函数session_start出错,原因是没有目录/var/lib/php/session

[root@zabbix-5 opt]# ls /var/lib/php/session

ls: cannot access /var/lib/php/session: No such file or directory

#这里可以发现,确实没有这个目录

解决方法:

mkdir /var/lib/php/session

chown -R nginx:nginx /var/lib/php/session

再次刷新浏览器,问题解决

a6e223be75c63cc2dd26d6d13d813701.png

接下来,点击Next step

ad5ed1733a6831c0d0a493f89489cf12.png

这里有几个警告,我们处理下

vim /etc/php.ini

post_max_size = 8M

修改为

post_max_size = 16M

max_execution_time = 30

修改为

max_execution_time = 300

max_input_time = 60

修改为

max_input_time = 300

;date.timezone =

去掉注释,并修改为

date.timezone = Asia/Shanghai

#重启php-fpm,并刷新浏览器

systemctl restart php-fpm.service

2f3cdd534cec9b6fec9a5719329ff93a.png

干干净净,这下舒服了

继续点击Next step

548b23ce2958d327bc6f72e5c063db28.png

到这里,我们先等一等,先安装下数据库和zabbix-server

4:安装zabbix-server

安装数据库

yum install mariadb-server.x86_64 -y

systemctl start mariadb.service

systemctl enable mariadb.service

#建议执行下mysql_secure_installation

#为zabbix创库授权

[root@zabbix-5 opt]# mysql -uroot -p

Enter password:

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by '123456';

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit

安装zabbix-server

rpm -ivh https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

yum install zabbix-server-mysql -y

#导入zabbix初始数据文件

zcat /usr/share/doc/zabbix-server-mysql-*/create.sql.gz |mysql -uzabbix -p123456 zabbix

修改zabbix-server配置

vim /etc/zabbix/zabbix_server.conf

#配置下数据库的连接信息

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=123456

启动zabbix-server

systemctl start zabbix-server.service

systemctl enable zabbix-server.service

#检查zabbix-server启动情况

[root@zabbix-5 opt]# netstat -lntup|grep 10051

tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 13190/zabbix_server

tcp6 0 0 :::10051 :::* LISTEN 13190/zabbix_server

5:最后的安装

继续访问浏览器

6e225fb6b598dd3387a524a88b5e46d0.png

下一步

55b085e45c7133add9fb6a018bc07fbe.png

继续下一步

692d75b57e67207e78149f69db592df0.png

继续下一步

2c992f392f80d91f0a15dfb6fe704d7a.png

点击完成,会自动跳转到登陆页面

c785c2146533926b68291fab15e0f5a2.png

初始的用户是Admin,密码zabbix(注意大小写)

登录成功之后的页面

b608d575d469ab8306a27134a8ba6625.png

这个web界面和之前的版本变化很大

关于zabbix 5.0的其他使用技巧,后续再更新

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以使用 Zabbix 5.0 进行虚拟机(VM)的监控。首先,确保你已经安装Zabbix 服务器和代理程序。然后,按照以下步骤进行配置: 1. 在 Zabbix 管理界面中,创建一个新的主机,该主机代表你要监控的虚拟机。提供主机的名称、IP 地址和所属的组。 2. 在主机配置页面的“Templates”选项卡中,添加一个适合的模板,如 "Template Virtual Machine"。这个模板包含了一些默认的监控项和触发器,用于监控虚拟机的状态和性能。 3. 在主机配置页面的“Applications”选项卡中,添加一个新的应用程序,用于管理与虚拟机相关的监控项和触发器。你可以将其命名为 "Virtual Machine Monitoring" 或类似的名称。 4. 在应用程序配置页面的“Items”选项卡中,添加需要监控的项。例如,你可以监控虚拟机的 CPU 使用率、内存使用率、磁盘空间等。选择适当的监控项类型,并设置相应的键值和触发器条件。 5. 在触发器配置页面中,定义当监控项达到特定阈值时触发的报警条件。例如,当 CPU 使用率超过 80% 或内存使用率超过 90% 时,触发警报。 6. 保存配置并等待 Zabbix 服务器和代理程序收集数据。你将能够在 Zabbix 界面上查看虚拟机的监控数据,并收到相关的警报通知。 请注意,以上步骤只是一个基本的指引,实际配置可能会因你的环境和需求而有所不同。你可以根据具体情况进行调整和扩展。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值