您现在的位置是:首页 > 文章详情

运维监控平台之zabbix详解1

日期:2016-08-15点击:546


       本来是想一篇文章介绍完的,写着写着发现篇幅太长,所以决定还是分两篇来介绍,本次软件所用的版本信息如下(基于LNMP环境),操作系统centos6.7

nginx-1.6.3.tar.gz

php-5.6.24.tar.gz

mysql-5.5.49-linux2.6-x86_64.tar.gz

zabbix-3.0.4.tar.gz (zabbix-3以上版本之支持php5.4以上环境)


LNMP环境搭建不再这里说明了,如果不懂的看本人之前写的nginx+php,这里简单介绍下php编译

[root@centos02 tools]# wget  http://cn2.php.net/distributions/php-5.6.24.tar.gz  [root@centos02 tools]# tar xf php-5.6.24.tar.gz  [root@centos02 tools]# cd php-5.6.24 [root@centos02 php-5.6.24]# ./configure \ > --prefix=/application/php5.6.24 \ > --with-mysql=/application/mysql \ >--with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd > --with-iconv-dir=/usr/local/libiconv \ > --with-freetype-dir \ > --with-jpeg-dir \ > --with-png-dir \ > --with-zlib \ > --with-libxml-dir=/usr \ > --enable-xml \ > --disable-rpath \ > --enable-safe-mode \ > --enable-bcmath \ > --enable-shmop \ > --enable-sysvsem \ > --enable-inline-optimization \ > --with-curl \ > --with-curlwrappers \ > --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-zip \ > --enable-soap \ > --enable-short-tags \ > --enable-zend-multibyte \ > --enable-static \ > --with-xsl \ > --with-fpm-user=nginx \ > --with-fpm-group=nginx \ > --enable-ftp >--with-gettext Generating files configure: creating ./config.status creating main/internal_functions.c creating main/internal_functions_cli.c +--------------------------------------------------------------------+ | License:                                                           | | This software is subject to the PHP License, available in this     | | distribution in the file LICENSE.  By continuing this installation | | process, you are bound by the terms of this license agreement.     | | If you do not agree with the terms of this license, you must abort | | the installation process at this point.                            | +--------------------------------------------------------------------+ Thank you for using PHP. config.status: creating php5.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating sapi/fpm/php-fpm.conf config.status: creating sapi/fpm/init.d.php-fpm config.status: creating sapi/fpm/php-fpm.service config.status: creating sapi/fpm/php-fpm.8 config.status: creating sapi/fpm/status.html config.status: creating sapi/cgi/php-cgi.1 config.status: creating ext/phar/phar.1 config.status: creating ext/phar/phar.phar.1 config.status: creating main/php_config.h config.status: executing default commands configure: WARNING: unrecognized options: --enable-safe-mode, --with-curlwrappers, --enable-zend-multibyte


编译过程截图如下

wKiom1exMFzzAjH-AACk7OPZjuk643.png

