Construction of Linux Monitoring Platform (1)--Introduction

A Linux monitoring platform introduction

Common open source monitoring software

  1. cacti、nagios、zabbix、smokeping、open-falcon等等
  2. cacti and smokeping tend to be basic monitoring, and the graphics are very beautiful.
    These two are suitable for monitoring network devices.
  3. The cacti, nagios, and zabbix server 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 items. The data will be recorded in the database, so that it can be graphed
  4. 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.
  5. The follow-up will mainly introduce zabbix

Two zabbix monitoring software introduction

  1. C/S architecture, based on C++ development, the monitoring center supports web interface configuration and management
    requires an agent, which means that a service must be started on the client side. This service is responsible for collecting data, and this data will be actively reported to the server. The server can be connected to the client to capture this data, so there are two modes: active mode and passive mode.
  2. A single server node can support tens of thousands of clients.
    The bottleneck lies in the amount of data collected. When the scale of the server reaches a certain level, some optimizations need to be done. For example, some proxy points can be added to act as the server and replace the server to collect data. data, and then he gets the analysis results and reports to the server
  3. The latest version 3.4, official documentation https://www.zabbix.com/manuals
  4. 5 components
  5. zabbix-server monitoring center, receives the information reported by the client, and is responsible for configuration, statistics, and operation data
  6. Data storage stores data, such as mysql
  7. The web interface is also called web UI. The operation configuration under the web interface is the main reason why zabbix is ​​easy to use.
  8. zabbix-proxy is an optional component, which can replace the function of zabbix-server and reduce the pressure on the server
  9. zabbix-agent client software, responsible for collecting the data of each monitoring service or project and reporting it

Zabbix monitoring flow chart

Enter image description

Three install zabbix

  1. Official website download address www.zabbix.com/download
  2. wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
  3. rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm In fact, we can see that installing this package is installing a yum source
[root@lijie-01 src]# ls !$ 
ls /etc/yum.repos.d/
CentOS7-Base-163.repo  CentOS-fasttrack.repo  CentOS-Vault.repo  zabbix.repo
CentOS-CR.repo         CentOS-Media.repo      epel.repo
CentOS-Debuginfo.repo  CentOS-Sources.repo    epel-testing.repo
[root@lijie-01 src]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/3.2/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch 
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
[root@lijie-01 src]# 
  1. Install zabbix server, frontend, proxy
# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql

Among them, zabbix-agent is the client software, zabbix-get is a tool used on the server, this tool can obtain the data of some monitoring items on the client through the command line, zabbix-server-mysql is to install some follow-up mysql related files, zabbix-web is web UI, zabbix-web-mysql is to install some files related to web and mysql

  1. Will install httpd and php together
作为依赖被安装:
  OpenIPMI-libs.x86_64 0:2.0.19-15.el7          OpenIPMI-modalias.x86_64 0:2.0.19-15.el7    
  apr.x86_64 0:1.4.8-3.el7_4.1                  apr-util.x86_64 0:1.5.2-6.el7               
  dejavu-fonts-common.noarch 0:2.33-6.el7       dejavu-sans-fonts.noarch 0:2.33-6.el7       
  fontpackages-filesystem.noarch 0:1.44-8.el7   fping.x86_64 0:3.10-4.el7                   
  httpd.x86_64 0:2.4.6-67.el7.centos.6          httpd-tools.x86_64 0:2.4.6-67.el7.centos.6  
  iksemel.x86_64 0:1.4-6.el7                    libX11.x86_64 0:1.6.5-1.el7                 
  libX11-common.noarch 0:1.6.5-1.el7            libXau.x86_64 0:1.0.8-2.1.el7               
  libXpm.x86_64 0:3.5.12-1.el7                  libxcb.x86_64 0:1.12-1.el7                  
  libzip.x86_64 0:0.10.1-8.el7                  mailcap.noarch 0:2.1.41-2.el7               
  php.x86_64 0:5.4.16-43.el7_4.1                php-bcmath.x86_64 0:5.4.16-43.el7_4.1       
  php-cli.x86_64 0:5.4.16-43.el7_4.1            php-common.x86_64 0:5.4.16-43.el7_4.1       
  php-gd.x86_64 0:5.4.16-43.el7_4.1             php-ldap.x86_64 0:5.4.16-43.el7_4.1         
  php-mbstring.x86_64 0:5.4.16-43.el7_4.1       php-mysql.x86_64 0:5.4.16-43.el7_4.1        
  php-pdo.x86_64 0:5.4.16-43.el7_4.1            php-xml.x86_64 0:5.4.16-43.el7_4.1          
  t1lib.x86_64 0:5.1.2-14.el7                   unixODBC.x86_64 0:2.3.1-11.el7              
完毕!
  1. If mysql has not been installed before, you need to install mysql according to the mysql installation method in the lamp chapter, and then start mysql
# systemctl start mysql
  1. Edit the mysql configuration file vim /etc/my.cnf to set the character set to utf8Enter image description
  2. After restarting the mysqld service, log in to the mysql command line, create the zabbix library, and specify the character set at the same time
