zoukankan      html  css  js  c++  java
  • ubuntu-编译安装zabbix-4.0.18

    编译安装zabbix-4.0.18

    1、cd /usr/local/src
    
    2、wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.0.18/zabbix-4.0.18.tar.gz/download
    
    3、apt-get install apache2 apache2-bin apache2-data apache2-utils fontconfig-config fonts-dejavu-core fping libapache2-mod-php libapache2-mod-php7.2 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libfontconfig1 libgd3 libiksemel3 libjbig0 libjpeg-turbo8 libjpeg8 liblua5.2-0 libodbc1 libopenipmi0 libsensors4 libsnmp-base libsnmp30 libsodium23 libssh2-1 libtiff5 libwebp6 libxpm4 php-bcmath php-common php-gd php-ldap php-mbstring php-mysql php-xml php7.2-bcmath php7.2-cli php7.2-common php7.2-gd php7.2-json php7.2-ldap php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-readline php7.2-xml snmpd ssl-cert ttf-dejavu-core libmysqlclient-dev libxml2-dev libxml2 snmp libsnmp-dev libevent-dev openjdk-8-jdk curl libcurl4-openssl-dev -y
    #解决依赖环境,apt安装会自动解决所依赖的环境,如php,但源码编译需要自己解决这些依赖
    
    数据库服务器需要进行创建账号及授权:
    root@test:~# mysql
    mysql> create database zabbix_server character set utf8 collate utf8_bin;
    mysql> grant all privileges on zabbix_server.* to dong@"192.168.3.%" identified by 'linux';
    #对于Zabbix server和proxy守护进程以及Zabbix前端,必须需要一个数据库。但是Zabbix agent并不需要。
    
    4、tar xvf zabbix-4.0.18.tar.gz
    
    5、useradd zabbix
    
    6、cd zabbix-4.0.18
    
    7、./configure --prefix=/apps/zabbinx-server --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-java
    #编译zabbix server、agent,指定zabbix使用mysql,指定无客户端监控通过snmp协议,开启对url的监控以及java服务器的监控
    
    8、make && make install
    
    9、vim /apps/zabbinx-server/etc/zabbix_server.conf
    DBHost=192.168.3.203
    DBName=zabbix_server
    DBUser=dong
    DBPassword=linux
    
    10、cd /usr/local/src/zabbix-4.0.18/database/mysql
    
    11、mysql -udong -plinux -h192.168.3.203 zabbix_server < schema.sql
        mysql -udong -plinux -h192.168.3.203 zabbix_server < images.sql
    	mysql -udong -plinux -h192.168.3.203 zabbix_server < data.sql
    #将初始化数据库表结构的sql脚本导入zabbix_server数据库中
    
    12、mkdir /var/www/html/zabbix
    
    13、cd /usr/local/src/zabbix-4.0.18/frontends/php
    
    14、cp -a ./* /var/www/html/zabbix/
    #zabbix的前端使用PHP编写的,所以必须运行在支持PHP的Web服务器上;把所有php代码拷贝到指定目录下
    
    15、vim /etc/php/7.2/apache2/php.ini
    post_max_size = 16M
    max_execution_time = 300
    max_input_time = 300
    date.timezone = Asia/Shanghai
    #不修改这些php参数,在zabbix web界面进行环境检查时,会提示错误
    
    16、systemctl restart apach2
    #在apache中,php只是apache的一个功能扩展模块,所以重启apache服务即可
    
    17、/apps/zabbinx-server/sbin/zabbix_agentd
    #zabbix server默认监控的是本身,所以需要把zabbix agent起来,客户端端口是11050
    
    18、/apps/zabbinx-server/sbin/zabbix_server -c /apps/zabbix-server/etc/zabbix_server.conf
    #启动zabbix server
    
    19、浏览器访问http://192.168.3.200/zabbix,进行相关的配置
    
    20、编译安装,不会把zabbix web配置的参数自动生成一个配置文件,需要手动下载下来,然后上传到指定目录下
    
    21、cd /var/www/html/zabbix/conf/
    
    22、rz
    

    zabbix-server以service文件方式启动

    1、root@test:~# vim /lib/systemd/system/zabbix-server.service
    [Unit]
    Description=Zabbix Server
    After=syslog.target
    After=network.target   #启动单元指定这三个即可,不需要依赖于别的服务,如果本机没有mysql等服务,则不要写
    
    [Service]
    Environment="CONFFILE=/apps/zabbix-server/etc/zabbix_server.conf"
    EnvironmentFile=-/etc/default/zabbix-server
    Type=forking
    Restart=on-failure
    PIDFile=/apps/zabbix-server/run/zabbix_server.pid
    KillMode=control-group
    ExecStart=/apps/zabbix-server/sbin/zabbix_server -c $CONFFILE
    ExecStop=/bin/kill -SIGTERM $MAINPID
    RestartSec=10s
    TimeoutSec=infinity
    
    [Install]
    WantedBy=multi-user.target
    
    2、vim /apps/zabbix-server/etc/zabbix_server.conf
    PidFile=/apps/zabbix-server/run/zabbix_server.pid
    #配置文件中也需要修改pid文件的路径
    
    3、mkdir /apps/zabbix-server/run
    
    4、chown zabbix.zabbix /apps/zabbix-server/ -R   
    #需要修改编译安装目录的所有者及所有组,否则用户没有权限在run目录下生成pid文件及无法记录日志等
    
    5、systemctl daemon-reload
    
    6、systemctl start zabbix-server
    
    7、systemctl enable zabbix-server
    

    zabbix-agent以service方式启动

    1、root@test:/apps# vim /lib/systemd/system/zabbix-agent.service
    [Unit]
    Description=Zabbix Agent
    After=syslog.target
    After=network.target
    
    [Service]
    Environment="CONFFILE=/apps/zabbix-server/etc/zabbix_agentd.conf"
    EnvironmentFile=-/etc/default/zabbix-agent
    Type=forking
    Restart=on-failure
    PIDFile=/tmp/zabbix_agentd.pid
    KillMode=control-group
    ExecStart=/apps/zabbix-server/sbin/zabbix_agentd -c $CONFFILE
    ExecStop=/bin/kill -SIGTERM $MAINPID
    RestartSec=10s
    User=zabbix
    Group=zabbix
    
    [Install]
    WantedBy=multi-user.target
    
    2、vim /apps/zabbix-server/etc/zabbix_agentd.conf
    PidFile=/tmp/zabbix_agentd.pid
    
    3、systemctl daemon-reload
    
    4、systemctl start zabbix-agent.service
    
    5、systemctl enable zabbix-agent
    

    注意事项

    对于没有agent的设备采集数据(如交换机、路由器、防火墙等),需要使用snmp协议;监控网络设备,通常是使用snmp协议监控的;IPMI协议是监控硬件服务器使用的,服务器需要有IPMI接口,主要采集CPU温度及风扇转速等;
    
    zabbix通过web界面对数据进行展示;
    
  • 相关阅读:
    使用textarea标签按Enter键后web页面中成换行 vue
    关于json数组对象和对象数组遇到的一些问题
    vue.js实现checkbox的全选和反选
    关于arcgis js 中要素更新的问题
    C# 图片上传问题
    arcgis js 几种拓扑关系详解
    ISS部署网站--HTTP 错误 404.17
    ADODB.Stream在进行文件上传时报错
    window.open 打开Excel或者Word 无权限问题
    Aspose.cell生成表格
  • 原文地址:https://www.cnblogs.com/dongzhanyi123/p/13299380.html
Copyright © 2011-2022 走看看