Zabbix安装(LNMP)

实验环境:CentOS 6.5(最小化安装)

[[email protected] software]# yum -y install gcc gcc-c++

安装PHP:

[[email protected] software]# yum -y install libxml2 libxml2-devel libjpeg-devel libpng-devel bzip2-devel libcurl-devel gd-devel
[[email protected] software]# tar -jxvf php-5.3.8.tar.bz2 &>/dev/null
[[email protected] software]# cd php-5.3.8
[[email protected] php-5.3.8]# ./configure --prefix=/usr/local/php --with-bz2 --with-curl --enable-ftp --enable-sockets --enable-bcmath --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local/photo --with-png-dir=/usr/local/photo --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64
[[email protected] php-5.3.8]# make &&make install
[[email protected] php-5.3.8]# cp php.ini-production /usr/local/php/lib/php.ini
[[email protected] php-5.3.8]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[[email protected] ~]# sed -i ‘/max_execution_time/s/30/300/‘ /usr/local/php/lib/php.ini
[[email protected] ~]# sed -i ‘/post_max_size/s/8/16/‘ /usr/local/php/lib/php.ini
[[email protected] ~]# sed -i ‘/max_input_time/s/60/300/‘ /usr/local/php/lib/php.ini
[[email protected] ~]# sed -i ‘/^;date.timezone/adate.timezone \= \"Asia\/Shanghai\"‘ /usr/local/php/lib/php.ini
[[email protected] ~]# sed -i ‘/^\;date\.timezone \=/d‘ /usr/local/php/lib/php.ini

注:如果PHP的时区不是"Asia/Shanghai",则在安装Zabbix的时候会出现下面的报错信息

--with-config-file-path=PATH这个参数可以指定php.ini文件的位置,默认在PREFIX/lib目录下

[[email protected] ~]# /usr/local/php/bin/php -i |grep date.timezone
date.timezone => Asia/Shanghai => Asia/Shanghai
[[email protected] ~]#
[[email protected] ~]# sed -i ‘/run\/php-fpm.pid/s/^;//g‘ /usr/local/php/etc/php-fpm.conf
[[email protected] ~]# sed -i ‘/^;pm.min_spare_servers/s/^;//g‘ /usr/local/php/etc/php-fpm.conf
[[email protected] ~]# sed -i ‘/^;pm.max_spare_servers/s/^;//g‘ /usr/local/php/etc/php-fpm.conf
[[email protected] ~]# sed -i ‘/^;pm.start_servers/s/^;//g‘ /usr/local/php/etc/php-fpm.conf
[[email protected] ~]# /usr/local/php/sbin/php-fpm
[[email protected] ~]# echo "/usr/local/php/sbin/php-fpm" >>/etc/rc.local
[[email protected] ~]# netstat -anp|grep php-fpm
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      106728/php-fpm      
unix  3      [ ]         STREAM     CONNECTED     98463  106728/php-fpm      
unix  3      [ ]         STREAM     CONNECTED     98462  106728/php-fpm      
[[email protected] ~]#
[[email protected] ~]# ps -ef|grep php|grep -v grep
root      30167      1  0 05:01 ?        00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
nobody    30168  30167  0 05:01 ?        00:00:00 php-fpm: pool www          
nobody    30169  30167  0 05:01 ?        00:00:00 php-fpm: pool www
···    
[[email protected] ~]#

安装Nginx:

[[email protected] software]# tar -jxvf pcre-8.12.tar.bz2 &>/dev/null
[[email protected] software]# cd pcre-8.12
[[email protected] pcre-8.12]# ./configure &&make &&make install
[[email protected] software]# tar -zxvf zlib-1.2.7.tar.gz &>/dev/null
[[email protected] software]# cd zlib-1.2.7
[[email protected] zlib-1.2.7]# ./configure &&make &&make install
[[email protected] software]# tar -zxvf openssl-1.0.1c.tar.gz &>/dev/null
[[email protected] software]# cd openssl-1.0.1c
[[email protected] openssl-1.0.1c]# ./config &&make &&make install
[[email protected] software]# tar -zxvf nginx-1.6.2.tar.gz &>/dev/null
[[email protected] software]# cd nginx-1.6.2
[[email protected] nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-pcre=/software/pcre-8.12 --with-zlib=/software/zlib-1.2.7 --with-openssl=/software/openssl-1.0.1c --with-http_stub_status_module
[[email protected] nginx-1.6.2]# make &&make install
[[email protected] nginx-1.6.2]# chmod 775 /etc/init.d/nginx
[[email protected] nginx-1.6.2]# chkconfig --add nginx
[[email protected] nginx-1.6.2]# chkconfig nginx on
[[email protected] nginx-1.6.2]# /etc/init.d/nginx start
Starting nginx:                                            [  OK  ]
[[email protected] nginx-1.6.2]#

安装mysql:

[[email protected] software]# yum -y install mysql*
[[email protected] software]# /etc/init.d/mysqld start
Starting mysqld:                                           [  OK  ]
[[email protected] software]# chkconfig mysqld on
[[email protected] software]# mysqladmin -uroot password redhat
[[email protected] software]# mysql -uroot -predhat
mysql>
[[email protected] software]#

安装Zabbix:

[[email protected] software]# yum -y install net-snmp net-snmp-devel libxml2-devel libcurl-devel
[[email protected] software]# tar -zxvf zabbix-2.0.14.tar.gz &>/dev/null
[[email protected] software]# cd zabbix-2.0.14
[[email protected] zabbix-2.0.14]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
[[email protected] zabbix-2.0.14]# make &&make install

zabbix server一般充当两个角色:server、angent,所以上面的配置参数也同时加上了–enable-agent。

备注:请安装好MySQL,snmp,curl开发库。

[email protected] software]# useradd -s /sbin/nologin zabbix

