Zabbix monitoring system (1) platform introduction, installation, what to do if you forget your password

1. Introduction to Linux monitoring platform

Common Linux monitoring platforms include cacti, nagios, zabbix, smokeping, open-falcon, etc.

  • cacti and smokeping are biased towards basic monitoring, and the mapping is very beautiful

  • The cacti, nagios, and zabbix server-side monitoring centers require php environment support. Both zabbix and cacti require mysql as data storage. Nagios does not need to store historical data, but focuses on the status of services or monitoring items. Zabbix will obtain the data of services or monitoring projects. The data will be recorded in the database, so that it can be graphed. These softwares have a web interface.

  • open-falcon was developed by Xiaomi. After open source, it is sought after by many large companies and operation and maintenance engineers. It is suitable for large enterprises. Big companies such as Didi, 360, Sina Weibo, JD.com are using this monitoring software, and it is worth studying.

2. Introduction to zabbix monitoring

C/S architecture (the monitored server needs to install monitoring software, it can actively connect to the client, or passively let the client push its own status), based on C++ development, the monitoring center supports web interface configuration and management.

A single server node can support tens of thousands of clients (it can support tens of thousands of server monitoring at the same time, the concurrency is high, if it exceeds a certain amount, the performance may be reduced, but we can increase the proxy point to act as a monitoring server to reduce the pressure )

2.1 5 components

  • The zabbix-server monitoring center receives the information reported by the client and is responsible for configuration, statistics, and operation data.

  • Data storage Store data, such as mysql.

  • The web interface is also called web UI , and the operation and configuration under the web interface is the main reason why zabbix is ​​easy to use.

  • zabbix-proxy is an optional component , which can replace the function of zabbix-server and reduce the pressure on the server.

  • zabbix-agent client software , responsible for collecting the data of each monitoring service or project and reporting it

2.2 zabbix monitoring flow chart

Enter image description

3. Install zabbix

3.1 Preparations

Because of the characteristics of Zabbix, it needs 2 at least 2 servers, 1 monitoring server, 1 client, PHP and Mysql environment support, as well as its own web UI, and httpd support.

CPU name IP address Role
yt-04 192.168.2.134 server
yt-05 192.168.2.135 cilent

The official website download address, the 2.2 version of the system's own yum source is very old, and the newer version is installed here using the corresponding version of the yum source officially provided by zabbix.

www.zabbix.com/download

We first configure the server, and then configure the client.

3.2 server installation zabbix

Before installing zabbix, you need to install its yum source repository

# 下载指定版本
[root@yt-04 src]# wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

# 安装zabbix的yum扩展源
[root@yt-04 src]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm

# 安装zabbix及其组件
[root@yt-04 src]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql

# zabbix-agent是客户端程序
# zabbix-get是服务端上命令行获取客户端检测项目的组件
# zabbix-server-mysql是zabbix-server MySQL组件
# zabbix-web是web界面组件
# zabbix-web-mysql:web界面MySQL相关组件
# 该过程会顺带安装上PHP和httpd服务。

3.3 Install and configure MySQL

Install MySQL

There are two ways to install mysql: 1. yum installation 2. compile mysql installation, you can refer to the previous LAMP installation process here to choose direct yum installation

[root@yt-04 src]# yum install -y mysql mysql-server mysql-devel 

[root@yt-04 src]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
ls -1 /etc/yum.repos.d/mysql-community*
yum install mysql-server


[root@yt-04 src]# systemctl start mysqld

[root@yt-04 src]# ps aux | grep mysql

Configure MySQL

[root@yt-04 src]# vim /etc/my.cnf 

# 需要增加配置。设置默认字符集的目的是让web UI可以正常的用中文显示。
character_set_server = utf8

# 重启mysqld服务
[root@yt-04 src]# /etc/init.d/mysqld restart

#进入mysql,创建zabbix库(类似安装wordpress,zabbix的web UI就是一个php写的监控网站)
[root@yt-04 ~]# mysql -uroot -p123456
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 '123456'; 
# 允许账户zabbix能从本机连接到数据库zabbix
Query OK, 0 rows affected (0.00 sec)

mysql> quit

3.4 Import the database that comes with zabbix

