环境检查
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