zabbix--完整安装攻略
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
rpm -ql zabbix-release # 查看zabbix-release安装了哪些包(其中就有/etc/yum.repos.d/zabbix.repo)
yum makecache # 就是把服务器的包信息下载到本地电脑缓存起来
安装zabbix部署包
yum install zabbix-server-mysql zabbix-web-mysql
自己监控自己需要如下两个包
yum -y install zabbix-server zabbix-agent
下载zabbix用的数据库,有的可略过
yum -y install mariadb-server
systemctl start mariadb # 开启数据库 mysql -uroot –p # 登录数据库 create database zabbix character set utf8 collate utf8_bin; # 创建数据库 grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; # 创建zabbix用户密码zabbix,并授权 FLUSH PRIVILEGES;
导入初始架构(Schema)和数据
cd /usr/share/doc/zabbix-server-mysql-3.4.15/ zcat create.sql.gz | mysql -uroot zabbix -p # 将表导入到刚刚创建的zabbix数据库中,可登陆数据库检查
修改配置文件:
vim /etc/zabbix/zabbix_server.conf
LogFileSize=0 PidFile=/var/run/zabbix/zabbix_server.pid SocketDir=/var/run/zabbix DBUser=zabbix SNMPTrapperFile=/var/log/snmptrap/snmptrap.log Timeout=4 AlertScriptsPath=/usr/lib/zabbix/alertscripts ExternalScripts=/usr/lib/zabbix/externalscripts LogSlowQueries=3000 DBHost=localhost DBName=zabbix DBPassword=zabbix DBPort=3306 LogFile=/var/log/zabbix/zabbix_server.log
关闭防火墙:vim /etc/selinux/config
SELINUXTYPE=targeted
SELINUX=disabled
setenforce 0
systemctl stop firewalld
启动zabbix服务
systemctl start zabbix-server
systemctl status zabbix-server
编辑zabbix的前端PHP配置:
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/ShangHai # 将时区改成上海,注释去掉
启动Apache服务
systemctl start httpd
systemctl status httpd
配置成功,访问 http://0.0.0.0/zabbix/setup.php ip改成部署服务的linux ip (ipconfig)即可
用户名/密码:Admin/zabbix
将自己添加到监控中:
vim /etc/zabbix/zabbix_agentd.conf
Include=/etc/zabbix/zabbix_agentd.d/*.conf
Hostname=Zabbix server
ServerActive=127.0.0.1
LogFileSize=0
LogFile=/var/log/zabbix/zabbix_agentd.log
PidFile=/var/run/zabbix/zabbix_agentd.pid
Server=192.168.88.136 # ip换成自己的ip
UserParameter=log_user, /usr/bin/w|awk 'NR==1{print $4}' # 或 w|awk -F ',' 'NR==1{print $2}'|awk 'NR==1{print $1}' 获取当前用户数量,
EnableRemoteCommands=1
重启server-agent,使配置生效
systemctl restart zabbix-agent
在页面上:--配置---主机(将接口改成自己ip)
至此,最简单的配置监控系统zabbix监控自己的任务已经搞定!!
转载自:01. https://www.cnblogs.com/xiaonq/p/9117226.html
02. https://www.cnblogs.com/xiaonq/p/9117420.html
# 启动服务命令 关闭selinux setenforce 0 查看状态 getenforce 关闭防火墙 systemctl stop firewalld 启动mysql systemctl start mariadb mysql -u root -p 启动server : systemctl start zabbix-server 查看日志 tail -999f /var/log/zabbix/zabbix_server.log 开启Apache服务: systemctl start httpd 启动 agent: systemctl start zabbix-agent 查看日志 tail -f /var/log/zabbix/zabbix_server.log