Zabbix1.0 4.4.5 + Centos7.7-安装

396 阅读2分钟

工作要求因为目前公司使用cacti过于古董,加上精力不足,所以学习一下怎么搭建zabbix,争取早日学会。

服务器安装

#按照文章顺序做:

Centos 7 增加Zabbix镜像源
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
Centos 7 添加阿里云镜像
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all 
yum clean packages

#安装常用的开发组件
yum install epel-release
yum -y groups install "Development Tools"

#关闭防火墙
systemctl stop firewalld.service
systemctl disable  firewalld.service

#关闭SElinux
vim /etc/selinux/config
SELINUX=disabled #改成这样

#安装 iptables(可有可无,我其实选择直接装firewall)
yum install iptables-services

#安装Zabbix Server和Frontend
yum install -y zabbix-server-mysql
yum install -y zabbix-web-mysql

#安装MySQL并添加开机自启动
yum install -y mariadb-server
systemctl  start mariadb.service
systemctl  status mariadb.service
systemctl enable mariadb.service

#初始化MySQL
mysql_secure_installation
>(这个符号不出现在现实里)
Set root password? [Y/n]    #是否设置root用户密码,输入y并回车或直接回车
New password:               #设置root用户的密码
Re-enter new password:      #再输入一次你设置的密码
Remove anonymous users? [Y/n]   #是否删除匿名用户,生产环境建议删除,所以直接回车
Disallow root login remotely? [Y/n] #是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
Remove test database and access to it? [Y/n] #是否删除test数据库,直接回车
Reload privilege tables now? [Y/n] #是否重新加载权限表,直接回车
>(这个符号不出现在现实里)

#创建数据库
mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;

GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'dubhe1989-zabbix';

Ps:《grant all privileges on zabbix.* to zabbix@localhost identified by ‘dubhe1989-zabbix’;》
中‘dubhe1989-zabbix’是密码,可以自定义,单引号也要打。

#导入数据结构
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pdubhe1989-zabbix  zabbix

Ps: 同理。dubhe1989-zabbix 也是密码。自定义后都要改。

#配置Zabbix Serve
vim /etc/zabbix/zabbix_server.conf

配置DBpasswd密码(就是你自己设置的密码)
91  DBHost=localhost
100 DBName=zabbix
116 DBUser=zabbix

#启动Zabbix Server
systemctl  start zabbix-server.service
systemctl  status zabbix-server.service

more /var/log/zabbix/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
date.timezone = Asia/Shanghai

启动httpd
systemctl  start  httpd.service
systemctl  status  httpd.service


http://你的服务器ip/zabbix/setup.php

Admin(A是大写的)
zabbix