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 install, configure and apply zabbix in Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces the Linux zabbix installation configuration and application, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Introduction to Zabbix:

1. Based on web open source software, open source monitoring system status can also monitor network equipment.

two。 Unlike nagios, zabbix saves the acquired data in the database, so zabbix needs database support.

3.Zabbix can also automatically discover hosts and network devices

4. Email and SMS alarms are supported

Most of the 5.Zabbix configuration can be done in the web interface.

6.Zabbix cacti nagios is based on website programs written by php, so to use these software, you need to use them based on lamp or lnmp (yum installs configuration files that they do not support nginx and lamp installation will generate a subprofile under the configuration file of apache, which can be accessed directly through IP).

The official website http://www.zabbix.com/

Install Zabbix:

Rpm-ivh http://www.lishiming.net/data/p_w_upload/forum/month_1211/epel-release-6-7.noarch.rpm # installs the yum source epel. The owner of the building is LAMP environment. The operation of this step is saved, and the next step is also saved.

Lamp environment yum install-y httpd mysql mysql-libs php php-mysql mysql-server php-bcmath php-gd php-mbstring where the rpm package is installed

Server Zabbix installation:

The client should also install zabbix20-agent, and the version should be consistent.

[root@OBird ~] # yum install zabbix20 zabbix20-agent zabbix20-server zabbix20-server-mysql zabbix20-web zabbix20-web-mysql net-snmp-devel

[root@OBird] # / etc/init.d/zabbix-server start; / etc/init.d/zabbix-agent start

Starting Zabbix server: [OK]

Starting Zabbix agent: [OK]

[root@OBird ~] # netstat-lnp # check that the port has 10050 10051, and the landlord found that 10051 zabbix-server was not enabled.

[root@OBird ~] # less / var/log/zabbix/zabbix_server.log # check the zabbix log and find that it is a database problem

'/ var/lib/mysql/mysql.sock' (2)

4510:20161229:102804.301 Database is down. Reconnecting in 10 seconds.

4510 connection to database 20161229 Can't connect to local MySQL server through socket 102814.302 [Z3001] Can't connect to local MySQL server through socket

[root@OBird] # / etc/init.d/httpd start; / etc/init.d/mysqld start # launch httpd & mysqld

Starting httpd: [OK]

Starting mysqld: [OK]

[root@OBird] # mysql-uroot-pzaq12wsx # enter the database

Mysql > create database zabbix

ERROR 2006 (HY000): MySQL server has gone away

No connection. Trying to reconnect...

Connection id: 43

Current database: * * NONE * *

Query OK, 1 row affected (0.00 sec)

Mysql > show databases

+-+

| | Database |

+-+

| | information_schema |

| | cacti |

| | discuz |

| | mysql |

| | test |

| | zabbix |

+-+

6 rows in set (0.05 sec)

Mysql > show variables like'% char%'; # View instance character set

ERROR 2006 (HY000): MySQL server has gone away

No connection. Trying to reconnect...

Connection id: 55

Current database: zabbix

+-+

| | Variable_name | Value |

+-+

| | character_set_client | latin1 |

| | character_set_connection | latin1 |

| | character_set_database | latin1 |

| | character_set_filesystem | binary |

| | character_set_results | latin1 |

| | character_set_server | latin1 |

| | character_set_system | utf8 |

| | character_sets_dir | / usr/share/mysql/charsets/ |

+-+

8 rows in set (0.00 sec)

Mysql > SET character_set_client = utf8; change the character set of the instance. I don't know if there is any problem. Do so first.

ERROR 2006 (HY000): MySQL server has gone away

No connection. Trying to reconnect...

Connection id: 13

Current database: * * NONE * *

Query OK, 0 rows affected (0.00 sec)

Mysql > SET NAMES 'utf8'

ERROR 2006 (HY000): MySQL server has gone away

No connection. Trying to reconnect...

Connection id: 8

Current database: * * NONE * *

Query OK, 0 rows affected (0.00 sec)

Mysql > show variables like'% char%';# check again

+-+

| | Variable_name | Value |

+-+

| | character_set_client | utf8 |

| | character_set_connection | utf8 |

| | character_set_database | latin1 |

| | character_set_filesystem | binary |

| | character_set_results | utf8 |

| | character_set_server | latin1 |

| | character_set_system | utf8 |

| | character_sets_dir | / usr/share/mysql/charsets/ |

+-+

8 rows in set (0.00 sec)

Import three databases:

[root@OBird] # mysql-uroot-pzaq12wsx zabbix

< /usr/share/zabbix-mysql/schema.sql [root@OBird ~]# mysql -uroot -pzaq12wsx zabbix < /usr/share/zabbix-mysql/p_w_picpaths.sql [root@OBird ~]# mysql -uroot -pzaq12wsx zabbix < /usr/share/zabbix-mysql/data.sql 再次启动zabbix-server 还是没有启动,日志报错和上面的一样。 [root@OBird ~]# mysql -uroot -pzaq12wsx mysql>

Grant all on *. * to 'zabbix'@'localhost' identified by' zabbix'; # create user & password and authorization

Query OK, 0 rows affected (0.00 sec)

[root@OBird ~] # vim / etc/zabbix/zabbix_server.conf # edits the write zabbix user password.

