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

zabbix安装部署

时间:2017-04-01 13:53:59      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:kconfig   fas   ble   storage   编译参数   delete   index.php   libcurl   agentd   

安装zabbix的前提 首先要有LAMP 或者LNMP的环境

我安装的是LNMP

一、LNMP的安装

Linux(RHEL6.4) + Nginx(FastCGI) + PHP(php-fpm) + MySQL

所需软件包:

nginx-1.4.4.tar.gz
php-5.5.7.tar.gz
cmake-2.8.10.2.tar.gz
mysql-5.5.33.tar.gz
Discuz_X3.1_SC_UTF8.zip
pcre-8.10.tar.gz

cmake-2.8.12.2.tar.gz

mysql-5.5.37.tar.gz

一、安装Nginx
1. pcre: 支持正则表达式,地址重写rewrite
# tar xvf pcre-8.10.tar.gz
# cd pcre-8.10
# ./configure  --prefix=/home/lnmp/pcre

#make && make install
2. Nginx
# yum -y install openssl openssl-devel gcc*
# groupadd www
# useradd -g www www
# tar xf nginx-1.4.4.tar.gz
# cd nginx-1.4.4
# ./configure \
--prefix=/home/lnmp/nginx \
--user=www \
--group=www \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre=pcre源程序目录  *tar解压完的目录
# make
# make install
# /home/lnmp/nginx/sbin/nginx 
# netstat -tnlp |grep :80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      11051/nginx
# elinks -dump http://localhost  *直接浏览器输入http://IP 即可验证
                               Welcome to nginx!
# echo "/home/lnmp/nginx/sbin/nginx" >> /etc/rc.local 

二、二进制安装mysql

5.5 版本以上的mysql 都是用cmake编译 所以先安装cmake

添加mysql用户

# groupadd mysql

#useradd -g mysql mysql 

1.解压cmake包并安装

#tar –xzvfcmake.tar.gz

# ./bootstrap --prefix=/home/mysql/tools/cmake

#make

#make install

#export PATH=$PATH:/home/mysql/tools/cmake/bin

2.cmake查看编译参数

cmake . –LAH

3.mysql 5.5安装

# tar –xzv mysql-5.5.37.tar.gz

# cd mysql-5.5.37

#bpath=/home/mysql/mysql_5537

#echo ${bpath}

#cmake . \

-DCMAKE_INSTALL_PREFIX=${bpath}  \

-DINSTALL_MYSQLDATADIR=“${bpath}/var”  \

-DMYSQL_DATADIR=${bpath}/var \

-DSYSCONFDIR=${bpath}/etc    \

-DWITH_INNOBASE_STORAGE_ENGINE=1  \

-DDEFAULT_CHARSET=utf8   \

-DDEFAULT_COLLATION=utf8_general_ci  \

-DMYSQL_TCP_PORT=5537  \

-DMYSQL_UNIX_ADDR=${bpath}/tmp/mysql.sock  \

-DWITH_EXTRA_CHARSETS=all

#make

#make install

#cd /home/mysql/mysql_5537

#mkdir etc var log tmp

#cd ./etc 

#rz  上传配置文件 my.cnf,确认配置文件里面的端口号和文件目录跟你安装的相对应

#chown -R mysql.mysql /home/mysql/mysql_5537 改下所属用户和组

3.初始化 mysql   /*初始化切换到mysql用户下进行

#./scripts/mysql_install_db --defaults-file=/home/mysql/mysql_5537/etc/my.cnf --user=mysql 

4.启动mysql实例

#./bin/mysqld_safe --defaults-file=/home/mysql/mysql_5537/etc/my.cnf --user=mysql &

OR

#cp support-files/mysql.server ./bin/

#./bin/mysql.server start 

5.shell登录mysql [mysql -u -p]

#ln -s /home/mysql/mysql_5537/bin/mysql /usr/bin/

#export PATH=$PATH:/home/mysql/mysql_5537/bin/

/*

多实例添加环境变量

# unlink /usr/bin/mysql  *取消软连

# ln -s /home/mysql/mysql_5537/bin/mysql /usr/bin/mysql_5537

#export PATH=$PATH:/home/mysql/mysql_5537/bin/

*/

