Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compile and install zabbix for Centos

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the "Centos how to compile and install zabbix" related knowledge, the editor through the actual case to show you the operation process, the method of operation is simple and fast, practical, I hope that this "Centos how to compile and install zabbix" article can help you solve the problem.

Introduction to zabbix

About zabbix zabbix is a completely open source tool, integrating features such as cacti and nagios. Snmp (udp 161x162) many network tools support this protocol, such as common route switching, os can be used as a management end, can also be managed side, snmp is roughly divided into three versions of v1 v2 v3, whether v1 and v2 their security is relatively poor, because the transmission is plaintext, v3 authentication password is encrypted with md5/sha digest algorithm.

Many tools support the function of network management, and the non-network devices (operating system) can be monitored without the insecure architecture of snmp, so many tools are control side and agent architecture, and they have their own agent.

The main functions of zabbix are:

With common commercial monitoring software functions such as: (host performance monitoring, network equipment performance monitoring, database, ftp and other general protocol monitoring) also has alarm mode, detailed report chart drawing.

Support automatic discovery of network devices and servers, can be achieved by configuring automatic discovery server rules, support distributed, centralized display, management of distributed monitoring points, strong expansibility server provides through the interface (api function) can develop and improve all kinds of monitoring, according to the relevant interface to write programs easy to write plug-ins, you can customize monitoring items, alarm level settings. Data collection, support for snmp (including trapping and polling) ipmi jmx ssh telnel

Custom detection; custom frequency of data collection

Server / agent and client mode; flexible triggers; very flexible problem thresholds can be defined, such as triggers, highly customizable alarms, send pass, customizable alarm upgrades, recipient media types, cpu load, memory usage, disk usage, network conditions, port monitoring, log monitoring, etc.

Hardware monitoring:

Zabbix ipmi interface system monitoring:

Zabbixagent interface java Monitoring:

Zabbix jmx interface network device monitoring:

Zabbix snmp interface Application Service Monitoring:

Zabbix agent userparameter mysql database monitoring: percona-monitoring-plulgins url monitoring: zabbix web monitoring zabbix important components

Description: 1) zabbix server: the core component responsible for receiving report information sent by agent, which organizes all configuration, statistics and operation data.

2) database storage: dedicated to storing all configuration information, as well as data collected by zabbix

3) gui interface of web interface:zabbix

4) proxy: optional component, which is often used in distributed environments with many monitoring nodes. Proxy server collects part of the data and forwards it to server, which can reduce the pressure on server.

5) agent: deployed on the monitored host, it is responsible for collecting host local data such as cpu, memory, database and sending it to server or proxy; in addition, zabbix server, proxy and agent all have their own configuration files and log files The general process of a monitoring system is as follows: agentd needs to be installed on the monitored host, it is responsible for collecting data regularly and sending it to zabbix server, zabbix server stores the data in the database, and zabbix web displays and draws according to the data in the front end.

Here, agentd collects data in two modes: active and passive:

Initiative: agent requests server to obtain a list of active monitoring items, and actively submits the data to be detected in the monitoring items to server/proxy

Passive: server requests agent to obtain data of monitoring items, and agent returns data. Zabbix is an enterprise-level open source solution based on web interface that provides distributed system monitoring and network monitoring capabilities. With the help of zabbix, the heavy server management tasks of operation and maintenance personnel can be easily reduced and the continuous operation of the business system can be realized.

The following is a step-by-step introduction to the deployment and use of the zabbix distributed monitoring system to configure ip, dns and gateways to ensure that you can connect to the server zabbix monitoring server using remote connection tools: 192.168.146.100 # zabbix server (if you want to monitor this machine, you need to configure local zabbix agent) zabbix agent monitored host: 192.168.146.110 # zabbix client (monitored side, need to be configured with zabbix agent)

First, compile and install zabbix3.21

Install compilation tools and library files

The copy code is as follows:

Yum-y install make apr* autoconf automake curl-devel gcc gcc-c++ openssl openssl-devel gd kernel keyutilspatch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-develkeyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-develzlib-devel libxpm* freetype libjpeg* libpng* libtool* libxml2 libxml2-devel patch libcurl-devel bzip2-devel freetype-devel2)

2) install mysql5.7 and install the gcc compiler as follows

[root@yankerp-zabbix ~] # yum install gcc gcc-c++-y

Because mysql's branch mariadb is installed by default in centos7, you need to uninstall mariadb

[root@yankerp-zabbix src] # rpm-qa | grep mariadb mariadb-libs-5.5.44-2.el7.centos.x86_64 [root@yankerp-zabbix src] # rpm-e mariadb-libs-5.5.44-2.el7.centos.x86_64-- nodeps

