部署zabbix监控服务器

部署zabbix监控服务器

zabbix是什么:是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。zabbix能监视各类网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各类问题。zabbix由2部分构成,zabbix server与可选组件zabbix agent。zabbix server能够经过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它能够运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。php

<!--more-->html

开始部署

环境准备

LNmp 192.168.1.10

安装Lnmp ( Lnmp所需文件)提取码:g9wa

[root@localhost ~]# ls   (上传文件)
libmcrypt-2.5.7.tar.gz  pcre-8.39.tar.gz   zlib-1.2.8.tar.gz 
initial-setup-ks.cfg  nginx-1.14.0.tar.gz     php-5.6.27.tar.gz

解压安装nginx

[root@localhost ~]# tar zxf pcre-8.39.tar.gz
[root@localhost ~]# tar zxf zlib-1.2.8.tar.gz
[root@localhost ~]# tar zxf nginx-1.14.0.tar.gz
[root@localhost ~]# groupadd www  //建立用户
[root@localhost ~]# useradd -g www www -s /sbin/nologin
[root@localhost ~]# cd nginx-1.14.0/
[root@localhost nginx-1.14.0]# yum -y install gcc gcc-c++ make libtool zlib zlib-devel pcre pcre-devel openssl openssl-devel //安装依赖包
[root@localhost nginx-1.14.0]# ./configure --prefix=/usr/local/nginx1.14 --with-http_dav_module  --with-http_stub_status_module --with-http_addition_module --with-http_sub_module   --with-http_flv_module --with-http_mp4_module --with-pcre=/root/pcre-8.39   --with-zlib=/root/zlib-1.2.8 --with-http_ssl_module --with-http_gzip_static_module  //安装nginx
[root@localhost nginx-1.14.0]# make && make install  //解析
[root@localhost nginx-1.14.0]# ln -s /usr/local/nginx1.14/sbin/nginx   /usr/local/sbin/  //软链接

启动nginx

[root@localhost nginx-1.14.0]# nginx 
[root@localhost nginx-1.14.0]# netstat -anpt | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      14014/nginx: master 
tcp        0      0 192.168.1.10:22         192.168.1.250:56180     ESTABLISHED 2843/sshd: root@not

网页访问nginx

部署zabbix监控服务器

安装php

[root@localhost nginx-1.14.0]# cd
[root@localhost ~]# tar zxf libmcrypt-2.5.7.tar.gz 
[root@localhost ~]# cd libmcrypt-2.5.7/
[root@localhost libmcrypt-2.5.7]# ./configure   --prefix=/usr/local/libmcrypt && make && make install

[root@localhost ~]# cd
[root@localhost ~]# tar zxf php-5.6.27.tar.gz
[root@localhost ~]# cd php-5.6.27/
[root@localhost php-5.6.27]# yum -y install  libxml2-devel  opensll-devel bzip2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel
[root@localhost php-5.6.27]# ./configure --prefix=/usr/local/php5.6 --with-config-file-path=/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-gd --with-iconv --with-libxml-dir=/usr  --with-mhash --with-mcrypt=/usr/local/libmcrypt  --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-zlib --with-freetype-dir --with-png-dir --with-jpeg-dir --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl
[root@localhost php-5.6.27]# make && make install

复制文件开启php

[root@localhost php-5.6.27]# cp php.ini-production   /etc/php.ini
[root@localhost php-5.6.27]#  vim /etc/php.ini 
[root@localhost php-5.6.27]# cp sapi/fpm/init.d.php-fpm   /etc/init.d/php-fpm
[root@localhost php-5.6.27]# chkconfig  --add php-fpm
[root@localhost php-5.6.27]# chkconfig php-fpm on  //开机自启
[root@localhost php-5.6.27]# chmod +x /etc/init.d/php-fpm
[root@localhost php-5.6.27]# cp /usr/local/php5.6/etc/php-fpm.conf.default  /usr/local/php5.6/etc/php-fpm.conf
[root@localhost php-5.6.27]# /etc/init.d/php-fpm  start 
Starting php-fpm  done
[root@localhost php-5.6.27]# netstat -anpt | grep 9000
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      15019/php-fpm: mast

配置nginx连接php

[root@localhost php-5.6.27]# vim /usr/local/nginx1.14/conf/nginx.conf
第65行
        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.conf;
        }
第43行
       location / {
            root   html;
            index  index.php index.html index.htm;
        }

建立php测试页面

vim /usr/local/nginx1.10/html/index.php
<?php
phpinfo();
?>

重启nginx网页访问

nginx  -s reload

部署zabbix监控服务器

安装mysql

[root@localhost ~]# ls  //上传文件
mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz   mysql.sh    
[root@localhost ~]# sh mysql.sh
[root@localhost ~]# mysql  -u root -p 
Enter password:    //密码123
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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>

安装zabbix

