Monitoring Server deployment zabbix

A, zabbix run architecture
Zabbix is an enterprise-class open source distributed monitoring solution. It can monitor the health of reliability, stability and various applications of the various network servers. When an exception occurs monitoring, Zabbix through flexible alarm policy, you can configure e-mail, text messaging, micro-letters warning mechanism for any event. And this all, and can be configured through the web interface provided by Zabbix, web-based front page also provides excellent reporting and data visualization capabilities. These functions and features allow operation and maintenance personnel can very easily build a powerful set of operation and maintenance monitoring and management platform.

Zabbix operational structure is as follows:

Monitoring Server deployment zabbix

The above operation can be seen from FIG architecture, there are several components that Zabbix, are as follows:
. 1, Zabbix Server
Zabbix Zabbix Server is the core component, all the configuration information, the memory core operation data and statistics. It is mainly responsible for receiving reports sent by the client and information, at the same time, all configuration, statistical data and configuration data by the operation of their organizations.

2, Zabbix Database Storage
primarily used to store data, all the data collected Zabbix configuration information and are stored in a database. You can use MySQL, oracle, SQLite and so on.

3, Zabbix Web interface
that is provided by Zabbix GUI interface, usually (but not necessarily) with Zabbix Server running on the same physical machine.

4, Zabbix Proxy proxy server
This is an optional component, commonly used in distributed monitoring environment, new proxy Server can collect performance and availability data, summarized and sent to Zabbix Server unified end for Zabbix.

5, Zabbix Agent monitoring agent
Zabbix Agent deployed on the monitored host that actively monitor local resources and applications, and is responsible for the collection of data sent to Zabbix Server Zabbix Proxy end or end.
Two, Zabbix term monitoring
in Zabbix monitoring system, some common terms, the following is a brief description.

1, the host (Host)
would monitor a server or network device can be specified by the host name or IP.

2, the host group (host group)
a logical group of hosts: it contains a host and a template, but within the same host group of host and the template without any direct correlation; host group commonly used in assigning monitoring privileges to users or user groups.

3, monitored item (item)
shows a specific object of monitoring, such as CPU load, disk space monitoring server, the data item is a Core Zabbix collected relative to a monitored object, each item by "key" to identify .

4, the trigger (Trigger)
is actually monitoring a threshold value expression, for assessing whether the monitored object in the received data is within a reasonable range; if the received data is greater than the threshold value, the state of the flip-flop from "OK" into "Problem", when the received data is below a threshold, and the transition is "OK" state.

5, the application set (the Applications)
a logical collection of a group consisting of monitored items.

6, the operation (action)
means a processing method for monitoring problems occurring in previously defined, such as sending notification, when to perform operations, the frequency of execution and so on.

7, the type of alarm media (Media)
represents means for transmitting a notification, the route alarm notification, such as Email, Jabber, or the like SMS.

8, the template (Template)
a group may be applied to achieve the set of one or more hosts, usually contains a template set of applications, monitored item, triggers, graphics, graphics polymerization, automatic discovery several rules, web scenes, etc. project; templates can link directly to a host.

Templates are learning zabbix a difficult and key, in order to achieve volume, automated monitoring, monitored items will usually have the same characteristics are summarized into a template, and then direct reference to the host, monitor for rapid deployment.
Third, the deployment of Zabbix monitoring platform
Zabbix monitoring platform deployment is relatively simple, the premise is ready LNMP or LAMP environment
I have here from the beginning of the deployment environment LNMP configuration.

Note: I will be here all the services deployed on the same server, just a simple monitoring framework, and not deployed zabbix proxy and so on.

Zabbix Official Links:
Zabbix 4.2 configuration files: https://www.zabbix.com/documentation/4.2/manual/it_services
required packages: https://pan.baidu.com/s/1UzzoFUuR84U2ccDf1qW2UQ
extraction code: grhh
1, deploy Nginx