[root@centos02 application]# ln -s /application/mysql/lib/libmysqlclient.so.18  /usr/lib64/ [root@centos02 application]# touch ext/phar/phar.phar [root@centos02 application]# make && make install Build complete. Don't forget to run 'make test'. Installing shared extensions:     /application/php5.6.24/lib/php/extensions/no-debug-non-zts-20131226/ Installing PHP CLI binary:        /application/php5.6.24/bin/ Installing PHP CLI man page:      /application/php5.6.24/php/man/man1/ Installing PHP FPM binary:        /application/php5.6.24/sbin/ Installing PHP FPM config:        /application/php5.6.24/etc/ Installing PHP FPM man page:      /application/php5.6.24/php/man/man8/ Installing PHP FPM status page:   /application/php5.6.24/php/php/fpm/ Installing PHP CGI binary:        /application/php5.6.24/bin/ Installing PHP CGI man page:      /application/php5.6.24/php/man/man1/ Installing build environment:     /application/php5.6.24/lib/php/build/ Installing header files:           /application/php5.6.24/include/php/ Installing helper programs:       /application/php5.6.24/bin/   program: phpize   program: php-config Installing man pages:             /application/php5.6.24/php/man/man1/   page: phpize.1   page: php-config.1 Installing PEAR environment:      /application/php5.6.24/lib/php/ [PEAR] Archive_Tar    - installed: 1.4.0 [PEAR] Console_Getopt - installed: 1.4.1 [PEAR] Structures_Graph- installed: 1.1.1 [PEAR] XML_Util       - installed: 1.3.0 [PEAR] PEAR           - installed: 1.10.1 Wrote PEAR system config file at: /application/php5.6.24/etc/pear.conf You may want to add: /application/php5.6.24/lib/php to your php.ini include_path /tools/php-5.6.24/build/shtool install -c ext/phar/phar.phar /application/php5.6.24/bin ln -s -f phar.phar /application/php5.6.24/bin/phar Installing PDO headers:           /application/php5.6.24/include/php/ext/pdo/


wKioL1exNY3SevdMAADiHhgb3-U268.png

[root@centos02 php-5.6.24]# ln -s /application/php5.6.24/ /application/php [root@centos02 php-5.6.24]# cp php.ini-production /application/php/lib/php.ini [root@centos02 php-5.6.24]# cd /application/php/etc/ [root@centos02 etc]# cp php-fpm.conf.default php-fpm.conf [root@centos02 etc]# cat php-fpm.conf [global] [www] user = nginx group = nginx listen = 127.0.0.1:9000 pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 [root@centos02 etc]# /application/php/sbin/php-fpm  nginx配置如下  [root@centos02 etc]# cat /application/nginx/conf/nginx.conf worker_processes  2; events {     worker_connections  1024; } http { log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                       '$status $body_bytes_sent "$http_referer" '                       '"$http_user_agent" "$http_x_forwarded_for"';     include       mime.types;     default_type  application/octet-stream;     sendfile        on;     keepalive_timeout  65;     server {         listen       80;         server_name  www.martin.com martin.com;         location / {             root   html/www;             index  index.php index.html index.htm;         }                            location ~ .*\.(php|php5)?$ {             root  html/www;             fastcgi_pass 127.0.0.1:9000;             fastcgi_index index.php;             include fastcgi.conf;                }          access_log  logs/access_www.log  main;            }     server {         listen       80;         server_name  bbs.martin.com;         location / {             root   html/bbs;             index  index.php index.html index.htm;         }                              location ~ .*\.(php|php5)?$ {             fastcgi_pass 127.0.0.1:9000;             fastcgi_index index.php;             include fastcgi.conf;                }          access_log  logs/access_bbs.log  main;            } ###status    server{       listen 80;       server_name status.martin.org;       location / {       stub_status on;       access_log off;         }    } }



浏览器访问测试    (www.martin.com---172.16.80.117)

wKioL1exN3OCKthKAAF0c9xhEj8606.png



至此整个LNMP环境准备完成,zabbix(在LNMP环境下)选择源码编译安装


curl 7.19.7  系统默认版本,升级该软件版本,否则后面邮件功能会有问题

