Zabbix3.0完整部署

0. 准备工作

0.1 初始化

#!/bin/shyum clean all

systemctl stop firewalld.service

systemctl disable firewalld.servicesed-i's/enforcing/disabled/g'/etc/selinux/configyum-yinstallvim openssh* ntpwgetscreen bash-completion

service ntpd stop

ntpdate time.nist.govsed-i's/0.centos.pool.ntp.org/time.nist.gov/g'/etc/ntp.conf

chkconfig ntpd on

service ntpd restart


0.2 依赖环境

0.2.1 直接使用LNMP环境

yum-yinstallgccgcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-develbzip2bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gmp-devel mysql-devel net-snmp-develperl-DBI libxml libxml-devel gd-devel httpd-manual mod_ssl mod_perl mod_auth_mysql mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp-devel curl-develwgetfping *ODBC* httpd

2. 启动LAMP环境

2.1 数据库编码统一

在MariaDB/MySQL关闭的前提下,/etc/my.cnf增加以下内容:

[client] port =3306default-character-set = utf8 [mysqld] port =3306character-set-server = utf8 character-set-filesystem = utf8

2.3 验证数据库编码:

MariaDB [(none)]> show variables like '%char%';

+--------------------------+----------------------------+

| Variable_name            | Value                      |

+--------------------------+----------------------------+

| character_set_client    | utf8                      |

| character_set_connection | utf8                      |

| character_set_database  | utf8                      |

| character_set_filesystem | utf8                      |

| character_set_results    | utf8                      |

| character_set_server    | utf8                      |

| character_set_system    | utf8                      |

| character_sets_dir      | /usr/share/mysql/charsets/ |

+--------------------------+----------------------------+

rows in set (0.00 sec)


3. Zabbix Server安装

3.1 环境下载准备

cd /usr/local/srcwgethttp://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.4/zabbix-3.0.4.tar.gzwgethttp://www.zabbix.com/downloads/3.0.0/zabbix_agents_3.0.0.linux2_6.amd64.tar.gztarzxvvf zabbix-3.0.4.tar.gz


3.2 创建Zabbix用户组

groupadd zabbix

useradd zabbix -g zabbix -s /sbin/nologin

3.3 创建数据库并授权用户

MariaDB [(none)]> create database zabbix character set utf8;

MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by'zabbix';

3.4 导入Zabbix定义的表结构和数据

cd /usr/local/src/zabbix-3.0.4/database/mysql

mysql -uzabbix -pzabbix zabbix < schema.sql

mysql -uzabbix -pzabbix zabbix < images.sql

mysql -uzabbix -pzabbix zabbix < data.sql

3.5 编译安装Zabbix Server

/usr/local/src/zabbix-3.0.4./configure \--prefix=/usr/local/zabbix \--enable-server \--enable-proxy \--enable-agent \--enable-java \--enable-ipv6 \--with-mysql \--with-net-snmp \--with-libcurl \--with-libxml2 \--with-ldap \--with-unixodbc \--with-ssh \--with-openipmi \--with-jabber

make&&makeinstall

配置参数说明:

参数|注释

—|—

–prefix=/usr/local/zabbix|//服务安装路径

–enable-server|//安装Zabbix Server

–enable-angent|//安装Zabbix Agent

–enable-proxy|//安装Zabbix Proxy

–with-mysql|//使用MySQL做数据库服务器

–with-net-snmp|//支持SNMP

–with-libcurl|//支持curl,用于web监控


3.6 服务端口定义

vim /etc/services

zabbix-agent10050/tcp              # Zabbix Agent

zabbix-agent10050/udp              # Zabbix Agent

zabbix-trapper10051/tcp              # Zabbix Trapper

zabbix-trapper10051/udp              # Zabbix Trapper

3.7 修改Zabbix Server配置文件

vim /usr/local/zabbix/etc/zabbix_server.conf

参数注释

LogFile=/tmp/zabbix_server.log//日志位置,根据需求修改

PidFile=/tmp/zabbix_server.pid//PID所在位置

DBHost=localhost//数据库IP,如果不是本机,请修改

DBName=zabbix//数据库名称

DBUser=zabbix//数据库用户名

DBPassword=zabbix//数据库密码

3.8 安装启动脚本,添加可执行权限

cd /usr/local/src/zabbix-3.0.4/misc/init.d/fedora/corecpzabbix_server /etc/init.d/chmod+x /etc/init.d/zabbix_server

3.9 修改启动脚本,启动Zabbix Server

vim /etc/init.d/zabbix_server

BASEDIR=/usr/local/zabbix//修改Zabbix的安装目录CONFILE=$BASEDIR/etc/zabbix_server.conf//添加此行,定义配置文件位置##搜索start,修改启动选项,默认是去/etc下去找配置文件

action $"Starting $BINARY_NAME: "$FULLPATH -c $CONFILE

3.10 启动服务

service zabbix_server start

创建虚拟主机-配置域名

4. 安装Zabbix Web界面

4.1 复制Web代码到httpd配置文件指定目录下

cd /usr/local/src/zabbix-3.0.4/frontends/

cp-r php /data/wwwroot/zabbix.test-1.com

然后把web代码copy到zabbix.test-1.com内


5. Zabbix Agent 安装(在被监控的客户机上安装)

5.1 下载解压编译好的客户端

cd /usr/local/srcwgethttp://www.zabbix.com/downloads/3.0.0/zabbix_agents_3.0.0.linux2_6.amd64.tar.gzmkdir/usr/local/zabbix_agentstarzxvvf zabbix_agents_3.0.0.linux2_6.amd64.tar.gz -C /usr/local/zabbix_agents/


5.2 编辑配置文件

cd /usr/local/zabbix_agents/conf/vim zabbix_agentd.conf

参数注释

LogFile=/tmp/zabbix_agentd.log//日志路径

Server=192.168.0.22//Zabbix Server IP

ServerActive=192.168.0.22//Zabbix Server IP

Hostname=192.168.0.23//设定本地主机名

5.3 安装修改启动脚本(脚本在服务端的源码包里)

cd /usr/local/src/zabbix-3.0.4/misc/init.d/fedora/core

vim zabbix_agentd

BASEDIR=/usr/local/zabbix_agents//修改zabbix_agentd安装路径CONFILE=$BASEDIR/conf/zabbix_agentd.conf//添加此行##搜索start,修改启动选项,默认是去/etc下去找配置文件

action $"Starting $BINARY_NAME: "$FULLPATH -c $CONFILE


5.4 脚本传送到被监控的客户端

cd /usr/local/src/zabbix-2.4.4/misc/init.d/fedora/corescpzabbix_agentd [email protected]:/etc/init.d/


5.5 启动Zabbix Agentd服务

groupadd zabbix

useradd zabbix -g zabbix -s /sbin/nologin/usr/local/zabbix_agents/sbin/zabbix_agentd -c /usr/local/zabbix_agents/conf/zabbix_agentd.conf



Zabbix3.0完整部署_第1张图片

查看运行状态 如果是 no  那么 查看zabbix状态  

你可能感兴趣的:(Zabbix3.0完整部署)