三、安装PHP
1. 以php-fpm的方式安装php

安装依赖包
# yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel libcurl libcurl-devel libxslt-devel

#tar -zxvf php-5.5.7.tar.gz

#cd php-5.5.7
#./configure \
--prefix=/home/lnmp/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-jpeg-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysql \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip \

--with-mysql-sock=/home/mysql/mysql_5537/tmp/    sock文件目录  /*最好加上*/
# make && make install 
2. php-fpm配置文件
# cp /home/lnmp/php/etc/php-fpm.conf.default /home/lnmp/php/etc/php-fpm.conf
# vim /home/lnmp/php/etc/php-fpm.conf
pid = run/php-fpm.pid
3. php主配置文件
# cp php.ini-production /home/lnmp/php/lib/php.ini

修改php配置文件如下

data.timezone = Asia/Shanghai

max_execution_time = 300

post_max_size = 32M

max_input_time = 300

memory_limit = 128M

mbstring.func_overload = 2

4. 添加到init启动
[root@test php-5.5.7]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
[root@test php-5.5.7]# chmod a+x /etc/rc.d/init.d/php-fpm
[root@test php-5.5.7]# chkconfig --add php-fpm
[root@test php-5.5.7]# chkconfig php-fpm on
[root@test php-5.5.7]# service php-fpm start
Starting php-fpm  done
四、整合Nginx和PHP
1. Nginx启用Fastcgi
[root@test php-5.5.7]#  vim /home/lnmp/nginx/conf/nginx.conf
启用:
location / {
            root   html;
            index  index.php index.html index.htm;
        }
去掉以下行的注释:
location ~ \.php$ {
            root            html;
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include         fastcgi_params;
        }
2. fastcgi模块参数文件
[root@test ~]# rm -rf /home/lnmp/nginx/conf/fastcgi_params
[root@test ~]# vim /home/lnmp/nginx/conf/fastcgi_params
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;
3. 最终确认并重启
[root@tianyun ~]# killall nginx; /home/lnmp/nginx/sbin/nginx
[root@tianyun ~]# /etc/init.d/php-fpm restart
[root@tianyun ~]# service mysqld restart
[root@tianyun ~]# netstat -tnlp |grep :80
tcp        0      0 0.0.0.0:80                  0.0.0.0:* LISTEN      17947/nginx        
[root@tianyun ~]# netstat -tnlp |grep :9000
tcp        0      0 127.0.0.1:9000              0.0.0.0:* LISTEN      17961/php-fpm      
[root@tianyun ~]#netstat -tnlp | grep 5537

tcp        0      0 :::5537                     :::*                    LISTEN      18265/mysqld   
                        二、安装zabbix

1.创建zabbix用户和组

#groupadd zabbix

#useradd -g zabbix zabbix

2.解压zabbix安装包

#tar -zxvf zabbix-2.0.12.tar.gz

#cd zabbix-2.0.12

#ll技术分享

#查看下相应目录

技术分享

3.安装相应依赖包

# yum -y install unixODBC  unixODBC-devel  library  net-snmp net-snmp-devel libssh2-devel  OpenIPMI-devel java*   openldap openldap-devel

4.编译 、连接文件 、安装

#./configure --prefix=/home/zabbix --sysconfdir=/etc/zabbix --enable-server --enable-proxy --enable-agent --enable-ipv6 --with-mysql=/home/mysql/mysql_5621/bin/mysql_config --with-net-snmp --with-libcurl --with-openipmi --with-unixodbc --with-ldap --with-ssh2 --enable-java

*configure: error: Curl library not found,可以通过yum install curl-devel来解决

*configure: error: SSH2 library not found  

yum install php-pecl-ssh2.x86_64 libssh2-devel.x86_64

