第二章:安裝zabbix過程

2.2 安裝zabbix過程

2.2.1 安裝方式選擇

  編譯安裝 (服務較多,環境複雜)php

  yum安裝(乾淨環境)html

  使用yum 須要鏡像yum源 http://www.cnblogs.com/clsn/p/7866643.htmlmysql

2.2.2 服務端快速安裝腳本

#!/bin/bash
#clsn

#設置解析 注意:網絡條件較好時,能夠不用自建yum源
# echo '10.0.0.1 mirrors.aliyuncs.com mirrors.aliyun.com repo.zabbix.com' >> /etc/hosts

#安裝zabbix源、aliyun YUM源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

#安裝zabbix 
yum install -y zabbix-server-mysql zabbix-web-mysql

#安裝啓動 mariadb數據庫
yum install -y  mariadb-server
systemctl start mariadb.service

#建立數據庫
mysql -e 'create database zabbix character set utf8 collate utf8_bin;'
mysql -e 'grant all privileges on zabbix.* to zabbix@localhost identified by "zabbix";'

#導入數據
zcat /usr/share/doc/zabbix-server-mysql-3.0.13/create.sql.gz|mysql -uzabbix -pzabbix zabbix

#配置zabbixserver鏈接mysql
sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf

#添加時區
sed -i.ori '18a php_value date.timezone  Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf

#解決中文亂碼
yum -y install wqy-microhei-fonts
\cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf

#啓動服務
systemctl start zabbix-server
systemctl start httpd

#寫入開機自啓動
chmod +x /etc/rc.d/rc.local
cat >>/etc/rc.d/rc.local<<EOF
systemctl start mariadb.service
systemctl start httpd
systemctl start zabbix-server
EOF

#輸出信息
echo "瀏覽器訪問 http://`hostname -I|awk '{print $1}'`/zabbix"

2.2.3 客戶端快速部署腳本

#!/bin/bash
#clsn

#設置解析
echo '10.0.0.1 mirrors.aliyuncs.com mirrors.aliyun.com repo.zabbix.com' >> /etc/hosts

#安裝zabbix源、aliyu nYUM源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

#安裝zabbix客戶端
yum install zabbix-agent -y
sed -i.ori 's#Server=127.0.0.1#Server=172.16.1.61#' /etc/zabbix/zabbix_agentd.conf
systemctl start  zabbix-agent.service

#寫入開機自啓動
chmod +x /etc/rc.d/rc.local
cat >>/etc/rc.d/rc.local<<EOF
systemctl start  zabbix-agent.service
EOF

2.3 檢測連通性

2.3.1 服務端安裝zabbix-get檢測工具

yum install zabbix-get

2.3.2 在服務端進行測試

注意:只能在服務端進行測試web

zabbix_get -s 172.16.1.61 -p 10050 -k "system.cpu.load[all,avg1]"
zabbix_get -s 172.16.1.21 -p 10050 -k "system.cpu.load[all,avg1]"

測試結果sql

[root@m01 ~]# zabbix_get -s 172.16.1.61 -p 10050 -k "system.cpu.load[all,avg1]"
0.000000

[root@m01 ~]# zabbix_get -s 172.16.1.21 -p 10050 -k "system.cpu.load[all,avg1]"
0.000000
相關文章
相關標籤/搜索