Install mysql

Download the mysql binary package

The copy code is as follows:

[root@yankerp-zabbix src] # wget http://mirrors.sohu.com/mysql/mysql-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

Extract the mysql binary package and copy it to the / usr/local/mysql directory

[root@yankerp-zabbix src] # tar zxf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz [root@yankerp-zabbix src] # mv mysql-5.7.18-linux-glibc2.5-x86_64 / usr/local/mysql

Go to the / usr/local/mysql/ directory to create the data directory and the log directory, and give data755 permission.

[root@yankerp-zabbix src] # cd / usr/local/mysql/ [root@yankerp-zabbix mysql] # mkdir data [root@yankerp-zabbix mysql] # mkdir log [root@yankerp-zabbix mysql] # chmod + 755 data/

Set variable

The copy code is as follows:

Echo "export path=$path:/usr/local/mysql/bin" > > / etc/profile & & source / etc/profile

Create mysql groups and mysql users

The copy code is as follows:

[root@yankerp-zabbix mysql] # groupadd mysql & & useradd-r-g mysql-s / bin/false mysql

Open the main configuration file for / etc/my.cnf to add mysql as follows:

Vim / etc/my.cnf

[client] socket=/usr/local/mysql/mysql.sock [mysqld] basedir=/usr/local/mysql datadir=/usr/local/mysql/data pid-file=/usr/local/mysql/data/mysqld.pid socket=/usr/local/mysql/mysql.sock log_error=/usr/local/mysql/log/mysql.err

Initialize the mysql database

The copy code is as follows:

[root@yankerp-zabbix mysql] # chmod 750data/ & & chown-r mysql. & & chgrp-r mysql. & & bin/mysqld-initialize-user=mysql

Copy the mysql startup script and start the mysql database

The copy code is as follows:

Cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld & & service mysqld start

After startup, the password of mysql is stored in the / usr/local/mysql/log/ directory

[root@yankerp-zabbix mysql] # cat / usr/local/mysql/log/mysql.err | grep password 2018-01-06t06:31:34.837627z 1 [note] a temporary password is generated for root@localhost: s > 2% 8 06t06:31:34.837627z Q > skp

Enter the mysql database and change the mysql database password

Here, the installation of mysql is officially completed.

Second, install nginx

1) install pcre-devel zlib-devel related support packages

[root@yankerp-zabbix ~] # yum install zlib-devel pcre-devel-y

2) create www groups and www users

[root@yankerp-zabbix ~] # groupadd www [root@yankerp-zabbix ~] # useradd-g www www-s / sbin/nologin

3) download the nginx source code package

[root@yankerp-zabbix ~] # wget http://nginx.org/download/nginx-1.10.2.tar.gz

4) decompress the nginx source package and enter the nginx directory

[root@yankerp-zabbix ~] # tar zxf nginx-1.10.2.tar.gz [root@yankerp-zabbix ~] # cd nginx-1.10.2

The copy code is as follows:

[root@yankerp-zabbix nginx-1.10.2] # / configure-- prefix=/usr/local/nginx1.10-- 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-http_ssl_module-- with-http_gzip_static_module-- user=www-- group=www

Make & & make install

5) create a soft connection, optimize the execution path, and start nginx service

Access Test:

Third, install php

[root@yankerp-zabbix] # wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz [root@yankerp-zabbix ~] # tar zxf libmcrypt-2.5.7.tar.gz [root@yankerp-zabbix ~] # cd libmcrypt-2.5.7/ [root@yankerp-zabbix libmcrypt-2.5.7] #. / configure & & make & & make installln-s / usr/local/mysql/lib/libmysqlclient.so. 20.3.0 / usr/local/mysql/lib/libmysqlclient_r.so

Download the php source code package

[root@yankerp-zabbix] # tar zxf php-5.6.27.tar.gz [root@yankerp-zabbix ~] # cd php-5.6.27/ [root@yankerp-zabbix php-5.6.27] #. / configure-- prefix=/usr/local/php5.6-- with-config-file-path=/etc-- with-mysql=/usr/local/mysql-- with-mysqli=/usr/local/mysql/bin/mysql_config-- with-mysql-sock=/usr/ Local/mysql/mysql.sock-with-gd-with-iconv-with-libxml-dir=/usr-with-mhash-with-mcrypt-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-- with-xmlrpc-- enable-zip-- enable-soap-- without-pear-- with-gettext-- enable-session-- with-mcrypt-- with-curl & & make & & make install [root@yankerp-zabbix php-5.6.27] # cp php.ini-production / etc/php.ini

Edit the configuration file / etc/php.ini, which is modified as follows:

