centos 7 安装zabbix 4.0

一、zabbix简介

1、简介

zabbix([`zæbiks])是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。zabbix能监视各种网络参数如:CPU负荷、内存使用、磁盘使用、网络状况、端口监视、日志监视等。zabbix主要由2部分构成,zabbix server与可选组件zabbix agent。

zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。

zabbix agent需要安装在被监视主机上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。zabbix agent可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X,Tru64/OSF1,Windows NT4.0,Windows (2000/2003/XP/Vista)等系统之上。

2、实验环境

系统:centos 7

软件:Apache 2.4.6-93 mariadb 5.5.65 php 5.4.16 zabbix 4.0.21

3、安装前的准备工作

1、设置本机IP地址:192.168.10.100
[root@bogon ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=84e3956a-e882-4039-baa3-1a7dd1c733ea
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.10.100
NETMASE=255.255.255.0
GATEWAY=192.168.10.2
DNS1=192.168.10.2

2、设置主机名为:zabbix-server
[root@bogon ~]# vim /etc/hostname
zabbix-server

3、关闭selinux
[root@bogon ~]# vim /etc/selinux/config
...

SELINUX=disabled
...

4、重启电脑
[root@bogon ~]# reboot

二、使用yum安装LAMP

1、安装Apache

[root@zabbix-server ~]# yum install httpd -y

1.1 验证Apache

启动Apache服务

[root@zabbix-server ~]# systemctl start httpd

访问本机127.0.0.1,你会看到如下界面:

centos 7 安装zabbix 4.0

2、安装mariadb

[root@zabbix-server ~]# yum install mariadb-server mariadb -y

2.1 验证mariadb

centos 7 安装zabbix 4.0

2.2 对mariadb进行初始化安全设置

centos 7 安装zabbix 4.0
1 [root@zabbix-server ~]# systemctl start mariadb  # 启动mariadb
 2 [root@zabbix-server ~]# mysql_secure_installation   # 初始化mariadb数据库
 3
 4 NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
 5       SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

 6
 7 In order to log into MariaDB to secure it, we'll need the current
 8 password for the root user.  If you've just installed MariaDB, and
 9 you haven't set the root password yet, the password will be blank,
10 so you should just press enter here.

11
12 Enter current password for root (enter for none):   # 默认root密码为空,这里回车即可
13 OK, successfully used password, moving on...

14
15 Setting the root password ensures that nobody can log into the MariaDB
16 root user without the proper authorisation.

17
18 Set root password? [Y/n] Y   # 是否设置root密码
19 New password:     # 设置root密码
20 Re-enter new password:   # 确认密码
21 Password updated successfully!

22 Reloading privilege tables..

23  ... Success!

24
25
26 By default, a MariaDB installation has an anonymous user, allowing anyone
27 to log into MariaDB without having to have a user account created for
28 them.  This is intended only for testing, and to make the installation
29 go a bit smoother.  You should remove them before moving into a
30 production environment.

31
32 Remove anonymous users? [Y/n] Y   # 是否删除匿名用户,建议删除,否则可以通过匿名用户访问数据库
33  ... Success!

34
35 Normally, root should only be allowed to connect from 'localhost'.  This
36 ensures that someone cannot guess at the root password from the network.

37
38 Disallow root login remotely? [Y/n] n  # 是否拒绝root远程登录,这里是实验环境我们允许
39  ... skipping.

40
41 By default, MariaDB comes with a database named 'test' that anyone can
42 access.  This is also intended only for testing, and should be removed
43 before moving into a production environment.

44
45 Remove test database and access to it? [Y/n] Y  # 是否删除默认test数据库,这个随意
46  - Dropping test database...

47  ... Success!

48  - Removing privileges on test database...

49  ... Success!

50
51 Reloading the privilege tables will ensure that all changes made so far
52 will take effect immediately.

53
54 Reload privilege tables now? [Y/n] Y  # 是否使设置立即生效
55  ... Success!

56
57 Cleaning up...

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

61
62 Thanks for using MariaDB!

mysql_secure_installation

2.3 设置客户端和服务端的字符集为utf-8

[root@zabbix-server ~]# vim /etc/my.cnf
[mysqld]

character-set-server=utf8             # 设置服务端的字符集
collation-server=utf8_general_ci      # 设置服务端的字符集

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
Settings user and group are ignored when systemd is used.

If you need to run mysqld under a different user or group,
customize your systemd unit file for mariadb according to the
instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

[client]                #  设置客户端的字符集
default-character-set=utf8
[mysql]                #  设置客户端的字符集
default-character-set=utf8
#
include all files from the config directory
#
!includedir /etc/my.cnf.d

重启mariadb

[root@zabbix-server ~]# systemctl restart mariadb

3、安装php

[root@zabbix-server ~]# yum install php php-mysql -y

3.1 验证php

在/var/www/html下创建index.php

[root@zabbix-server ~]# vim /var/www/html/index.php
<?php
phpinfo();
?>

重启Apache

[root@zabbix-server ~]# systemctl restart httpd

访问127.0.0.1进行验证

centos 7 安装zabbix 4.0

三、安装zabbix

1、下载zabbix

[root@zabbix-server ~]# wget https://cdn.zabbix.com/zabbix/sources/stable/4.0/zabbix-4.0.21.tar.gz -P /usr/src/

2、解压

[root@zabbix-server ~]# tar -zxvf /usr/src/zabbix-4.0.21.tar.gz -C /opt/

3、创建运行zabbix账户

[root@zabbix-server ~]# groupadd zabbix
[root@zabbix-server ~]# useradd -g zabbix zabbix

4、创建zabbix数据库

[root@zabbix-server mysql]# mysql -uroot -p
MariaDB [(none)]> create database zabbix;
MariaDB [(none)]> use zabbix;
MariaDB [zabbix]> source /opt/zabbix-4.0.21/database/mysql/schema.sql
MariaDB [zabbix]> source /opt/zabbix-4.0.21/database/mysql/data.sql

5、配置zabbix

[root@zabbix-server ~]# cd /opt/zabbix-4.0.21/
[root@zabbix-server zabbix-4.0.21]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

这时可能报如下错误:

centos 7 安装zabbix 4.0

原因是缺少mysql-devel,安装即可。

[root@zabbix-server zabbix-4.0.21]# yum install mysql-devel -y

安装完成后再次进行配置

[root@zabbix-server zabbix-4.0.21]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

这时可能会报如下错误:

centos 7 安装zabbix 4.0

原因是缺少libxml,安装即可。

[root@zabbix-server zabbix-4.0.21]# yum install libxml2 libxml2-devel -y

安装完成后再次进行配置

[root@zabbix-server zabbix-4.0.21]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

这时可能会报如下错误:

centos 7 安装zabbix 4.0

原因是缺少 net-snmp-devel,安装即可。

[root@zabbix-server zabbix-4.0.21]# yum install net-snmp-devel -y

安装完成后再次进行配置

[root@zabbix-server zabbix-4.0.21]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

这时可能会报如下错误:

centos 7 安装zabbix 4.0

原因是缺少libevent-devel,安装即可。

[root@zabbix-server zabbix-4.0.21]# yum install libevent-devel -y

安装完成后再次进行配置

[root@zabbix-server zabbix-4.0.21]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

这时可能会报如下错误:

centos 7 安装zabbix 4.0

原因是缺少curl-devel,安装即可。

[root@zabbix-server zabbix-4.0.21]# yum install curl-devel -y

安装完成后再次进行配置

[root@zabbix-server zabbix-4.0.21]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

经过上面诸多错误,终于来到了如下所示:

centos 7 安装zabbix 4.0

6、安装zabbix

[root@zabbix-server zabbix-4.0.21]# make install

7、编辑配置文件/usr/local/etc/zabbix_server.conf

[root@zabbix-server zabbix-4.0.21]# vim /usr/local/etc/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=root
DBPassword=root的密码
DBPort=3306

8、使用web界面安装zabbix

8.1 创建zabbix在web中的工作目录

[root@zabbix-server zabbix-4.0.21]# mkdir /var/www/html/zabbix

8.2 将/opt/zabbix-4.0.21/frontends/php/下的所有文件复制到/var/www/html/zabbix

[root@zabbix-server zabbix-4.0.21]# cd frontends/php/
[root@zabbix-server php]# cp -a . /var/www/html/zabbix/

8.3 在web上进行安装

访问http://127.0.0.1/zabbix我们会看到如下:

centos 7 安装zabbix 4.0

此时我们只能在centos本机上访问http://127.0.0.1/zabbix,这样操作不方便,并且其它主机将不能使用zabbix,所以调整httpd.conf文件。

[root@zabbix-server php]# vim /etc/httpd/conf/httpd.conf
Listen 192.168.10.100:80    # 将监听地址改成服务器的IP地址

修改完成后重启Apache
[root@zabbix-server php]# systemctl restart httpd

停止防火墙
[root@zabbix-server php]# systemctl stop firewalld

此时我们便可以在宿主机上访问Apache服务了。

centos 7 安装zabbix 4.0

点击下一步后我们会看到一个提示信息,提示哪里需要整改。

centos 7 安装zabbix 4.0

错误大致分为两部分,一个是需要调整PHP的配置文件,一个缺少一些php组件。

8.4 调整php配置文件

[root@zabbix-server php]# vim /etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai

重启Apache

[root@zabbix-server php]# systemctl restart httpd

再次访问http://192.168.10.100/zabbix/

centos 7 安装zabbix 4.0

我们可以看到关于php配置文件的错误没了,现在只剩php组件了。

8.5 安装php缺失的组件

[root@zabbix-server ~]# yum install php-bcmath php-mbstring php-gd libjpeg* php-ldap php-xml php-xmlrpc -y

安装完成后,重启Apache。

[root@zabbix-server ~]# systemctl restart httpd

再次访问http://192.168.10.100/zabbix/,你会看到如下:

centos 7 安装zabbix 4.0

点击下一步后,会进入到连接数据库的界面:

centos 7 安装zabbix 4.0

如果下一步出现如下错误:

centos 7 安装zabbix 4.0

表示数据库zabbix的字符集有问题。

删除数据库zabbix,并重新创建zabbix,导入数据。

[root@zabbix-server ~]# mysql -uroot -p
MariaDB [(none)]> drop database zabbix;
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> use zabbix;
MariaDB [zabbix]> source /opt/zabbix-4.0.21/database/mysql/schema.sql
MariaDB [zabbix]> source /opt/zabbix-4.0.21/database/mysql/images.sql
MariaDB [zabbix]> source /opt/zabbix-4.0.21/database/mysql/data.sql

设置完成后刷新页面,我们会看到如下界面:

centos 7 安装zabbix 4.0

点击下一步后,我们会看到如下界面:

centos 7 安装zabbix 4.0

下一步后我们会看到如下界面:

centos 7 安装zabbix 4.0

点击下一步后来到安装页面:

centos 7 安装zabbix 4.0

造成该错误的原因是Apache的用户对/var/www/html/zabbix/conf没有写入的权限。

我们给写入权限即可,如下:

[root@zabbix-server ~]# chmod a+w /var/www/html/zabbix/conf

刷新页面后你会看到如下:

centos 7 安装zabbix 4.0

点击Finish后你会看到如下界面:

centos 7 安装zabbix 4.0

登录成功后你会看到如下界面:

centos 7 安装zabbix 4.0

我们可以看到zabbix server并没有运行,造成这种情况的原因很多,我们可以通过查看日志文件来了解问题产生的原因,默认日志文件在/tmp/zabbix_server.log。

如果是数据库连接的问题,我们要确保/var/www/html/zabbix/conf/zabbix.conf.php和vim /usr/local/etc/zabbix_server.conf中的数据库信息一致,并且数据库用户名和密码正确。

我们这里出现这个问题的原因是没有开启zabbix server服务。

[root@zabbix-server ~]# zabbix_server

刷新页面我们会看到如下:

centos 7 安装zabbix 4.0

此时zabbix是英文界面,如果想换成中文界面,如下操作:

设置成功后你会看到如下:

到此zabbix的安装就简单介绍到这里。

Original: https://www.cnblogs.com/caesar-id/p/13123496.html
Author: id_iot
Title: centos 7 安装zabbix 4.0

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/582594/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • linux free命令available小于free值

    问题:前段时间在做服务器巡检时发现系统可用内存值小于空闲内存值 分析:查询网上各种资料,都说的是 available=free + buff/cache 这样一个大致计算方式,按这…

    Linux 2023年6月14日
    0153
  • 位运算(一)

    位运算的一般应用 功能 例子 运算 去掉最后一位 1110101->111010 x>>1 在最后加0 1110101->11101010 x< 通过…

    Linux 2023年6月8日
    0125
  • 小白上手Linux系统安装Tomcat教程

    1.准备阶段: 要有JDK环境,在安装好JDK后再配置tomcat,JDK安装详情在我博客中可以看到。 3.导入 进入到Xshell输入在自己的文件中(cd /home/lzh)好…

    Linux 2023年6月13日
    093
  • 离线版centos8安装docker笔记

    嗨嗨哈哈,已经很久没有坐下来胡编乱造一点笔记了,平时云服务器搞惯了,一个命令就安装好了docker了的,但这次生不逢时的新机房就没那么幸运了,有多不逢时超乎想象,不仅仅服务器没有外…

    Linux 2023年5月27日
    0116
  • 快速登陆linux服务器

    前言 本文适用于喜欢原生终端的用户,钟爱第三方ssh客户端的可以无视….客户端可以保存用户信息和密码,比较无脑。mac可以使用终端,win可以使用git的bash。 上…

    Linux 2023年6月14日
    097
  • shell operator EOF shell 操作符 << <<<

    总结: 这些被叫做shell操作符 shell operator 主要分为 control operators和redirection operators < Origina…

    Linux 2023年5月28日
    086
  • WPF 解决 ObservableCollection 提示 Cannot change ObservableCollection during a CollectionChanged event 异常

    本文告诉大家在使用 ObservableCollection 时,抛出 InvalidOperationException 异常,提示 Cannot change Observab…

    Linux 2023年6月6日
    071
  • Java — 注解

    Java 注解(Annotation)又称为 Java 标注,是 Java5 开始支持加入源代码的特殊语法元数据。 Java 语言中的类、方法、变量、参数和包等都可以被标注。 Ja…

    Linux 2023年6月8日
    089
  • JavaWeb创建一个公共的servlet

    对于初学者来说,每次前端传数据过来就要新建一个类创建一个doget、dopost方法,其实铁柱兄在大学的时候也是这么玩的。后面铁柱兄开始认真了,就想着学习点容易的编程方式,其实说白…

    Linux 2023年6月13日
    084
  • Docker下部署LNMP黄金架构

    404. 抱歉,您访问的资源不存在。 可能是网址有误,或者对应的内容被删除,或者处于私有状态。 代码改变世界,联系邮箱 contact@cnblogs.com 园子的商业化努力-困…

    Linux 2023年6月7日
    089
  • 数据库_存储过程简介(oracle版)

    应朋友要求,写个存储过程说明,本篇比较简单,适合新接触存储过程的同学 先来个简单的 begin dbms_output.put_line(‘my first execute’); …

    Linux 2023年6月6日
    082
  • source insight4.0最常用到的设置

    1、常用功能 1.1:全局查找 1.2:当前文件查找 1.3:高亮设置 1.4:配置字体以及其他 1.5:配置自动缩进 1.6:其他 1. 常用功能 全局查找 Ctl+/ 查找到的…

    Linux 2023年5月27日
    0114
  • 基本数据类型的长度

    32位机器和64位机器中int、char等数据类型所占字节长度对比。 在32位机器和64机器中int类型都占用4个字节。编译器可以根据自身硬件来选择合适的大小,但是需要满足约束:s…

    Linux 2023年6月13日
    084
  • SSH_远程终端

    SSH 远程服务 目的 Windwos 和 Linux 的终端控制系统or传送传送文件, 当然 Linux和Linux 以及 Windwos 和 Windwos 之间的通信都是OK…

    Linux 2023年6月7日
    081
  • Java类初始化顺序小结

    第一种情况(单一类) 测试结果 &#x9759;&#x6001;&#x53D8;&#x91CF; &#x9759;&#x6001;&…

    Linux 2023年6月7日
    092
  • 如何在 pyqt 中解决启用 DPI 缩放后 QIcon 模糊的问题

    问题描述 如今显示器的分辨率越来越高,如果不启用 DPI 缩放,软件的字体和图标在高分屏下就会显得非常小,看得很累人。从 5.6 版本开始,Qt 便能支持 DPI 缩放功能,Qt6…

    Linux 2023年6月7日
    0187
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球