zabbix介绍
通过官网我们可以了解zabbix5.0和之前版本的差异及作出的改进
下载zabbix5.0源码
1
2
3
4yum -y install epel-release wget tar
wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.2.tar.gz
tar zxvf zabbix-5.0.2.tar.gz
cd zabbix-5.0.2创建zabbix用户
1
2
3groupadd zabbix
useradd -g zabbix zabbix
usermod -s /sbin/nologin zabbixmysql相关操作
安装mysql5.7请参考地址
- 创建zabbix数据库并且授权给zabbix@123456访问
1
2
3create database zabbix character set utf8 collate utf8_bin;
grant all on zabbix.* to zabbix@localhost identified by '123456';
flush priviledges; - 导入zabbix数据到mysql
1
2
3mysql -uzabbix -p123456 zabbix < database/mysql/schema.sql
mysql -uzabbix -p123456 zabbix < database/mysql/images.sql
mysql -uzabbix -p123456 zabbix < database/mysql/data.sql
- 创建zabbix数据库并且授权给zabbix@123456访问
php7.2安装
安装php7.2请参考地址
nginx安装
安装nginx请参考地址
安装zabbix-server
1
2
3./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make&&make install
chown zabbix:zabbix /usr/local/zabbix/ -R- 创建软链接,把zabbix命令设置为系统命令
1
ln -s /usr/local/zabbix/sbin/zabbix_* /usr/local/sbin/
配置zabbix启动脚本
1
2# 在zabbix源码目录下
cp misc/init.d/tru64/{zabbix_agentd,zabbix_server} /etc/init.d/;chmod o+x /etc/init.d/zabbix_*配置zabbix-web
1
2
3# 在zabbix源码目录下
cp -a ui/* /var/www/html/zabbix/
chown -R nginx:nginx /var/www/html/zabbix- 配置nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14server{
listen 80;
server_name localhost;
set $host_path "/var/www/html/zabbix";
root "$host_path";
index index.html index.htm index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
} 配置php
1
2
3
4post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai修改 zabbix server 配置文件
1
2
3
4
5
6
7
8cd /usr/local/zabbix/etc
cp zabbix_server.conf zabbix_server.conf.bak
# 修改以下配置
LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456重启zabbix server和nginx和php-fpm
1
2
3/etc/init.d/zabbix_server restart
nginx -s reload
systemctl restart php访问zabbix web gui进行安装配置
源码部署zabbix agent
1
2
3
4
5
6
7
8yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI
groupadd zabbix
useradd -g zabbix zabbix
usermod -s /sbin/nologin zabbix
tar -xzf zabbix-5.0.2.tar.gz
cd zabbix-5.0.2
./configure --prefix=/usr/local/zabbix --enable-agent
make install- 创建软链接
1
ln -s /usr/local/zabbix/sbin/zabbix_* /usr/local/sbin/
配置启动脚本
1
2
3cd zabbix-5.0.2
cp misc/init.d/tru64/zabbix_agentd /etc/init.d/zabbix_agentd
chmod o+x /etc/init.d/zabbix_agentd修改配置
1
2
3
4
5vim /usr/local/zabbix/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=192.168.2.214 #server端ip
ServerActive=192.168.2.214 #server端ip
Hostname = 192.168.2.215 #agent端ip或者是主机名都可以启动agent
1
/etc/init.d/zabbix_agentd
- 自动发现agent