环境配置

zabbix_server:10.0.0.1

zabbix_agentd:10.0.0.1,10.0.0.2(暂定)

操作系统:centos7.6

安装环境配置

1. LNMP环境

  zabbix监控管理基于web页面展示出来的,并且需要使用mysql来存储数据,需先配置好LNMP环境

# 安装环境包
[root@tanbaobao ~]# yum -y install gcc pcre-devel openssl-devel # 安装nginx,这里我之前安装好了(https://www.cnblogs.com/HeiDi-BoKe/p/11417155.html
[root@VM_0_10_centos tmp]# tar -zxf nginx-1.16.1.tar.gz
# 切换到解压目录
[root@VM_0_10_centos nginx-1.16.1]# mkdir -p /var/tmp/nginx
# 配置
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_realip_module
# 编译安装
[root@VM_0_10_centos nginx-1.16.1]# make
[root@VM_0_10_centos nginx-1.16.1]# make install
# 启动服务
[root@VM_0_10_centos nginx]# cd sbin/
[root@VM_0_10_centos sbin]# pwd
/usr/local/nginx/sbin
[root@VM_0_10_centos sbin]# ./nginx -c /usr/local/nginx/conf/nginx.conf
[root@VM_0_10_centos sbin]# ./nginx -s reload # 安装php
[root@tanbaobao ~]# yum -y install php php-mysql mariadb mariadb-devel mariadb-server php-fpm

2. 修改nginx配置文件

1)主配置文件