Find:

; date.timezone =

Modified to:

Date.timezone = prc # set time zone

Find:

Expose_php = on

Modified to:

Expose_php = off # suppresses the display of php version information

Find:

Short_open_tag = off

Modified to:

Short_open_tag = on / / support php short tags

Find:

Post_max_size = 8m

Modified to:

Post_max_size = 16m / / upload file size

Find:

Max_execution_time = 30

Modified to:

Max_execution_time = 300 / / maximum execution time of php script

Find:

Max_input_time = 60

Modified to:

Max_input_time = 300 / / limits the time to receive data by post, get, and put in seconds

Always_populate_raw_post_data =-1

Mbstring.func_overload = 0

Create a php service startup script

[root@yankerp-zabbix php-5.6.27] # cp sapi/fpm/init.d.php-fpm / etc/init.d/php-fpm [root@yankerp-zabbix php-5.6.27] # chmod + x / etc/init.d/php-fpm [root@yankerp-zabbix php-5.6.27] # chkconfig-- add php-fpm [root@yankerp-zabbix php-5.6.27] # chkconfig php-fpm on [root@yankerp-zabbix php-5.6.27] # cp / usr/local/php5.6/etc/php-fpm.conf.default / usr/local/php5.6/etc/php-fpm.conf [root@yankerp-zabbix php-5.6.27] # vim / usr/local/php5.6/etc/php-fpm.conf

The modifications are as follows:

Pid = run/php-fpm.piduser = wwwgroup = wwwlisten = 127.0.0.1:9000pm.max_children = 300pm.start_servers = 10pm.min_spare_servers = 10pm.max_spare_servers = 50

Start the php-fpm service

Configure nginx and parse php

# user nobody; worker_processes 1; # error_log logs/error.log; # error_log logs/error.log notice; # error_log logs/error.log info; # pid logs/nginx.pid; events {worker_connections 1024;} http {include mime.types; default_type application/octet-stream # log_format main'$remote_addr-$remote_user [$time_local] "$request" #'$status $body_bytes_sent "$http_referer" #'"$http_user_agent"$http_x_forwarded_for"; # access_log logs/access.log main; sendfile on; # tcp_nopush on; # keepalive_timeout 0; keepalive_timeout 65; # gzip on; server {listen 80; server_name localhost # charset koi8-r; # access_log logs/host.access.log main; location / {root html; index index.php index.html index.htm;} # error_page 404 / 404.html; # redirect server error pages to the static page / 50x.html # error_page 500502 503504 / 50x.html; location = / 50x.html {root html } # proxy the php scripts to apache listening on 127.0.0.1 location 80 # location ~. Php$ {# proxy_pass http://127.0.0.1; #} # pass the php scripts to fastcgi server listening on 127.0.0.1 proxy_pass 9000 # location ~. Php$ {root html; fastcgi_pass 127.0.0.1 php$ 9000; fastcgi_index index.php; fastcgi_param script_filename / scripts$fastcgi_script_name Include fastcgi.conf;} # deny access to .htaccess files, if apache's document root # concurs with nginx's one # # location ~ /\ .ht {# deny all; #}} # another virtual host using mix of ip-, name-, and port-based configuration # # server {# listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / {# root html; # index index.html index.htm #} #} # https server # # server {# listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:ssl:1m; # ssl_session_timeout 5m; # ssl_prefer_server_ciphers on; # location / {# root html; # index index.html index.htm #} #}}

Create an test.php write test page access test under the html directory:

Write to the mysql test page

Vim / usr/local/nginx/html/test2.php

The above picture shows that the lnmp environment has been working properly!

Fourth, formally install zabbix. The above is only the formal installation of zabbix under the environment.

This environment requires the lnmp environment to be installed in advance (the installation directory of mysql,nginx,php is under / usr/local/)

Create a zabbix running user

[root@yankerp-zabbix ~] # groupadd zabbix [root@yankerp-zabbix ~] # useradd-g zabbix zabbix

Install the required packages

The copy code is as follows:

[root@yankerp-zabbix ~] # yum install-y net-snmp net-snmp-devel curl-devel java-1.8.0-openjdk java-1.8.0-openjdk-devel openipmi-devel libssh2-devel

Install fping

[root@yankerp-zabbix ~] # tar zxf fping-3.10.tar.gz [root@yankerp-zabbix ~] # cd fping-3.10/ [root@yankerp-zabbix fping-3.10] #. / configure & & make & & make install [root@yankerp-zabbix fping-3.10] # chown root:zabbix / usr/local/sbin/fping [root@yankerp-zabbix fping-3.10] # chmod 4710 / usr/local/sbin/fpin