[root@localhost ~]# cd /usr/src/
[root@localhost src]# ls
fping-3.12.tar.gz  zabbix-3.2.1.tar.gz   //上传文件
[root@localhost src]# tar zxf fping-3.12.tar.gz 
[root@localhost src]# cd fping-3.12/
[root@localhost fping-3.12]# ./configure  && make && make install
[root@localhost fping-3.12]# useradd zabbix -s /sbin/nologin   //建立用户
[root@localhost fping-3.12]# chown zabbix:zabbix   /usr/local/sbin/fping
[root@localhost fping-3.12]# cd ..
[root@localhost src]# tar zxf zabbix-3.2.1.tar.gz 
[root@localhost src]# cd zabbix-3.2.1/
[root@localhost zabbix-3.2.1]# yum -y install net-snmp-devel  curl-devel java-devel OpenIPMI-devel libssh2-devel  //安装依赖
[root@localhost zabbix-3.2.1]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent  --enable-java --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl  --with-openipmi  //解析安装
***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************
[root@localhost zabbix-3.2.1]# make && make install

建立软链接

[root@localhost zabbix-3.2.1]# ln -s /usr/local/zabbix/bin/*  /usr/local/bin/
[root@localhost zabbix-3.2.1]# ln -s /usr/local/zabbix/sbin/*  /usr/local/sbin/

进入mysql

mysql> create database zabbix character set utf8;   //建立用户
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '123.com';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit
Bye

[root@localhost mysql]# cd /usr/src/zabbix-3.2.1/database/mysql/
[root@localhost mysql]# mysql -u zabbix -p123.com -hlocalhost zabbix < schema.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -u zabbix -p123.com -hlocalhost zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -u zabbix -p123.com -hlocalhost zabbix < data.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql> use zabbix   //查看数据库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| application_discovery      |
| application_prototype      |
| application_template       |
| applications               |
| auditlog                   |
| auditlog_details           |
| autoreg_host               |
| conditions                 |
| config                     |
| corr_condition             |
| corr_condition_group       |
| corr_condition_tag         |
| corr_condition_tagpair     |

[root@localhost ~]# chown -R zabbix:zabbix  /usr/local/zabbix/   //给予权限

进入zabbix文件修改内容

[root@localhost ~]# vim /usr/local/zabbix/etc/zabbix_server.conf
DBHost=192.168.1.10
DBPort=3306
DBName=zabbix
DBUser=zabbix
Timeout=4
LogFile=/usr/local/zabbix/logs/zabbix_server.log
PidFile=/usr/local/zabbix/logs/zabbix_server.pid
DBPassword=123.com
DBSocket=/usr/local/mysql/mysql.sock
FpingLocation=/usr/local/sbin/fping
LogSlowQueries=3000
[root@localhost ~]# ldconfig
[root@localhost ~]# vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/mysql/lib
[root@localhost ~]# mkdir /usr/local/zabbix/logs  //建立文件
[root@localhost ~]# chown -R zabbix:zabbix  /usr/local/zabbix/logs/   //给予权限
[root@localhost ~]# ldconfig

返回/usr/src/zabbix/下拷贝文件

[root@localhost zabbix-3.2.1]# cd /usr/src/zabbix-3.2.1/misc/init.d/fedora/core
[root@localhost core]# cp zabbix_agentd  /etc/init.d/
[root@localhost core]# cp zabbix_server  /etc/init.d/
[root@localhost core]# vim  /etc/init.d/zabbix_server 
[root@localhost core]# vim  /etc/init.d/zabbix_agentd
第22行:BASEDIR=/usr/local/zabbix
第31行:PIDFILE=/usr/local/zabbix/logs/$BINARY_NAME.pid
[root@localhost core]# ls /usr/local/zabbix/logs/  //查看
zabbix_server.log  zabbix_server.pid
[root@localhost core]# cd /usr/src/zabbix-3.2.1/frontends/
[root@localhost frontends]# cp -r php/ /usr/local/nginx1.14/html/zabbix

网页访问zabbix

部署zabbix监控服务器

部署zabbix监控服务器

修改文件参数

[root@localhost frontends]# vim /etc/php.ini
第635行:post_max_size = 16M
第372行:max_execution_time = 300
第382行:max_input_time = 300
第702行:always_populate_raw_post_data = -1
第936行:date.timezone =Asia/Shanghai
[root@localhost frontends]# /etc/init.d/php-fpm  restart //重启php
Gracefully shutting down php-fpm . done
Starting php-fpm  done

部署zabbix监控服务器

进入数据库受权IP

[root@localhost frontends]# mysql -u root -p123
mysql> grant all on zabbix.* to zabbix@'192.168.1.%' identified by '123.com';
Query OK, 0 rows affected, 1 warning (0.00 sec)

部署zabbix监控服务器

下一步

部署zabbix监控服务器

部署zabbix监控服务器

下载文件并上传到指定文件

部署zabbix监控服务器

[root@localhost frontends]# cd /usr/local/nginx1.14/html/zabbix/conf/  //上传
[root@localhost conf]# ls
maintenance.inc.php  zabbix.conf.php  zabbix.conf.php.example

完成

部署zabbix监控服务器

默认用户是admin 密码是zabbixjava

部署zabbix监控服务器

解决图形乱码问题

在控制面版中的字体->选择一种字体复制到桌面mysql

上传到/usr/local/nginx1.14/html/zabbix/fonts/下linux

修改配置文件中的DejaVuSans替换成所选的字体名称nginx

/usr/local/nginx1.10/html/zabbix/include/defines.inc.php
:%s/DejaVuSans/simkai/g
相关文章
相关标签/搜索