LNMP架构基础上zabbix监控平台部署

一、zabbix

1.1 简介

  • 是一款开源的功能强大的分布式监控系统,一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
  • server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视。
  • 是由2部分构成,分别是zabbix server(监控端)与zabbix agent(被监控端)。

1.2 zabbix主要功能

  • CPU负荷
  • 内存使用
  • 磁盘使用
  • 网络状况
  • 端口监视
  • 日志监视

1.3 zabbix的主要特点

  • 安装与配置简单,学习成本低
  • 支持多语言(包括中文)
  • 免费开源
  • 自动发现服务器与网络设备
  • 分布式监视以及WEB集中管理功能
  • 可以无agent监视
  • 用户安全认证和柔软的授权方式
  • 通过WEB界面设置或查看监视结果
  • email等通知功能

1.4 zabbix组件

在这里插入图片描述

  • zabbix server:负责接收agent发送的报告信息的核心组件,所有配置,统计数据及操作数据均由其组织进行
  • zabbix database:用户存储所有配置信息,以及存储由zabbix server收集到的数据
  • zabbix web:zabbix的interface接口,通常与Server运行在同一台主机上
  • zabbix agent:部署在被监控主机上,负责收集本地数据发往server端或proxy端
  • zabbix proxy:常用于分布监控环境中,代理Server收集部分被监控的监控数据并统一发往Server端(通常大于500台主机才需要使用)

1.5 其他组件

cacti是一款图形化的监控分析工具

  • zabbix是基于web界面的提供分布式功能的监控工具,监控上线是300-500台
  • zabbix可以监控网络设备(例如思科、华为等)、服务器(例如IBM、联想、戴尔等)、应用监控(Apache、MQ、中间件、Tomcat等)和服务(HTTP、https、nginx、ssl等)等监控
  • zabbix使用的最稳定的版本是4.0,LTS是指测试,5.0版本在官网下载的时候比4.0版本多了一个nginx服务器的选择
  • ajax:异步刷新
  • zcat:不解压直接查看压缩包

二 LNMP安装环境(使用yum安装的方式)

zabbix(server端)部署

  1. 主机分配
    在这里插入图片描述

  2. 开局优化
    关闭防火墙、网络管理、主机名修改(server、client),仅展示server操作

[root@192 ~]# hostnamectl set-hostname server
[root@192 ~]# su
[root@server ~]# 
[root@server ~]# systemctl stop firewalld && systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@server ~]# setenforce 0 && sed -i "s/SELINUX=*/SELINUX=disabled/g" /etc/selinux/config
[root@server ~]# systemctl stop NetworkManager && systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service. 

在这里插入图片描述

2.1 安装nginx
[root@server ~]# wget 
 http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm	'//下载nginx软件包'
[root@server ~]# vim /etc/yum.repos.d/nginx.repo	'//编辑yum源'
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
[root@server ~]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: base extras nginx-stable updates
Cleaning up list of fastest mirrors
[root@server ~]# yum makecache	'//建立yum缓存'
[root@server ~]# yum install -y nginx
[root@server ~]# systemctl start nginx
[root@server ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 检查80端口
[root@localhost ~]# netstat -natp | grep 80 

在这里插入图片描述
在这里插入图片描述

3.2 安装mysql(mariadb)
 [root@server ~]# yum -y install mariadb-server mariadb
[root@server ~]# systemctl start mariadb.service 
[root@server ~]# systemctl enable mariadb.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@server ~]# netstat -ntap |grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      95170/mysqld  
'//接下来执行mysql安全配置向导'
[root@server ~]# 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): 	'//初次运行直接回车'
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? [Y/n] y	'//y。设置密码'
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? [Y/n] y	'//是否删除匿名用户,建议y删除'
 ... Success!

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? [Y/n] y	'//是否禁止root远程登录,建议y禁止'
 ... Success!

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? [Y/n] n	'//是否删除test数据库,根据实际情况'
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y	'//是否重新加载权限表,建议y'
 ... 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!
[root@server ~]# mysql -uroot -p	'//测试登陆mysql数据库'
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 5.5.65-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               |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> exit
Bye

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

2.3 安装PHP
[root@server ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm	'//升级rpm包'
获取https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
警告:/var/tmp/rpm-tmp.xsEbUC: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:epel-release-7-12                ################################# [100%]
[root@server ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
获取https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
警告:/var/tmp/rpm-tmp.YidqBL: 头V4 RSA/SHA1 Signature, 密钥 ID 62e74ca5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:webtatic-release-7-3             ################################# [100%]

在这里插入图片描述

[root@server ~]# cd /etc/yum.repos.d/
[root@server yum.repos.d]# yum -y install php72w php72w-devel php72w-fpm php72w-gd php72w-mbstring php72w-mysql	'//安装PHP环境工具包'	
[root@server yum.repos.d]# php -v	'//查看版本'
PHP 7.2.27 (cli) (built: Jan 26 2020 15:49:49) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

在这里插入图片描述
在这里插入图片描述

2.4 修改php-fpm配置文件
vim /etc/php-fpm.d/www.conf

user = nginx	     #第8行
group = nginx	     #第10行

在这里插入图片描述

2.5 修改nginx配置文件支持PHP并修改php配置文件
vim /etc/nginx/conf.d/default.conf
index  index.php index.html index.htm;		#第10行添加index.php
 
location ~ \.php$ {                                                  #配置php模块,去掉注释
    root           /usr/share/nginx/html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

在这里插入图片描述
在这里插入图片描述

vim /etc/php.ini

short_open_tag = On    		 		 #202行修改,支持php短标签
expose_php  = Off 		 			 #359行修改,隐藏php版本

##为PHP兼容zabbix进行修改,优化配置要求
max_execution_time = 300				 #368行修改,执行时间
max_input_time = 300					 #378行修改,接收数据等待时向
memory_limit = 128M 					 #389行,每个脚本占用内存
post_max_size = 16M 					 #656行修改,POST数据大小
upload_max_filesize = 2M 				 #799行,下载文件大小
always_populate_raw_post_data = -1   	 #800行添加,可以用$HTTP_RAW_POST DATA
date.timezone = Asia/Shanghai 	         #877行取消注释并添加时区

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
开启服务

systemctl start php-fpm
systemctl enable php-fpm
netstat -natp | grep 9000

systemctl restart nginx

在这里插入图片描述

2.6 测试网页
vim /usr/share/nginx/html/info.php

<?php
     phpinfo();
?>

http://192.168.204.159/info.php

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值