Use zabbix to Monitor your servers

news/2025/4/22 0:56:46

为什么80%的码农都做不了架构师?>>>   hot3.png

本次主要介绍一款开源免费的分布式监控软件Zabbix的安装使用,底层存储数据用的是Postgres 9.1,以下是步骤:

1.准备
下载zabbix的服务端和客户端文件,
下载地址: http://www.zabbix.com/download.php
服务端IP:192.168.2.140
客户端IP:192.168.2.138

2.服务端操作:
groupadd zabbix
useradd zabbix -g zabbixtar -zxvf  zabbix-2.0.5.tar.gz
cd zabbix-2.0.5source /home/postgres/.bash_profile
./configure --prefix=/usr/local/zabbix --enable-server  --with-postgresql --with-net-snmp --with-libcurl
期间遇到了几个软件包找不到的问题
checking for pg_config... no
configure: error: PostgreSQL library not foundchecking for curl-config... no
configure: error: Curl library not foundchecking for net-snmp-config... no
configure: error: Invalid NET-SNMP directory - unable to find net-snmp-config
因为已经在服务端装好了postgres数据库,所以第一个问题是在root下引用了postgres的环境变量解决的,即source $PGHOME/.bash_profile 其余两个用yum搞定。
yum install curl-devel
yum install net-snmp-devel
完了以后就是下面这样,

然后安装
make && make install

3.配置数据库
[postgres@localhost ~]$psql
Password: 
psql (9.1.3)
Type "help" for help.
postgres=# create database zabbix;
CREATE DATABASE
postgres=# create user zabbix with password '123456';
CREATE ROLE
postgres=# grant all on database zabbix to zabbix;
GRANT
postgres=# \q
[postgres@localhost ~]$--导入zabbix的数据
[postgres@localhost ~]$ cd /home/kenyon/zabbix-2.0.5/database/postgresql/
[postgres@localhost postgresql]$ psql -U zabbix -d zabbix -f schema.sql 
[postgres@localhost postgresql]$ psql -U zabbix -d zabbix -f images.sql
[postgres@localhost postgresql]$ psql -U zabbix -d zabbix -f data.sql
配置zabbix与Postgres的连接
vi /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBName=zabbix
DBUser=zabbix[root@localhost ~]# mkdir -p /var/www/html/zabbix
[root@localhost ~]# cp -r /home/kenyon/zabbix-2.0.5/frontends/php/*  /var/www/html/zabbix/
4.启动服务器端的软件
启动apache
/etc/init.d/httpd restart

--apache的下载地址:http://apache.org/dist/httpd/
启动zabbix
/usr/local/zabbix/sbin/zabbix-server start
[postgres@localhost tmp]$ pwd
/tmp
[postgres@localhost tmp]$ ll zabbix_server.*
-rw-rw-r--. 1 zabbix zabbix 2517 Feb 26 22:19 zabbix_server.log
-rw-rw-r--. 1 zabbix zabbix 4 Feb 26 22:19 zabbix_server.pid

浏览网页,看是否正常 http://192.168.2.140/zabbix 可能会有一些选项异常,我遇到了几个,通过yum的方式和修改/etc/php.ini的方式解决,如果界面没出来,出来的是一些目录文件,则很有可能是php没有安装yum install php即可,改完重启一下apache。
yum install php-pgsql
yum install php-bcmath
yum install php-mbstring
yum install php-xml
yum install php-gd


配置DB



如果出现
  • pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Permission denied Is the server running on host "192.168.2.158" and accepting TCP/IP connections on port 1949? [include/db.inc.php:99]
  • Error connecting to database
则检查一下pg_hba.conf文件和防火墙,以及最好关闭selinux,在/etc/sysconfig/selinux中改一下
 
登陆窗口,注意首字母是大写,忘记用户密码可以通过修改DB数据来获取,默认是Admin/zabbix:
psql -U zabbix -d zabbix
zabbix=# select userid,name,surname,passwd from users;     
userid |  name   |    surname    |              passwd              
--------+---------+---------------+----------------------------------
1 | Zabbix  | Administrator | 5fce1b3e34b520afeffb37ce08c7cd66
2 | Default | User          | d41d8cd98f00b204e9800998ecf8427e
(2 rows)