Install zabbix-server

[root@yankerp-zabbix ~] # tar zxf zabbix-3.2.1.tar.gz [root@yankerp-zabbix ~] # cd zabbix-3.2.1/

The copy code is as follows:

[root@yankerp-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

When compiling, it is best to take the parameter-- enable-java, to facilitate subsequent monitoring of tomcat and other programs.

Make & & make install

Add system soft connection

[root@yankerp-zabbix zabbix-3.2.1] # ln-s / usr/local/zabbix/bin/* / usr/local/bin/ [root@yankerp-zabbix zabbix-3.2.1] # ln-s / usr/local/zabbix/sbin/* / usr/local/sbin/

Create the zabbix database and mysql users:

Mysql > create database zabbix character set utf8; query ok, 1 row affected (0.18 sec) mysql > grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; query ok, 0 rows affected, 1 warning (0.37 sec) mysql >

Import zabbix initial data; (switch to zabbix directory)

/ root/zabbix-3.2.1/database/mysql [root@yankerp-zabbix mysql] # mysql-uzabbix-pzabbix-hlocalhost zabbix

< schema.sql mysql: [warning] using a password on the command line interface can be insecure. [root@yankerp-zabbix mysql]# mysql -uzabbix -pzabbix -hlocalhost zabbix < images.sql mysql: [warning] using a password on the command line interface can be insecure. [root@yankerp-zabbix mysql]# mysql -uzabbix -pzabbix -hlocalhost zabbix < data.sql mysql: [warning] using a password on the command line interface can be insecure. 编辑/usr/local/zabbix/etc/zabbix_server.conf(修改如下) logfile=/usr/local/zabbix/logs/zabbix_server.logpidfile=/usr/local/zabbix/logs/zabbix_server.piddbhost=localhostdbname=zabbixdbuser=zabbixdbpassword=zabbixdbport=3306fpinglocation=/usr/local/sbin/fping[root@yankerp-zabbix mysql]# mkdir -p /usr/local/zabbix/logs [root@yankerp-zabbix mysql]# chown -r zabbix:zabbix /usr/local/zabbix/ 启动zabbix server

Solution:

Add / usr/local/mysql/lib to ld.so.conf

[root@yankerp-zabbix ~] # cat / etc/ld.so.confinclude ld.so.conf.d/*.conf/usr/local/mysql/lib/usr/local/lib

Execute after insertion

We found that it still hasn't started, so the next step is to check the log of zabbix_server as follows:

The above prompts for the mysql.sock problem, then open the zabbix main configuration file and modify it as follows:

Add startup script

[root@yankerp-zabbix zabbix-3.2.1] # cp misc/init.d/fedora/core/zabbix_server / etc/rc.d/init.d/zabbix_server [root@yankerp-zabbix zabbix-3.2.1] # cp misc/init.d/fedora/core/zabbix_agentd / etc/rc.d/init.d/zabbix_agentd [root@yankerp-zabbix zabbix-3.2.1] # chmod + x / etc/rc.d/init.d/zabbix_server [root Yankerp-zabbix zabbix-3.2.1] # chmod + x / etc/rc.d/init.d/zabbix_agentd [root@yankerp-zabbix zabbix-3.2.1] # chkconfig-- add zabbix_server [root@yankerp-zabbix zabbix-3.2.1] # chkconfig-- add zabbix_agentd [root@yankerp-zabbix zabbix-3.2.1] # chkconfig zabbix_server on [root@yankerp-zabbix zabbix-3.2.1] # chkconfig zabbix_agentd on

Modify the zabbix installation directory in the zabbix boot script

Vi / etc/rc.d/init.d/zabbix_server # Edit server configuration file basedir=/usr/local/zabbix/ # zabbix installation directory pidfile=/usr/local/zabbix/logs/$binary_name.pid # pid file path: wq! # Save exit vi / etc/rc.d/init.d/zabbix_agentd # Edit client configuration file basedir=/usr/local/zabbix/ # zabbix installation directory pidfile=/usr/local/zabbix/logs / $binary_name.pid # pid file path: wq! # Save exit

Officially launch zabbix_server

Configure the web interface of zabbix after successful startup

[root@zabbix-yankerp ~] # cd / root/zabbix-3.2.1/ [root@zabbix-yankerp zabbix-3.2.1] # cp-r frontends/php/ / usr/local/nginx/html/zabbix [root@zabbix-yankerp zabbix-3.2.1] # chown-r www:www / usr/local/nginx/html/zabbix/

The following interface appears to prove

The appearance of the above picture proves that zabbix is officially built successfully!

This is the end of the introduction to "how Centos compiles and installs zabbix". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report