zabbix5.2安装教程

视频教程

Zabbix+Grafana视频讲解

准备工作

工作目录/opt

cd /opt

关闭防火墙

# 关闭防火墙
systemctl stop firewalld.service
# 禁止开机自启
systemctl disable firewalld.service

关闭selinux

# 打开selinux的配置文件
vim /etc/selinux/config
# 将第7行的enforcing改为disabled
SELINUX=disabled

Yum清华源

sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
         -e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' \
         -i.bak \
         /etc/yum.repos.d/CentOS-*.repo
# 生成缓存
sudo yum makecache

下载依赖环境

yum install deltarpm -y
yum -y install gcc gcc-c++ unixODBC-devel httpd mysql-devel libcurl libcurl-devel libevent libevent-devel fping curl-devel libxml2  libxml2-devel snmpd net-snmp-devel net-snmp
yum install -y pcre-devel  java-devel openssl-devel libxslt* perl-ExtUtils-Embed at gcc-c++ python subversion gperf make rpm-build git curl bzip2-devel libcurl-devel gd gd-devel t1lib t1lib-devel libmcrypt libmcrypt-devel libtidy libtidy-devel GeoIP-devel libatomic_ops-devel zlib-devel unzip libstdc++* net-snmp net-snmp* gmp gmp-devel openldap openldap-devel libpcap-devel glib2-devel GeoIP-devel libxml2-devel redis vim wget git htop iftop libtool make automake mlocate openssl-devel pam-devel unzip gcc screen openssl openssl-devel iptables-services bash-completion* pcre-devel openssl-devel libxslt* perl-ExtUtils-Embed at gcc-c++ python subversion gperf make rpm-build git curl bzip2-devel libcurl-devel gd gd-devel t1lib t1lib-devel libmcrypt libmcrypt-devel libtidy libtidy-devel GeoIP-devel libatomic_ops-devel zlib-devel unzip libstdc++* net-snmp net-snmp* gmp gmp-devel openldap openldap-devel net-tools libevent-devel net-snmp-devel mysql-devel libxslt-devel libssh2-devel jdk-8u191-linux-x64.rpm unixODBC-devel httpd  libcurl  libevent  fping curl-devel libxml2  snmpd net-snmp-devel net-snmp

准备LNMP

参考文章:

  1. Centos安装Lnmp
  2. Grafana图形展示软件

安装Zabbix

下载zabbix-server

# 进入到opt目录
cd /opt
# 下载二进制包
wget https://cdn.zabbix.com/zabbix/sources/stable/5.2/zabbix-5.2.1.tar.gz
# 解压
tar -zxvf zabbix-5.2.1.tar.gz
# 进入到zabbix目录
cd zabbix-5.2.1
# 编译安装
./configure --prefix=/usr/local/zabbix/zabbix-server --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --enable-java && make && make install
# 参数说明
--prefix              #编译安装路径
--enable-server       #启动server端
--enable-agent        #启动agent端
--with-mysql          #编译连接mysql相关依赖包
--with-net-snmp       #启动snmp相关,用于snmp监控设备
--with-libcurl        #启动curl相关
--with-libxml2        #启动xml相关
--with-unixodbc       #启动odbc相关用于监控数据库
--enable-java         #启动java-agent 用于监控java类

# 设置环境变量
vim /etc/profile

export PATH=$PATH:/usr/local/zabbix/zabbix-server/sbin/:/usr/local/zabbix/zabbix-server/bin/

source /etc/profile

创建zabbix数据库

# mariadb
# 创建用户
CREATE USER '用户名'@'localhost' IDENTIFIED BY '密码';

# 创建数据库zabbix
CREATE DATABASE `数据库名` CHARACTER SET utf8 COLLATE utf8_bin;

# 赋予权限
grant all privileges on 数据库名.*to 用户名@'localhost' identified by '密码';

# 刷新权限
flush privileges;

# 设置编码
set names utf8;

# 创建完导入zabbix 初始化数据

mysql -uroot -p密码 zabbix < /opt/zabbix-5.2.1/database/mysql/schema.sql # 表结构
mysql -uroot -p密码 zabbix < /opt/zabbix-5.2.1/database/mysql/images.sql # 图片相关数据
mysql -uroot -p密码 zabbix < /opt/zabbix-5.2.1/database/mysql/data.sql   # 模版相关数据

Centos准备

# 创建用户
useradd zabbix
passwd  zabbix
# 赋予权限
chown -R zabbix:zabbix /usr/local/zabbix/zabbix-server/

# 修改zabbix-server的配置文件
vi /usr/local/zabbix/zabbix-server/etc/zabbix_server.conf

# 找到对应的属性修改
#数据库地址
DBHost=localhost
#数据库名
DBName=zabbix
#数据库用户名
DBUser=zabbix
#数据库密码
DBPassword=root
#数据库端口
DBPort=3306
Timeout=30
AlertScriptsPath=/usr/local/zabbix/zabbix-server/share/zabbix/alertscripts
ExternalScripts=/usr/local/zabbix/zabbix-server/share/zabbix/externalscripts

# 检查端口
ps auxf|grep zabbix_server
netstat -tulnp|grep zabbix

# 清空html下的文件并剪切
rm -rf /usr/local/nginx/nginx/html/*
cp -a /opt/zabbix-5.2.1/ui/* /usr/local/nginx/nginx/html/
# php.ini调整
vim /etc/opt/remi/php74/php.ini

post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai

#启动相关项目
systemctl restart php74-php-fpm.service
zabbix_server

##Zabbix默认用户名密码
Admin
zabbix

zabbix客户端安装

# 创建用户
useradd zabbix
# 下载Zabbix_agent安装包
wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.4.7/zabbix-4.4.7.tar.gz
# 解压
tar -zxvf zabbix-3.4.15.tar.gz
# 进入目录
cd zabbix-3.4.15/
编译zabbix agent
./configure --prefix=/usr/local/zabbix_agent --enable-agent
# 安装
make && make install
# 修改配置文件
vim /usr/local/zabbix_agent/etc/zabbix_agentd.conf

Server=服务端ip地址或域名
ServerActive=服务端ip地址或域名
Hostname=客户端主机名
HostMetadata=自动注册的关键字

# 启动
/usr/local/zabbix_agent/sbin/zabbix_agentd

版权声明:
作者:江霁月
链接:https://www.jiangjiyue.com/maintenance/258.html
来源:江霁月的私人小屋
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
< <上一篇
下一篇>>
文章目录
关闭
目 录