[root@centos02 application]# rpm -Uvh http://www.city-fan.org/ftp/contrib/yum-repo/rhel6/x86_64/city-fan.org-release-1-13.rhel6.noarch.rpm Retrieving http://www.city-fan.org/ftp/contrib/yum-repo/rhel6/x86_64/city-fan.org-release-1-13.rhel6.noarch.rpm warning: /var/tmp/rpm-tmp.jSwm5A: Header V3 DSA/SHA1 Signature, key ID b56a8bac: NOKEY Preparing...                ########################################### [100%]    1:city-fan.org-release   ########################################### [100%] [root@centos02 application]#  yum install libcurl -y [root@centos02 application]# curl -V   再次查看版本 curl 7.50.1 (x86_64-redhat-linux-gnu) libcurl/7.50.1 OpenSSL/1.0.1e zlib/1.2.3 c-ares/1.11.0 libidn/1.18 libssh2/1.7.0 nghttp2/1.6.0 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp  Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets Metalink  安装zabbix依赖包 [root@centos02 zabbix-3.0.4]#  yum -y install mysql-devel libxml2-devel net-snmp-devel libcurl-devel      [root@centos02 tools]# wget http://ncu.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.4/zabbix-3.0.4.tar.gz  [root@centos02 tools]# tar xf zabbix-3.0.4.tar.gz  [root@centos02 tools]# cd zabbix-3.0.4 [root@centos02 zabbix-3.0.4]#  ./configure --prefix=/application/zabbix-server --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-agent --enable-proxy    Enable server:         yes   Server details:     With database:         MySQL     WEB Monitoring:        cURL     Native Jabber:         no     SNMP:                  yes     IPMI:                  no     SSH:                   no     TLS:                   no     ODBC:                  no     Linker flags:             -L/usr/lib64/mysql        -L/usr/lib64      -rdynamic       Libraries:               -lmysqlclient      -lxml2    -lnetsnmp      -lcurl -lm -ldl -lrt  -lresolv    Enable proxy:          yes   Proxy details:     With database:         MySQL     WEB Monitoring:        cURL     SNMP:                  yes     IPMI:                  no     SSH:                   no     TLS:                   no     ODBC:                  no     Linker flags:             -L/usr/lib64/mysql       -L/usr/lib64      -rdynamic       Libraries:               -lmysqlclient     -lxml2    -lnetsnmp      -lcurl -lm -ldl -lrt  -lresolv    Enable agent:          yes   Agent details:     TLS:                   no     Linker flags:              -rdynamic       Libraries:                 -lcurl -lm -ldl -lrt  -lresolv    Enable Java gateway:   no   LDAP support:          no   IPv6 support:          no *********************************************************** *            Now run 'make install'                       * *                                                         * *            Thank you for using Zabbix!                  * *              <http://www.zabbix.com>                    * ***********************************************************


wKiom1exOt6zMV8jAACF4_c-jNM910.png


[root@centos02 zabbix-3.0.4]# make install


wKiom1exO0nRYIwfAADVL0k25Ag946.png

由于zabbix启动脚本路径默认指向的是/usr/local/sbin路径,因此,需要提前建立软链接 [root@centos02 zabbix-3.0.4]# ln -s /application/zabbix-server/sbin/* /usr/local/sbin/ [root@centos02 zabbix-3.0.4]# ln -s /application/zabbix-server/bin/* /usr/local/bin/ 生成zabbix的web文件 [root@centos02 zabbix-3.0.4]# mkdir /application/nginx/html/zabbix [root@centos02 zabbix-3.0.4]# cp -a /tools/zabbix-3.0.4/frontends/php/* /application/nginx/html/zabbix/ 手动创建zabbix数据库及授权 [root@centos02 zabbix-3.0.4]# mysql -uroot -p123456 Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.5.49-log MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database zabbix default charset utf8; Query OK, 1 row affected (0.16 sec) mysql> grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix'; Query OK, 0 rows affected (0.16 sec) mysql> flush privileges; Query OK, 0 rows affected (0.19 sec)


wKiom1exPR-ToQo3AABdqjNeR6I658.png

导入zabbix数据库文件 [root@centos02 mysql]# pwd /tools/zabbix-3.0.4/database/mysql [root@centos02 mysql]# mysql -uzabbix -pzabbix zabbix < schema.sql  [root@centos02 mysql]# mysql -uzabbix -pzabbix zabbix < p_w_picpaths.sql  [root@centos02 mysql]# mysql -uzabbix -pzabbix zabbix < data.sql

wKioL1exPgGQ8DkOAAAUOnE7jVc927.png