#make

#make install 

#vim /etc/services  OR grep zabbix /etc/servce  *添加zabbix 到系统服务文件  在rhel系列中,下面的服务参数可以不添加,默认已经有了

技术分享

5. 导入zabbix数据库

#cd database/mysql/

#mysql -uroot (登录数据库)

mysql> create database zabbix character set utf8;

mysql>grant all privileges on zabbix.* to zabbix@‘127.0.0.1‘ identified by‘zabbix‘;

mysql> flush privileges;

mysql>\q

更换zabbix用户 导入数据

# mysql -uzabbix -pzabbix 

mysql> \! ls

data.sql  images.sql  schema.sql

mysql> show databases;

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

| Database                    |

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

| information_schema  |

| test                              |

| zabbix                         |

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

mysql> use zabbix;

Database changed

mysql>  source schema.sql;

mysql>  source images.sql;

mysql>  source data.sql;

mysql> \q

确保导入数据过程无误

# mkdir /var/log/zabbix

# chown -R zabbix.zabbix /var/log/zabbix

6.拷贝 service 启动脚本

# cp misc/init.d/fedora/core/zabbix_*  /etc/init.d/

#chmod 755 /etc/init.d/zabbix_*

编辑zabbix_server 和zabbix_agentd文件

BASEDIR=/home/zabbix

7.配置 zabbix_server.conf服务端文件

路径:/etc/zabbix/zabbix_server.conf

修改参数如下

# cat /etc/zabbix/zabbix_server.conf | grep -v "^#" | grep -v "^$"

OR

#egrep -v "(#|^$)" /etc/zabbix/zabbix_server.conf

LogFile=/tmp/zabbix_server.log
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/home/mysql/mysql_5537/tmp/mysql.sock
DBPort=5537
StartPollers=160
StartTrappers=20
StartPingers=100
StartDiscoverers=120
MaxHousekeeperDelete=5000
CacheSize=512M
StartDBSyncers=16
HistoryCacheSize=512M
TrendCacheSize=512M
HistoryTextCacheSize=256M
AlertScriptsPath=/etc/zabbix/alertscripts
LogSlowQueries=1000

8.配置zabbix_agentd.conf文件

参数修改如下

# egrep -v "(#|^$)" /etc/zabbix/zabbix_agentd.conf
LogFile=/var/log/zabbix_agentd.log
EnableRemoteCommands=0
Server=127.0.0.1,192.168.28.15
StartAgents=8
ServerActive=192.168.28.15:10051
Hostname=Zabbix.server.com
Timeout=30
Include=/etc/zabbix/zabbix_agentd.conf.d/
UnsafeUserParameters=1

9.拷贝网页文件到nginx目录

#ll frontends/

#ll frontends/php/

#ll /home/lnmp/nginx/html/

#mkdir /home/lnmp/nginx/html/zabbix

#cp -r ./frontends/php/ /home/lnmp/nginx/html/zabbix/

#chown -R www.www /home/lnmp/nginx/html/zabbix/

10.设置zabbix开机启动

#chkconfig zabbix_server on

#chkconfig zabbix_agentd on

#service zabbix_server start

#service zabbix_agentd start

######反正我开启的时候各种报错 有错就排查吧 

[root@node5 etc]# service zabbix_server start
Starting zabbix_server:  /home/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
                                                           [FAILED]
[root@node5 etc]# ln -s /home/mysql/mysql_5621/lib/libmysqlclient.so.18 /usr/lib64/

11.通过web页面配置zabbix

在浏览器中输入http://192.168.28.15/zabbix/php/

技术分享

技术分享

技术分享

技术分享

技术分享

这时候 把文档下载下来 再传入到相应的目录下

技术分享

技术分享

默认用户为admin 密码为zabbix

zabbix安装部署

标签:kconfig   fas   ble   storage   编译参数   delete   index.php   libcurl   agentd   

原文地址:http://www.cnblogs.com/wcwen1990/p/6655450.html

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