# 进入zabbix自带的数据库目录
[root@yt-04 ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/
[root@yt-04 zabbix-server-mysql-3.2.11]# ls
AUTHORS  ChangeLog  COPYING  create.sql.gz  NEWS  README

# 解压create.sql.gz包,导入到新建的zabbix库
[root@zhdy-04 zabbix-server-mysql-3.2.11]# gzip -d create.sql.gz
[root@z1 zabbix-server-mysql-3.2.11]# mysql -uroot -p123456 zabbix < create.sql

3.5 Start the zabbix service

# 启动zabbix服务
[root@yt-04 zabbix-server-mysql-3.2.11]# systemctl start zabbix-server

# 启动http服务(如果之前有配置nginx,或者tomcat(配置了80端口)服务一定要先停掉。不然启动httpd会报错)
[root@yt-04 zabbix-server-mysql-3.2.11]# systemctl start httpd.service
[root@yt-04 zabbix-server-mysql-3.2.11]# netstat -lntp |grep httpd
tcp6      0      0 :::80                  :::*                    LISTEN      2370/httpd      

# 把zabbix、http等服务设置开机启动  
[root@yt-04 ~]# 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@yt-04 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

3.6 View zabbix logs

[root@yt-04 ~]# less /var/log/zabbix/zabbix_server.log

3.7 Configure zabbix

[root@yt-04 ~]# vim /etc/zabbix/zabbix_server.conf 
# 更改配置文件

DBHost=127.0.0.1
# 此处写的是本机MySQL的IP,实际生产环境中zabbix可能单独使用一台机器,则要填实际IP地址
# 该IP应该和数据库授权时指定的IP一致
DBname=zabbix
DBUser=zabbix
DBPassword=123456

# 更改完成后,重启zabbix服务
[root@z1 ~]# systemctl restart zabbix-server.service

# 启动完成后查看其状态
[root@z1 ~]# ps aux |grep zabbix
netstat -lntp |grep zabbix
服务端zabbix默认监听10051端口

3.8 Install and configure the zabbix web interface

Use a browser to access the IP:192.168.2.134/zabbixinstallation guide interface on the server machine. Before performing this operation, ensure that the server has turned off the firewall.

Click "Next step" to enter the detection interface

Error : There is an error message here, the awareness is that PHP does not recognize "data.timezone" (timezone)

Solution : Edit the PHP configuration file and change the time zone

# 修改时区
[root@yt-04 ~]# vim /etc/php.ini 
date.timezone =Asia/Shanghai

# 重启httpd服务
[root@yt-05 ~]# systemctl restart httpd.service

Browser refresh, problem solved! Then, continue to click "Next step" to configure the database information

Click "Next step", set the server username (custom)

Continue to click "Next step" until the prompt interface appears

Installation is complete!

# 切记:配置好了之后,第一件事情

# 更改密码!更改密码!更改密码!

# Administration→Users→Admin→Change password

# 并且在修改密码下,可以更改web界面为中文。

4. zabbix client configuration

4.1 Install Zabbix client

# 下载指定版本
[root@yt-05 ~]# wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

# 安装zabbix的yum扩展源
[root@yt-05 ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm

# client端仅仅只需要安装服务
[root@yt-05 ~]# yum install -y zabbix-agent

# 配置mysql
(略)

4.2 Configure zabbix

[root@yt-05 ~]# vim /etc/zabbix/zabbix_agentd.conf
# 增加如下配置

Server=192.168.2.134
#定义监控服务端的ip
ServerActive=192.168.2.134
#定义监控服务端的ip,不过该参数决定了监控的 主/被动模式
#如果只有参数Server,则采用被动模式(只能等待服务端来采集信息)
#设置此参数,则为主动模式(客户端主动向服务端发送信息)
Hostname=yt-05 
#定义客户端主机名字,只是便于服务端识别,不参与实际的控制

# 启动zabbix服务
[root@yt-05 ~]# systemctl start zabbix-agent.service 

# 查看进程是否运行
[root@yt-05 ~]# ps aux | grep zabbix

# 查看监控的端口,默认端口是10050
[root@yt-05 ~]# netstat -lntp

# 设置为开机运行
[root@yt-05 ~]# systemctl enable zabbix-agent

5. What to do if you forget the Admin password

Modifying zabbix's administrator password (web interface) is similar to modifying wordpress and modifying mysql's own login password. Select the database directly in the database and select the user table to modify.

[root@yt-04 ~]# mysql -uroot
# 切换到zabbix库
> show databases;
> use zabbix;
> show tabales;
> desc users;

# 更改密码
mysql> update users set passwd=md5('123456') where alias='Admin';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> quit

这样就成功修改了zabbix管理web的登录密码为123456!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325173236&siteId=291194637