初始化数据库:

[[email protected] software]# mysql -uroot -predhat
mysql> create database zabbix default charset utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to [email protected] identified by ‘zabbix‘;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>

zabbix server与proxy需要数据库,angent不需要。尤其要注意的是proxy只需要导入一个sql文件,而server一共要导入3个sql文件。我当时在搭建proxy的时候导入了3个sql,导致出现报错。后来才发现proxy只需要导入一个表结构即可

[[email protected] zabbix-2.0.14]# mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
[[email protected] zabbix-2.0.14]# mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
[[email protected] zabbix-2.0.14]# mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql
[[email protected] zabbix-2.0.14]# cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
[[email protected] zabbix-2.0.14]# chmod 775 /etc/init.d/zabbix_*
[[email protected] ~]# sed -i ‘/LogFile/s/tmp/var\/log/‘ /usr/local/zabbix/etc/zabbix_server.conf
[[email protected] ~]# sed -i ‘/^DBUser\=/s/root/zabbix/‘ /usr/local/zabbix/etc/zabbix_server.conf
[[email protected] ~]# sed -i ‘/DBPassword\=$/s/^#//g‘ /usr/local/zabbix/etc/zabbix_server.conf
[[email protected] ~]# sed -i ‘/DBPassword\=$/s/^[ \t]//g‘ /usr/local/zabbix/etc/zabbix_server.conf
[[email protected] ~]# sed -i ‘/DBPassword\=$/s/\=/&zabbix/g‘ /usr/local/zabbix/etc/zabbix_server.conf
[[email protected] ~]# sed -i -e ‘/DBPort\=/s/^#//g‘ /usr/local/zabbix/etc/zabbix_server.conf -e ‘/DBPort\=/s/^[ \t]//g‘ /usr/local/zabbix/etc/zabbix_server.conf
[[email protected] ~]# cat /usr/local/zabbix/etc/zabbix_agent.conf|grep Server|grep -v ^#
Server=127.0.0.1           //服务端的IP
[[email protected] ~]# cat /usr/local/zabbix/etc/zabbix_agent.conf|grep UnsafeUser
### Option: UnsafeUserParameters
# UnsafeUserParameters=0
[[email protected] ~]#

默认是不启用自定义脚本功能的,要自定义key,需开启,设置为 1

[[email protected] ~]# mkdir /usr/local/nginx/html/zabbix
[[email protected] ~]# cp -rf /software/zabbix-2.0.14/frontends/php/* /usr/local/nginx/html/zabbix/
[[email protected] ~]# chown zabbix:zabbix /usr/local/nginx/html/zabbix/ -R
[[email protected] ~]# chmod o+w /usr/local/nginx/html/zabbix/conf
[[email protected] ~]# ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/
[[email protected] ~]# touch /var/log/zabbix_server.log
[[email protected] ~]# chown zabbix:zabbix /var/log/zabbix_server.log
[[email protected] ~]# chmod 775 /var/log/zabbix_server.log
[[email protected] ~]# /etc/init.d/zabbix_server start
Starting zabbix_server:                                    [  OK  ]
[[email protected] ~]# /etc/init.d/zabbix_agentd start
Starting zabbix_agentd:                                    [  OK  ]
[[email protected] ~]# chkconfig --add zabbix_server
[[email protected] ~]# chkconfig --add zabbix_agentd
[[email protected] ~]# chkconfig zabbix_server on
[[email protected] ~]# chkconfig zabbix_agentd on
[[email protected] ~]# chkconfig --list|grep zabbix
zabbix_agentd  0:off1:off2:on3:on4:on5:on6:off
zabbix_server  0:off1:off2:on3:on4:on5:on6:off
[[email protected] ~]#
[[email protected] ~]# ps -ef|grep zabbix|grep -v grep
zabbix    12929      1  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12931  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12932  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12933  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12934  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12935  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12936  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12937  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12938  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12939  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12940  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12941  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12942  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12943  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12944  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12945  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12946  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12947  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12948  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12949  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12961  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12962  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12963  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12964  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12965  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12966  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12967  12929  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_server
zabbix    12994      1  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    12995  12994  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    12996  12994  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    12997  12994  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    12998  12994  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    12999  12994  0 01:56 ?        00:00:00 /usr/local/sbin/zabbix_agentd
[[email protected] ~]# netstat -tunlp|grep zabbix
tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      12994/zabbix_agentd
tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      12929/zabbix_server
[[email protected] ~]#
[[email protected] ~]# touch /usr/local/nginx/logs/zabbix.access.log
[[email protected] conf]# /etc/init.d/nginx reload
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Reloading nginx:                                           [  OK  ]
[[email protected] conf]#

