运维监控平台之zabbix详解1
本来是想一篇文章介绍完的,写着写着发现篇幅太长,所以决定还是分两篇来介绍,本次软件所用的版本信息如下(基于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
编译过程截图如下
[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/
[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)
至此整个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> * ***********************************************************
[root@centos02 zabbix-3.0.4]# make install
由于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)
导入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
配置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
用户名/密码 默认是 Admin/zabbix
再来看下中文界面
安装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 ]
按照图示步骤启用主机监控即可
这次我们简单介绍到这里,下篇我们正式开始介绍zabbix监控

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
[Zabbix问题解决]Zabbix discoverer processes 75% busy
Zabbix只要开启了Discovery功能,这个报警就会出现,如图: 这个问题想要优化掉,比较简单粗暴的办法就是把discovery功能关闭掉,囧~ 那么不囧的方法是什么呢? 找到zabbix_server下的zabbix_server.conf,找到里面的StartDiscoverers,默认值是1,适当增大,3或者5都行,我改成了5,然后重新启动一下zabbix_server,看下效果。 从时间来看,11:59分还有一般严重的报警,到了12:03分,报警解除,Oh Yeah~~ 请看红色框体内,原来是100%,现由于配置文件改成5,cpu就下降到1/5,只有20%了。(请自动过滤时间轴,因为我在11:56分的时候就执行了这个命令并且重启了zabbix_server,zabbix的web接收信息有延迟,所以11:59还显示有problem。)
- 下一篇
关于Exchange Server 2010 启用邮箱时MMC控制台崩溃问题处理
最近有小伙伴咨询问题,关于对已有的AD帐号启用邮箱功能时,EMC控制台崩溃,并提示如下界面显示,反复操作都是无法创建,一直崩溃,那么我们先来看看这个EMC控制台引出的MMC控制台报错。当然这时会有一个疑问为什么EMC崩溃时会显示的是MMC控制台呢?这个好理解,因为EMC其实也是建立在MMC基础上的哦。 OK,我们现在来重现一下这个报错场景,跟我来: 首先,创建一个用于批量创建帐号的CSV文件,格式内容如下: 接下来,我们执行PowerShell,运行创建帐号脚本: 命令执行后,没有报错,这时可以通过AD控制台看到,小高也已经创建出来了 来看看小高的帐号属性,可以看到已经创建好帐号了。 好,接下来去EMC控制台通过GUI方式来启用帐号邮箱,这时我们可以看到,小伙伴反馈的问题重现了。 好,报错场景重现成功了,那么我们来一起看看这个问题原因: 首先:先通过PowerShell命令行看看这个帐号创建完成的属性,哦?来看看,有意思的事情出现啦,CN名后带有斜杠?也不知道这是不是百年难见的一幕…….,反正我是看到了……. 那我们就不得不对CN属性有所怀疑了…CSV中并没有CN字段设置,那我们先...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- CentOS7安装Docker,走上虚拟化容器引擎之路
- SpringBoot2初体验,简单认识spring boot2并且搭建基础工程
- Windows10,CentOS7,CentOS8安装MongoDB4.0.16
- CentOS关闭SELinux安全模块
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- CentOS7编译安装Gcc9.2.0,解决mysql等软件编译问题
- Docker安装Oracle12C,快速搭建Oracle学习环境
- SpringBoot2全家桶,快速入门学习开发网站教程
- SpringBoot2配置默认Tomcat设置,开启更多高级功能
- Eclipse初始化配置,告别卡顿、闪退、编译时间过长