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

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

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

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

1、关闭防火墙和selinux。 

 systemctl stop firewalld

  systemctl disable firewalld

  setenforce 0 # 设置临时关闭selinux  

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config #设置永久关闭selinux

  reboot #重启

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

 groupadd --system zabbix
    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 数据库和用户

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


导入数据

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


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

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


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

cd /usr/local/nginx/html 
mkdir   zabbix
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

 #!/bin/sh
 #chkconfig: 2345  10  90
# Zabbix
# Copyright (C) 2001-2018 Zabbix SIA
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
# Start/Stop the Zabbix server daemon.
# Place a startup script in /sbin/init.d, and link to it from /sbin/rc[023].d
 
SERVICE="Zabbix server"
DAEMON=/usr/local/zabbix/sbin/zabbix_server
PIDFILE=/tmp/zabbix_server.pid
 
case $1 in
  'start')
    if [ -x ${DAEMON} ]
    then
      $DAEMON
      # Error checking here would be good...
      echo "${SERVICE} started."
    else
      echo "Can't find file ${DAEMON}."
      echo "${SERVICE} NOT started."
    fi
  ;;
  'stop')
    if [ -s ${PIDFILE} ]
    then
      if kill `cat ${PIDFILE}` >/dev/null 2>&1
      then
        echo "${SERVICE} terminated."
        rm -f ${PIDFILE}
      fi
    fi
  ;;
  'restart')
    $0 stop
    sleep 10
    $0 start
  ;;
  *)
    echo "Usage: $0 start|stop|restart"
    ;;
esac

exit 0

 给文件授权

chmod +x /etc/init.d/zabbix_server

chkconfig  --add  zabbix_server   加入服务列表
chkconfig  zabbix_server  on   添加开机启动

service    zabbix_server  start   启动服务


netstat -tnlp| grep 10051 或者   ps  -ef|grep   zabbix

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

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

#!/bin/sh
#chkconfig: 2345   10  90
# Zabbix
# Copyright (C) 2001-2018 Zabbix SIA
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
# Start/Stop the Zabbix agent daemon.
# Place a startup script in /sbin/init.d, and link to it from /sbin/rc[023].d
 
SERVICE="Zabbix agent"
DAEMON=/usr/local/zabbix/sbin/zabbix_agentd
PIDFILE=/tmp/zabbix_agentd.pid
 
case $1 in
  'start')
    if [ -x ${DAEMON} ]
    then
      $DAEMON
      # Error checking here would be good...
      echo "${SERVICE} started."
    else
      echo "Can't find file ${DAEMON}."
      echo "${SERVICE} NOT started."
    fi
  ;;
  'stop')
    if [ -s ${PIDFILE} ]
    then
      if kill `cat ${PIDFILE}` >/dev/null 2>&1
      then
        echo "${SERVICE} terminated."
        rm -f ${PIDFILE}
      fi
    fi
  ;;
  'restart')
    $0 stop
    sleep 10
    $0 start
  ;;
  *)
    echo "Usage: $0 start|stop|restart"
    ;;
esac

exit  0

授予文件执行权限

chmod +x /etc/init.d/zabbix_agentd
chkconfig --add   zabbix_agentd
chkconfig  zabbix_agentd  on

service    zabbix_agentd  start 

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

 检查原命令对应包情况

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


执行上边命令还报错的话

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


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

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

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

启动PHP服务

service php-fpm start
service php-fpm stop
service php-fpm reload


启动zabbix服务

service    zabbix_server  start
service    zabbix_agentd  start 

systemctl start nginx.service    启动nginx

systemctl stop nginx.service    结束nginx

systemctl restart nginx.service    重启nginx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

温柔-的-女汉子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值