[root@tanbaobao zabbix-3.4.4]# cat /usr/local/nginx/conf/nginx.conf
#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"';
sendfile on;
keepalive_timeout 65;
# 缓存php生成页面内容,8个16k
# fastcgi_buffers 8 16k;
# 缓存php生成的头部信息
# fastcgi_buffers_size 32k;
# 连接php的超时时间
# fastcgi_connect_timeout 300;
# 发送请求的超时时间
# fastcgi_send_timeout 300;
# 读取请求的超时时间
# fastcgi_read_timeout 300;
# 连接外部conf文件
include /usr/local/nginx/conf/thy/*.conf;
}

2)外部文件

[root@tanbaobao zabbix-3.4.4]# cat /usr/local/nginx/conf/thy/other.conf
server{
listen 80;
server_name 10.0.0.1;
location / {
root html;
# Turn on nginx state
# stub_status on;
index index.html index.htm index.php;
}
location /nginx_status {
stub_status on;
access_log off;
allow 10.0.0.1;
allow 10.0.0.2;
deny all;
} # 缓存php生成页面内容,8个16k
# fastcgi_buffers 8 16k;
# 缓存php生成的头部信息
# fastcgi_buffers_size 32k;
# 连接php的超时时间
# fastcgi_connect_timeout 300;
# 发送请求的超时时间
# fastcgi_send_timeout 300;
# 读取请求的超时时间
# fastcgi_read_timeout 300; location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

3)启动服务

# 确保防火墙已关闭,selinux为disabled
[root@tanbaobao zabbix-3.4.4]# /usr/local/nginx/sbin/nginx -s reload
[root@tanbaobao zabbix-3.4.4]# systemctl restart mariadb
[root@tanbaobao zabbix-3.4.4]# systemctl restart php-fpm

4)测试PHP页面网页连通性

# 编写test测试页面
[root@tanbaobao zabbix-3.4.4]# cat /usr/local/nginx/html/test.php
<?php
phpinfo();
?> # 通过浏览器或curl访问
[root@tanbaobao zabbix-3.4.4]# curl http://10.0.0.1/test.php

部署监控服务zabbix_server

1. 源码安装zabbix server

1)安装依赖包

[root@tanbaobao zabbix-3.4.4]# yum -y install net-snmp-devel curl-devel libevent-devel
# 将下载好的zabbix源码包解压编译安装zabbix_server
[root@tanbaobao zabbix-3.4.4]# tar -zxvf zabbix-3.4.4.tar.gz
[root@tanbaobao zabbix-3.4.4]# cd zabbix-3.4.4/
[root@tanbaobao zabbix-3.4.4]# ./configure --enable-server \
> --enable-proxy \
> --enable-agent \
> --with-mysql=/usr/bin/mysql_config \
> --with-netsnmp \
> --with-libcurl
[root@tanbaobao zabbix-3.4.4]# make && make install

2)初始化zabbix

  创建数据库,上线zabbix web页面

创建数据库:

# 创建zabbix数据库,支持中文集,并授予相应权限
[root@tanbaobao zabbix-3.4.4]# mysql
MariaDB [(none)]> create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'localhost' identified by '密码';
Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec) # 上面创建的是空数据库,数据在/usr/local/src/zabbix-3.4.4/database/mysql目录下,导入数据注意顺序
[root@tanbaobao zabbix-3.4.4]# cd /usr/local/src/zabbix-3.4.4/database/mysql/
[root@tanbaobao mysql]# ls
data.sql images.sql schema.sql
[root@tanbaobao mysql]# mysql -uzabbix -p数据库密码 zabbix < schema.sql
[root@tanbaobao mysql]# mysql -uzabbix -p数据库密码 zabbix < images.sql
[root@tanbaobao mysql]# mysql -uzabbix -p数据库密码 zabbix < data.sql

上线的web页面:

# 将zabbix的php页面代码复制到nginx发布目录下
[root@tanbaobao src]# cd /usr/local/src/zabbix-3.4.4/frontends/php/
[root@tanbaobao php]# cp -r * /usr/local/nginx/html/
[root@tanbaobao php]# chmod -R 777 /usr/local/nginx/html/

修改zabbix_server配置文件相关参数:

[root@tanbaobao php]# cat /usr/local/etc/zabbix_server.conf | grep -v '^$' | grep -v "^#"
LogFile=/tmp/zabbix_server.log # 日志设置
DBHost=localhost # 数据库主机,默认注释
DBName=zabbix # 数据库名称
DBUser=zabbix # 数据库用户
DBPassword=密码 # 数据库密码,默认注释
Timeout=4
LogSlowQueries=3000 # 创建zabbix用户
[root@tanbaobao php]# useradd -s /sbin/nologin zabbix # 启动zabbix_server服务
[root@tanbaobao php]# zabbix_server
# 查看服务是否正常启动,如果没有启动,先用killall 服务名之后再重新启动服务
[root@tanbaobao php]# ss -ntulp | grep zabbix_server
tcp    LISTEN     0      128       *:10051                 *:*                   users:(("zabbix_server"......

修改zabbix_agentd配置文件:

[root@tanbaobao php]# cat /usr/local/etc/zabbix_agentd.conf | grep -v '^$' | grep -v "^#"
LogFile=/tmp/zabbix_agentd.log # 日志设置
Server=127.0.0.1,10.0.0.1 # 允许哪些主机可以监控本机
ServerActive=127.0.0.1,10.0.0.1 # 允许哪些主机通过主动模式监控本机
Hostname=tanbaobao # 设置本机主机名
UnsafeUserParameters=1 # 开启允许自定义key # 启动agentd服务
[root@tanbaobao php]# zabbix_agentd
[root@tanbaobao php]# ss -ntulp | grep zabbix_agentd
tcp LISTEN 0 128 *:10050 *:* users:(("zabbix_agentd"........

浏览器访问页面:http://ip/index.php

点击下一步根据错误提示:

[root@tanbaobao html]# yum -y install php-gd php-xml php-bcmath php-mbstring

修改/etc/php.ini文件如下内容:

# 重启php-fpm服务
[root@tanbaobao html]# systemctl restart php-fpm

发现有个警告:(当然这个warning不解决也没关系,但是我这边还是解决比较好点)

解决:

# 查看是否有该模块(发现并没有该模块)
[root@tanbaobao html]# find / -name "ldap.so" # 安装ldap模块(参考https://www.cnblogs.com/bigdevilking/p/9440098.html)
[root@tanbaobao html]# yum -y install php-ldap # 再次查看发现ldap模块已经存在了
[root@tanbaobao html]# find / -name "ldap.so"
/usr/lib64/php/modules/ldap.so # 重启服务
[root@tanbaobao html]# systemctl restart php-fpm

初始化数据库页面:

使用用户名和密码登录zabbix(登录之后可以设置界面语言环境为中文):

2. 搭建被监控端zabbix_agentd

[root@VM_0_16_centos zabbix-3.4.4]# useradd -s /sbin/nologin zabbix
[root@VM_0_16_centos zabbix-3.4.4]# tar -zxvf zabbix-3.4.4.tar.gz
[root@VM_0_16_centos src]# cd zabbix-3.4.4/ [root@VM_0_16_centos zabbix-3.4.4]# ./configure --enable-agent
[root@VM_0_16_centos zabbix-3.4.4]# make && make install [root@VM_0_16_centos zabbix-3.4.4]# cat /usr/local/etc/zabbix_agentd.conf
Server=监控服务ip # 被动模式
ServerActive=监控服务ip # 主动模式
Hostname=VM_0_16_centos # 被监控主机自己主机名
EnableRemoteCommands=1 # 监控异常后,允许远程登录执行命令

3.配置使用zabbix监控系统

1)添加监控主机

添加监控主机,名称建议和主机名一致,也可以不一致

2)为被监控主机添加模板

  选择模板并连接到主机

到此,监控端主机添加完成

【zabbix部署】基于linux安装zabbix监控服务和被监控服务的更多相关文章

  1. Linux 安装zabbix

    Linux 安装zabbix   zabbix是基于web界面的开源分布式监控平台,可以监控各种服务器的配置参数,支持自定义配置和自定义告警,并且可以实现邮件.短信等方式的告警,zabbix基本组件如 ...

  2. linux安装Zabbix监控

    源码包3.4.0下载  https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.0/zabbix-3.4 ...

  3. zabbix源码编译安装以及添加第一台host监控

    基础准备 硬件需求 数据库需求   软件需求 其他软件需求 安装 安装方式 source code 编译好的二进制包 rpm或者deb 源码编译安装部署zabbix以及附件 前提准备 最小化安装操作系 ...

  4. linux安装zabbix的tar包和另外一个并存

    在安装zabbix客户端的时候,发现存在一个zabbix客户端,现在我们要重新建一个来与之并存 第一步安装: cd /data0/software/ tar xf zabbix-3.0.28.tar. ...

  5. 基于Oracle安装Zabbix

    软件版本 Oracle Enterprise Linux 7.1 64bit Oracle Enterprise Edition 12.1.0.2 64bit Zabbix 3.2.1 准备工作 上传 ...

  6. (转)基于CentOS 7安装Zabbix 3.4和Zabbix4.0

    原文:https://blog.csdn.net/leshami/article/details/78708049 CentOS 7环境下Zabbix4.0的安装和配置实例-----------htt ...

  7. 使用Ubuntu系统编译安装Zabbix企业级监控系统

    使用Ubuntu系统编译安装Zabbix企业级监控系统   作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. Ubuntu系统部署笔记:https://www.cnblogs.com/ ...

  8. Centos 源码安装zabbix 2.4.5

    Zabbix简介 Zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案.zabbix能监视各种网络参数,保证服务器系统 的安全运营:并提供柔软的通知机制以让系统管 ...

  9. CentOS 7 源码安装 Zabbix 6.0

    Zabbix 主要有以下几个组件组成: Zabbix Server:Zabbix 服务端,是 Zabbix 的核心组件.它负责接收监控数据并触发告警,还负责将监控数据持久化到数据库中. Zabbix ...

随机推荐

  1. Leetcode_01【两数之和】

    文章目录:  题目 脚本一及注释 脚本逻辑 脚本二及注释 脚本逻辑 题目: 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标. ...

  2. Vue + TypeScript 踩坑总结

    vue 和 TypeScript 结合的情况下,很多写法和我们平时的写法都不太一样,这里总结我项目开发过程中遇到的问题和问题的解决方案 有些问题可能还没解决,欢迎各位大佬给与提点. 另外,使用本文前可 ...

  3. 灵魂拷问:Java 的 substring() 是如何工作的?

    在逛 programcreek 的时候,我发现了一些小而精悍的主题.比如说:Java 的 substring() 方法是如何工作的?像这类灵魂拷问的主题,非常值得深入地研究一下. 另外,我想要告诉大家 ...

  4. Python的Requests库基本方法函数

    一.Requests 库的七个常用函数: 1. requests.request(method,url,**kwargs) :method:请求方式,对应get/put/post等七种 :拟获取页面的 ...

  5. luogu P3830 [SHOI2012]随机树

    输入格式 输入仅有一行,包含两个正整数 q, n,分别表示问题编号以及叶结点的个数. 输出格式 输出仅有一行,包含一个实数 d,四舍五入精确到小数点后 6 位.如果 q = 1,则 d 表示叶结点平均 ...

  6. vue 组件传递值以及获取DOM元素的位置信息

    1.父组件 select_li.vue 1.1 父组件模板 <template> <div id='selectLi' ref="selectLi"> &l ...

  7. 面试还搞不懂redis,快看看这40道面试题(含答案和思维导图)

    Redis 面试题 1.什么是 Redis?. 2.Redis 的数据类型? 3.使用 Redis 有哪些好处? 4.Redis 相比 Memcached 有哪些优势? 5.Memcache 与 Re ...

  8. webpack学习_webpack-dev-server自动编译代码

    之前每次修改完之后都要执行npm run build来编译,下面有三种方式可以实现代码变化后自动编译代码,下面只重点说webpack-dev-server,其他的请看webpack开发文档 1.web ...

  9. CCF-CSP题解 201403-4 无线网络

    新建不超过\(k\)个无线路由器,求使路由器1.2连通最少的中间路由器. 首先常规建图,将相距不超过\(r\)的路由器(包括新建的)相连. 想到了分层\(dijkstra\).类似的,作\(bfs\) ...

  10. 《Java基础知识》Java变量的声明、初始化和作用域

    一.Java变量的声明 在 Java 程序设计中,每个声明的变量都必须分配一个类型.声明一个变量时,应该先声明变量的类型,随后再声明变量的名字.下面演示了变量的声明方式. double salary; ...