Zabbix是当前主流开源的企业级分布式监控系统。Zabbix特点是:安装部署较简单,且默认自带了多种监控告警模板。也具备较强的仪表盘展示功能;提供API接口,支持脚本调用;支持自定义编写插件以及监控模板。
这里记一下zabbix部署方法。 主要是以下几步。
- 环境配置
- yum安装
- mariadb配置zabbix表结构数据
- 配置zabbix
- 登陆zabbix web
1 基础配置
确保zabbix可用, 测试的时候最好关闭firewalld、selinux
2 安装
yum安装也很方便,只是先要添加yum源。
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
yum install epel-release
EPEL是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目。装上了 EPEL之后,就相当于添加了一个第三方源。
yum -y install zabbix-*
3 数据库中导入zabbix表结构数据
# 安装zabbix
yum -y install mariadb-*
# 开机自启动给
systemctl enable mariadb
# 启动mariadb
systemctl start mariadb
mariadb启动之后, 进入数据库,mariadb和mysql用法一样
mysql -u root
配置
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix@123';
flush privileges;
quit;
sql需要冒号结尾
导入数据
zcat /usr/share/doc/zabbix-server-mysql-*/create.sql.gz |mysql -uzabbix -p'zabbix@123' -b zabbix
4 修改zabbix_server.conf配置
先保存一份默认配置备用
cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.source
修改配置
cat > /etc/zabbix/zabbix_server.conf << EOF
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
DebugLevel=3
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix@123
StartPollers=16
StartPollersUnreachable=4
StartTrappers=10
StartPingers=8
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
CacheSize=1024M
StartDBSyncers=8
HistoryCacheSize=1024M
HistoryIndexCacheSize=256M
TrendCacheSize=1024M
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
EOF
启动
# systemctl enable zabbix-server
# systemctl start zabbix-server
配置nginx
vim /etc/nginx/conf.d/zabbix.conf
# 修改端口 和 server_name ,取消注释
listen 8080;
server_name monitor.com;
# 修改时区
echo "php_value[date.timezone] = Asia/Shanghai" >> /etc/php-fpm.d/zabbix.conf
启动 php-fpm和nginx
systemctl enable php-fpm
systemctl restart php-fpm
systemctl enable nginx
systemctl start nginx
5 访问登陆
最后访问 http://ip:8080
按照提示登陆即可。