当前位置:   article > 正文

Linux安装部署zabbix运维监控平台,实操,步骤明晰+常见问题解决方案_zabbix部署详细流程nginx方式

zabbix部署详细流程nginx方式

Linux安装部署zabbix运维监控平台,实操,步骤明晰+常见问题解决方案

工作中,如果服务器多且需要对服务器进行24小时不间断的监控,保证业务的正常运行,那么就需要一款高效的监控管理工具,那么zabbix运维监控平台必不可少。

首先准备lnmp环境和相关安装包文件zabbix-5.0.0.tar.gz。

1、关闭防火墙和selinux。 

  1.  systemctl stop firewalld
  2.   systemctl disable firewalld

  setenforce 0 # 设置临时关闭selinux  

  1. sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config #设置永久关闭selinux
  2.   reboot #重启

2、为zabbix新建用户和组(可以不用)
   

  1. groupadd --system zabbix
  2.     useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix


为zabbix家目录修改权限
2、安装依赖

 yum -y install gcc gcc-c++ mysql-devel  libdbi-dbd-mysql net-snmp-devel curl-devel net-snmp libcurl-devel libxml2-devel  libevent-devel

3、编译

 ./configure --prefix=/usr/local/zabbix  --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

4、安装
make install

5、进入数据库配置 zabbix 数据库和用户

  1.   mysql  -uroot  -p      输入密码
  2.  create database zabbix character set utf8 collate utf8_bin;
  3.  create user 'zabbix'@'localhost' identified by '123456';
  4.  grant all privileges on zabbix.* to 'zabbix'@'localhost';
  5.   flush privileges;


导入数据

  1. mysql -uzabbix -p zabbix < database/mysql/schema.sql
  2. mysql -uzabbix -p zabbix <  database/mysql/images.sql
  3. mysql -uzabbix -p zabbix <  database/mysql/data.sql


6.配置zabbix_server 配置件中的加上数据库密码

  1. cd  /usr/local/zabbix/etc
  2. vim   zabbix_server.conf
  3. DBPassword=123456


