CentOS7.2 安装zabbix 3.2版本
一、ZABBIX概述前戏:几年之前使用了zabbix3.2版本,最近才有时间分享。zabbix功能很强大,安装简单。
个人看法:一般测试使用yum方式安装,生产环境建议编译安装,因为yum安装的LAMP版本比较旧。
Zabbix是一个基于Web界面的分布式系统监控的企业级开源软件。可以监视各种系统与设备的参数,保障服务器及设备的安全运营。
Zabbix的功能和特性:
1、安装与配置简单;
2、可视化web管理界面;
3、免费开源;
4、支持中文;
5、自动发现;
6、分布式监控;
7、实时绘图.
Zabbix架构:
1、Zabbix Server:负责接收Agent发送的报告信息,组织所有配置、数据和操作。
2、Database Storage:存储配置信息以及收集到的数据。
3、Web Interface:Zabbix的GUI 接口,通常与Server运行在同一台机器上。
4、Proxy:可选组件,常用于分布式监控环境中。
5、Agent:部署在被监控主机上,负责收集数据发送给Server。
工作流程:
Agent获取被监控端数据,发送给Server。
Server记录所接收到的数据,存储在Database中并按照策略进行相应操作。
如果是分布式,Server会将数据传送一份到上级Server中。
Web Interface将收集到的数据和操作信息显示给用户。https://s1.运维网.com/images/20190406/1554557127237765.png
以上文字图片来自互联网
二、系统环境准备
1、防火墙及SELINUX关闭
# systemctl stop firewalld.service
#systemctl disable firewalld.service
#sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
#grep SELINUX=disabled /etc/selinux/config
#setenforce 0 2、yum源配置
# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# cd /etc/yum.repos.d/
# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
# yum -y install http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
# yum install http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm -y 三、zabbix和数据库安装
1、yum源安装
# yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get mariadb-server 2、启动mariadb数据库
# systemctl start mariadb.service
# systemctl enable mariadb.service
# systemctl status mariadb.service
# mysql_secure_installation 3、创建数据库
# mysql -uroot -p
>create database zabbix character set utf8 collate utf8_bin;
>grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
>flush privileges; 4、初始数据导入
# cd /usr/share/doc/zabbix-server-mysql-3.2.10/
# zcat create.sql.gz |mysql -uroot -p zabbix 四、zabbix配置
1、编辑zabbix_server.conf
# grep-n ^/etc/zabbix/zabbix_server.conf
38:LogFile=/var/log/zabbix/zabbix_server.log
49:LogFileSize=0
72:PidFile=/var/run/zabbix/zabbix_server.pid
81:DBHost=localhost
91:DBName=zabbix
107:DBUser=zabbix
115:DBPassword=zabbix
287:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
413:Timeout=4
455:AlertScriptsPath=/usr/lib/zabbix/alertscripts
465:ExternalScripts=/usr/lib/zabbix/externalscripts
501:LogSlowQueries=3000 2、启动zabbix server并设置开机启动
# systemctl enable zabbix-server
# systemctl start zabbix-server
# systemctl status zabbix-server 3、编辑Zabbix前端PHP配置,更改时区
# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai 4、启动httpd并设置开机启动
# systemctl start httpd
# systemctl enable httpd
# systemctl status httpd 5、可以测试下zabbix-get工具
# zabbix_get -s 192.168.246.134 -p 10050 -k "system.uname"
Linux localhost.localdomain 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64
# zabbix_get -s 192.168.246.134 -p 10050 -k "system.cpu.load"
0.020000 五、安装Zabbix Web
如果80端口访问不了,或已经被占用,可以用其他端口,比如改成8739
# vim /etc/httpd/conf/httpd.conf
# systemctl restart httpd
# systemctl status httpd 1、浏览器访问,并进行安装
http://192.168.0.128:3206/zabbix/
https://s1.运维网.com/images/20190406/1554557441256057.png
https://s1.运维网.com/images/20190406/1554557450601718.png
https://s1.运维网.com/images/20190406/1554557458672472.png
https://s1.运维网.com/images/20190406/1554557467901585.png
https://s1.运维网.com/images/20190406/1554557475649933.png
https://s1.运维网.com/images/20190406/1554557483576617.png
https://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gif
https://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gif
完成安装,会将在/etc/zabbix/web/zabbix.conf.php生成配置文件
默认用户名/密码:Admin/zabbix 六、客户端agent安装(注意客户端操作系统版本)
1、centos7客户端安装---如果要监控的agent很多的话,可以使用ansible安装:
# yum install http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm -y
# yum install zabbix-agent zabbix-sender 修改配置文件:
# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.0.128
Hostname=localhost
# systemctl restart zabbix-agent
# systemctl enable zabbix-agent
# systemctl status zabbix-agent 2、centos6客户端安装
# yum -y install # vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.0.128
Hostname=localhost
/etc/init.d/zabbix-agent restart 七、将zibbix web改成中文,如下图(如果改后还有方块的乱码,麻烦参考最后面的备注信息)
https://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gifhttps://s1.运维网.com/images/20190406/1554557620219306.png
八、添加主机,我以添加服务器本机为例,其实本机已经存在,这里只是举个例子。如下图:
https://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gifhttps://s1.运维网.com/images/20190406/1554557629538969.png
https://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gif
https://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gifhttps://s1.运维网.com/images/20190406/1554557643392129.png
https://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gifhttps://s1.运维网.com/images/20190406/1554557763212787.png
https://s1.运维网.com/images/20190406/1554557771177263.png
备注:解决中文乱码,变方块的方法
https://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gifhttps://s1.运维网.com/images/20190406/1554557785601698.png
首先要在系统的windows那里找一个楷体中文
然后通过Xftp或者sambaWindows的共享方式,把字体复制到指定路径下。
这个楷体常规的字体,复制到CentOS下就变成了simkai.ttf
# mkdir /usr/share/fonts/simkai/
# ll /usr/share/fonts/simkai/simkai.ttf
-rw-r--r--. 1 root root 11785184 Nov 22 14:25 /usr/share/fonts/simkai/simkai.ttf
修改默认字体:
# vim /usr/share/zabbix/include/defines.inc.php
define('ZBX_FONTPATH', '/usr/share/fonts/simkai'); # where to search for font (GD > 2.0.18)
define('ZBX_GRAPH_FONT_NAME', 'simkai'); // font file name
中文字没有变成方块!
在"监测" -> "图形"中
下面四行字的中文字没有变成方块,表示去乱码成功!!https://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gifhttps://s1.运维网.com/images/20190406/1554557796800629.png
页:
[1]