配置zabbix server端 修改zabbix配置文件,配置zabbix_server cd /usr/local/zabbix/etc vi/usr/local/zabbix/etc/zabbix_server.conf DBName=zabbix #数据库名称 DBUser=zabbix #数据库用户名 DBPassword=zabbix#数据库密码 ListenIP=localhost #数据库ip地址 DBSocket=/tmp/mysql.sock  #这里填写mysql实际的socket位置  查看/etc/my.cnf即可 AlertScriptsPath=/application/zabbix-server/share/zabbix/alertscripts#zabbix运行脚本存放目录 修改php.ini文件  /application/php/lib/php.ini post_max_size = 16M max_execution_time = 300 memory_limit = 128M max_input_time = 300 date.timezone = Asia/Shanghai always_populate_raw_post_data = -1 extension=php_gettext.dll 修改nginx配置文件如下 [root@centos02 mysql]# cat /application/nginx/conf/nginx.conf worker_processes  2; events {     worker_connections  1024; } http { log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                       '$status $body_bytes_sent "$http_referer" '                       '"$http_user_agent" "$http_x_forwarded_for"';     include       mime.types;     default_type  application/octet-stream;     sendfile        on;     keepalive_timeout  65;     server {         listen       80;         server_name  www.martin.com martin.com;         location / {             root   html/zabbix;             index  index.php index.html index.htm;         }                            location ~ .*\.(php|php5)?$ {             root  html/zabbix;             fastcgi_pass 127.0.0.1:9000;             fastcgi_index index.php;             include fastcgi.conf;                }          access_log  logs/access_zabbix.log  main;            }                  server {         listen       80;         server_name  bbs.martin.com;         location / {             root   html/bbs;             index  index.php index.html index.htm;         }                              location ~ .*\.(php|php5)?$ {             fastcgi_pass 127.0.0.1:9000;             fastcgi_index index.php;             include fastcgi.conf;                }          access_log  logs/access_bbs.log  main;            } ###status    server{       listen 80;       server_name status.martin.org;       location / {       stub_status on;       access_log off;         }    } } [root@centos02 mysql]# /application/nginx/sbin/nginx -s reload [root@centos02 mysql]# useradd -s /sbin/nologin -M zabbix  [root@centos02 mysql]# /etc/init.d/zabbix_server start     Starting zabbix_server:                                    [  OK  ] [root@centos02 mysql]# /application/php/sbin/php-fpm    [root@centos02 init.d]# /application/zabbix-server/sbin/zabbix_server -c /application/zabbix-server/etc/zabbix_server.conf



浏览器访问http://www.martin.com/

wKiom1exTKDiSTfkAADBxm68aLU337.png


wKioL1exYZqQIU9kAACkU1zhSm8692.png


wKiom1exTh2xtkSTAACGa3XaDf8996.png


wKioL1exYc3z9MnDAABoDUycOFw340.png


wKioL1exYhODyrNYAACTInA_n8I471.png

wKiom1exYiSxZM79AABpKJ_4vPI932.png

wKiom1exYjngihWsAAAxtkZkwEE228.png


用户名/密码 默认是  Admin/zabbix

wKiom1exaajh8xFmAAEr9jMm35U698.png

再来看下中文界面

wKioL1exahbTwm36AABzhLK3aH8278.png

安装agent [root@centos02 tools]# wget  http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm       [root@centos02 tools]# rpm -ivh zabbix-release-3.0-1.el6.noarch.rpm  Preparing...                ########################################### [100%]    1:zabbix-release         ########################################### [100%] [root@centos02 tools]# yum -y install zabbix-agent [root@centos02 tools]# /etc/init.d/zabbix-agent start    启动agent Starting Zabbix agent:                                     [  OK  ]


  wKiom1exbkfxV5sRAACQ-tuzH0Y364.png


按照图示步骤启用主机监控即可

wKiom1excE6gaXyNAAEHX4TewBI581.png

这次我们简单介绍到这里,下篇我们正式开始介绍zabbix监控


原文链接:https://blog.51cto.com/huaxin/1838438
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章