DBPassword=zabbix

[root@OBird ~] # ls / tmp/mysql.sock # mysql.sock is under the tmp folder

/ tmp/mysql.sock

[root@OBird] # ln-s / tmp/mysql.sock / var/lib/mysql/mysql.sock # make a soft link

[root@OBird ~] # service mysqld restart # restart the database

Stopping mysqld: [OK]

Starting mysqld: [OK]

[root@OBird ~] # / etc/init.d/zabbix-server restart # restart the zabbix-server service

Shutting down Zabbix server: [OK]

Starting Zabbix server: [OK]

Query to confirm that the Zabbix service has been started:

Web-side Zabbix installation:

Http://10.72.4.43/zabbix/

The following three tests failed:

PHP option post_max_size8M16MFail

PHP option max_execution_time30300FailPHP option max_input_time60300Fail

[root@OBird ~] # vim / etc/php.ini # Edit php.ini file

Post_max_size = 16m # 8m-> 16m

Max_execution_time = 300 # 30-> 300

Ax_input_time = 300 # 60-> 300

[root@OBird ~] # service httpd restart

Refresh: http://10.72.4.43/zabbix/, all through, directly next step, next step until the installation is complete.

Zabbix acknowledges the administrator account: admin ps:zabbix. At this point, the Zabbix server installation is complete.

-- split line--

Install the client host for access monitoring: the environment of the client machine is LNMP.

[root@LNMP ~] # yum install zabbix20-agent

[root@LNMP ~] # vim / etc/zabbix_agentd.conf # Edit the configuration file and change it to the following

Server=10.72.4.43 # server IP

ServerActive=0.0.0.0:10050 # listening port

Hostname=Zabbix_liven_linux # customized hostname

[root@LNMP ~] # / etc/init.d/zabbix-agent start # start the zabbix-agent service

Starting Zabbix agent: [OK]

[root@OBird] # zabbix_get-s 10.72.4.38-p10050-k "system.hostname"

LNMP

# check the client hostname on the server and check it correctly. It shows that the communication between the two machines is correct.

Add a monitoring template:

Server monitoring data view:

Create a custom template:

Zabbix comes with many templates, in which there are many monitoring projects, such as CPU, network cards, memory, processes, and so on. There are a bit too many templates that come with the system, so we can customize the templates. Click configuration to select templates, and click create template in the upper right corner

Template name and Visible name customization. Select templates for Groups and click save.

Then we pick some items and copy them to the template: for example, we find Template OS Linux, click items, select the project we want, and then select copy selected to below. Then click go.

Group choose templates, find the templates we customized just now, and click copy.

Click configuration to select templates to see that the new templates already has the items of our copy.

We can use the same method as above to customize the copy Triggers (trigger), which is used to set the alarm threshold, or you can customize and edit it.

-- split line--

[root@OBird ~] # / etc/init.d/postfix restart # start the postfix service

Shutting down postfix: [OK]

Starting postfix: [OK]

[root@OBird] # mail-s "2016-12-30" 111111111@qq.com

< /etc/inittab #发邮件 [root@OBird ~]# mailq #查看邮件有没有发出去 Mail queue is empty #楼主是用QQ 邮箱测试的,是可以收到邮件的。如下图 在zabbix-server 端来编写发邮件脚本 [root@OBird ~]# mkdir -p /home/zabbix/bin [root@OBird ~]# vim /home/zabbix/bin/bj.sh #!/bin/bash echo "$3" |/bin/mail -s "$2" $1 # $3 是邮件内容 ,$2 是主题 $1 是收件人 [root@OBird ~]# chmod +x /home/zabbix/bin/bj.sh #加入可执行的权权 [root@OBird ~]# vim /etc/zabbix/zabbix_server.conf #更改邮件脚本路径, #AlertScriptsPath=/var/lib/zabbixsrv/alertscripts AlertScriptsPath=/home/zabbix/bin #ExternalScripts=/var/lib/zabbixsrv/externalscripts ExternalScripts=/home/zabbix/bin 创建mediea types: "Administration" -->

"Media types", click "Create Media Type" in the upper right corner, where Description fill in "bj" or other custom name, Type select "Script", Script fill in "bj.sh" and then click "Save".

Create user: "Adimistration"-- > "Users" in the upper right corner, select "Users", click "Create User", alias: test1, Custom name and lastname password:zaq12wsx;group Select guest, go back to the above, click media,type, select baojing,send to to write to the mailbox to send email, click add, and finally click save.

Create action: "configuration"-> actions, "Create Actions" in the upper right corner, Name customization, I'll write "baojing" here, other defaults, then click the "New" button under "Operations" on the right, "Operation Type" select "Send message", "Send Message to" select one or more user groups to send messages, Send to Users select our new test1, "Send only to" select bj, click add

Last point: save

Create action: "configuration"-> actions, "Create Actions" in the upper right corner, Name customization, I'll write "baojing" here, other defaults, then click the "New" button under "Operations" on the right, "Operation Type" select "Send message", "Send Message to" select one or more user groups to send messages, Send to Users select our new test1, "Send only to" select baojing, click add

Last point: save

Thank you for reading this article carefully. I hope the article "how to install, configure and apply zabbix in Linux" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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

Database

Wechat

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

12
Report