[root@zabbix /]# mkdir /zabbix           # 个人习惯,可忽略
[root@zabbix /]# cd zabbix/
[root@zabbix zabbix]# rz   # shangchaun上传所需源码包
[root@zabbix zabbix]# tar zxf nginx-1.14.0.tar.gz 
[root@zabbix zabbix]# cd nginx-1.14.0/
[root@zabbix nginx-1.14.0]# yum -y install pcre-devel openssl-devel zlib-devel
[root@zabbix zabbix]# cd nginx-1.14.0/
[root@zabbix nginx-1.14.0]# useradd -s /sbin/nologin -M www
[root@zabbix nginx-1.14.0]# ./configure --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module  --with-http_sub_module --with-http_flv_module  --with-http_mp4_module  --with-pcre=/usr/src/pcre-8.39 --with-zlib=/usr/src/zlib-1.2.8 --with-http_ssl_module --with-http_gzip_static_module --user=www --group=www && make && make install
[root@zabbix /]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
[root@zabbix /]# vim /usr/local/nginx/conf/nginx.conf
   server {
        listen       80;
        location / {
            root   html;
            index index.php index.html index.htm;    #添加index.php
        }
                #注意删除下面段落的注释符号
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;   #修改此行
        }
[root@zabbix /]# netstat -anput |grep  80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      46551/nginx: master 
[root@zabbix /]# cat > /usr/local/nginx/html/index.php << EOF     # 创建测试文件
> <?php
> phpinfo();
> ?>
> EOF

2, deployment of PHP

[root@zabbix /]# yum -y install libxml2-devel openssl-devel bzip2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel           # 安装依赖包
[root@zabbix /]# cd /zabbix/
[root@zabbix zabbix]# tar zxf libmcrypt-2.5.7.tar.gz          
[root@zabbix zabbix]# cd libmcrypt-2.5.7/
[root@zabbix libmcrypt-2.5.7]# ./configure --prefix=/usr/local/libmcrypt && make && make install      # 编译并安装
[root@zabbix libmcrypt-2.5.7]# cd ..
[root@zabbix zabbix]# tar zxf php-5.6.27.tar.gz 
[root@zabbix php-5.6.27]# ./configure --prefix=/usr/local/php5.6 --with-config-file-path=/etc --with-mysql=mysqlnd  --with-mysqli=mysqlnd --with-gd  --with-iconv --with-libxml-dir=/usr --with-mhash  --with-mcrypt=/usr/local/libmcrypt  --with-config-file-scan-dir=/etc/php.d  --with-bz2  --with-zlib --with-freetype-dir --with-png-dir --with-jpeg-dir --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip  --enable-soap  --without-pear  --with-gettext  --enable-session --with-curl && make && make install
[root@zabbix php-5.6.27]# cp php.ini-production /etc/php.ini
[root@zabbix php-5.6.27]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@zabbix php-5.6.27]# chmod +x /etc/init.d/php-fpm 
[root@zabbix php-5.6.27]# chkconfig --add php-fpm
[root@zabbix php-5.6.27]# chkconfig php-fpm on
[root@zabbix php-5.6.27]# cp /usr/local/php5.6/etc/php-fpm.conf.default /usr/local/php5.6/etc/php-fpm.conf
[root@zabbix php-5.6.27]# cd /
[root@zabbix /]# sed -i 's/pm.max_children = 5/pm.max_children = 50/g' /usr/local/php5.6/etc/php-fpm.conf
[root@zabbix /]# sed -i 's/pm.start_servers = 2/pm.start_servers = 5/g' /usr/local/php5.6/etc/php-fpm.conf
[root@zabbix /]# sed -i 's/pm.min_spare_servers = 1/pm.min_spare_servers = 5/g' /usr/local/php5.6/etc/php-fpm.conf
[root@zabbix /]# sed -i 's/pm.max_spare_servers = 3/pm.max_spare_servers = 35/g' /usr/local/php5.6/etc/php-fpm.conf
[root@zabbix /]# service php-fpm start     # 启动php
Starting php-fpm  done
[root@zabbix /]# netstat -anput | grep 9000
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      60347/php-fpm: mast 