[root@lijie-01 src]# mysql -uroot -p112233
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 6
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;
Query OK, 1 row affected (0.01 sec)
mysql> 
  1. Create a user again. This user allows the web code to connect to the mysql database. The prerequisite for the zabbix service to start is to be able to connect to the database.
mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by '112233';
Query OK, 0 rows affected (0.11 sec)
mysql> 
  1. Import the data that comes with zabbix
[root@lijie-01 src]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/       切换到自带数据所在目录
[root@lijie-01 zabbix-server-mysql-3.2.11]# ls    可以看到数据压缩包
AUTHORS  ChangeLog  COPYING  create.sql.gz  NEWS  README
[root@lijie-01 zabbix-server-mysql-3.2.11]# gzip -d create.sql.gz    解压
[root@lijie-01 zabbix-server-mysql-3.2.11]# ls
AUTHORS  ChangeLog  COPYING  create.sql  NEWS  README
[root@lijie-01 zabbix-server-mysql-3.2.11]# mysql -uroot -p112233 zabbix < create.sql  恢复数据到zabbix库
Warning: Using a password on the command line interface can be insecure.
[root@lijie-01 zabbix-server-mysql-3.2.11]# systemctl start zabbix-server  启动zabbix服务
[root@lijie-01 zabbix-server-mysql-3.2.11]# systemctl start httpd^C
  1. start httpd service
[root@lijie-01 zabbix-server-mysql-3.2.11]# ps aux |grep nginx   查看nginx是否占用80端口
root      6716  0.0  0.0 112676   984 pts/0    S+   17:15   0:00 grep --color=auto nginx
[root@lijie-01 zabbix-server-mysql-3.2.11]# systemctl start httpd  启动httpd服务      
[root@lijie-01 zabbix-server-mysql-3.2.11]# systemctl enable httpd     
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@lijie-01 zabbix-server-mysql-3.2.11]# 
  1. Modify the configuration file vim /etc/zabbix/zabbix_server.conf Configure the account password for connecting to the database host DBHost=127.0.0.1 //Add DBName= zabbix
    above
    DBName= zabbix DBUser =zabbix DBPassword=112233 //Add under DBuser

  2. netstat -lntp |grep zabbix //View the listening port
