Linux配置监控服务器:Zabbix监控
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux配置监控服务器:Zabbix监控相关的知识,希望对你有一定的参考价值。
一、Linux监控平台介绍
二、Zabbix监控介绍
- C/S架构,基于C++开发,监控中心支持web界面配置和管理;
- 单server节点可以支持上万台客户端;
- 最新版本3.4 ,官网文档https://www.zabbix.com/manuals
1、组件
Zabbix整个体系架构中有几个主要角色:
- zabbix-server:核心,监控中心,接收客户端上报信息,负责配置、统计、操作数据;
- 数据存储:存放数据,比如mysql;
- web界面:也叫web UI ,在web界面下操作配置是zabbix简单易用的主要原因;
- zabbix-proxy:可选组件,它可以代替zabbix-server的功能,减轻server的压力;
- zabbix-agent:客户端软件,负责采集各个监控服务或项目的数据,并上报。
2、架构
三、Zabbix监控安装与部署
1、用yum安装Zabbix
[[email protected] ~]# wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm //下载Zabbix的yum扩展源
[[email protected] ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm //安装扩展源
[[email protected] ~]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql //安装相关安装包
#会连带安装httpd和php
#如果mysql之前没有装的话,需要根据lamp那一章的mysql安装方法安装msyql
[[email protected] ~]# ps aux | grep mysql //查看mysql服务是否启动,没有就启动下
2、配置MySQL
[[email protected] ~]# vim /etc/my.cnf //在[mysqld]下添加以下一行
character_set_server = utf8
[[email protected] ~]# systemctl restart mysql //重启mysql
[[email protected] ~]# mysql -uroot -pzlinux123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.36-log MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql> create database zabbix character set utf8; //创建zabbix库,字符集utf8
Query OK, 1 row affected (0.00 sec)
mysql> grant all on zabbix.* to ‘zabbix‘@‘127.0.0.1‘ identified by ‘zlinux123456‘; //创建zabbix用户,为了zabbix连接数据库
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
#导入zabbix数据库
[[email protected] ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/
[[email protected] zabbix-server-mysql-3.2.11]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[[email protected] zabbix-server-mysql-3.2.11]# gzip -d create.sql.gz
[[email protected] zabbix-server-mysql-3.2.11]# mysql -uroot -pzlinux123456 zabbix < create.sql
#修改zabbix-server配置文件
[[email protected] ~]# vim /etc/zabbix/zabbix_server.conf //加入以下内容
DBHost=127.0.0.1
DBPassword=zlinux123456
3、启动相关服务
[[email protected] ~]# systemctl stop nginx //先停止掉Nginx服务因为占用了80,或者Nginx做下代理配置,可参考前文
[[email protected] ~]# systemctl start httpd //启动httpd
[[email protected] ~]# ps aux | grep httpd
root 3472 0.0 0.8 394324 15480 ? Ss 15:20 0:00 /usr/sbin/httpd -DFOREGROUND
apache 3474 0.0 0.4 394460 7680 ? S 15:20 0:00 /usr/sbin/httpd -DFOREGROUND
apache 3475 0.0 0.4 394460 7680 ? S 15:20 0:00 /usr/sbin/httpd -DFOREGROUND
apache 3476 0.0 0.4 394460 7680 ? S 15:20 0:00 /usr/sbin/httpd -DFOREGROUND
apache 3477 0.0 0.4 394460 7680 ? S 15:20 0:00 /usr/sbin/httpd -DFOREGROUND
apache 3478 0.0 0.4 394460 7680 ? S 15:20 0:00 /usr/sbin/httpd -DFOREGROUND
[[email protected] ~]# systemctl start zabbix-server //启动zabbix服务
[[email protected] ~]# ps aux | grep zabbix //查看zabbix相关,成功的情况下有很多条服务
[[email protected] ~]# netstat -lntp //80,3306,11051三个端口
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:45930 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:20048 0.0.0.0:* LISTEN 995/rpc.mountd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 839/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1703/master
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 3393/zabbix_server
tcp 0 0 0.0.0.0:42343 0.0.0.0:* LISTEN 824/rpc.statd
tcp6 0 0 :::3306 :::* LISTEN 3330/mysqld
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::80 :::* LISTEN 3472/httpd
tcp6 0 0 :::38704 :::* LISTEN -
tcp6 0 0 :::20048 :::* LISTEN 995/rpc.mountd
tcp6 0 0 :::22 :::* LISTEN 839/sshd
tcp6 0 0 :::40375 :::* LISTEN 824/rpc.statd
tcp6 0 0 ::1:25 :::* LISTEN 1703/master
tcp6 0 0 :::2049 :::* LISTEN -
tcp6 0 0 :::10051 :::* LISTEN 3393/zabbix_server
4、配置web界面
步骤1:
步骤2:
要解决此问题,需要编辑phph.ini或者Zabbix的httpd配置:
[[email protected] ~]# vim /etc/httpd/conf.d/zabbix.conf //在最后增加下面一行
php_value date.timezone Asia/Shanghai
[[email protected] ~]# systemctl restart httpd //重启
步骤3:刷新下浏览器,继续下一步
步骤4:
步骤5:登录管理后台首先更改密码,默认账户:admin,密码:zabbix
5、Zabbix客户端部署
[[email protected] ~]# http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
[[email protected] ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
[[email protected] ~]# yum install -y zabbix-agent
[[email protected] ~]# vim /etc/zabbix/zabbix_agentd.conf //修改以下内容
Server=192.168.242.128 //定义服务端IP(被动模式)
Server=192.168.242.128 //定义服务点IP(主动模式)
Hostname=zlinux-01 //自定义主机名
[[email protected] ~]# systemctl start zabbix-agent //启动
[[email protected] ~]# netstat -lnp | grep zabbix //zabbix-agent监听10050端口
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2436/zabbix_agentd
tcp6 0 0 :::10050 :::* LISTEN 2436/zabbix_agentd
以上是关于Linux配置监控服务器:Zabbix监控的主要内容,如果未能解决你的问题,请参考以下文章