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

An example of installing and deploying Zabbix3.0 version and fast basic configuration on CentOS7 at one time

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The installation, deployment and configuration of Zabbix3.0 must be based on LAMP environment or LNMP environment.

For simple and quick construction of the LAMP environment, see blog: http://afterdawn.blog.51cto.com/7503144/1923139

Note: the following steps are done after LAMP configuration.

This article will no longer introduce the theoretical knowledge of zabbix-server and zabbix-agent, and it is recommended to watch the http://afterdawn.blog.51cto.com/7503144/1922502 before carrying on the zabbix actual combat.

Zabbix3.0 has very low requirements for hardware and software, and the general host configuration and LAMP version can be met.

For software and hardware requirements documentation, please see: http://www.ttlsa.com/zabbix/zabbix-requirements-4-ttlsa/

Let's start with the installation and deployment of the Zabbix3.0 version on CentOS7 and the rapid basic configuration. Two hosts are used in this case.

One is used as the zabbix_server terminal and the other as the zabbix_agent terminal. The details are as follows:

Zabbix_server (default listening port 10051)

IP:10.10.10.3 OS:CentOS7

Zabbix_agent (default listening port 10050)

IP:10.10.10.10 OS:CentOS7

Specific steps:

1. Specify the location of zabbix3.0 package storage warehouse (take Aliyun yum Source as an example)

By default, the yum source of Aliyun's CentOS7 has been configured, but the yum source does not have a zabbix installation package, so manually specify the path of the zabbix installation package as follows:

~] # vim / etc/yum.repos.d/zabbix.repo [epel] name=aliyun_zabbix baseurl= https://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/ gpgcheck=0

2. Software package installation

Since the LAMP environment is already deployed, I won't repeat it here. However, the database used by zabbix needs to create a zabbix library and the users used to create zabbix have already been manipulated in the http://afterdawn.blog.51cto.com/7503144/1923139 document. Repeat here:

~] # mysql-uroot-p # root user logs in to MariaDB [(none)] > CREATE DATABASE zabbix CHARSET 'utf8'; # to create a zabbix library. The default character set is utf8MariaDB [(none)] > GRANT ALL ON zabbix.* TO zbxuser@'127.0.0.1' IDENTIFIED BY' zbxpass';MariaDB [(none)] > GRANT ALL ON zabbix.* TO zbxuser@'localhost' IDENTIFIED BY 'zbxpass' # zbxuser can be logged in locally with a password of zbxpass, and have all permissions for zabbix MariaDB [(none)] > GRANT ALL ON zabbix.* TO zbxuser@'10.10.10.%' IDENTIFIED BY 'zbxpass'; # zbxuser can log in from the 10.10.10.0 network segment with password of zbxpass, and have all permissions for zabbix MariaDB [(none)] > flush privileges; # refresh permission

Server software package: zabbix-server-mysql zabbix-get

Web GUI package: zabbix-web zabbix-web-mysql must be installed at the same time or dependencies cannot be resolved (interdependencies)

Agent (installed only on the monitored side): zabbix-agent zabbix-sender

One-time installation using yum:

~] # yum install-y zabbix-server-mysql zabbix-get zabbix-web zabbix-web-mysql zabbix-agent zabbix-sender

It was wrong to install zabbix-server-mysql Times. The error is as follows:

Error: package: zabbix-server-mysql-3.0.9-1.el7.x86_64 (epel) need: fping error: package: zabbix-server-mysql-3.0.9-1.el7.x86_64 (epel) need: libiksemel.so.3 () (64bit) you can try to add-- skip-broken option to solve this problem you can try to execute: rpm-Va-- nofiles-- nodigest

Error reason: yum source support for epel is not installed, so fping cannot be installed automatically

Solution: install the epel package

# yum install-y epel-release

After installing the epel package, because the epel repository has collected zabiix stable version (2.0), the default installation of yum will not be version 3.0.

Solution: directly specify the URL path of the zabbix installation package. You can log in to https://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/ to view the latest zabbix version and choose your own.

Here are the commands I installed with yum:

~] # yum install-y https://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-server-mysql-3.0.0-1.el7.x86_64.rpm~]# yum install-y https://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-get-3.0.0-1.el7.x86_64.rpm# yum install-y https://mirrors.aliyun.com/ Zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-web-mysql-3.0.0-1.el7.noarch.rpm https://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-web-3.0.0-1.el7.noarch.rpm ~] # yum install-y https://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-agent-3.0.0 -1.el7.x86_64.rpm ~] # yum install-y https://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-sender-3.0.0-1.el7.x86_64.rpm

At this point, all the installation packages on the zabbix-server side have been installed.

3. Zabbix server initialization

Note: there is only one sql script in the zabbix3.x version and three sql scripts in 2.x

The process is to execute the sql script provided officially by zabbix and automatically create the table structure required by zabbix. The process is as follows:

~] # cd / usr/share/doc/zabbix-server-mysql-3.0.0/~] # gzip-d create.sql.gz~] # mysql- h227.0.0.1-uzbxuser-p zabbix

< create.sql~]# mysql -uroot -p # 登录上mysql查看有没有创建成功MariaDB [zabbix]>

Use zabbixMariaDB [zabbix] > show tables

4. Zabbix server configuration file

Configuration file: / etc/zabbix/system/zabbix-server.conf

There are four types of instructions:

# GENERAL PARAMETERS # # ADVANCED PARAMETERS # # LOADABLE MODULES # # TLS-RELATED PARAMETERS #

Just modify # GENERAL PARAMETERS # others to use the default configuration

