zabbix 3.0 源码安装

  1. 云栖社区>
  2. 博客>
  3. 正文

zabbix 3.0 源码安装

机智如我丶 2015-09-09 11:54:00 浏览2321
展开阅读全文

安装依赖包

yum -y install make gcc-c++ elinks lrzsz

一、安装Nginx

  • 建立用户、组
  • 解依赖包及Nginx
  • 编译安装
groupadd nginx
useradd -M -s /sbin/nologin -g nginx nginx

tar zxf nginx-1.0.14.tar.gz -C /usr/local/src/
tar jxf pcre-8.30.tar.bz2 -C /usr/local/src/
tar zxf zlib-1.2.7.tar.gz -C /usr/local/src/

./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-pcre=/usr/local/src/pcre-8.30/ --with-zlib=/usr/local/src/zlib-1.2.7/ --with-http_ssl_module
make && make install && echo -e "\e[;32mInstall Sccuess \e[0m" || echo -e "\e[;31mInstall Failed \e[0m"

二、安装MySQL mysql-5.6.13.tar.gz

  • yum安装Mysql依赖
  • 添加用户组
  • 创建数据目录及Cmake编译安装
yum -y install gcc* ncurses-devel cmake bison

groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
mkdir -p /usr/local/mysql/data

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGING=1 -DWITH_INNOBASE_STORAGE_ENGING=1 -DWITH_MEMORY_STORAGE_ENGING=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
make && make install && echo -e “\e[;32mInstall Sccuess \e[0m” || echo -e “\e[;31mInstall Failed \e[0m”

cp support-files/my-default.cnf /usr/local/mysql/data/my.cnf
cd /usr/local/mysql/scripts/
./mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/ --basedir=/usr/local/mysql/
ln -s /usr/local/mysql/bin/* /usr/local/bin/
ln -s /usr/local/mysql/include/mysql/* /usr/include/
ln -s /usr/local/mysql/lib/* /usr/lib/
chown -R mysql:mysql /usr/local/mysql/

修改my.cnf配置

[mysqld]
socket = /usr/local/mysql/data/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
log-error = /usr/local/mysql/data/mysql_error.log
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
tmpdir = /tmp

复制启动进程

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
rm -rf /etc/my.cnf

三、安装Zabbix

  • 安装依赖包
  • 安装jdk
  • 设置环境变量
  • 安装fping
  • 编译安装Zabbix
yum -y install unixODBC-devel net-snmp-devel OpenIPMI-devel openldap openldap-devel libssh2 libssh2-devel curl-devel

tar zxf jdk1.7.0_45.tar.gz -C /usr/local/
cd /usr/local
mv jdk1.7.0_45/ java

设置环境变量

vim /etc/profile
    export JAVA_HOME=/usr/local/java
    export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    export PATH=$JAVA_HOME/bin:$PATH
source /etc/profile 

需要zabbix源

wget http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm
yum -y install fping 
rm -rf /etc/yum.repos.d/zabbix.repo

tar zxf zabbix-2.5.0.tar.gz -C /usr/local/src
cd /usr/local/src/zabbix-2.5.0/

./configure --prefix=/usr/local/zabbix/ --sysconfdir=/usr/local/zabbix/etc/ --enable-server --enable-proxy --enable-agent --enable-ipv6 --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-openipmi --with-unixodbc --with-ldap --with-ssh2 --enable-java
make && make install  && echo -e "\e[;32mInstall Sccuess \e[0m" || echo -e "\e[;31mInstall Failed \e[0m"

四、安装PHP

  • yum安装PHP依赖,有些yum安装或没找到,则用tar安装
  • 编译安装PHP
yum -y install libxml2-devel libjpeg-turbo-devel libpng-devel freetype-devel  php-bcmath  curl-devel php-xml php-mbstring php-xmlrpc bzip2-devel

tar zxf libgd-2.1.0.tar.gz -C /usr/local/src/
./configure --prefix=/usr/local/libgd 
make && make install && echo -e "\e[;32mInstall Sccuess \e[0m"  || echo -e "\e[;31mInstall Failed \e[0m"

tar zxf /root/libmcrypt-2.5.7.tar.gz -C /usr/local/src/
./configure --prefix=/usr/local/libmcrypt
make && make install  && echo -e "\e[;32mInstall Sccuess \e[0m" ||  echo -e "\e[;31mInstall Failed \e[0m"

tar jxf php-5.6.13.tar.bz2 -C /usr/local/src/

./configure –prefix=/usr/local/php –with-mysql=/usr/local/mysql/ –with-openssl –enable-fpm –with-mysqli=/usr/local/mysql/bin/mysql_config –enable-mbstring –with-freetype-dir=/usr/local –with-jpeg-dir=/usr/local –with-png-dir=/usr/local –with-zlib-dir=/usr/local/zlib –with-libxml-dir=/usr/local –enable-xml –with-mhash –with-mcrypt=/usr/local/libmcrypt/ –with-config-file-path=/usr/local/php/etc –with-config-file-scan-dir=/usr/local/php –with-bz2 –with-curl=/usr/local –enable-bcmath –enable-sockets –with-gettext –with-gd

make && make install  && echo -e "\e[;32mInstall Sccuess \e[0m" || echo -e "\e[;31mInstall Failed \e[0m"

Nginx配置

  • 设置Zabbix的PHP目录
  • 设置PHP进程来解析index.php
    ——————————nginx-configuration-start——————————
vim /usr/local/nginx/conf/nginx.conf

 server {
        listen         80;
        server_name    192.168.0.216;
        root /usr/local/zabbix/php;
        index index.php index.html index.htm;

        location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;

                        }
}

cp -rf /usr/local/src/zabbix-2.5.0/frontends/php /usr/local/zabbix/php

——————————nginx-configuration-end——————————


Mysql配置
创建Zabbix库,并授权及导入三个表

  • schema.sql
  • images.sql
  • data.sql

——————————MySQL-configuration-start——————————

zabbix导入数据库
create database zabbix character set utf8;
grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
grant all privileges on zabbix.* to 'zabbix'@'192.168.1.200' identified by 'zabbix';
flush privileges;
use zabbix;
source /usr/local/src/zabbix-2.5.0/database/mysql/schema.sql;
source /usr/local/src/zabbix-2.5.0/database/mysql/images.sql;
source /usr/local/src/zabbix-2.5.0/database/mysql/data.sql;
show tables;

——————————MySQL-configuration-end——————————


Zabbix_Server配置

——————————Zabbix-Server-configuration-start——————————

groupadd zabbix
useradd -M -s /sbin/nologin -g zabbix zabbix

配置zabbix_server.conf
egrep -v "(^#|^$)" /usr/local/zabbix/etc/zabbix_server.conf
mkdir -p /usr/local/zabbix/data

修改配置
ListenPort=10051
LogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/usr/local/mysql/data/mysql.sock
DBPort=3306
StartPollers=15
StartPollersUnreachable=10
StartTrappers=10
StartPingers=10
StartDiscoverers=1
JavaGateway=127.0.0.1
JavaGatewayPort=10052
StartJavaPollers=5
StartDBSyncers=8
AlertScriptsPath=/usr/local/zabbix/alertscripts
ExternalScripts=/usr/local/zabbix/externalscripts
FpingLocation=/usr/sbin/fping
LogSlowQueries=3000
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/

chown -R zabbix:zabbix /usr/local/zabbix

——————————Zabbix-Server-configuration-end——————————


Zabbix_Agentd配置

——————————Zabbix-Agentd-configuration-start——————————

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

egrep -v "(^$|^#)" /usr/local/zabbix/etc/zabbix_agentd.conf

PidFile=/tmp/zabbix_agentd.pid
LogFile=/tmp/zabbix_agentd.log
EnableRemoteCommands=1
Server=192.168.0.216
ListenPort=10050
ListenIP=192.168.0.217
StartAgents=5
ServerActive=192.168.0.216:10051
Hostname=yixiao
MaxLinesPerSecond=500
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/


/usr/local/zabbix/sbin/zabbix_agentd 

ln -s /usr/local/zabbix/bin/zabbix_get /usr/local/bin

zabbix_get -s 192.168.0.216 -k system.uname     #如果可以获取数据,则说明正常,这在测试自定义监控的时候特别有用

zabbix_get  
  -s   远程Zabbix-Agent的IP地址或者是主机名
  -p   远程Zabbix-Agent的端口
  -I   本机出去的IP地址,用于一台机器中有多个网卡的情况
  -k   获取远程Zabbix-Agent数据所使用的Key

——————————Zabbix-Agentd-configuration-end——————————


PHP配置
——————————PHP-configuration-start——————————


rm -rf /etc/php.ini
cp /usr/local/src/php-5.6.13/php.ini-development /usr/local/php/etc/php.ini
ln -s /usr/local/php/etc/php.ini /etc/php.ini
vim /usr/local/php/etc/php.ini
 date.timezone = Asia/Shanghai            #设置时区
 expose_php = On 设置为 expose_php = OFF   #禁止显示php版本的信息
 post_max_size = 16M
 max_execution_time = 300
 max_input_time = 300
 always_populate_raw_post_data = -1       #这个在2.2版本中不用设置

 设置zabbix php环境 
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf    #php-fpm配置文件
cp /usr/local/src/php-5.6.13/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm       #php-fpm启动文件
chmod +x /etc/init.d/php-fpm
vim /usr/local/php/etc/php-fpm.conf
 user = nginx
 group = nginx
 pid = /usr/local/php/var/run/php-fpm.pid

——————————PHP-configuration-end——————————


zabbix默认账户

user:admin
pass:zabbix

开机自启

/usr/loca/nginx/sbin/nginx
/etc/init.d/mysqld start
/usr/local/zabbix/sbin/zabbix_server
/etc/init.d/php-fpm start
/usr/local/zabbix/sbin/zabbix_agentd

开启所有nginx,mysqld,php,zabbix所有服务

/usr/local/nginx/sbin/nginx
/etc/init.d/mysqld start
/etc/init.d/php-fpm start
/usr/local/zabbix/sbin/zabbix_server
/usr/local/zabbix/sbin/zabbix_agentd

这时候基本上已经差不多了,下面我们通过访问web页面来做最后的几个步骤:

1、访问http://ip即可打开Zabbix页面,看到Zabbix 3.0,继续
这里写图片描述


2、查看PHP是否符合当前Zabbix的需求,如果某条不行,则这关就过不去,不过大家按照前面的步骤做下来,基本上是没问题的,注意zabbix 3.0的php版本必须为2.4以上。不然无法打开php页面。
这里写图片描述


3、这里Zabbix服务器需要你输入数据库类型及授权用户等信息,接着下一步
这里写图片描述


4、输入Zabbix 服务器的host,port以及描述信息,继续
这里写图片描述


5、安装前信息汇总,可以确认下自己先前输入的信息,如果有误,则Back返回,如果确认无误,则继续。
这里写图片描述


6、安装时Zabbix提示缺少一只conf档,你需要在这里下载,然后丢在Zabbix Server指定的位置,并且刷新页面。
这里写图片描述


7、刷新之后Zabbix提示你需要登录才可以访问,那么login登录咯~
这里写图片描述


8、默认user,pass分别为admin:zabbix
这里写图片描述


9、OK,如果你能打开这个页面,那就说明安装成功啦~~~,现在可以根据自己的需求去监控Server啦~
这里写图片描述

网友评论

登录后评论
0/500
评论
机智如我丶
+ 关注