目标:快速搭建zabbix使用环境,无需花费太多时间在安装上。通常公司招聘有zabbix需求的,zabbix应该都是已安装好的。
多熟悉功能比较好。
环境如下:
CentOS Linux release 7.4.1708 (Core) //最小化安装
初始化
//更新一次系统
yum update -y
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld
reboot
安装,使用官方源进行安装
rpm -ivhhttp://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
//zabbix 基于Apache、MysqL、PHP进行构建,所以需要安装httpd、MysqL、PHP
//centos7使用mariadb取代MysqL,但操作命令都一样
yum install zabbix-server-MysqL zabbix-web-MysqL mariadb-server mariadb -y
//启动apache、mariadb
systemctl start httpd
systemctl enable httpd
systemctl start mariadb
systemctl enable mariadb
MysqL_secure_installation //MysqL初始化,设置密码,全部选Y
//创建zabbix数据库,zabbix用户、密码zabbix
//输入你刚刚设置的密码
MysqL -uroot -p
// 创建zabbix数据库,并设置编码为utf8,防止中文乱码
create database zabbix character set utf8 collate utf8_bin;
//创建zabbix用户给zabbix数据库,zabbix用户密码为zabbix
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
flush privileges;
//写入数据,需输入zabbix用户的密码zabbix
zcat /usr/share/doc/zabbix-server-MysqL-3.4.2/create.sql.gz |MysqL -uzabbix -p zabbix
配置
cp /etc/zabbix/zabbix_server.conf{,.bak20170929}
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
//修改下时区
cp /etc/httpd/conf.d/zabbix.conf{,.bak20170929}
/etc/httpd/conf.d/zabbix.conf
PHP_value date.timezone Asia/Shanghai
//启动zabbix-server,并设置开机启动
systemctl start zabbix-server
systemctl enable zabbix-server
访问web页面:ip/zabbix
设置中文
在被监控主机上安装zabbix-agent
yum update -y
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld
reboot
rpm -ivhhttp://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
yum install zabbix-agent
cp /etc/zabbix/zabbix_agentd.conf{,.bak20170929}
vim /etc/zabbix/zabbix_agentd.conf
systemctl start zabbix-agent
systemctl enable zabbix-agent
等10分钟左右,到 监测中--图形那里去查看
乱码解决
将windows下的C:\Windows\Fonts\msyh.ttc 上传到zabbix-server /usr/share/zabbix/fonts 目录下
替换字体
sed -i 's/graphfont/msyh/g' /usr/share/zabbix/include/defines.inc.PHP