linux监控平台介绍
- cacti、nagios、zabbix、smokeping、open-falcon等等
- cacti、smokeping偏向于基础监控,成图非常漂亮
- cacti、nagios、zabbix服务端监控中心,需要php环境支持,其中zabbix和cacti都需要mysql作为数据存储,nagios不用存储历史数据,注重服务或者监控项的状态,zabbix会获取服务或者监控项目的数据,会把数据记录到数据库里,从而可以成图
- open-falcon为小米公司开发,开源后受到诸多大公司和运维工程师的追捧,适合大企业,滴滴、360、新浪微博、京东等大公司在使用这款监控软件,值得研究
zabbix监控介绍
- C/S架构,基于C++开发,监控中心支持web界面配置和管理,需要php和mysql支持
- 单server节点可以支持上万台客户端
- 最新版本3.4,官方文档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 repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm,下载zabbix源并安装源,客户端也要安装
[[email protected] ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm 警告:zabbix-release-3.2-1.el7.noarch.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:zabbix-release-3.2-1.el7 ################################# [100%]
- 服务端安装zabbix
yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql
- 会连带安装httpd和php
- 如果mysql之前没有安装的话,需要根据lamp那一章的mysql安装方法安装mysql
- vim /etc/my.cnf //需要增加配置
character_set_server = utf8 - 重启mysqld服务后,进入mysql命令行,创建zabbix库和用户
mysql> create database zabbix character set utf8; Query OK, 1 row affected (0.34 sec) mysql> grant all on zabbix.* to ‘zabbix‘@‘127.0.0.1‘ identified by ‘s5381561‘; Query OK, 0 rows affected (0.05 sec)
- 导入数据
[[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]# ls AUTHORS ChangeLog COPYING create.sql NEWS README [[email protected] zabbix-server-mysql-3.2.11]# mysql -uroot -ps5381561 zabbix < create.sql Warning: Using a password on the command line interface can be insecure.
- 开启服务并开机启动
如果有nginx服务需要先停掉并禁掉开机启动 [[email protected] ~]# systemctl stop nginx [[email protected] ~]# chkconfig nginx off [[email protected] ~]# systemctl start httpd [[email protected] ~]# systemctl enable httpd [[email protected] ~]# systemctl start zabbix-server [[email protected] ~]# systemctl enable zabbix-server [[email protected] ~]# ps aux |grep zabbix zabbix 2048 0.0 0.1 254588 3496 ? S 22:56 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf root 2154 0.0 0.0 112676 984 pts/0 S+ 23:01 0:00 grep --color=auto zabbix
- 修改配置文件
[[email protected] ~]# vim /etc/zabbix/zabbix_server.conf DBHost=127.0.0.1 DBName=zabbix DBUser=zabbix DBPassword=s5381561 [[email protected] ~]# systemctl restart zabbix-server [[email protected] ~]# netstat -lntp |grep zabbix tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 2176/zabbix_server tcp6 0 0 :::10051 :::* LISTEN 2176/zabbix_server
- 在浏览器里输入http://192.168.21.128/zabbix/进入zabbix的web界面,点击下一步
- PHP option "date.timezone" unknown Fail提示时区不对
[[email protected] ~]# vim /etc/php.ini date.timezone = Asia/Shanghai [[email protected] ~]# systemctl restart httpd
- 下一步,定义mysql信息和主机名,最后完成
- 默认用户名Admin 密码zabbix
- 进入后台第一件事情就是修改密码,改中文
- 在客户端上也需要下载zabbix的yum源
- yum install -y zabbix-agent
- vim /etc/zabbix/zabbix_agentd.conf //修改如下配置
Server=127.0.0.1修改为Server=192.168.21.128 //定义服务端的ip(被动模式) ServerActive=127.0.0.1修改为ServerActive=192.168.21.128 //定义服务端的ip(主动模式) Hostname=Zabbix server修改为Hostname=Zabbix server //这是自定义的主机名,一会还需要在web界面下设置同样的主机名
- 启动服务并开机启动
[[email protected] ~]# systemctl start zabbix-agent [[email protected] ~]# systemctl enable zabbix-agent Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
忘记Admin密码如何做
[[email protected] ~]# mysql -uroot -ps5381561 mysql> use zabbix mysql> desc users; #密码存在users表里 +----------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------------+------+-----+---------+-------+ | userid | bigint(20) unsigned | NO | PRI | NULL | | | alias | varchar(100) | NO | UNI | | | | name | varchar(100) | NO | | | | | surname | varchar(100) | NO | | | | | passwd | char(32) | NO | | | | | url | varchar(255) | NO | | | | | autologin | int(11) | NO | | 0 | | | autologout | int(11) | NO | | 900 | | | lang | varchar(5) | NO | | en_GB | | | refresh | int(11) | NO | | 30 | | | type | int(11) | NO | | 1 | | | theme | varchar(128) | NO | | default | | | attempt_failed | int(11) | NO | | 0 | | | attempt_ip | varchar(39) | NO | | | | | attempt_clock | int(11) | NO | | 0 | | | rows_per_page | int(11) | NO | | 50 | | +----------------+---------------------+------+-----+---------+-------+ 16 rows in set (0.00 sec) mysql> update users set passwd=md5(‘5381561‘) where alias=‘Admin‘; #更改Admin用户密码 Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from users; #目前有俩个用户 +--------+-------+--------+---------------+----------------------------------+-----+-----------+------------+-------+---------+------+---------+----------------+------------+---------------+---------------+ | userid | alias | name | surname | passwd | url | autologin | autologout | lang | refresh | type | theme | attempt_failed | attempt_ip | attempt_clock | rows_per_page | +--------+-------+--------+---------------+----------------------------------+-----+-----------+------------+-------+---------+------+---------+----------------+------------+---------------+---------------+ | 1 | Admin | Zabbix | Administrator | 8735d2f54dde47455a2558e0f138dc89 | | 1 | 0 | zh_CN | 30 | 3 | default | 0 | | 0 | 50 | | 2 | guest | | | d41d8cd98f00b204e9800998ecf8427e | | 0 | 900 | en_GB | 30 | 1 | default | 0 | | 0 | 50 | +--------+-------+--------+---------------+----------------------------------+-----+-----------+------------+-------+---------+------+---------+----------------+------------+---------------+---------------+ 2 rows in set (0.00 sec)
原文地址:http://blog.51cto.com/akui2521/2137391
时间: 2024-10-10 10:51:49