1. yum安装zabbix方式
1.1 环境准备
[root@master ~]# setenforce 0
[root@master ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
[root@master ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@master ~]# yum install epel-release.noarch wget vim gcc gcc-c++ lsof chrony tree nmap unzip rsync -y
[root@master ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
1.2 LAMP安装
[root@master ~]# yum install httpd mariadb mariadb-server mariadb-client php php-mysql
1.3 Zabbix安装
[root@master ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
[root@master ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
[root@master ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-agent
1.4 创建数据库
mysqladmin -u root password '111111'
GRANT ALL PRIVILEGES ON *.* TO zabbix@localhost IDENTIFIED BY 'zabbix';
[root@master ~]# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE zabbix DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
MariaDB [(none)]> GRANT ALL ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY 'zabbix';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> quit
1.5 导入数据
[root@master ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.0/
[root@master zabbix-server-mysql-3.2.0]# zcat create.sql.gz | mysql -uroot zabbix
[root@master zabbix-server-mysql-3.2.0]# cd
1.6 修改配置
[root@master ~]# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
[root@master ~]# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Chongqing
1.7 启动
[root@master ~]# systemctl start httpd
[root@master ~]# systemctl start zabbix-server
[root@master ~]# systemctl start zabbix-agent
通过 http://ip/zabbix
访问默认用户名/密码:Admin/zabbix,注意用户名也区分大小写
# 配置中重写了访问路径
[root@master ~]# vim /etc/httpd/conf.d/zabbix.conf
Alias /zabbix /usr/share/zabbix
2. 编译安装zabbix方式
2.1 环境准备
yum -y install mysql-devel httpd libxml2-devel net-snmp-devel libcurl-devel php-mysql libXpm php-bcmath php-gd php-mbstring php-xml t1lib
2.2 下载zabbix源码包
Zabbix Download
下载zabbix-3.2.0.tar.gz
2.3 编译安装
tar xf zabbix-3.2.0.tar.gz
cd zabbix-3.2.0
groupadd zabbix
useradd -g zabbix zabbix
./configure --prefix=/usr/local/zabbix-server --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-agent
make && make install
2.4 创建数据库和授权用户
说明:
数据文件导入的顺序不能变,也可以在命令行使用mysql命令导入数据文件
systemctl start mariadb
create database zabbix default charset utf8;
use zabbix;
source /home/softwares/zabbix-3.2.0/database/mysql/schema.sql
source /home/softwares/zabbix-3.2.0/database/mysql/images.sql
source /home/softwares/zabbix-3.2.0/database/mysql/date.sql
grant all on zabbix.* to 'zabbix'@'%' identified by 'zabbix';
2.5 修改配置文件并启动
mkdir /var/log/zabbix
chown -R zabbix:zabbix /var/log/zabbix
vim /usr/local/zabbix-server/etc/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
/usr/local/zabbix-server/sbin/zabbix_server
查看端口,已经监听:
[root@localhost conf]# netstat -lntup | grep 10051
tcp 0 0 192.168.56.12:10051 0.0.0.0:* LISTEN 53243/./zabbix_serv
tcp 0 0 127.0.0.1:10051 0.0.0.0:* LISTEN 53243/./zabbix_serv
2.6 配置zabbix web页面
vim /etc/httpd/conf.d/zabbix.conf
#
# Zabbix monitoring system php web frontend
#
#Alias /zabbix /usr/share/zabbix
Alias /zabbix /home/softwares/zabbix-3.2.0/frontends/php
Options FollowSymLinks
AllowOverride None
Require all granted
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
php_value date.timezone Asia/Chongqing
Require all denied
Require all denied
Require all denied
Require all denied
systemctl start httpd
浏览器输入IP地址访问
http://ip/zabbix
3. 如果zabbix web初始配置失败,可以手动修改解决
vim /usr/local/nginx/html/zabbix/conf/zabbix.conf.php
修改好后刷新zabbix web页面即可。
输入用户名/密码登录
默认用户名密码为:Admin zabbix
4. yum方式安装zabbix agent
4.1 zabbix agent 安装
[root@client01 ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-agent-3.2.0-1.el7.x86_64.rpm
[root@client01 ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[root@client01 ~]# yum install zabbix-agent
4.2 配置修改
[root@client01 ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.1.11
ServerActive=192.168.1.11
Hostname=agent-1.12
4.3 启动
[root@client01 ~]# systemctl start zabbix-agent
5. 编译方式安装zabbix agent
5.1 下载zabbix agent源码包
Zabbix Download
下载zabbix-3.2.0.tar.gz
5.2 编译并安装
tar xf zabbix-3.2.0.tar.gz
cd zabbix-3.2.0
groupadd zabbix
useradd -g zabbix zabbix
./configure --prefix=/usr/local/zabbix-server --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-agent
make && make install
5.3 配置
mkdir /var/log/zabbix
chown -R zabbix-agent:zabbix-agent /var/log/zabbix/
vim /usr/local/zabbix-agent/etc/zabbix_agentd.conf
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=192.168.1.11
ServerActive=192.168.1.11
Hostname=linux-agent-12
User=zabbix-agent
5.4 启动
/usr/local/zabbix-agent/sbin/zabbix_agent
之后就可以在zabbix web页面添加host主机了。
6. Zabbix-Get的使用
Zabbix-Get是Zabbix中的一个应用程序,用于Zabbix-Server到Zabbix-Agent的数据获取,通常可以用来测试Agent的配置是否正确。
#使用帮助:
usage:
zabbix_get -s host-name-or-IP [-p port-number] [-I IP-address] -k item-key
zabbix_get -s host-name-or-IP [-p port-number] [-I IP-address]
--tls-connect cert --tls-ca-file CA-file
[--tls-crl-file CRL-file] [--tls-agent-cert-issuer cert-issuer]
[--tls-agent-cert-subject cert-subject] --tls-cert-file cert-file
--tls-key-file key-file -k item-key
zabbix_get -s host-name-or-IP [-p port-number] [-I IP-address]
--tls-connect psk --tls-psk-identity PSK-identity
--tls-psk-file PSK-file -k item-key
zabbix_get -h zabbix_get -V
测试 Agent 配置
[root@master zabbix-server-mysql-3.0.3]# zabbix_get -s 192.168.60.104 -k system.uname
Linux client01 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64
zabbix_get -s 127.0.0.1 -p10050 -k "system.cpu.load[all,avg15]";
7. 下载字体修复乱码
下载中文字体:
wget http://down1.chinaunix.net/distfiles/ttf-arphic-uming_0.0.20050501-1.tar.gz
tar xf /root/ttf-arphic-uming_0.0.20050501-1.tar.gz
cd /var/www/html/zabbix/php/fonts ## 注意此处为zabbix web文件所在路径
mv DejaVuSans.ttf /root/ ## 备份原有字体文件
cp /root/ttf-arphic-uming_0.0.20050501/uming.ttf ./DejaVusans.ttf # 将下载的字体替换到此处;
修改你的defines.inc.php 这个文件
vim /var/www/html/zabbix/php/include/defines.inc.php
#修改第93行
define('ZBX_FONT_NAME', 'uming');
#修改第45行改为
define('ZBX_GRAPH_FONT_NAME', 'uming')
重启httpd
service httpd restart
参考
CentOS 7 下快速搭建 Zabbix 3.0 环境
CentOS-7 编译安装 Zabbix-3.0
Centos7 编译安装 zabbix3.0