linux 7搭建zabbix

linux 7搭建zabbix

1、配置ip

2、各服务器配置主机名
#hostnamectl set-hostname --static zabbixserver
其他服务器互相绑定ip和主机名
#vim /etc/hosts

3、时间同步

Service ntpd restart
Chkconfig –add ntpd
或者
ntpdate time1.aliyun.com

4、配置yum(安装完centos后默认的yum源+下面zabbix官方源)

所有机器(zabbix服务器和所有被监控端)加上zabbix官方的yum源
# vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=zabbix
baseurl=http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/
enabled=1
gpgcheck=0
[zabbix_deps]
name=zabbix_deps
baseurl=http://repo.zabbix.com/non-supported/rhel/7/x86_64/
enabled=1
gpgcheck=0

zabbix服务器安装:

1,安装zabbix和mariadb数据库

上面的yum源确认OK并能连外网,直接下面一条命令就把zabbix服务器相关软件包都装上
[root@zabbixserver ~]# yum install zabbix-server-mysql zabbix-web-mysql mariadb-server

2, 在mysql(mariadb)里建立存放数据的库并授权,然后导入zabbix所需要用的表和数据

[root@zabbixserver ~]# systemctl restart mariadb.service
[root@zabbixserver ~]# systemctl enable mariadb.service
[root@zabbixserver ~]# systemctl status mariadb.service

[root@zabbixserver ~]# mysql
MariaDB [(none)]> create database zabbix default charset utf8;		这里一定要用utf8字符集,否则后面zabbix很多中文用不了(比如创建中文名用户就创建不了)
MariaDB [(none)]> grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> quit

3, 导入表数据

下面这条命令不要乱复制粘贴,如果你版本不一样(或者官网yum源版本升级),3.4.15就要改成对应版本
[root@zabbixserver ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.15/create.sql.gz |mysql -u zabbix -p zabbix zabbix

4, 配置zabbix主配置文件,并启动服务,确认端口

找到并确认如下参数(默认值正确的可以打开注释也可以不打开.默认值不对的,要修改正确并打开注释)
[root@zabbixserver ~]# vim /etc/zabbix/zabbix_server.conf	--我这里只需要改连接数据的密码和socket
ListenPort=10051
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123						--这里要对应上面第2步的授权进行修改
DBSocket=/var/lib/mysql/mysql.sock 	--这里默认的socket路径不对,改成我这个路径
ListenIP=0.0.0.0

[root@zabbixserver ~]# systemctl restart zabbix-server
[root@zabbixserver ~]# systemctl enable zabbix-server
[root@zabbixserver ~]# systemctl status zabbix-server
[root@zabbixserver ~]# lsof -i:10051	

5, 配置zabbix的httpd子配置文件,并启动httpd
可以进行端口等其他配置的修改,修改完成后启动

vim /etc/httpd/conf/httpd.conf

修改时区位置:

vim /etc/httpd/conf.d/zabbix.conf
打开第20行注释,并修改成你的时区
[root@zabbixserver ~]# vim /etc/httpd/conf.d/zabbix.conf

20 php_value date.timezone Asia/Shanghai

[root@zabbixserver ~]# systemctl restart httpd 
[root@zabbixserver ~]# systemctl enable httpd
[root@zabbixserver ~]# systemctl status httpd

6, 使用浏览器访问http://10.1.1.11/zabbix,并按提示进行安装

按照图示过程安装
1,welcome
2,Check of pre-requisites
3,Configure DB connection
数据库用户名填zabbix,密码填123(前面授权过的)
4,Zabbix server details
在name选项填上你zabbix服务器的IP或者主机名
5,Pre-Installation summary
6,install

完成后
登陆用户名为:admin
登陆密码为:zabbix

监控本机:

1.在master上安装zabbix-agent

[root@zabbixserver ~]# yum install zabbix-agent

2,启动zabbix-agent服务

[root@zabbixserver ~]# vim /etc/zabbix/zabbix_agentd.conf	--下面两个常见选项都为默认值,不用配置
Server=127.0.0.1		--zabbix服务器的IP,这里是本机
ListenPort=10050		--监控服务器连接被监控客户端的端口

[root@zabbixserver ~]# systemctl restart zabbix-agent
[root@zabbixserver ~]# systemctl enable  zabbix-agent
[root@zabbixserver ~]# systemctl status  zabbix-agent
[root@zabbixserver ~]# lsof -i:10050

3, 解决乱码方法: 换一个字体

下载ttf-arphic-ukai.tar.gz软件包,并做如下修改
# tar xf ttf-arphic-ukai.tar.gz -C /usr/share/zabbix/fonts/
# mv /usr/share/zabbix/fonts/ukai.ttc /usr/share/zabbix/fonts/ukai.ttf
# vim /usr/share/zabbix/include/defines.inc.php

54 define('ZBX_GRAPH_FONT_NAME',           'ukai'); 		--修改原来的graphfont字体改成ukai

启动zabbix-agent:

systemctl start zabbix-agent

通过zabbix-agent监控远程机器:

1,在agent1上安装zabbix-agent包

[root@agent1 ~]# yum install zabbix-agent

2,配置zabbix-agent端的配置文件,启动服务并做成开机自动启动

[root@agent1 ~]# vim /etc/zabbix/zabbix_agentd.conf
95 Server=10.1.1.11				--修改成zabbix监控服务器的IP(被动监控)
136ServerActive= 127.0.0.1
147 Hostname=agent1.cluster.com	--修改成agent1的主机名

[root@agent1 ~]# systemctl restart zabbix-agent
[root@agent1 ~]# systemctl enable zabbix-agent
[root@agent1 ~]# systemctl status zabbix-agent

[root@agent1 ~]# lsof -i:10050

添加自定义监控项:
在/etc/zabbix/zabbix_agentd.conf中找到# UserParameter=

UserParameter=Mem_pre,free -m|awk '/^Mem/{print $NF*100/$2}'
UserParameter=proc.web_httpd,ps -ef |grep /export/home/cms/servers/apache/bin/httpd|grep -v grep |wc -l
UserParameter=proc.aliyun,ps -ef|grep /usr/sbin/aliyun-service|grep -v grep |wc -l
UserParameter=proc.zabbix_agent,ps -ef |grep /usr/sbin/zabbix_agentd|grep -v grep |wc -l
UserParameter=proc.supervisor,ps -ef |grep /usr/bin/supervisord |grep -v grep |wc –l

添加监控项:在这里插入图片描述
添加触发器:在这里插入图片描述
添加图形:在这里插入图片描述
效果图:
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值