30.zabbix5.0搭建

zabbix5.0搭建

zabbix 5.0 版本于 2020 年 5 月 11 日正式发布,是最新的 LTS(长期支持)版本,5.0 带来很多功能和特性

SoftwareVersionComments
Apache1.3.12 or later
PHP7.2.0 or later
PHP extensions:
gd2.0.28 or laterPHP GD extension must support PNG images (–with-png-dir), JPEG (–with-jpeg-dir) images and FreeType 2 (–with-freetype-dir).
bcmathphp-bcmath (–enable-bcmath)
ctypephp-ctype (–enable-ctype)
libXML2.6.15 or laterphp-xml, if provided as a separate package by the distributor.
xmlreaderphp-xmlreader, if provided as a separate package by the distributor.
xmlwriterphp-xmlwriter, if provided as a separate package by the distributor.
sessionphp-session, if provided as a separate package by the distributor.
socketsphp-net-socket (–enable-sockets). Required for user script support.
mbstringphp-mbstring (–enable-mbstring)
gettextphp-gettext (–with-gettext). Required for translations to work.
ldapphp-ldap. Required only if LDAP authentication is used in the frontend.
opensslphp-openssl. Required only if SAML authentication is used in the frontend.
mysqliRequired if MySQL is used as Zabbix backend database.
oci8Required if Oracle is used as Zabbix backend database.
pgsqlRequired if PostgreSQL is used as Zabbix backend database.

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

1.安装 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 扩展模块
#安装nginx仓库源
vim /etc/yum.repos.d/nginx.repo 
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key

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   /home/zabbix;
            index  index.php index.html index.htm;
        }
        location ~ \.php$ {
            root           /home/zabbix;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /home/zabbix$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}
#启动 nginx 和 php-fpm
systemctl start nginx
systemctl enable nginx
systemctl start php-fpm
systemctl enable php-fpm

2.安装 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 /home/zabbix
#拷贝zabbix-web到站点目录
cp -a zabbix-5.0.4/ui/* /home/zabbix
#修改站点目录属主和属组
chown -R nginx:nginx /home/zabbix

在这里插入图片描述

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

[root@nacos opt]# tail -100f /var/log/nginx/error.log 
2020/10/23 09:39:42 [error] 6138#0: *1 FastCGI sent in stderr: "PHP message: PHP Warning:  session_start(): open(/var/lib/php/session/sess_1f917dbd048d410b869254e9597f4c68, O_RDWR) failed: No such file or directory (2) in /home/zabbix/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 /home/zabbix/include/classes/core/CSession.php on line 45
PHP message: PHP Fatal error:  Uncaught Exception: Cannot start session. in /home/zabbix/include/classes/core/CSession.php:46
Stack trace:
#0 /home/zabbix/setup.php(66): CSession::start()
#1 {main}
  thrown in /home/zabbix/include/classes/core/CSession.php on line 46" while reading response header from upstream, client: 192.168.34.19, server: localhost, request: "GET /setup.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.10.62"

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

[root@nacos opt]# ll /var/lib/php/session
ls: cannot access /var/lib/php/session: No such file or directory
[root@nacos opt]# mkdir -p /var/lib/php/session
[root@nacos opt]# chown -R nginx:nginx /var/lib/php/session

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

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

这里有告警

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

刷新一下

在这里插入图片描述

点击Next step

在这里插入图片描述

到这里,先安装下数据库和 zabbix-server

3.安装 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

4.安装 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@nacos opt]# netstat -lntup|grep 10051
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      6693/zabbix_server  
tcp6       0      0 :::10051                :::*                    LISTEN      6693/zabbix_server 

继续访问浏览器

在这里插入图片描述
此处如果报错Your database version: 4000000. Required version: 5000000. Please contact your system administrator.请执行下面操作,如果没有报错,请忽略

[root@manager ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 56
Server version: 5.5.68-MariaDB MariaDB Server

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

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

MariaDB [(none)]> select version();
+----------------+
| version()      |
+----------------+
| 5.5.68-MariaDB |
+----------------+
1 row in set (0.00 sec)
MariaDB [(none)]> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [zabbix]> update dbversion set mandatory=5000000;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0
MariaDB [zabbix]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [zabbix]> select version();
+----------------+
| version()      |
+----------------+
| 5.5.68-MariaDB |
+----------------+
1 row in set (0.00 sec)

下一步

在这里插入图片描述

下一步

在这里插入图片描述

下一步

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

显示此页面就是安装完成

5.汉化

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

到此就安装完成了,新的功能待后研究

6.监控本机

在这里插入图片描述

#安装zabbix-agent
yum install zabbix-agent -y
[root@nacos opt]# systemctl start zabbix-agent
[root@nacos opt]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@nacos opt]# netstat -lntp | grep 10050
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      6952/zabbix_agentd  
tcp6       0      0 :::10050                :::*                    LISTEN      6952/zabbix_agentd
[root@nacos opt]# systemctl restart zabbix-server

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值