[root@lijie-01 ~]# systemctl start zabbix-server
[root@lijie-01 ~]# systemctl enable zabbix-server
[root@lijie-01 zabbix-server-mysql-3.2.11]# systemctl disable nginx   禁止nginx启动
nginx.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig nginx off
[root@lijie-01 zabbix-server-mysql-3.2.11]# chkconfig nginx off
[root@lijie-01 ~]# ps aux |grep zabbix   
zabbix    7388  2.0  0.2 254760  4168 ?        S    00:16   0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
zabbix    7391  0.0  0.1 254760  2520 ?        S    00:16   0:00 /usr/sbin/zabbix_server: configuration syncer [waiting 60 sec for processes]
zabbix    7392  0.0  0.1 254760  2732 ?        S    00:16   0:00 /usr/sbin/zabbix_server: db watchdog [synced alerts config in 0.004178 sec, idle 60 sec]
zabbix    7393  0.8  0.2 361704  5244 ?        S    00:16   0:00 /usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000009 sec, idle 5 sec]
zabbix    7394  1.1  0.2 361704  5244 ?        S    00:16   0:00 /usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000010 sec, idle 5 sec]
zabbix    7395  1.1  0.2 361704  5244 ?        S    00:16   0:00 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000008 sec, idle 5 sec]
zabbix    7396  1.1  0.2 361704  5244 ?        S    00:16   0:00 /usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000247 sec, idle 5 sec]
zabbix    7397  1.0  0.2 361704  5244 ?        S    00:16   0:00 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000008 sec, idle 5 sec]
zabbix    7398  1.4  0.2 361704  5244 ?        S    00:16   0:00 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000008 sec, idle 5 sec]
zabbix    7399  0.3  0.1 254760  3628 ?        S    00:16   0:00 /usr/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection]
zabbix    7400  0.1  0.1 254760  3624 ?        S    00:16   0:00 /usr/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection]
zabbix    7401  0.0  0.1 254760  3628 ?        S    00:16   0:00 /usr/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection]
zabbix    7402  0.0  0.1 254760  3628 ?        S    00:16   0:00 /usr/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection]
zabbix    7403  0.0  0.1 254760  3628 ?        S    00:16   0:00 /usr/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection]
zabbix    7407  0.0  0.1 257336  2660 ?        S    00:16   0:00 /usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000004 sec, idle 5 sec]
zabbix    7408  0.0  0.1 254760  2736 ?        S    00:16   0:00 /usr/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.004105 sec, idle 30 sec]
zabbix    7410  0.0  0.1 254760  2516 ?        S    00:16   0:00 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes]
zabbix    7411  0.0  0.1 254760  2736 ?        S    00:16   0:00 /usr/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 events in 0.000000 sec, 0 maintenances in 0.000000 sec, idle 21 sec]
zabbix    7413  0.1  0.1 254760  2876 ?        S    00:16   0:00 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.001905 sec, idle 5 sec]
zabbix    7414  1.4  0.2 359120  5032 ?        S    00:16   0:00 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.009963 sec, idle 60 sec]
zabbix    7416  0.0  0.1 254760  2864 ?        S    00:16   0:00 /usr/sbin/zabbix_server: history syncer #1 [synced 0 items in 0.000001 sec, idle 1 sec]
zabbix    7418  0.0  0.1 254760  2864 ?        S    00:16   0:00 /usr/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000003 sec, idle 1 sec]
zabbix    7420  0.0  0.1 254760  2864 ?        S    00:16   0:00 /usr/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000002 sec, idle 1 sec]
zabbix    7422  0.0  0.1 254760  2864 ?        S    00:16   0:00 /usr/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000002 sec, idle 1 sec]
zabbix    7424  0.2  0.2 254760  3808 ?        S    00:16   0:00 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.004486 sec, idle 3 sec]
zabbix    7425  0.1  0.2 254760  3808 ?        S    00:16   0:00 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000006 sec, idle 5 sec]
zabbix    7426  0.0  0.1 254760  2628 ?        S    00:16   0:00 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000009 sec, idle 1 sec]
zabbix    7428  0.0  0.1 254760  2852 ?        S    00:16   0:00 /usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.003621 sec, idle 5 sec]
root      7439  0.0  0.0 112680   984 pts/1    S+   00:16   0:00 grep --color=auto zabbix
[root@lijie-01 ~]# netstat -lntp |grep zabbix
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      7388/zabbix_server  
tcp6       0      0 :::10051                :::*                    LISTEN      7388/zabbix_server  
[root@lijie-01 ~]# 
  1. Configure the web interface Open the browser to visit http://192.168.75.136/zabbix/ The web interface configures zabbix Enter image description
    and click Next to enter the following page. We don’t care about the OK option. You can see that there is a fail item, timezone time zone fail, Enter image descriptionthis When we need to go to the php configuration file /etc/php.ini to find the timezone, set date.timezone=Asia/shanghai or chongqin, after the configuration is complete, we need to restart the apache service, and then refresh the page just now, you can see that the time zone has been OK Enter image descriptionand then click Next, here we need to fill in the mysql related information Enter image descriptionClick Next Enter image descriptionNext Next Enter image descriptionNextEnter image description
  2. Login Click Finish to enter the login interface and fill in the login information. After logging in Enter image description
    with the default username Admin and password zabbix, enter the home page as followsEnter image description
  3. The first thing to do when entering the background is to change the password and enter the personal information center of the admin user in the order shown below. After Enter image descriptionentering , click Change Password, fill in the new password twice, and change the language to Chinese Enter image description. After the modification is complete, click the update below to update the settings, and then Refresh, the interface will become ChineseEnter image description

4 What to do if you forget the Admin password

If you forget the password, we can directly enter the users table of mysql's zabbix library to modify the database data.

  1. Enter the mysql command line and select the zabbix library
[root@lijie-01 ~]# mysql -uroot -p112233
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 464
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> 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> 
  1. change the password
mysql> update users set passwd=md5('112233') where alias='Admin';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

This changed the password of the Admin user

Five zabbix client installation

  1. You also need to download the yum source of zabbix on the client
# wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
  1. install yum source
# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm 
  1. Install the client
# yum install -y zabbix-agent   
  1. vim /etc/zabbix/zabbix_agentd.conf //Modify the following configuration
    Server=127.0.0.1 to Server=192.168.75.136 //Define the ip of the server (passive mode) ServerActive=127.0.0.1 to ServerActive=192.168.75.136 // Define the ip of the server (active mode)
    Hostname=Zabbix server is changed to Hostname=lijie-01 //This is a custom hostname, and the same hostname needs to be set in the web interface for a while
  2. systemctl start zabbix-agent
[root@lijie-02 src]# systemctl start zabbix-agent
[root@lijie-02 src]# ps aux |grep zabbix
zabbix   50606  0.0  0.0  82964  1272 ?        S    01:46   0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix   50607  0.0  0.0  82964  1432 ?        S    01:46   0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix   50608  0.0  0.0  82964  1852 ?        S    01:46   0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix   50609  0.0  0.0  82964  1852 ?        S    01:46   0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix   50610  0.0  0.0  82964  1852 ?        S    01:46   0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix   50611  0.0  0.1  83096  2208 ?        S    01:46   0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root     50621  0.0  0.0 112680   980 pts/1    S+   01:46   0:00 grep --color=auto zabbi
[root@lijie-02 src]# netstat -lntp |grep zabbix    可以看到监控的端口为10050
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      50606/zabbix_agentd 
tcp6       0      0 :::10050                :::*                    LISTEN      50606/zabbix_agentd 
  1. systemctl enable zabbix-agent
[root@lijie-02 src]# 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.
[root@lijie-02 src]# 

Guess you like

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