linux運(yùn)維學(xué)習(xí)筆記:zabbix系列之:01 zabbix3.0搭建手冊
作者:周少言
201年 月,于北京
聲明:本博客是本人周少言在某培訓(xùn)機(jī)構(gòu)學(xué)習(xí)期間所寫,其中參考借鑒了他人的博客,本文將會選擇性給出相關(guān)鏈接,如有侵權(quán),懇請告知。本文如有錯誤,懇請告知,歡迎交流。
一、初始化系統(tǒng)設(shè)置
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
二、安裝 LAMP 環(huán)境
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
yum clean all
yum makecache
yum -y install mariadb mariadb-server httpd php php-mysql
systemctl enable httpd
systemctl restart httpd
systemctl enable mariadb
systemctl restart mariadb
mysql_secure_installation
mariadb root passwd 123
三、安裝 Zabbix 程序
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get
初始化數(shù)據(jù)庫:
mysql -u root -p
CREATE DATABASE zabbix DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
讀入數(shù)據(jù)庫
cd /usr/share/doc/zabbix-server-mysql-3.2.11/
zcat create.sql.gz | mysql -uroot -p zabbix
啟動 Zabbix 服務(wù)
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
systemctl start zabbix-server
systemctl enable zabbix-server
編輯 zabbix 前端 php 配置
vim /etc/httpd/conf.d/zabbix.conf
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 Asia/Shanghai
注意取消注釋
調(diào)整時間同步
yum -y install ntpdate
ntpdate cn.pool.ntp.org
yum -y install ntp
vim /etc/ntp.conf
restrict 192.168.22.0 mask 255.255.255.0 nomodify notrap
#server 0.rhel.pool.ntp.org iburst 注釋
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst
server 127.127.1.0
fudge 127.127.1.0 stratum 10
systemctl start ntpd
systemctl enable ntpd
無網(wǎng)絡(luò)情況下:
date -s 2018-01-15
date -s 21:00:49
vim /etc/httpd/conf/httpd.conf
DocumentRoot "/usr/share/zabbix"
重啟 Apache 服務(wù)生效
systemctl restart httpd
瀏覽器訪問192.168.22.39
點(diǎn)擊Next step ....
進(jìn)入Configuration DB connection
port 3306
password zabbix
進(jìn)入登錄界面后:
username: Admin
password: zabbix
更改為中文:
adminstration-user-admin-language
選擇中文
cd /etc/zabbix
vim zabbix_agentd.conf
Server=192.168.22.39
ServerActive=192.168.22.39
Hostname=192.168.22.39
systemctl start zabbix-agent
systemctl enable zabbix-agent
zabbix-agent點(diǎn)擊
配置-主機(jī)-zabbix-server 勾選刪除
點(diǎn)擊 創(chuàng)建主機(jī)
四、修改中文亂碼問題
Win+R>fonts>拷貝簡體字改名為 simsun.ttf >/usr/share/zabbix/fonts
cd /usr/share/zabbix/fonts
chmod 777 simsun.ttf
vim /usr/share/zabbix/include/defines.inc.php
修改 zabbix php 頁面配置,將'graphfont' 修改為 simsun
define('ZBX_GRAPH_FONT_NAME', 'simsun');
五、添加zabbix客戶端
添加監(jiān)控192.168.22.35 (CentOS6)可添加多臺
yum -y install zabbix-agent-3.2.6-1.el6.x86_64.rpm
cd /etc/zabbix
vim zabbix_agentd.conf
Server=192.168.22.39
ServerActive=192.168.22.39
Hostname=192.168.22.35
service zabbix-agent start
chkconfig zabbix-agent on
配置(以下操作別忘了點(diǎn)擊 添加 )
自動發(fā)現(xiàn)
名稱
IP范圍
檢查: ICMP ping
動作
事件源:自動發(fā)現(xiàn)————>創(chuàng)建動作
新的觸發(fā)條件:在線/不在線
操作->新的->操作類型
添加主機(jī)
添加到主機(jī)群組
與模板關(guān)聯(lián)
templete ICMP Ping
templete OS Linux
啟用主機(jī)
設(shè)置報(bào)警
點(diǎn)擊用戶頭像--> 正在發(fā)送消息
勾選前端信息中
創(chuàng)建聚合圖形
賬號:Admin
密碼:zabbix