[root@linux-node1 ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[root@linux-node1 ~]# uname -r
2.6.32-573.el6.x86_64
[root@linux-node1 ~]# ifconfig eth0|awk -F "[ :]+" ‘NR==2 {print $4}‘
10.0.0.10
[root@linux-node1 ~]# /etc/init.d/iptables status
iptables: Firewall is not running.
[root@linux-node1 ~]# getenforce
Disabled
[root@linux-node1 ~]# hostname
linux-node1.example.com
# 配置hosts文件
[root@linux-node1 ~]# vi /etc/hosts
127.0.0.1localhost localhost.localdomain localhost4 localhost4.localdomain4
::1localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.10 linux-node1.example.com linux-node1
10.0.0.11 linux-node2.example.com linux-node2
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
更换zabbix源
rpm -ql zabbix-release
yum list zabbix*
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
更换阿里云源
yum -y install zabbix-server-mysql zabbix-web-mysql
PS:zabbix官网
https://www.zabbix.com/documentation/2.4/manual/installation/install_from_packages
检查安装
rpm -ql zabbix
rpm -ql zabbix-server
rpm -ql zabbix-server-mysql
rpm -ql zabbix-web
rpm -ql zabbix-web-mysql
yum -y install mysql-server mysql
\cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
# vim /etc/my.cnf
[mysqld] # 在[mysqld]标签下增加如下三行后保存
character-set-server = utf8
init-connect = ‘SET NAMES utf8‘
collation-server = utf8_general_ci
# /etc/init.d/mysqld start
# mysql
create database zabbix character set utf8 collate utf8_bin;
grant all on zabbix.* to zabbix@‘localhost‘ identified by ‘zabbix‘;
flush privileges;
[root@linux-node1 ~]# cd /usr/share/doc/zabbix-server-mysql-2.4.6/create/
[root@linux-node1 create]# ll -h
总用量 3.0M
-rw-r--r-- 1 root root 951K 8月 11 01:09 data.sql # 数据,最后导入
-rw-r--r-- 1 root root 1.9M 8月 10 16:57 images.sql # 图形,其次导入
-rw-r--r-- 1 root root 103K 8月 10 16:58 schema.sql # 表结构,首先导入
mysql -uroot zabbix<schema.sql
mysql -uroot zabbix<images.sql
mysql -uroot zabbix<data.sql
[root@linux-node1 ~]# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock # socket效率高于tcp
# 修改时区
[root@linux-node1 ~]# vim /etc/httpd/conf.d/zabbix.conf
原
# php_value date.timezone Europe/Riga
改为
php_value date.timezone Asia/Shanghai
#启动zabbix服务
[root@linux-node1 ~]# /etc/init.d/zabbix-server start
Starting Zabbix server: [确定]
#检查zabbix服务启动成功
[root@linux-node1 ~]# netstat -tunlp|grep 10051
tcp0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 1775/zabbix_server
tcp0 0 :::10051 :::* LISTEN 1775/zabbix_server
[root@linux-node1 ~]# ps -ef|grep zabbix
[root@linux-node1 ~]# cat /var/log/zabbix/zabbix_server.log
#如果不成功,查看zabbix错误日志
[root@linux-node1 ~]# /etc/init.d/httpd start
###
坑,如果已经启动服务,那么再修改完配置之后,start无法生效,要restart
#浏览器输入http://ServerIp/zabbix
ServerIP为zabbix服务端的主机IP
#安装检查先决条件,必须都满足,如果有不通过的选项要解决
#之前zabbix配置文件内设置的数据(用户,用户密码等)
#如果无法连接数据库,出现错误提示:
Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘回到服务端检查数据库用户、密码是否正确,并且配置是否生效
#监控zabbix服务端,组态——主机——把停用改为启用即可
# 中文乱码
yum -y install wqy-microhei-fonts
rpm -ql wqy-microhei-fonts
ll /etc/alternatives/zabbix-web-font
rm -f /etc/alternatives/zabbix-web-font
ln -s /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /etc/alternatives/zabbix-web-font
ll /etc/alternatives/zabbix-web-font
[root@linux-node2 ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[root@linux-node2 ~]# uname -r
2.6.32-573.el6.x86_64
[root@linux-node2 ~]# ifconfig eth0|awk -F "[ :]+" ‘NR==2 {print $4}‘
10.0.0.11
[root@linux-node2 ~]# hostname
linux-node2.example.com
[root@linux-node2 ~]# groupadd zabbix
[root@linux-node2 ~]# useradd zabbix -g zabbix -s /sbin/nologin
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
#更换zabbix源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
#更换阿里云源
yum -y install zabbix-agent
# zabbix-agent安装
PS:zabbix官网
https://www.zabbix.com/documentation/2.4/manual/installation/install_from_packages
[root@linux-node2 ~]# vim /etc/zabbix_agentd.conf
Server=10.0.0.10 #zabbix server端 IP地址
ServerActives=10.0.0.10 #zabbix server端 IP地址
Hostname=linux-node2 #本机主机名
# /etc/init.d/zabbix_agentd start
# netstat –tunlp|grep -10050
下面的命令需要在server端执行,其中10.0.0.11是agent的ip
[root@linux-node1 ~]# zabbix_get -s 10.0.0.11 -p10050 -k"system.uptime" 11166
有返回值说明配置成功,zabbix客户端,安装完成!
组态——主机——创建主机——编辑
主机名称——可见名称——添加群组——更改IP——点击添加即可
服务端
yum -y install zabbix-get
zabbix_get -h
[root@linux-node1 ~]# zabbix_get -s 10.0.0.8 -p 10050 -k "system.cpu.load[all,avg1]"
0.000000
原文地址:http://10970492.blog.51cto.com/10960492/1836319