General parameters, no need to modify

# ListenPort=10051 # SourceIP= by default all IP# LogType=file logs are actively saved to the file LogFile=/var/log/zabbix/zabbix_server.log log location, and then scroll the path of the PidFile=/var/run/zabbix/zabbix_server.pid server PID file after the size of the LogFileSize=0 log

Items that need to be modified:

DBHost=localhost# uncomment DBName=zabbix# fill in the library name, default is zabbixDBUser=zbxuser# database user name DBPassword=zbxpass# database password DBSocket=/var/lib/mysql/mysql.sock# if the database is on the local machine, communicate with the database locally, it should be consistent with the configuration socket=/var/lib/mysql/mysql.sock in / etc/my.conf

Start the service:

~] # systemctl start zabbix-server.service~] # systemctl enable zabbix-server.service # boot automatically

Note: the default trousers versions of CentOS7.0 and 7.1are relatively low, so you need to upgrade trousers-0.3.13-1.el7.x86_64. You can install it directly using yum.

After starting the service, I checked it with systemctl status zabbix-server.service and found that it didn't get up. I checked the solution online and didn't solve it.

Finally, it was found that the table in the zabbix library was not successfully imported and was tossed about for more than an hour because of its own carelessness.

Summary: every step of the operation should be verified, otherwise it will be unable to eliminate the fault because of one of its own mistakes, and finally all will be knocked down, which is time-consuming and laborious.

Encounter this kind of situation, should check the log patiently, according to the prompt of the system, carefully find out the reason. No, go to the Internet to find out the reason.

5. Configure zabbix web

Almost all the monitoring and configuration of agent hosts by zabbix are carried out at the front end of zabbix web. Here, we first carry out the basic configuration of zabbix server.

Configure the time zone assignment for php:

(1) php.ini (optional)

Max_execution_time = 300memory_limit = 128Mpost_max_size = 16Mupload_max_filesize = 2Mmax_input_time = 300date.timezone PRC

(2) / etc/httpd/conf.d/zabbix.conf

Php_value date.timezone Asia/Shanghai # add this item

Visit URL: http://server/zabbix

Configuration file after zabbix web login: / etc/zabbix/web/zabbix.conf.php

Login: admin/zabbix

The login process from the client is as follows:

The [Database port] configuration 0 in the following figure represents the default port, that is, the mysql is 3306

[Database name] [User] [Password] fill in according to your own settings

10051 is the default listening port for zabbix server

The entry [Name] can be left unfilled, and the custom name can be defined.

The default login user name and password is: admin/zabbix

The interface for the first login:

6. Add and configure an agent host instance

6.1 install zabbix agent on the monitored host

~] # scp root@10.10.10.3:/etc/yum.repos.d/CentOS-Base.repo / etc/yum.repos.d/ # yum configuration file ~] # yum install-y ~] # yum install-y https://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-sender-3.0.0-1.el7.x86_64.rpm

6.2 agent side configuration

Configuration file: / etc/zabbix/zabbix_agentd.conf

# Passive checks related (passive detection-related configuration: agent waits for server to request data) Take the agent side as the judgment reference Server=10.10.10.3 # Comma separated authorization to those server or porxy to collect data server address list # ListenPort=10050 # listening IP# ListenIP=0.0.0.0 # listening port # StartAgents=3 # initiated agent detection # Active checks related (active detection related configuration: agent actively sends data to server) ServerActive=10.10.10.3 [: Port] separated by comma, The current agent actively sends monitoring data to the server in the past Can follow the port, generally default to the host label sent by 10051Hostname=agent2, generally fill in the hostname EnableRemoteCommands=1 # you can execute remote commands on the agent side (see below for summary instructions) LogRemoteCommands=1 # remote operations are recorded in the log

Note: there is no need to manually establish a zabbix account, but the zabbix account automatically created by zabbix agent cannot be logged in by default, and CentOS7 cannot execute commands without logging in to the terminal, so you need to make some configurations:

(1) zabbix users have the permissions they need to manage (based on sudo authorization)

# visudo#% wheel ALL= (ALL) NOPASSWD: ALLzabbix ALL= (ALL) NOPASSWD: ALL# Defaults requiretty# comment this line

Description of this configuration:

1) Defaults requiretty, modified to # Defaults requiretty, indicating that you do not need to control the terminal (you do not need to log in from the terminal to execute the command)

Test:

~] # su-zabbix-c 'sudo / usr/bin/systemctl restart httpd.service'

2) Defaults requiretty, modified to Defaults:nobody! requiretty, which means that only nobody users do not need to control the terminal (only nobody users do not need to log in from the terminal to execute commands)

(2) zabbix users can log in

~] # mkdir / var/lib/zabbix # create a home directory, but do not do ~] # grep "^ zabbix" / etc/passwdzabbix:x:996:994:Zabbix Monitoring System:/var/lib/zabbix:/sbin/nologin~] # usermod-s / bin/bash zabbix~] # grep "^ zabbix" / etc/passwdzabbix:x:996:994:Zabbix Monitoring System:/var/lib/zabbix:/bin/bash

Start zabbix agent

~] # systemctl start zabbix-agent.service~] # systemctl status zabbix-agent.service~] # systemctl enable zabbix-agent.service

7. Add a Linux monitoring host on the zabbix web side

Use the following screenshot steps:

Set up a host group

Create a host and belong to test group

Apply a Templates OS Linux monitoring template

The completed display is as follows:

You can view the monitoring status by following the screenshot below:

Monitored data:

Monitor trigger status

Monitor triggered events

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

Wechat

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

12
Report