码迷,mamicode.com
首页 > 其他好文 > 详细

zabbix3

时间:2016-08-10 14:17:51      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:

zabbix 3.0
安装:
1、环境要求:
php >= 5.4 (centos 6 默认5.3.3 需更新)
curl >= 7.20 (如需支持smtp认证,需更新)
# yum install net-snmp-devel libssh2-devel libssh2 tree nmap lrzsz dos2unix cmake zlib-devel libxml2-devel libjpeg-devel libiconv-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel libmcrypt-devel mhash mcrypt pcre pcre-devel openssl openssl-devel
*****若有提示找不到的包,试一下添加以下源再重新安装
# rpm -ivh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
sed -i "s/SELINUXTYPE=targeted/#SELINUXTYPE=targeted/g" /etc/selinux/config

2、安装nginx
wget http://nginx.org/download/nginx-1.9.7.tar.gz
# tar xf nginx-1.9.7.tar.gz
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx-1.9.7 --with-http_stub_status_module --with-http_ssl_module
# make
# make install
# vim /etc/profile.d/nginx.sh
export PATH=/usr/local/nginx-1.9.7/sbin/nginx:$PATH
# . /etc/profile.d/nginx.sh

3、安装mysql
# groupadd -r mysql
# useradd -g mysql -r mysql
# mkdir -pv /data/mydata/data/
# chown -R mysql.mysql /data/mydata/data/
# wget http://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.27.tar.gz
# tar xf mysql-5.6.27.tar.gz
# cd mysql-5.6.27
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mydata/data/ -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
# make && make install
# cd /usr/local/mysql/
# chown -R :mysql *
# scripts/mysql_install_db --user=mysql --datadir=/data/mydata/data/
# cp support-files/my-default.cnf /etc/my.cnf
# vim /etc/my.cnf
datadir = /data/mydata/data/
innodb_file_per_table = 1
# cp support-files/mysql.server /etc/init.d/mysqld
# chmod +x /etc/init.d/mysqld
# service mysqld start
# vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
# . /etc/profile.d/mysql.sh

4、php安装
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
# tar xf libiconv-1.14.tar.gz
# cd libiconv-1.14
# ./configure --prefix=/usr/local/libiconv
# make
# make install

ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/

# wget http://cn2.php.net/distributions/php-5.5.34.tar.gz
# tar xf php-5.5.34.tar.gz
# cd php-5.5.34
./configure \
--prefix=/usr/local/php5.5.34 \
--with-mysql=/usr/local/mysql/ \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--with-gettext \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-ftp \
--enable-opcache=no

注:--with-mysqli=mysqlnd和--with-gettext一定要加上,否则前者不装时安装 zabbix时database type没有选项 默认出来的数据库是SqLite 3,且不能切换 ,后者不装时,会报PHP gettext warning

# make
# make test
# make install
# cp php.ini-production /usr/local/php5.5.34/etc/php.ini
# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
# cd /usr/local/php5.5.34/etc
# cp php-fpm.conf.default php-fpm.conf

# vim /etc/profile.d/php-fpm.sh
export PATH=/usr/local/php5.5.34/sbin:$PATH
# . /etc/profile.d/php-fpm.sh

修改php.ini
# vim /usr/local/php5.5.34/etc/php.ini
post_max_size 16M
max_execution_time 300
max_input_time 300
date.timezone = Asia/Shanghai

5、安装zabbix
# wget http://heanet.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.1/zabbix-3.0.1.tar.gz
# tar xf zabbix-3.0.1.tar.gz
# groupadd zabbix
# useradd -g zabbix zabbix
# ln -s /usr/local/libiconv/lib/libiconv.so.2 /usr/lib/libiconv.so.2
# /sbin/ldconfig
# ./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-ssh2
若提示configure: error: Not found mysqlclient library
yum install mysql-devel -y
cd /usr/lib64/mysql/
ln -s libmysqlclient.so.16.0.0 libmysqlclient.so
ln -s libmysqlclient_r.so.16.0.0 libmysqlclient_r.so

参数说明
―prefix=/usr/local/zabbix为指定安装目录为/usr/local/zabbix
―enable-server为安装zabbix服务端程序
―enable-agent为安装agent程序
―with-mysql为使用mysql数据库
―enable-ipv6为启用ipv6支持
―with-net-snmp为启用snmp支持
―with-libcurl为启用curl
―with-libxml2编译xml模块,主要用于监控vm虚拟机
--enable-java 监控jvm

# make
# make install

创建对应的数据库
# mysql
设置 root 密码
mysql> SET PASSWORD = PASSWORD(‘YourPassword‘);
mysql> create database zabbix default charset utf8;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by ‘zabbix@123‘;
mysql> flush privileges;

顺序导入sql语句

mysql> use zabbix
mysql> source /home/zabbix-3.0.1/database/mysql/schema.sql
mysql> source /home/zabbix-3.0.1/database/mysql/images.sql
mysql> source /home/zabbix-3.0.1/database/mysql/data.sql

修改zabbix.conf

# vim /usr/local/zabbix/etc/zabbix_server.conf
增加:DBPassword=zabbix
DBName=zabbix #数据库名称
DBUser=zabbix #数据库用户名
DBPassword=zabbix #数据库密码
ListenIP=localhost #数据库ip地址
AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts #zabbix运行脚本存放目录

启动
复制启动脚本
# cp /home/zabbix-3.0.1/misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server
# cp /home/zabbix-3.0.1/misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd

启动php
php-fpm

配置web
# cd /home/zabbix/zabbix-3.0.1/frontends
# cp -rf php /data/html/

启动zabbix
# zabbix_server

修改zabbix_server的配置文件
# vim /usr/local/nginx-1.9.7/html/conf/zabbix.conf.php

修改zabbix_agent 配置文件
修改
Server
Hostname 要跟创建主机时填的名字一致

邮件报警

报警媒介--->用户-->动作

zabbix3

标签:

原文地址:http://www.cnblogs.com/Mrhuangrui/p/5735906.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!