一.Zabbix-Server服务器端的安装
监控学习重要参考地址:
https://zabbix.org/wiki/Main_Page
https://zabbix.org/wiki/Zabbix_Templates
https://www.zabbix.com/integrations
https://share.zabbix.com/
https://github.com/monitoringartist/zabbix-community-repos

概述:10050是Agent的端口,Agent采用被动方式,Server主动连接Agent的10050端口;10051是Server的端口,Agent采用主动或Trapper方式,会连接Server的10051端口。
#centos7启动防火墙
systemctl start firewalld.service
#centos7停止防火墙/关闭防火墙
systemctl stop firewalld.service
#centos7重启防火墙
systemctl restart firewalld.service
#设置开机启用防火墙
systemctl enable firewalld.service
#设置开机不启动防火墙
systemctl disable firewalld.service

2.新增开放一个端口号
firewall-cmd --zone=public --add-port=80/tcp --permanent
#说明:#–zone #作用域
#–add-port=80/tcp #添加端口,格式为:端口/通讯协议
#–permanent 永久生效,没有此参数重启后失效
#多个端口:firewall-cmd --zone=public --add-port=80-90/tcp --permanent

前提条件:永久关闭SELinux和时间同步
#vim /etc/selinux/config
SELINUX=disabled
或者
#setenforce 0
#yum -y install ntp
#systemctl enable ntpd
#systemctl start ntpd
1.访问Zabbix的软件仓库网站http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/ 将zabbix-release-4.0-1.el7.noarch.rpm下载的本地,然后在服务器上安装。
#rpm -ivh zabbix-release-4.0-1.el7.noarch.rpm
CentOS7上搭建Zabbix4.0监控系统
#rpm -qa | grep zabbix-release
CentOS7上搭建Zabbix4.0监控系统
#cd /etc/yum.repos.d/
CentOS7上搭建Zabbix4.0监控系统
2.安装Zabbix-Server服务器端,由于服务器端也是需要监控的,故这里也一并安装了Zabbix-Agent(4.0版本的安装命令)。
#yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get
3.安装数据库在CentOS7系统包仓库安装源中,需要安装mariadb-server,而不是MySQL数据库服务(7.0以后的版本用MariaDB替换了MySQL)。#yum -y install mariadb-server mariadb-devel修改MySQL配置文件#vim /etc/my.cnf
CentOS7上搭建Zabbix4.0监控系统
character-set-server=utf8
innodb_file_per_table=1
#注意:以上mysql配置参数仅满足小规模监控环境使用,如果监控环境为中型规模(如1000台设备以上),则需要调整更多的mysql配置参数,可以参考https://github.com/zabbix-book/MySQL_conf中提供的参数。
启动服务:
#systemctl start mariadb
#systemctl stop mariadb
设置开机自启动:
#systemctl enable mariadb
#ps aux|grep mysql
#netstat -ntulp | grep 3306

4.创建Zaabix数据库首先设置mysql 的 root 用户密码,然后创建zabbix数据库。
#mysqladmin -uroot password admin
#mysql -uroot -padmin
CentOS7上搭建Zabbix4.0监控系统
create database zabbix character set utf8;
grant all privileges on zabbix.* to ‘zabbix’@‘192.168.203.136’ identified by ‘zabbix’;
flush privileges;
注意:如果创建zabbix数据库的字符集部位UTF-8,则可能会导致web界面切换到中文语言时出现乱码。

5.倒入zabbix库的数据文件
#cd /usr/share/doc/zabbix-server-mysql-4.0.13/
#gunzip create.sql.gz
#mysql -uzabbix -pzabbix -h192.168.203.136
mysql>use zabbix
mysql>source /usr/share/doc/zabbix-server-mysql-4.0.13/create.sql;

6.配置zabbix_server.conf
#vim /etc/zabbix/zabbix_server.conf
DBHost=192.168.203.136
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
StartPollers=100
StartIPMIPollers=10
StartPollersUnreachable=10
StartTrappers=10
StartPingers=10
StartDiscoverers=10
CacheSize=256M
HistoryCacheSize=128M
TrendCacheSize=128M
ValueCacheSize=2048M
Timeout=30
TrapperTimeout=300

7.开启Zabbix-Server服务
#systemctl start zabbix-server
#systemctl stop zabbix-server
#systemctl enable zabbix-server
#ps aux|grep zabbix
#tail -f /ver/log/zabbix/zabbix_server.log
#systemctl start httpd
#systemctl enable httpd
注意:在安装zabbix server的时候默认就安装了apache,zabbix依靠apache提供的web服务,修改Zabbix的浏览器访问端口,就是修改apache的服务端口(默认端口:80),修改默认端口
#vim /etc/httpd/conf/httpd.conf 8888
#systemctl restart httpd

8.防火墙设置
#firewall-cmd --zone=public --add-port=8888/tcp --permanent
#firewall-cmd --zone=public --add-port=10050/tcp --permanent
#firewall-cmd --zone=public --add-port=10051/tcp --permanent
#systemctl restart firewalld.service
#–zone #作用域
#–add-port=80/tcp #添加端口,格式为:端口/通讯协议
#–permanent 永久生效,没有此参数重启后失效

9.php.ini文件配置
#vim /etc/php.ini
去掉date.timezone的注释,将时区改为Asia/Shanghai
或者:#vim /etc/httpd/conf.d/zabbix.conf
CentOS7上搭建Zabbix4.0监控系统
php_value date.timezone Asia/Shanghai
#systemctl restart httpd
#systemctl restart zabbix-server

10.配置Zabbix-Web:
打开浏览器,输入http://192.168.203.135:8888/zabbix 出现下图
CentOS7上搭建Zabbix4.0监控系统
单机“Next.step”按钮,如下图,如果提示参数不通过,则修改php.ini配置文件,并重启Web(httpd)服务
CentOS7上搭建Zabbix4.0监控系统
配置数据库连接的各项参数
CentOS7上搭建Zabbix4.0监控系统
Zabbix-Server的连接地址,端口,名称设置将会显示在zabbix的前端页面注意:如果zabbix-server在其他机器上,那么这里的Host要填写Zabbix-Server所在机器的IP地址,必须保证从Zabbix前端PHP所在的这台服务器能连接到Server服务器端口10051
CentOS7上搭建Zabbix4.0监控系统
这些配置信息将会被写入/${PATH}/zabbix/conf/zabbix.conf.php文件中
CentOS7上搭建Zabbix4.0监控系统
配置文件生成成功:Finish
CentOS7上搭建Zabbix4.0监控系统
如图所示,登陆页面,默认账户时Admin,密码是zabbix
CentOS7上搭建Zabbix4.0监控系统
登录成功后的页面
CentOS7上搭建Zabbix4.0监控系统
注意:
CentOS7上搭建Zabbix4.0监控系统
注意2:访问zabbix登录页面时出现白屏情况,请重启httpd
#systemctl restart httpd
#systemctl enabtle httpd

相关文章: