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

部署zabbix环境的搭建

时间:2017-09-17 19:05:25      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:部署zabbix环境的搭建

部署zabbix环境的搭建

 

配置LAMP环境(因为之前已经搭建过了lnmp所以这里就不一一演示了)

也可以yum源安装:

[root@centos-1 ~]#yum install make mysql-server httpd php mysql-devel gcc net-snmp-devel curl-devel perl-DBI php-gd php-mysql php-bcmath php-mbstring php-xml unixODBC-devel OpenIPMI-devel libxml2-devel

下载zabbix安装包:

wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.7/zabbix-3.2.7.tar.gz

 

 

1、新建一个zabbix账户:

[root@centos-1 ~]useradd zabbix -s /sbin/nologin

 

2、创建zabbix数据库、并赋给咱必须权限:

mysql> create database zabbix character set utf8 collate utf8_bin;

 

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

 

flush privileges;

 

下载zabbix,并且导入数据库,

 

[root@centos-1 src]# cd /usr/local/src/zabbix-2.2.2

[root@centos-1 zabbix-2.2.2]# cd database/mysql/

[root@centos-1 mysql]# mysql -uzabbix -pzabbix zabbix < schema.sql

[root@centos-1 mysql]# mysql -uzabbix -pzabbix zabbix < images.sql

[root@centos-1 mysql]# mysql -uzabbix -pzabbix zabbix < data.sql

4、编译安装zabbix_server:

[root@centos-1 zabbix-2.2.2]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-unixodbc --prefix=/usr/local/zabbix

[root@centos-1 zabbix-2.2.2]# make && make install

 

5、编辑nginx.conf支持index.php

假如使用apache的时候就改apache下的配置文件原理一样)

[root@centos-1 zabbix-2.2.2]# vim /usr/local/nginx/conf/nginx.conf

 server {

        listen       80;

        server_name  localhost;

 

        #charset koi8-r;

 

        #access_log  logs/host.access.log  main;

 

        location / {

            root   /web;

            index  index.php index.html index.htm;

        }

………………………………

 location ~ \.php$ {###(把location里面的前面注释#去掉后修改成)

            root           /web;   ###(index.php存放的目录)

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            include        fastcgi_params;

        }

6、修改zabbix文件对应的数据库账号和密码:

[root@centos-1 zabbix-2.2.2]# vim /usr/local/zabbix/etc/zabbix_server.conf

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

7、复制启动脚本,并修改相应选项:

[root@centos-1 zabbix-2.2.2]# cp misc/init.d/fedora/core5/zabbix_server /etc/init.d/

[root@centos-1 zabbix-2.2.2]# cp misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/

修改两个配置文件把

[root@centos-1 zabbix-2.2.2]# vim /etc/init.d/zabbix_agentd

ZABBIX_BIN="/usr/local/sbin/zabbix_agentd" 改成ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd"

[root@centos-1 zabbix-2.2.2]# vim /etc/init.d/zabbix_server

ZABBIX_BIN="/usr/local/sbin/zabbix_server"改成ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_server"

 

启动:

[root@centos-1 zabbix-2.2.2]# /etc/init.d/zabbix_server start

[root@centos-1 zabbix-2.2.2]# /etc/init.d/zabbix_agentd start

[root@centos-1 zabbix-2.2.2]# chkconfig zabbix_agentd on

[root@centos-1 zabbix-2.2.2]# chkconfig zabbix_server on

8、修改php.ini文件支持大小,不然web也没容易报错:

[root@centos-1 zabbix-2.2.2]# vim /usr/local/php/etc/php.ini

max_execution_time = 300

max_input_time = 300

date.timezone =Asia/Shanghai

post_max_size = 32M

重启nginx使php配置生效

 

9、复制zabbixphp项目早http目录下,并且给权限:

[root@centos-1 /]# cd /usr/local/src/zabbix-3.2.7/frontends/

[root@centos-1 frontends]#

[root@centos-1 frontends]# cp -rf php /web

[root@centos-1 htdocs]# chown -R apache.apache /web

在这里我是使用nginx+php的所以在php配置文件:vim  /usr/local/nginx/conf/nginx.conf修改网页主目录:

  location ~ \.php$ {

            root           /web;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            include        fastcgi_params;

        }

 

所以php网页目录就要放在/web目录下 以上操作改为nginx实现。

 

 

重启服务:

启动php服务:

ps -ef | grep php | awk ‘{print $2}‘ | xargs kill  -9

 

想要达到php不会自动挂掉就执行

/usr/local/php/sbin/php-fpm --daemonize -c /usr/local/php/etc/php.ini &

####--daemonize:关闭终端php不会down掉 -c:指定配置文件  & :后台运行

启动nginx:

/usr/local/nginx/sbin/nginx -s reload

 

[root@centos-1 frontends]# netstat -ntlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   

tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      50648/zabbix_agentd

tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      50584/zabbix_server

tcp        0      0 0.0.0.0:9000                0.0.0.0:*                   LISTEN      35148/php-fpm       

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      35053/mysqld        

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      24389/nginx         

tcp        0      0 0.0.0.0:6000                0.0.0.0:*                   LISTEN      1852/X              

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      2327/sshd           

tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      26396/master        

tcp        0      0 :::6000                     :::*                        LISTEN      1852/X              

tcp        0      0 :::22                       :::*                        LISTEN      2327/sshd           

tcp        0      0 ::1:25                      :::*                        LISTEN      26396/master  

 

端口:80 9000 10050 10051起来了就可以!

10、然后访问web: http://IP/php/index.php默认下一步:

11、安装gettext扩展模块(有时候会出现很多模块没安装上网查找一下就ok)

面对的问题:

在安装zabbix时碰到如下错误:

PHP gettext extension missing (PHP configuration parameter --with-gettext)

 

分析可知道在编译安装php时,没有加上--with-gettext

 

 

扩展安装gettext时:

1、先进入php源文件中在cd /usr/local/src/php-5.5.38/ext/gettext目录下

2、在执行/usr/local/PHP/bin/phpize

3、./configure –with-php-config=/usr/local/php/bin/php-config

4、make && make install

6、系统缺少gettext-devel工具库,或者已经编译安装了gettext但是在编译php时没找到路径

vim /usr/local/php/etc/php.ini

找到extensions选项,添加如下项:

extension = "gettext.so"

5、重启php,nginx服务

 

安装成功,登录的账号默认为:Admin,密码为:zabbix:

访问zabbix

技术分享 

 

 

12agent安装步骤:

客户端安装的话不用依赖LAMP环境,直接装上就好

 

1)添加账户:

[root@centos-1 ~]# useradd zabbix -s /sbin/nologin

 

2)编译安装zabbix_agent:

[root@centos-1 zabbix-2.2.2]# ./configure --with-net-snmp --with-libcurl --enable-agent --prefix=/usr/local/zabbix

[root@centos-1 zabbix-2.2.2]# make && make install

 

3)设置启动项和修改配置文件:

[root@centos-1 zabbix-2.2.2]# cp misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/

[root@centos-1 zabbix-2.2.2]# chmod 700 /etc/init.d/zabbix_agentd

[root@centos-1 zabbix-2.2.2]# vim /etc/init.d/zabbix_agentd

ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd"

 

4)修改zabbix指向的服务器:

[root@centos-1 zabbix-2.2.2]# vim /usr/local/zabbix/etc/zabbix_agentd.conf

Server=192.168.10.205

 

[root@centos-1 fonts]# pwd

/var/www/html/zabbix/fonts

上传一个字体:替换

[root@centos-1 fonts]# mv simhei.ttf DejaVuSans.ttf 


本文出自 “第一个legehappy51cto博客” 博客,请务必保留此出处http://legehappy.blog.51cto.com/13251607/1966047

部署zabbix环境的搭建

标签:部署zabbix环境的搭建

原文地址:http://legehappy.blog.51cto.com/13251607/1966047

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