一、前言
(一)、概述
(二)、预处理
配置环境
OS:CentOS 7.5 64bit
Zabbix版本:3.4
MySQL:5.7.22
hostname:zabbix-1-1
ip:10.18.43.141
基础需求
[root@zabbix-1-1 ~]# systemctl stop firewalld
[root@zabbix-1-1 ~]# sed -ri '/^SELINUX=*/cSELINUX=disabled' /etc/selinux/config
[root@zabbix-1-1 ~]# setenforce 0
[root@zabbix-1-1 ~]# mkdir -p /date/zabbix
[root@zabbix-1-1 ~]# groupadd zabbix
[root@zabbix-1-1 ~]# useradd -r -g zabbix -s /sbin/nologin zabbix
二、Zabbix安装
(一)、Zabbix编译
依赖环境库下载:
[root@zabbix-1-1 ~]# yum install net-snmp-devel libevent-devel mysql-devel -y
[root@zabbix-1-1 ~]# wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.4.11/zabbix-3.4.11.tar.gz -C /data/zabbix
[root@zabbix-1-1 ~]# cd /data/zabbix/
[root@zabbix-1-1 zabbix]# tar xf zabbix-3.4.11.tar.gz
[root@zabbix-1-1 zabbix]# cd zabbix-3.4.11/
执行编译:
[root@zabbix-1-1 zabbix-3.4.11]# ./configure \
--enable-server \
--enable-agent \
--with-mysql \
--enable-ipv6 \
--with-net-snmp \
--with-libcurl \
--with-libxml2 \
--prefix=/usr/local/zabbix [root@zabbix-1-1 zabbix-3.4.11]# make install
(二)、MySQL配置
MySQL编译安装请参考:https://www.cnblogs.com/sky-k/p/9364842.html
[root@zabbix-1-1 ~]# mysql -p'Passwd@123'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1070
Server version: 5.7.22 Source distribution
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database zabbix default character set utf8; Query OK, 1 row affected (0.00 sec) mysql> grant all privileges on zabbix.* to 'zabbixadmin'@'10.18.43.141' identified by 'Zabbix@123'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> grant all privileges on zabbix.* to 'zabbixadmin'@'127.0.0.1' identified by 'Zabbix@123'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> grant all privileges on zabbix.* to 'zabbixadmin'@'localhost' identified by 'Zabbix@123'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> grant all privileges on zabbix.* to 'zabbixadmin'@'%' identified by 'Zabbix@123'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
mysql> \q
Bye
数据导入(注意导入数据的先后顺序,如果顺序错误,就会使数据导入不成功或者其它错误)
[root@zabbix-1-1 ~]# cd /data/zabbix/zabbix-3.4.11/database/mysql/
[root@zabbix-1-1 mysql]# mysql -u'zabbixadmin' -p'Zabbix@123' zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix-1-1 mysql]# mysql -u'zabbixadmin' -p'Zabbix@123' zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix-1-1 mysql]# mysql -u'zabbixadmin' -p'Zabbix@123' zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
(三)、Zabbix server配置
[root@zabbix-1-1 ~]# vim /usr/local/zabbix/etc/zabbix_server.conf
### Option: LogFile
# Log file name for LogType 'file' parameter.
#
# Mandatory: no
# Default:
# LogFile=
LogFile=/tmp/zabbix_server.log #日志存放位置
### Option: DBHost
# Database host name.
# If set to localhost, socket is used for MySQL.
# If set to empty string, socket is used for PostgreSQL.
#
# Mandatory: no
# Default:
# DBHost=localhost
DBHost=10.18.43.141 #数据库IP地址
### Option: DBName
# Database name.
# For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored.
#
# Mandatory: yes
# Default:
# DBName=
DBName=zabbix #数据库名称
### Option: DBUser
# Database user. Ignored for SQLite.
#
# Mandatory: no
# Default:
# DBUser=
DBUser=zabbixadmin #数据库用户名称
### Option: DBPassword
# Database password. Ignored for SQLite.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBPassword=
DBPassword=Zabbix@123 #数据库用户密码
### Option: AlertScriptsPath
# Full path to location of custom alert scripts.
# Default depends on compilation options.
#
# Mandatory: no
# Default:
# AlertScriptsPath=${datadir}/zabbix/alertscripts
AlertScriptsPath=/usr/local/zabbix/alertscripts #脚本存放位置
(四)、Nginx配置
Nginx编译安装请参考:
[root@zabbix-1-1 ~]# vim /usr/local/nginx/conf/nginx.conf
user nginx; #修改使用用户
http {
include /usr/local/nginx/conf/conf.d/*.conf; #添加子配置路径
}
[root@zabbix-1-1 ~]# vim /usr/local/nginx/conf/conf.d/zabbix.conf
server {
listen 80;
server_name _;
location / {
root /usr/local/nginx/html;
index index.php;
}
location ~ "\.php$" {
root /usr/local/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$fastcgi_script_name;
include fastcgi_params;
}
}
(五)、PHP参数修改
PHP编译安装请参考:
[root@mysql-1-1 ~]# vim /usr/local/php/lib/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300