一,Zabbix大纲
,
一,zabbix6.4安装
配置:
技术 | 版本 |
---|---|
CentOS | 8.0 |
Zabbix | 6.0 |
一,zabbix部署安装流程:
1,环境配置
1.1,关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i "s/enforcing/permissive/g" /etc/selinux/config
1.2,换源
cd /etc/yum.repos.d
rm -rf *
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum clean all
yum makecache
1.3,安装依赖包
yum install scl-utils-* apr-* rsync lsof perl-DBD-MySQL socat php-bcmath php-xml php-ldap php-json php-gd php-mysqlnd php-mbstring php-fpm php-bcmath OpenIPMI httpd net-snmp-* boost-program-options-* createrepo unzip -y
1.4,安装Zabbix存储库
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
#去zabbix官网复制rpm包
dnf clean all
下载Zabbixhttps://www.zabbix.com/cn/download
目录 | 地址 |
zabbix.6.4 | rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/8/x86_64/zabbix-release-6.4-1.el8.noarch.rpm |
zabbix.6.0 | rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpm |
1.5,安装Zabbix server与Web前端
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy
2,配置数据库
2.1,引入mariadb源
cat <<EOF > /etc/yum.repos.d/mariadb.repo
# MariaDB 10.6 CentOS repository list - created 2022-01-16 15:10 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://mirrors.cloud.tencent.com/mariadb/yum/10.6/centos8-amd64
module_hotfixes=1
gpgkey=https://mirrors.cloud.tencent.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF
2.2,安装数据库
dnf -y install mariadb-server
2.3,启动数据库并设置开机自启
systemctl start mariadb && systemctl enable mariadb
2.4,初始化数据库
mariadb-secure-installation
2.5,授权数据库
mysql -uroot -p #此处我直接回车未定义密码
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@localhost identified by 'password'; #此处我定义密码为password
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;
2.6,导入初始架构和数据
# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
#输入密码:password
或者手动导入表结构
mysql -uzabbix -pzabbix@findsec123 zabbix < /home/zabbix-6.4.8/database/mysql/schema.sql
mysql -uzabbix -pzabbix@findsec123 zabbix < /home/zabbix-6.4.8/database/mysql/images.sql
mysql -uzabbix -pzabbix@findsec123 zabbix < /home/zabbix-6.4.8/database/mysql/data.sql
#密码自定义
此时执行下述命令查看数据库,可见架构与数据均已导入
mysql -u root -p
> use zabbix;
> show tables;
2.7,为Zabbix server配置数据库
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost #去掉注释
DBPassword=password #去掉注释并填入password
3,配置php
vim /etc/php.ini
post_max_size = 16M #由8M改为16M
max_execution_time = 300 #由30改为300
max_input_time = 300 #由60改为300
4,配置nginx
vim /etc/nginx/conf.d/zabbix.conf
listen 80; #去掉注释
server_name example.com; #去掉注释
cp -r /usr/share/zabbix/ /usr/share/nginx/html/ #复制主目录
5,安装中文包
dnf install langpacks-zh_CN.noarch # 安装zh_CN语言包
dnf -y install glibc-common # 安装glibc-common实现对语言包的识别
# locale -a | grep zh_CN
zh_CN
zh_CN.gb18030
zh_CN.gbk
zh_CN.utf8
6,启动服务并设置开机自启
systemctl restart zabbix-server nginx php-fpm
systemctl enable zabbix-server nginx php-fpm
7,访问页面
用户:Admin
密码:zabbix
1,依赖关系
2,zabbix二进制安装
关闭selinux | vim /etc/selinux/config SELINUX=disabled Sestatus rboot |
centos 7 添加阿里云镜像(这是7的镜像,如果安装8请改成“centos-8.repo”) | wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum install epel-release
或者: # rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm # yum clean all (zabbix官方镜像5.0)
|
安装常用的开发组件 | yum groups install "Development Tool" yum groups info "Development Tools" |
| |
增加zabbix镜像源 | zabbix4.0 : rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm zabbix5.0 : rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm Zabbix6.0 rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/7/x86_64/zabbix-release-6.4-1.el7.noarch.rpm |
| |
| yum install iptables-services |
| |
安装zabbix server和fronted | yum install zabbix-server-mysql yum install zabbix-web-mysql |
| |
数据库安装 | yum install mariadb-server |
systemctl start mariadb.service | |
systemctl status mariadb.service | |
mysql_secure_installation | |
| |
Passwd:zhao | |
创建数据库 | mysql -uroot -p |
create database zabbix character set utf8 collate utf8_bin; | |
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix@findsec123'; | |
| |
导入数据结构 | zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix@findsec123 zabbix |
| |
修改zabbix server配置 | vim /etc/zabbix/zabbix_server.conf |
DBHost=localhost | |
DBName=zabbix | |
DBUser=zabbix | |
DBPassword=zabbix@findsec123 | |
| |
| |
| |
启动服务 | systemctl start zabbix-server.service systemctl enable zabbix-server.service systemctl status zabbix-server.service |
tailf /tmp/zabbix_server.log | |
| |
配置Zabbix frontend | vim /etc/php.ini |
max_execution_time = 300 | |
memory_limit = 128M | |
post_max_size = 16M | |
upload_max_filesize = 2M | |
max_input_time = 300 | |
max_input_vars = 10000 | |
always_populate_raw_post_data = -1 | |
date.timezone = Asia/Shanghai | |
| |
启动httpd | systemctl start httpd.service systemctl enable httpd.service |
systemctl status httpd.service | |
| |
web登录 | |
| |
默认账户名 | Admin |
默认密码 | zabbix |
| |
安装Zabbix Agent | yum install zabbix-agent |
systemctl start zabbix-agent.service |
虚拟机会自动更改IP地址,注意!
3,zabbix容器安装
yum install docker | ||
4,安装一个agent
安装zabbix源 | rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm | |
安装zabbix-agent包 | yum search zabbix-agent yum install zabbix-agent | |
配置agent | vim /etc/zabbix/zabbix_agentd.conf server= //server的IP地址 serveractive= //server的IP地址 hostname= //server的名称保持一致 | |
打开agent服务 | systemctl start zabbix-agent.service | |
开机自启agent服务 | systemctl enable zabbix-agent.service | |