In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Overview of Zabbix
Zabbix is a highly integrated enterprise-class open source network monitoring solution, similar to Cacti and Nagios, which provides distributed monitoring and centralized Web management interface. It is composed of zabbix serve r end and zabbix agent. The monitored object can only support the SNMP protocol or run the Zabbix_agents agent. The official website of Zabbix is http://www.zabbix.com/, and the software can be downloaded and used freely.
Zabbix has the functions of common commercial monitoring software: host performance testing, network equipment performance monitoring, database performance monitoring, ftp equivalent to protocol monitoring, can make use of flexible and customizable warning mechanism, run users to send E-mail-based warnings to events, can ensure that relevant maintenance personnel can make a rapid response to problems, but also can use stored data to provide outstanding reports and real-time graphical data processing.
Characteristics of Zabbix
Support for automatic discovery of network devices and servers
Support for distributed monitoring
Alarm threshold can be set
Data can be collected in a variety of ways
Customizable alarm mode
Real-time drawing function
Monitor the system and settings through web
Case environment, as shown in the table.
Host operating system IP address main operation
Zabbix server Centos 7 192.168.66.146 builds LAMP architecture and deploys zabbix-sever
Linux client Centos 7 192.168.66.145 deploy zabbix-agent
Software package links to solve Chinese garbled code:
Link: https://pan.baidu.com/s/1ObFt9zepWO9l05k-f79ZfQ
Extraction code: nxy3
Zabbix collects data through the Cramp S mode, and displays and configures it on the Web side through the Bamp S mode. Among them, Zabbix_server can run on Linux systems such as CentOS, RHEL, SUSE, Ubuntu, etc., and it also needs to use LAMP platform to carry database and Web interface.
one。 Deploy LAMP architecture on the monitoring side
1. Turn off the firewall
[root@localhost ~] # systemctl stop firewalld.service
[root@localhost ~] # systemctl disable firewalld.service
Removed symlink / etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink / etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~] # setenforce 0
two。 Install the required software packages for LAMP
[root@localhost ~] # yum install-y httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash
3. Modify the configuration file
[root@localhost ~] # vim / etc/httpd/conf/httpd.conf / / httpd's main configuration file
95 ServerName www.yun.com:80 / / set servername
one hundred and sixty three
164DirectoryIndex index.html index.php / / index.php is supported for the home page type
Edit / etc/php.ini configuration file, set time zone
[root@localhost ~] # vim / etc/php.ini
878 date.timezone = PRC / / set China time zone
4. Start the httpd service and the maruadb service, and view the port.
[root@localhost ~] # systemctl start httpd.service
[root@localhost ~] # systemctl start mariadb.service
[root@localhost ~] # netstat-ntap | egrep'(3306 | 80)'/ / View ports 3306 and 80
Tcp 0 0 0.0.0.0 3306 0.0.0.015 * LISTEN 4630/mysqld
Tcp6 0 0: 80: * LISTEN 4351/httpd
5. Initialize the configuration of the database
[root@localhost ~] # mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
Password for the root user. If you've just installed MariaDB, and
You haven't set the root password yet, the password will be blank
So you should just press enter here.
Enter current password for root (enter for none): / / enter
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
Root user without the proper authorisation.
Set root password? [Yzone] y / / set the root password
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
To log into MariaDB without having to have a user account created for
Them. This is intended only for testing, and to make the installation
Go a bit smoother. You should remove them before moving into a
Production environment.
Remove anonymous users? [YBO] n / / whether to delete anonymous user n
... Skipping.
Normally, root should only be allowed to connect from 'localhost'. This
Ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [YBO] n / / run remote login
... Skipping.
By default, MariaDB comes with a database named 'test' that anyone can
Access. This is also intended only for testing, and should be removed
Before moving into a production environment.
Remove test database and access to it? [YBO] n / / Delete test database n
... Skipping.
Reloading the privilege tables will ensure that all changes made so far
Will take effect immediately.
Reload privilege tables now? [YBO] y / / reload
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
Installation should now be secure.
Thanks for using MariaDB!
6. After the database initialization is complete, you can log in to the database
[root@localhost ~] # mysql-uroot-p / / Log in to the database using the root user
Enter password:
Welcome to the MariaDB monitor. Commands end with; or\ g.
Your MariaDB connection id is 6
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
MariaDB [(none)] > create database zabbix character set utf8 collate utf8_bin; / / create zabbix database, and the character set is set to simplified Chinese
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)] > show databases; / / View the database
+-+
| | Database |
+-+
| | information_schema |
| | mysql |
| | performance_schema |
| | test |
| | zabbix |
+-+
5 rows in set (0.00 sec)
MariaDB [(none)] > grant all privileges on *. * to 'zabbix'@'%' identified by' admin123'
/ / create zabbix users. All libraries and tables are managed by zabbix. The password is: admin123.
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)] > flush privileges; / / refresh the database
Query OK, 0 rows affected (0.00 sec)
Log in to the database using the create user zabbix
[root@localhost html] # mysql-uzabbix-p
Enter password:
ERROR 1045 (28000): Access denied for user 'zabbix'@'localhost' (using password: YES)
Failed to log in to the database using zabbix users. The reason is that the local connection cannot be made due to the occupation of the available user name. The solution is to delete the empty user name.
Log in to the database as root user and delete the unused user name
[root@localhost html] # mysql-uroot-p
Enter password:
Welcome to the MariaDB monitor. Commands end with; or\ g.
Your MariaDB connection id is 8
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
MariaDB [(none)] > select user,host from mysql.user; / / View current user
+-+
| | user | host |
+-+
| | zabbix |% | |
| | root | 127.0.0.1 | |
| | root |:: 1 |
| localhost | / / two empty user names exist |
| | root | localhost |
| | localhost.localdomain |
| | root | localhost.localdomain |
+-+
7 rows in set (0.00 sec)
MariaDB [(none)] > drop user''@ localhost; / / Delete empty users
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)] > drop user'@ localhost.localdomain
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)] > quit
Bye
Exit at this point and log in to the database as zabbix user
[root@localhost html] # mysql-uzabbix-p
Enter password:
Welcome to the MariaDB monitor. Commands end with; or\ g.
Your MariaDB connection id is 9
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
MariaDB [(none)] > show databases
+-+
| | Database |
+-+
| | information_schema |
| | mysql |
| | performance_schema |
| | test |
| | zabbix |
+-+
5 rows in set (0.00 sec)
7. Test php, whether you can use zabbix users to connect to the database
[root@localhost ~] # cd / var/www/html/
[root@localhost html] # ls
[root@localhost html] # vim index.php Edit php Home Page
Use the browser to access the IP address of the monitor, that is, 192.168.66.146. View the php home page
Change the php home page to test connecting to the database
[root@localhost html] # vim index.php
Use zabbix users to connect to the database, the output is successful: successful connection!, if the connection fails, output: failed! information
Use the browser to access the test again
At this point, the deployment of the LAMP platform is complete, and then the service of Zabbix _ server is deployed on the monitoring side.
Two. Deploy Zabbix_server services
1. Install php-related software packages
[root@localhost html] # yum install php-bcmath php-mbstring-y
Install the yum source of zabbix and automatically generate repo files
[root@localhost html] # rpm-ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
Get http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
Warning: / var/tmp/rpm-tmp.85LcDm: header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing. # # [100%]
Upgrading / installing...
1:zabbix-release-3.5-1.el7 # # [100%]
Install zabbix-server-mysql and zabbix-web-mysql
[root@localhost html] # yum install zabbix-server-mysql zabbix-web-mysql-y
two。 Initialize the database module, generate the database file, and be careful not to type the password into root
[root@localhost html] # zcat / usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql- uzabbix-p zabbix
Enter password: / / password is admin123
3. (1) change the configuration file (these filtered contents are automatically configured in the configuration file and do not need to be changed, only the database login password needs to be changed)
[root@localhost html] # grep-n'^'[Amurz] / etc/zabbix/zabbix_server.conf
38:LogFile=/var/log/zabbix/zabbix_server.log / / Log file path
49:LogFileSize=0 / / Log file size
72:PidFile=/var/run/zabbix/zabbix_server.pid / / pid file path
82:SocketDir=/var/run/zabbix
101:DBName=zabbix / / Database name
117:DBUser=zabbix / / database user
357:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
475:Timeout=4 / / timeout information
518:AlertScriptsPath=/usr/lib/zabbix/alertscripts / / script file path
529:ExternalScripts=/usr/lib/zabbix/externalscripts / / Extensibility script file
565:LogSlowQueries=3000 / / slow log file
Change the database login password
[root@localhost html] # vim / etc/zabbix/zabbix_server.conf
125 DBPassword=admin123
(2) modify the time zone
[root@localhost html] # vim / etc/httpd/conf.d/zabbix.conf
20 php_value date.timezone Asia/Shanghai / / modified to Shanghai time zone
(3) correct the Chinese garbled code of the chart
[root@localhost html] # vim / usr/share/zabbix/include/defines.inc.php
:% s / graphfont/kaiti/g / / replace graphfont full text with kaiti
Copy the appropriate font file to / usr/share/zabbix/fonts/
[root@localhost html] # yum install lrzsz-y / / lrzsz tool can transfer files between windows and Linux systems
[root@localhost html] # mkdir / aaa
[root@localhost html] # cd / aaa
[root@localhost aaa] # ls
[root@localhost aaa] # rz
[root@localhost aaa] # ls
Php-bcmath-5.4.16-42.el7.x86_64.rpm STKAITI.TTF
Php-mbstring-5.4.16-42.el7.x86_64.rpm
[root@localhost aaa] # cp STKAITI.TTF / usr/share/zabbix/fonts/
4 start the zabbix-server service and view the port
[root@localhost aaa] # systemctl start zabbix-server.service
[root@localhost aaa] # systemctl enable zabbix-server.service / / Boot self-start
Created symlink from / etc/systemd/system/multi-user.target.wants/zabbix-server.service to / usr/lib/systemd/system/zabbix-server.service.
[root@localhost aaa] # netstat-an | Port of grep 10051 / / zabbix is 10051
Tcp 00 0.0.0.0 10051 0.0.0.015 * LISTEN
Tcp6 00: 10051: * LISTEN
Restart the httpd service because the configuration file has been modified
[root@localhost aaa] # systemctl restart httpd.service
5. After the service is restarted, visit http://192.168.66.146/zabbix, install zabbix and log in.
Test the connectivity of the database. Successful test connectivity will display the word OK. As shown in the following figure
Add host information
Log in with the default user Admin, password zabbix
Launch the Chinese interface, the Zabbix Web management interface comes with multiple language packs, and the default language is English. Switch the Zabbix language to the Chinese version
Three. Deploy the zabbix_agent service (built on the monitored side)
The function of Agent is to get host data, and then send the collected data to Server (active mode) or Server to get the data actively (passive mode).
1. Turn off the firewall
[root@localhost ~] # systemctl stop firewalld.service
[root@localhost ~] # systemctl disable firewalld.service
Removed symlink / etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink / etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~] # setenforce 0
two。 Install yum source, install zabbix-agent service
[root@localhost ~] # rpm-ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
Get http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
Warning: / var/tmp/rpm-tmp.hITfvK: header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing. # # [100%]
Upgrading / installing...
1:zabbix-release-3.5-1.el7 # # [100%]
[root@localhost ~] # yum install zabbix-agent-y
3. Change zabbix_agent profile
[root@localhost ~] # grep-n'^'[Amurz] / etc/zabbix/zabbix_agentd.conf
13:PidFile=/var/run/zabbix/zabbix_agentd.pid
32:LogFile=/var/log/zabbix/zabbix_agentd.log
43:LogFileSize=0
98:Server=127.0.0.1
139:ServerActive=127.0.0.1
150:Hostname=Zabbix server
268:Include=/etc/zabbix/zabbix_agentd.d/*.conf
Specify the IP address of the server
[root@localhost ~] # vim / etc/zabbix/zabbix_agentd.conf
98 Server=192.168.66.146
139 ServerActive=192.168.66.146
150 Hostname=test
4. Start the zabbix-agent service and view the port
[root@localhost ~] # systemctl start zabbix-agent.service
[root@localhost ~] # systemctl enable zabbix-agent.service
Created symlink from / etc/systemd/system/multi-user.target.wants/zabbix-agent.service to / usr/lib/systemd/system/zabbix-agent.service.
[root@localhost ~] # netstat-natp | grep 10050
Tcp 00 0.0.0.0 10050 0.0.0.015 * LISTEN 54896/zabbix_agentd
Tcp6 00: 10050: * LISTEN 54896/zabbix_agentd
The port of server is 10051. The port of agent is 10050.
At this point, both zabbix-server and zabbix-agent are configured, and the service is started. Go to the web page of zabbix and add the monitored host.
Create a host. Host is the basic carrier of Zabbix monitoring, and all monitoring projects are based on Host. You can go from configuration-> hosts-> create hosts.
Four. Deploy mail delivery service (configure mail alarm on the monitor side)
1. Install the mailx mail package
[root@localhost aaa] # yum install mailx-y
Change the configuration file
[root@localhost aaa] # vim / etc/mail.rc / / Note if you use NetEase or QQ Mail, you need to open the client authorization code for third-party login.
Set from=1947... @ qq.com / / QQ Mail address
Set smtp=smtp.qq.com
Set smtp-auth-user=1947... . @ qq.com
Set smtp-auth-password=ahixbfxiuztjcfjb / / third party authorization code
Set smtp-auth=login
The method for obtaining QQ Mail's third-party authorization code is as follows: enter QQ Mail, select "Settings", and then "account"
Send mail test
[root@localhost aaa] # echo "this is zabbix" | mail-s "testmail" 1947... . @ qq.com / / Test sending email to see if it can be received
two。 Write an e-mail script
[root@localhost aaa] # cd / usr/lib/zabbix/
[root@localhost zabbix] # ls
Alertscripts externalscripts
[root@localhost zabbix] # cd alertscripts/
[root@localhost alertscripts] # ls
[root@localhost alertscripts] # vim mail.sh
#! / bin/bash
# send mail
Messages= `echo $3 | tr'\ r\ n''\ n'`
Subject= `echo $2 | tr'\ r\ n''\ n'`
Echo "${messages}" | mail-s "${subject}" $1 > > / tmp/mailx.log 2 > & 1
Give script execution permission
[root@localhost alertscripts] # mv mail.sh mailx.sh
[root@localhost alertscripts] # touch / tmp/mailx.log
[root@localhost alertscripts] # chown-R zabbix.zabbix / tmp/mailx.log
[root@localhost alertscripts] # chmod + x / usr/lib/zabbix/alertscripts/mail.sh
[root@localhost alertscripts] # chown-R zabbix.zabbix / usr/lib/zabbix/
Test the email script
[root@localhost alertscripts] #. / mailx.sh 1947... .. @ qq.com "yum"heihei"
Summary:
Zabbix is an enterprise-class, open source, distributed monitoring suite that monitors the status of networks and services.
Zabbix can use data to provide graphical reports and has a flexible alarm mechanism.
Zabbix can use the Zabbix Web administration page for administrative configuration.
Zabbix comes with a variety of monitoring templates that can be used directly.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.