zabbix=# update users set passwd = md5('123456') where userid = 1;
UPDATE 1



 最终见下图,说明服务端准备好了,只等客户端传数据过来。


5.安装配置客户端
把客户端文件(本次下载的是zabbix_agents_2.0.4.linux2_6_23.amd64.tar.gz,下载地址同服务端)拷贝到/home/kenyon/
tar -zxvf zabbix_agents_2.0.4.linux2_6_23.amd64.tar.gz
[root@localhost kenyon]# ls -l
total 284
drwxr-xr-x. 5 root root   4096 Feb 26 17:39 zabbix_agents
-rw-r--r--. 1 root root 286523 Feb 25 23:22 zabbix_agents_2.0.4.linux2_6_23.amd64.tar.gz[root@localhost kenyon]# cd zabbix_agents/conf/
[root@localhost conf]# vi zabbix_agentd.conf
Server=192.168.2.140
ServerActive=192.168.2.138
Hostname=192.168.2.138
如有错误或图片出不来,再看服务端和客户端的/tmp/zabbix_server.log信息

正常情况下:


 参考:http://metaler.dyndns.org/wordpress/?p=481

转载于:https://my.oschina.net/Kenyon/blog/111202


https://dhexx.cn/news/show-2654234.html

相关文章

vue + ueditor 单图片跨域上传

UEditor官网说不提供单图片的跨域,所以只能自己解决。查了网上的很多方案,但是没看到和vue一起用的,不过倒是获得了一些思路。本着不想改太多源代码的基础上尝试着...一不小心就可以用了解决方案:上传单图片的时后端不直接返回JSO…

LeetCode Search in Rotated Sorted Array II

题目: Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a function to determine if a given target is in the array. 题意: 继续上…

管理Oracle实例

前言 正常生产环境下往往是通过应用服务器来与Oracle数据库相连接,大多数使用Oracle的开发语言以Java为主,针对于Java的中间件有很多,我们这里具体来看一下Oracle整体产品线的WLS产品 安装Weblogic 执行上图所示命令,启动WLS安装页…

sklearn学习——特征处理

sklearn学习——特征处理 特征提取(feature extraction): 从文字,图像,声音等其他非结构化数据中提取新信息作为特征。比如说,从淘宝宝贝的名称中提取出产品类别,产品颜色,是否是网红产品等等。 特征创造(feature cre…

环境变量问题

软件出现下面的问题: 解决方法: 直接用export命令:#export PATH$PATH:/usr/local/sbin:/usr/sbin:/sbin

粒子群优化支持向量机代码(PSO-SVM)

粒子群优化支持向量机代码 数据WFs1 import pandas as pd import numpy as np import random from sklearn.svm import SVC import matplotlib.pyplot as plt from sklearn.model_selection import cross_val_predict from sklearn.metrics import confusion_matrix from skl…

LeetCode Bulb Switcher

题目: There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if its off or turning off if its on). For the nth round, you only …

C++操作MySQL,有用的朋友顶下,辛苦的原创啊. - 天下 - C++博客

C操作MySQL,有用的朋友顶下,辛苦的原创啊. - 天下 - C博客C操作MySQL,有用的朋友顶下,辛苦的原创啊.向google大神搜 :mysql-connector得http://www.mysql.com/products/connector/这些就是mysql所谓的连接器吧.一路向下看到:C Wrapper for MySQL C API (MySQL) Download http:/…

sklearn学习——递归特征消除法(RFE)

sklearn学习——递归特征消除法(RFE) 1 作用 消除特征之间的冗余,选取最优特征组合。降低特征维数。 2 步骤 将筛选的k个特征作为初始特征子集输入到随机森林分类器中,计算得到每个特征的重要性,并利用交叉验证方法…

Java Code Review清单

2019独角兽企业重金招聘Python工程师标准>>> 整洁的代码 清单项目分类使用可以表达实际意图(Intention-Revealing)的名称有意义的名称每一个概念只用一个词有意义的名称使用方案/问题领域名称有意义的名称类应该是比较小的!类函数应该是比较小的!函数只做一件事函数…