Client Access-defined php page:
Monitoring Server deployment zabbix
3, install and configure the MySQL database

[root@zabbix ~]# sh mysql.sh           # 执行脚本,等待一会出现如下提示表示安装成功
Starting MySQL. SUCCESS! 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix ~]# mysql -uroot -p123        #登录MySQL
mysql> create database zabbix character set utf8;
mysql> grant all on zabbix.* to zabbix@'localhost' identified by '123.com';
mysql> grant all on zabbix.* to zabbix@'192.168.171.%' identified by '123.com';
mysql> exit

4, service deployment zabbix

[root@zabbix zabbix]# tar zxf fping-3.12.tar.gz
[root@zabbix zabbix]# tar zxf zabbix-3.2.1.tar.gz 
[root@zabbix zabbix]# cd fping-3.12/
[root@zabbix fping-3.12]# ./configure && make && make install
[root@zabbix fping-3.12]# cd ../zabbix-3.2.1/
[root@zabbix zabbix-3.2.1]# useradd -M -s /sbin/nologin zabbix
[root@zabbix zabbix-3.2.1]# chown zabbix:zabbix /usr/local/sbin/fping 
[root@zabbix zabbix-3.2.1]# yum -y install net-snmp net-snmp-devel curl-devel java-1.8.0-openjdk java-1.8.0-openjdk-devel OpenIPMI-devel libssh2-devel
[root@zabbix zabbix-3.2.1]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-java --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-openipmi && make && make install
#--enable-java:方便后续监控 tomcat 程序所用
#--with-openipmi:用户可以利用 IPMI 监视服务器的物理特征,如温度、电压、风扇工作状态、电源供应等
[root@zabbix zabbix-3.2.1]# ln -s /usr/local/zabbix/bin/* /usr/local/bin/
[root@zabbix zabbix-3.2.1]# ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/
#导入zabbix数据到MySQL,注意导入的顺序,如果导入后返回提示信息,可忽略,是因为导入的命令将密码展示在了终端
[root@zabbix zabbix-3.2.1]# pwd
/zabbix/zabbix-3.2.1
[root@zabbix zabbix-3.2.1]# cd  database/mysql/
[root@zabbix mysql]# mysql -u zabbix -p123.com -h localhost zabbix < schema.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix mysql]# mysql -u zabbix -p123.com -h localhost zabbix < images.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix mysql]# mysql -u zabbix -p123.com -h localhost zabbix < data.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix mysql]# chown -R zabbix:zabbix /usr/local/zabbix/

5, optimization and start zabbix