7、把zabbix网址文件复制到nginx网站发布目录下,在html目录下新建zabbix文件夹

  1. cd /usr/local/nginx/html 
  2. mkdir   zabbix
  3. mv   /usr/local/zabbix-5.0.0/ui/* /usr/local/nginx/html/zabbix/


8、把配置文件zabbix.conf.php(在Linux\项目实施\zabbix安装部署  目录下)文件放到
  /usr/local/nginx/html/zabbix/conf(这个是你的zabbix网站页面存放路径)
zabbix.conf.php 此文件要根据你的实际情况进行修改,例如数据库的IP账号和密码等

9、创建server启动脚本

1
 vim /etc/init.d/zabbix_server

  1.  #!/bin/sh
  2.  #chkconfig: 2345  10  90
  3. # Zabbix
  4. # Copyright (C) 2001-2018 Zabbix SIA
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  19.  
  20. # Start/Stop the Zabbix server daemon.
  21. # Place a startup script in /sbin/init.d, and link to it from /sbin/rc[023].d
  22.  
  23. SERVICE="Zabbix server"
  24. DAEMON=/usr/local/zabbix/sbin/zabbix_server
  25. PIDFILE=/tmp/zabbix_server.pid
  26.  
  27. case $1 in
  28.   'start')
  29.     if [ -x ${DAEMON} ]
  30.     then
  31.       $DAEMON
  32.       # Error checking here would be good...
  33.       echo "${SERVICE} started."
  34.     else
  35.       echo "Can't find file ${DAEMON}."
  36.       echo "${SERVICE} NOT started."
  37.     fi
  38.   ;;
  39.   'stop')
  40.     if [ -s ${PIDFILE} ]
  41.     then
  42.       if kill `cat ${PIDFILE}` >/dev/null 2>&1
  43.       then
  44.         echo "${SERVICE} terminated."
  45.         rm -f ${PIDFILE}
  46.       fi
  47.     fi
  48.   ;;
  49.   'restart')
  50.     $0 stop
  51.     sleep 10
  52.     $0 start
  53.   ;;
  54.   *)
  55.     echo "Usage: $0 start|stop|restart"
  56.     ;;
  57. esac
  58. exit 0

 给文件授权

  1. chmod +x /etc/init.d/zabbix_server
  2. chkconfig  --add  zabbix_server   加入服务列表
  3. chkconfig  zabbix_server  on   添加开机启动
  4. service    zabbix_server  start   启动服务
  5. netstat -tnlp| grep 10051 或者   ps  -ef|grep   zabbix

######################################

 创建自带agent的启动脚本
 vim /etc/init.d/zabbix_agentd

  1. #!/bin/sh
  2. #chkconfig: 2345   10  90
  3. # Zabbix
  4. # Copyright (C) 2001-2018 Zabbix SIA
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  19.  
  20. # Start/Stop the Zabbix agent daemon.
  21. # Place a startup script in /sbin/init.d, and link to it from /sbin/rc[023].d
  22.  
  23. SERVICE="Zabbix agent"
  24. DAEMON=/usr/local/zabbix/sbin/zabbix_agentd
  25. PIDFILE=/tmp/zabbix_agentd.pid
  26.  
  27. case $1 in
  28.   'start')
  29.     if [ -x ${DAEMON} ]
  30.     then
  31.       $DAEMON
  32.       # Error checking here would be good...
  33.       echo "${SERVICE} started."
  34.     else
  35.       echo "Can't find file ${DAEMON}."
  36.       echo "${SERVICE} NOT started."
  37.     fi
  38.   ;;
  39.   'stop')
  40.     if [ -s ${PIDFILE} ]
  41.     then
  42.       if kill `cat ${PIDFILE}` >/dev/null 2>&1
  43.       then
  44.         echo "${SERVICE} terminated."
  45.         rm -f ${PIDFILE}
  46.       fi
  47.     fi
  48.   ;;
  49.   'restart')
  50.     $0 stop
  51.     sleep 10
  52.     $0 start
  53.   ;;
  54.   *)
  55.     echo "Usage: $0 start|stop|restart"
  56.     ;;
  57. esac
  58. exit  0

授予文件执行权限

  1. chmod +x /etc/init.d/zabbix_agentd
  2. chkconfig --add   zabbix_agentd
  3. chkconfig  zabbix_agentd  on
  4. service    zabbix_agentd  start 
  5. service    zabbix_server  start

################################常见问题解决方案##############################


1、报错处理

/application/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory


 此时需要配置一个软连接指向该位置。

ln -s /usr/local/mysql/lib/libmysqlclient.so.21 /usr/lib64


2、页面报    zabbix Cannot connect to the database

原因是php页面文件conf目录下缺少一个数据库配置文件(zabbix.conf.php):
  解决方法:
 cd /usr/local/nginx/html/zabbix/conf    #进入网页根目录下,目录地址根据自己的实际情况来
 cp zabbix.conf.php.example zabbix.conf.php #重命名文件
 vim zabbix.conf.php #修改正确的端口、账号及密码


3、 报error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such fil

 检查原命令对应包情况

  1.  ldd $(which /usr/local/zabbix/sbin/zabbix_server)
  2. ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1 
  3. ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1


执行上边命令还报错的话

  1. find  / -name   libssl.so.1.1 
  2. find  / -name   libcrypto.so.1.1


找到这个文件目录,直接拷贝到    /usr/lib64   目录下

  1. cp   /usr/local/mysql/lib/private/libssl.so.1.1   /usr/lib64
  2. cp   /usr/local/mysql/lib/private/libcrypto.so.1.1   /usr/lib64

启动PHP服务

  1. service php-fpm start
  2. service php-fpm stop
  3. service php-fpm reload


启动zabbix服务

  1. service    zabbix_server  start
  2. service    zabbix_agentd  start 
  3. systemctl start nginx.service    启动nginx
  4. systemctl stop nginx.service    结束nginx
  5. systemctl restart nginx.service    重启nginx

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/654486
推荐阅读
相关标签
  

闽ICP备14008679号