環境檢查
cat /etc/redhat-release # 查看系統發行版本php
uname -r # 查看內核版本html
getenforce #查看安全機制java
systemctl status firewalld # 查看防火牆mysql
環境配置
Centos7.5 版本linux
192.168.200.123 server.zabbix.comc++
192.168.200.124 agent.zabbix.comweb
192.168.200.2 windows10sql
編寫 /etc/hostname 文件更改主機名數據庫
192.168.200.123:express
vim /etc/hostname
server.zabbix.com
192.168.200.124:
vim /etc/hostname
agent.zabbix.com
測試可否上網
nslookup www.baidu.com //若是沒有此命令,可下載 bind-utils
Server: 202.106.0.20
Address: 202.106.0.20#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 182.61.200.6
Name: www.a.shifen.com
Address: 182.61.200.7
配置 /etc/hosts 文件
192.168.200.123:
vim /etc/hosts
192.168.200.123 server.zabbix.com
192.168.200.124 agent.zabbix.com
192.168.200.2 windows10
scp /etc/hosts 192.168.200.124:/etc/
關閉 firewalld 及 selinux
臨時:
systemctl stop firewalld
setenforce 0
iptables -F
永久:
systemctl disable firewalld
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
yum源配置
兩臺主機都配置
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
部署 lamp 環境,提供 zabbix 訪問頁面,其中 PHP 部分選項是爲 zabbix 提供支持
192.168.200.123:
yum -y install httpd mariadb-server mariadb mariadb-devel php php-mbstring php-mysql php-bcmath php-gd php-xmlrpc php-ldap php-xml libevent libevent-devel net-snmp net-snmp-devel libxml2 libxml2-devel ntpdate libcurl
同步時間
192.168.200.123:
ntpdate s1a.time.edu.cn
啓動 lamp 對應服務
192.168.200.123:
systemctl start mariadb
systemctl enable mariadb //設置爲開機自啓動
mysqladmin -uroot password 123123 //爲 mysql root 用戶設置密碼
systemctl start httpd
systemctl enable httpd
jdk 環境配置
192.168.200.123:
tar xf jdk-8u191-linux-x64.tar.gz
mv jdk1.8.0_191/ /usr/local/java
vim /etc/profile
export JAVA_HOME=/usr/local/java
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
javac -version
javac 1.8.0_191
源碼安裝 zabbix
yum -y install gcc gcc-c++ make
tar xf zabbix-3.4.11.tar.gz -C /usr/src/
cd /usr/src/zabbix-3.4.11/
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --enable-java && make -j2 && make install
Mariadb 數據庫受權
mysql -uroot -p123123
create database zabbix character set utf8;
grant all on zabbix.* to zabbix@localhost identified by 'zabbix';
grant all on zabbix.* to zabbix@'192.168.200.123' identified by 'zabbix';
flush privileges;
\q
導入 zabbix 須要的 mysql 數據
cd /usr/src/zabbix-3.4.11/
mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql
登陸查看
mysql -uroot -p123123
show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| zabbix |
+--------------------+
5 rows in set (0.00 sec)
use zabbix;
show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
| dashboard_user |
| dashboard_usrgrp |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| groups |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| httpstep |
| httpstep_field |
| httpstepitem |
| httptest |
| httptest_field |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| item_application_prototype |
| item_condition |
| item_discovery |
| item_preproc |
| items |
| items_applications |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| problem |
| problem_tag |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| task |
| task_acknowledge |
| task_close_problem |
| task_remote_command |
| task_remote_command_result |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
+----------------------------+
140 rows in set (0.00 sec)
\q
建立 zabbix 程序用戶並受權防止權限報錯
useradd -M -s /sbin/nologin zabbix
cd /usr/local/
chown -R zabbix:zabbix zabbix/
cd ./zabbix/
pwd
/usr/local/zabbix
mkdir logs
chown zabbix:zabbix logs/
cp -p etc/zabbix_server.conf{,.bak}
cp -p etc/zabbix_agentd.conf{,.bak}
修改 zabbix 配置文件
cd /usr/local/zabbix/etc/
ls
zabbix_agentd.conf zabbix_agentd.conf.d zabbix_server.conf.bak
zabbix_agentd.conf.bak zabbix_server.conf zabbix_server.conf.d
vim zabbix_server.conf
原先內容 dG 刪除
LogFile=/usr/local/zabbix/logs/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=192.168.200.123
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
註釋:
LogFile=/usr/local/zabbix/logs/zabbix_server.log #指定 zabbix 日誌位置
PidFile=/tmp/zabbix_server.pid #指定 zabbix pid 文件位置
DBHost=192.168.200.123 #指定數據庫主機
DBName=zabbix #指定數據庫名爲 zabbix
DBUser=zabbix #指定用戶爲 zabbix
DBPassword=zabbix #指定密碼爲 zabbix
DBSocket=/var/lib/mysql/mysql.sock #指定 mariadb 數據庫的 sock 文件
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
vim zabbix_agentd.conf
PidFile=/tmp/zabbix_agentd.pid
Server=127.0.0.1,192.168.200.123
ServerActive=192.168.200.123
Hostname=server.zabbix.com #指定 zabbixserver 主機名
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
ln -s /usr/local/zabbix/sbin/* /usr/local/bin
zabbix_server
zabbix_agentd
配置 php 與 apache
mv /usr/src/zabbix-3.4.11/frontends/php/ /var/www/html/zabbix
chown -R apache:apache /var/www/html/zabbix/
vim /etc/php.ini
date.timezone = Asia/Shanghal
max_ececution_time = 300
max_input_time = 300
post_max_size = 32M
memory_limit = 128M
extension = bcmath.so
註釋:
878 date.timezone = Asia/Shanghal #時區
384 max_ececution_time = 300 #單位秒,經過 POST、GET 以及 PUT 方式接收數據時間進行限制
394 max_input_time = 300 #php 程序上傳文件解析數據時的時間限制
672 post_max_size = 32M #POST 方式請求數據所容許的最大大小
405 memory_limit = 128M #設置 php 程序的內存限制
854 extension = bcmath.so #加載 zabbix 程序須要加載的擴展模塊 bcmath.so 手動添加
systemctl restart httpd
netstat -anpt | egrep ':10050|:10051|:80'
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 26134/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 26072/zabbix_server
tcp6 0 0 :::10050 :::* LISTEN 26134/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 26072/zabbix_server
tcp6 0 0 :::80 :::* LISTEN 26154/httpd
web 安裝 zabbix
瀏覽器訪問 192.168.200.123/zabbix/setup.php