#修改zabbix配置文件
[root@zabbix /]# sed -i 's/# ListenPort=10051/ListenPort=10051/g' /usr/local/zabbix/etc/zabbix_server.conf
[root@zabbix /]# sed -i 's/LogFile=\/tmp\/zabbix_server.log/LogFile=\/usr\/local\/zabbix\/logs\/zabbix_server.log/g' /usr/local/zabbix/etc/zabbix_server.conf
[root@zabbix /]# sed -i 's/# PidFile=\/tmp\/zabbix_server.pid/PidFile=\/usr\/local\/zabbix\/logs\/zabbix_server.pid/g' /usr/local/zabbix/etc/zabbix_server.conf
[root@zabbix /]# sed -i 's/# DBHost=localhost/DBHost=localhost/g' /usr/local/zabbix/etc/zabbix_server.conf
[root@zabbix /]# sed -i 's/# DBPassword=/DBPassword=123.com/g' /usr/local/zabbix/etc/zabbix_server.conf[root@zabbix /]# sed -i 's/# DBSocket=\/tmp\/mysql.sock/DBSocket=\/usr\/local\/mysql\/mysql.sock/g' /usr/local/zabbix/etc/zabbix_server.conf
[root@zabbix /]# sed -i 's/# DBPort=3306/DBPort=3306/g' /usr/local/zabbix/etc/zabbix_server.conf
[root@zabbix /]# sed -i 's/# FpingLocation=\/usr\/sbin\/fping/FpingLocation=\/usr\/local\/sbin\/fping/g' /usr/local/zabbix/etc/zabbix_server.conf
[root@zabbix /]# sed -i 's/# LogSlowQueries=0/LogSlowQueries=3000/g' /usr/local/zabbix/etc/zabbix_server.conf
#如果数据库名称和数据库用户没有和我创建的一样,那么还需要更改以下两项
#DBName=zabbix     #数据库名称
#DBUser=zabbix     #登录数据库的用户名
[root@zabbix /]# echo "/usr/local/mysql/lib" >> /etc/ld.so.conf
[root@zabbix /]# ldconfig             # 刷新上面更改的配置
[root@zabbix /]# mkdir /usr/local/zabbix/logs
[root@zabbix /]# chown -R zabbix:zabbix /usr/local/zabbix/
[root@zabbix /]# cd /zabbix/zabbix-3.2.1/misc/init.d/fedora/core
[root@zabbix core]# cp zabbix_agentd /etc/init.d/
[root@zabbix core]# cp zabbix_server /etc/init.d/
[root@zabbix core]# sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_server 
[root@zabbix core]# sed -i 's/PIDFILE=\/tmp\/$BINARY_NAME.pid/PIDFILE=\/usr\/local\/zabbix\/logs\/$BINARY_NAME.pid/g' /etc/init.d/zabbix_server 
[root@zabbix core]# /etc/init.d/zabbix_server start         #启动zabbix,也可以执行“zabbix-server”来启动 
Reloading systemd:                                         [  OK  ]
Starting zabbix_server (via systemctl):                    [  OK  ]
[root@zabbix core]# netstat -anput | grep 10051
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      74199/zabbix_server 
[root@zabbix core]# cd /zabbix/zabbix-3.2.1/frontends/
[root@zabbix frontends]# cp -r php/ /usr/local/nginx/html/zabbix

6, client access nginx proxy to configure zabbix
access Nignx server IP / zabbix can, it will automatically jump to the following page:
Monitoring Server deployment zabbix
Monitoring Server deployment zabbix
above there is something wrong about php configuration items do not meet their requirements:

[root@zabbix /]# sed -i 's/post_max_size = 8M/post_max_size =16M/g' /etc/php.ini 
[root@zabbix /]# sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php.ini 
[root@zabbix /]# sed -i 's/max_input_time = 60/max_input_time = 300/g' /etc/php.ini 
[root@zabbix /]# sed -i 's/;date.timezone =/date.timezone = Asia\/Shanghai/g' /etc/php.ini 
[root@zabbix /]# sed -i 's/;always_populate_raw_post_data = -1/always_populate_raw_post_data = -1/g' /etc/php.ini 
[root@zabbix /]# service php-fpm restart             # 重启服务
Gracefully shutting down php-fpm . done
Starting php-fpm  done

Monitoring Server deployment zabbix
Monitoring Server deployment zabbix
Monitoring Server deployment zabbix
Monitoring Server deployment zabbix
And error, not prompted to create a profile, let us manually download the configuration file and upload it to the specified directory, then click to download

[root@zabbix /]# ls /usr/local/nginx/html/zabbix/conf/zabbix.conf.php
/usr/local/nginx/html/zabbix/conf/zabbix.conf.php

Monitoring Server deployment zabbix
Zabbix enter user name and password to log in (the default user name: admin, password: zabbix):
Monitoring Server deployment zabbix
Monitoring Server deployment zabbix
7, solve the subsequent charting of Chinese garbage problem

[root@zabbix ~]# cd /usr/local/nginx/html/zabbix/fonts/    #切换至该目录
[root@zabbix fonts]# rz
[root@zabbix fonts]# ls
DejaVuSans.ttf  simkai.ttf
[root@zabbix fonts]# sed -i 's/DejaVuSans/simkai/g' /usr/local/nginx/html/zabbix/include/defines.inc.php 

Guess you like

Origin blog.51cto.com/14227204/2474670