访问:http://172.24.17.130/zabbix/

基于LNMP的Zabbix安装完成

更改Zabbix语言:Profile---User---Language:

PHP探针:

[[email protected] phpinfo]# cat index.php
<?php
phpinfo();
?>
[[email protected] phpinfo]#
时间: 2024-09-30 07:56:58

Zabbix安装(LNMP)的相关文章

Zabbix源码安装(LNMP)

实验环境:CentOS 6.5(最小化安装) Zabbix Install Scripts:https://yunpan.cn/crF5YFDkRqsGh  访问密码 cfd7 [[email protected] software]# yum -y install gcc gcc-c++ make 安装PHP: [[email protected] software]# yum -y install libxml2 libxml2-devel libjpeg-devel libpng-deve

ubuntu 14.10安装zabbix(lnmp环境)

今天折腾了好一阵,终于在lnmp环境下装好了zabbix.激动的我眼泪都流出来几滴,总结一下碰到的问题 安装 lnmp环境和zabbix的过程我就不多说,网上很多,我就是参照: https://github.com/itnihao/zabbix-book/blob/master/03-chapter/zabbix_install_on_ubuntu.md 不过上面介绍的是lamp环境下安装zabbix.其实也没差多少,就是将apache换成nginx(为apt-get安装).但问题往往就出现在这

细化如何安装LNMP + Zabbix 监控安装文档以及故障排除

1.LNMP所需安装包: 上传如下软件包到/soft目录中 mysql- 5.1.71(centos6.5 64位自带)也可根据版本自行挑选,前提你了解这个版本 pcre-8.36.tar.gz nginx-1.6.2.tar.gz jpegsrc.v9a.tar.gz libmcrypt-2.5.8.tar.gz php-5.6.3.tar.gz 2.配置系统YUM源 cd /etc/yum.repos.d/ vim install.repo [LOCALYUMSOURCE] name=PD3

LNMP zabbix安装

LNMP一键安装 zabbix安装          zabbix安装图文介绍 php.ini修改,重启nginx后,不生效原因: php5.3中要重启php-fpm,单纯的重启nginx不能使php.ini设置生效 ps aux | grep php-fpm kill -QUIT xxxx 启动:/usr/local/php/sbin/php-fpm nginx 启动 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

安装LNMP和zabbix的脚本

#!/bin/bash #coding:utf-8 #author:fjiangjun #date:2018/1/30 check_dir(){ if [ ! -d $1 ] then mkdir -p $1 else echo -e "\033[33m检测到$1这个目录已经存在\033[0m" fi } check_dir /opt/lnmp BASE_DIR=/opt/lnmp check_env(){ echo  } echo "--------------this i

安装zabbix及LNMP的平台的搭建

Zabbix3.0.3安装文档 环境rhel 5.8 IP:192.168.0.8 需要安装: Nginx Php Mysql Zabbix 安装步骤: 一 .  Nginx1.6安装 安装nginx前要先安装pcre(支持正则表达式),最好也安装一下openssl(可以支持安全协议的站点) [[email protected] tmp]# tar zxvf pcre-8.35.tar.gz [[email protected] pcre-8.35]# ./configure [[email p

linux----centos7 yum安装lnmp+zabbix

安装yum utils工具包,若不安装则会找不到命令yum-config-manageryum -y install yum-utils 启用yum仓库yum-config-manager --enable rhel-7-server-optional-rpms 使用yum直接安装php,php-gd,php-mysql,php-fpm php-mbstring php-xmlyum install -y php php-gd php-mysql php-fpm 编辑/etc目录下php.ini

zabbix 安装和基础监控

Zabbix安装和监控 系统环境 [[email protected]~]# cat /etc/redhat-release CentOSrelease 6.3 (Final) [[email protected]~]#  uname -a Linux zabbix2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64GNU/Linux Yum安装nginx.php.mysql 配置nginx

zabbix 安装和基本配置

Server:zabbix服务的服务器 采用mysql存储监控数据并使用nginx+php的方式呈现. Agent  被监控设备上的zabbix代理SNMP   指支持SNMP协议的设备   IPMI:设备的物理性能监控 LNMP架构安装配置方法  http://9272317.blog.51cto.com/9262317/1826042 php依赖的包 yum install -y gcc gcc-c++  make zlib zlib-devel pcre pcre-devel  libjp