linux监控平台介绍
常见开源监控软件
- cacti、nagios、zabbix、smokeping、open-falcon等等
- cacti、smokeping偏向于基础监控,成图非常漂亮
- cacti、nagios、zabbix服务端监控中心,需要php环境支持,其中zabbix和cacti都需要mysql作为数据存储,nagios不用存储历史数据,注重服务或者监控项的状态,zabbix会获取服务或者监控项目的数据,会把数据记录到数据库里,从而可以成图
- open-falcon为小米公司开发,开源后受到诸多大公司和运维工程师的追捧,适合大企业,滴滴、360、新浪微博、京东等大公司在使用这款监控软件,值得研究
zabbixx监控介绍
- C/S架构,基于C++开发,监控中心支持web界面配置和管理
- 单server节点可以支持上万台客户端
- 官方文档https://www.zabbix.com/manuals
- 5个组件
- zabbix-server监控中心,接收客户端上报信息,负责配置、统计、操作数据
- 数据存储,存放数据,比如mysql
- web界面,也加web UI,在web界面下操作配置是zabbix简单易用的主要原因
- zabbix-proxy可选组建,它可以代替zabbix-server的功能,减轻server的压力
- zabbix-agent客户端软件,负责采集各个监控服务或项目的数据,并上报
安装zabbix
- 官网下载地址www.zabbix.com/download
- wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
- rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
- yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql
- 会连带安装httpd和php
- vi /etc/my.cnf character_set_server=utf8
- 重启mysqld服务后,进入mysql命令行,创建zabbix库
- create database zabbix character set utf8;
- 再创建用户
- grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'user-zabbix';
- 导入数据
- cd /usr/share/doc/zabbix-server-mysql-3.2.7
- gzip -d create.sql.gz
- mysql -uroot -pxxx zabbix < create.sql
[root@node15 ~]# wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
[root@node15 ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
[root@node15 ~]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql
[root@node15 ~]# vi /etc/my.cnf
character_set_server = utf8
[root@node15 ~]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
mysql> create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'aming-zabbix';
Query OK, 0 rows affected (0.00 sec)
导入数据
[root@node15 ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/
[root@node15 zabbix-server-mysql-3.2.11]# gzip -d create.sql.gz
[root@node15 zabbix-server-mysql-3.2.11]# mysql -uroot -paminglinux zabbix < create.sql
Warning: Using a password on the command line interface can be insecure.
[root@node15 ~]# systemctl start zabbix-server
[root@node15 ~]# ps aux |grep nginx
root 4798 0.0 0.0 112676 984 pts/2 S+ 22:06 0:00 grep --color=auto nginx
[root@node15 ~]# /etc/init.d/nginx stop
Stopping nginx (via systemctl): [ 确定 ]
[root@node15 ~]# systemtl start httpd
-bash: systemtl: 未找到命令
[root@node15 ~]# systemctl start httpd
[root@node15 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@node15 ~]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@node15 ~]# systemctl disable nginx
nginx.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig nginx off
[root@node15 ~]# chkconfig nginx off
[root@node15 ~]# vim /etc/zabbix/zabbix_server.conf
//修改或增加
DBHost=127.0.0.1 //在DBName=zabbix上面增加
DBPassword=aming-zabbix //在DBuser下面增加
[root@node15 ~]# systemctl start zabbix-server
[root@node15 ~]# systemctl restart zabbix-server
[root@node15 ~]# netstat -lntp |grep zabbix
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 4952/zabbix_server
tcp6 0 0 :::10051 :::* LISTEN 4952/zabbix_server
[root@node15 ~]#
[root@node15 ~]# vi /etc/php.ini
date.timezone = Asia/Shanghai
[root@node15 ~]# systemctl restart httpd
忘记Admin密码如何做
进入mysql命令行,选择zabbix库
mysql -uroot -p zabbix
update users set passwd=md5(‘newpasswd’) where alias=‘Admin’;
这样就更改了Admin用户的密码
mysql> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update users set passwd=md5('lishiming1') where alias='Admin';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0