Zabbix框架
server端:zabbix-server zabbix-server-mysql zabbix-get
web端:zabbix-web zabbix-web-mysql
agent端:zabbix-sender zabbix-agent
前提:
配好本地yum源,以便安装时自动解决依赖
环境:
server:192.168.10.11 agent:192.168.10.12 mysql:192.168.10.10
配置本地域名解析
# cat /etc/hosts
192.168.10.11 node1.kazihuo.com node1
192.168.10.12 node2.kazihuo.com node2
配置HOSTNAME
[root@node1 ~]# cat /etc/sysconfig/network
node1.kazihuo.com
[root@node1 ~]# cat /etc/hostname
node1.kazihuo.com
[root@node2 ~]# cat /etc/sysconfig/network
node2.kazihuo.com
[root@node2 ~]# cat /etc/hostname
node2.kazihuo.com
说明:
因虚拟机环境有限,故zabbix-server也作为一台zabbix-agent使用,当其需要监控起来时要按照agent端进行配置,及修改对应的zabbix_agent.conf文件!
服务端配置:
# wget https://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
# yum -y install zabbix-release-3.2-1.el7.noarch.rpm
# yum -y install zabbix zabbix-server zabbix-server-mysql zabbix-get zabbix-web zabbix-web-mysql zabbix-agent
#安装完成后自动生成以下目录及文件
[root@node1 /etc/zabbix]# tree
.
├── web
│ └── maintenance.inc.php
├── zabbix_agentd.conf
├── zabbix_agentd.d
│ └── userparameter_mysql.conf
└── zabbix_server.conf
2 directories, 4 files
[root@node1 /etc/httpd/conf.d]# ls
zabbix.conf
[root@node1 /usr/share/doc/zabbix-server-mysql-3.2.10]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@node1]# mysql -uroot -p<root_password>
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix';
[root@node1]# zcat /usr/share/doc/zabbix-server-mysql-3.2.*/create.sql.gz | mysql -uzabbix -p zabbix
[root@node1 ~]# cat /etc/zabbix/zabbix_server.conf|grep DB
DBName=zabbix DBUser=zabbix DBHost=192.168.10.10 DBPassword=zabbix
[root@node1 ~]# cat /etc/php.ini
[zabbix] php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 php_value always_populate_raw_post_data -1 # php_value date.timezone Europe/Riga date.timezone = Asia/Shanghai
# 此配置也可在zabbix_server.conf的配置文件中配置,默认以包含,根据需求修改时区即可
[root@node1 ~]# systemctl start httpd.service
[root@node1 ~]# systemctl start zabbix-server
客户端配置:
[root@node2 ~]# yum -y install zabbix-sender zabbix-agent
[root@node2 ~]# cat /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 Server=192.168.10.11 # 允许谁来取我数据 ListenPort=10050 ServerActive=192.168.10.11 # 我主动向谁汇报 Hostname=node2.kazihuo.com
[root@node2 ~]# systemctl start zabbix-agent
页面初始化
# 浏览器输入192.168.10.11/zabbix ,进入欢迎页面
# 检查所需插件是否OK
# 配置zabbix连接的数据库
# 细节设置
# 安装完成
# zabbix初始化页面设置后生成对应的配置文件:/etc/zabbix/web/zabbix.conf.php
# 默认的登录名及密码:Admin/zabbix