ZABBIX部署流程

一、zabbix基础服务架构

在这里插入图片描述

二、zabbix环境部署

zabbix部署前置环境配置

1、centos7.6纯净环境;
2、确认防火墙是否关闭:

systemctl status firewalld.service
systemctl stop firewalld.service
systemctl disable firewalld.service

3、确认关闭SELINUX:
方法一永久关闭:


 - 方法1

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config 
#记得修改完cat /etc/selinux/config查看一下,然后reboot重启主机

 - 方法2

vim /etc/sysconfig/selinux:

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing – SELinux security policy is enforced.

# permissive – SELinux prints warnings instead of enforcing.

# disabled – SELinux is fully disabled.

SELINUX=enforcing

# SELINUXTYPE= type of policy in use. Possible values are:

# targeted – Only targeted network daemons are protected.

# strict – Full SELinux protection.

SELINUXTYPE=targeted

把 SELINUX修改为disable, 重新启动系统后将会停止SElinux。
方法二暂时关闭:

不重启关闭selinux的解决办法:

执行命令:setenforce 0
部署过程
  • server端安装
#安装php 第三方源
yum install epel-release.noarch -y
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
​
#安装 nginx、php7.2 和所需 php 扩展模块
yum install nginx  php72w-cli php72w-fpm php72w-common php72w-mysqlnd php72w-mbstring  php72w-gd php72w-bcmath php72w-ldap php72w-xml -y
​
#修改php-fpm的配置
vim  /etc/php-fpm.d/www.conf

PS:如果选择是部署时nginx,就将
user = 
group = 
均修改为nginx,否则默认apache

#修改nginx的配置(参照默认default的nginx配置进行配置,需要注意配置的html路径)
vim  /etc/nginx/nginx.conf
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   /html;
            index  index.php index.html index.htm;
        }
        location ~ \.php$ {
            root           /html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /html$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}#启动nginx和php-fpm
systemctl start nginx
systemctl enable nginx
systemctl start php-fpm
systemctl enable php-fpm
​
#安装 zabbix-web
​
cd /opt/
#下载源码包
wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.4.tar.gz
tar xf zabbix-5.0.4.tar.gz
mkdir /html
#拷贝zabbix-web到站点目录
cp -a zabbix-5.0.4/ui/* /html
#修改站点目录属主和属组
chown -R nginx:nginx /html
​
#解决web页面500 ERROR
mkdir /var/lib/php/session
chown -R nginx:nginx /var/lib/php/session
​
#修改php配置消除警告
vim /etc/php.ini
post_max_size = 8M
修改为
post_max_size = 16M
​
max_execution_time = 30
修改为
max_execution_time = 300
​
max_input_time = 60
修改为
max_input_time = 300
​
;date.timezone =
去掉注释,并修改为
date.timezone = Asia/Shanghai
​
#重启php-fpm,并刷新浏览器
systemctl restart php-fpm.service
​
#安装 zabbix-server#安装数据库 
yum install mariadb-server -y
启动数据库
systemctl start mariadb
systemctl enable mariadb.service
设置密码
[root@test3 ~]# mysql_secure_installation
#建议执行下mysql_secure_installation
Enter current password for root (enter for none):  
提示输入密码,没有密码就直接回车
Set root password? [Y/n] 
提示设置root user密码  
New password: 输入密码
Re-enter new password: 再次输入密码
Remove anonymous users? [Y/n] 
生产环境建议删除系统创建的匿名用户  
Disallow root login remotely? [Y/n] 
禁止root用户远程登录  
Remove test database and access to it? [Y/n] 
删除test数据库  
Reload privilege tables now? [Y/n] 
重载权限表  

#为zabbix创库授权
[root@zabbix-5 opt]# mysql -uroot -p
Enter password:
​
MariaDB [(none)]>  create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
​
MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
​
#安装 zabbix-server
rpm -ivh https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum install zabbix-server-mysql -y
#导入zabbix初始数据文件
zcat /usr/share/doc/zabbix-server-mysql-*/create.sql.gz |mysql -uzabbix -p123456 zabbix
​
#修改zabbix-server配置
vim /etc/zabbix/zabbix_server.conf
#配置下数据库的连接信息
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
​
#启动 zabbix-server
systemctl start zabbix-server.service
systemctl enable zabbix-server.service
​
#打开浏览器,继续安装
浏览器初始化配置
  1. 浏览器输入安装zabbix-server的主机ip,进入zabbix配置页面;
  2. 初始页面点击next step;
  3. 接着是Zabbix要求和当前配置对比,需要全部满足要求即全部呈现OK,点击next step;
  4. 接着是配置mysql数据库账号和密码,将之前数据库创建zabbix用户的密码填入后,点击next step;
  5. 接着配置zabbix的web页面显示名称,这个随意配置为XXX的zabbix监控,点击next step;
  6. 接着页面来到登录页面,首次登陆zabbix页面密码为Admin,密码为zabbix,点击sign in,进入zabbix配置页面。
  7. 初始页面为英文,可以手动配置中文模式 点击左下角user settings,在语言中选择中文。保存就配置完成,刷新就会呈现中文页面了。
配置接入监控主机

1、监控zabbix-server自己
下载agent端进行监听:

yum install zabbix-agent.x86_64 -y
systemctl enable zabbix-agent.service 
systemctl start zabbix-agent.service

浏览器配置:
1、创建主机:
在这里插入图片描述
2、配置被监控主机:
在这里插入图片描述
3、选择模板,进行模板配置(点击模板进行配置,在输入栏选择linux by zabbix agent,这个模板,选择确认):
在这里插入图片描述
4、添加成功之后,稍等一会,刷新页面,灰色的ZBX变成绿色,则表示添加完成。
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值