51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Zabbix v4.4.6部署

主机信息

Centos 7.5 64bit    master.lolicp.com    192.168.230.101
Centos 7.5 64bit    agent.lolicp.com    192.168.230.102

依赖环境配置

配置主机名

[root@localhost ~]# vim /etc/hostname
master.lolicp.com
[root@localhost ~]# vim /etc/hostname
agent.lolicp.com

配置java_jdk

[root@master ~]# rpm -ivh jdk-8u241-linux-x64.rpm 
warning: jdk-8u241-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk1.8-2000:1.8.0_241-fcs        ################################# [100%]
Unpacking JAR files...
    tools.jar...
    plugin.jar...
    javaws.jar...
    deploy.jar...
    rt.jar...
    jsse.jar...
    charsets.jar...
    localedata.jar...
[root@master ~]# javac -version
javac 1.8.0_241
[root@master ~]# java -version
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

配置Yum源:https://lolicp.com/linux/2020/29425.html

安装Nginx环境:https://lolicp.com/linux/nginx/2020/53108.html

安装PHP环境: https://lolicp.com/linux/php/2020/19113.html

安装MySQL环境: https://lolicp.com/linux/mysql/2020/12435.html

Zabbix部署

下载并安装zabbix4.4.6 server &agent

[root@master ~]# wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.4.6/zabbix-4.4.6.tar.gz
[root@master ~]# tar xf zabbix-4.4.6.tar.gz 
[root@master ~]# cd zabbix-4.4.6/
[root@server zabbix-4.4.6]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-java &&make -j 4 &&make install

zabbix agent安装

[root@agent zabbix-4.4.6]# rpm -ivh jdk-8u241-linux-x64.rpm 
warning: jdk-8u241-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk1.8-2000:1.8.0_241-fcs        ################################# [100%]
Unpacking JAR files...
    tools.jar...
    plugin.jar...
    javaws.jar...
    deploy.jar...
    rt.jar...
    jsse.jar...
    charsets.jar...
    localedata.jar...
[root@agent zabbix-4.4.6]# yum -y install libcurl-devel
[root@agent zabbix-4.4.6]# ./configure --prefix=/usr/local/zabbix --enable-agent --with-net-snmp --with-libcurl --with-libxml2 --enable-java &&make -j 4 &&make install
配置MySQL
[root@master zabbix-4.4.6]# mysql -uroot -p123456
mysql> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
mysql> use zabbix;
mysql> source /root/zabbix-4.4.6/database/mysql/schema.sql;
mysql> source /root/zabbix-4.4.6/database/mysql/images.sql;
mysql> source /root/zabbix-4.4.6/database/mysql/data.sql;
mysql> create user 'zabbix'@'master.lolicp.com' identified by 'Yan@123&d';
mysql> grant all privileges on zabbix.* to 'zabbix'@'master.lolicp.com';
mysql> ALTER USER 'zabbix'@'master.lolicp.com' IDENTIFIED WITH mysql_native_password BY 'Yan@123&d';
mysql> flush privileges;
mysql> show grants for zabbix@'master.lolicp.com';
+-----------------------------------------------------------------+
| Grants for zabbix@master.lolicp.com                                |
+-----------------------------------------------------------------+
| GRANT USAGE ON *.* TO `zabbix`@`master.lolicp.com`                 |
| GRANT ALL PRIVILEGES ON `zabbix`.* TO `zabbix`@`master.lolicp.com` |
+-----------------------------------------------------------------+
2 rows in set (0.06 sec)
`mysql> quit
Bye`

创建zabbix相关

[root@master ~]# useradd -M -s /sbin/nologin zabbix
[root@master ~]# mkdir /usr/local/zabbix/logs
[root@master ~]# chown -R zabbix:zabbix /usr/local/zabbix/
[root@master ~]# cd /usr/local/zabbix/

配置server

[root@server zabbix]# cp -p etc/zabbix_server.conf{,.bak}
[root@master zabbix]# sed -i -e '/^#/d' -e '/^$/d' etc/zabbix_server.conf
[root@server zabbix]# vim etc/zabbix_server.conf
LogFile=/usr/local/zabbix/logs/zabbix_server.log
DBHost=192.168.230.101
DBName=zabbix
DBUser=zabbix
DBPassword=Yan@123&d
DBSocket=/var/lib/mysql/mysql.sock
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
Timeout=4
LogSlowQueries=3000
[root@master ~]# firewall-cmd --zone=public --add-port=10051/tcp --permanent
success
[root@master ~]# firewall-cmd --reload
success

配置agent

[root@server zabbix]# cp -p etc/zabbix_agentd.conf{,.bak}
[root@server zabbix]# vim etc/zabbix_agentd.conf
:%g/^#/d
:%g/^$/d
PidFile=/tmp/zabbix_agentd.pid
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Server=127.0.0.1,192.168.230.101
ServerActive=192.168.230.101
Hostname=master.zabbix.com
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
[root@agent zabbix]# firewall-cmd --zone=public --add-port=10050/tcp --permanent
success
[root@agent zabbix]# firewall-cmd --reload
success

启动zabbix

[root@server zabbix]# /usr/local/zabbix/sbin/zabbix_server &&/usr/local/zabbix/sbin/zabbix_agentd

配置nginx及php

[root@master zabbix]# mv /root/zabbix-4.4.6/frontends/php/ /wwwroot/zabbix
[root@master zabbix]# vim /usr/local/nginx17/vhost/zabbix.conf
server
{
    #Conf-Start
    listen 80;
    server_name zabbix.lolicp.com;
    index index.html index.htm index.php;
    root /wwwroot/zabbix;
    #Conf-END
    #PHP-INFO-START  PHP引用配置,可以注释或修改
        location ~ \.php$ {
            root           /wwwroot/zabbix;
            fastcgi_pass   192.168.230.101:9002;
            fastcgi_index  index.php;
            include        fastcgi.conf;
        }
    #PHP-INFO-END

    #限制文件访问-Start
        location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
            {
                return 404;
            }
    #限制文件访问-END

    #缓存规则-Start
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
            {
                expires      30d;
                error_log off;
                access_log off;
            }
        
        location ~ .*\.(js|css)?$
            {
                expires      12h;
                error_log off;
                access_log off; 
            }
    #缓存规则-END

    #Log-Start
    error_log  /usr/local/nginx17/logs/zabbix.error.log;
    #Log-END



`}
[root@master zabbix]# chown -R nginx:nginx /wwwroot/zabbix
[root@master zabbix]# sed -i 's#;(date.timezone =).`#\1 Asia/Shanghai#g' /etc/php.ini
[root@master zabbix]# sed -i 's#(max_execution_time =).`#\1 300#g' /etc/php.ini
[root@master zabbix]# sed -i 's#(max_input_time =).`#\1 300#g' /etc/php.ini
[root@master zabbix]# sed -i 's#(post_max_size =).`#\1 32M#g' /etc/php.ini
[root@master zabbix]# sed -i 's#(memory_limit =).*#\1 128M#g' /etc/php.ini
[root@master zabbix]# sed -i '854 aextension=bcmath.so' /etc/php.ini
[root@master zabbix]# nginxd restart
Nginx Server Is Stop!
Nginx Server Is Running!
[root@master zabbix]# firewall-cmd --zone=public --add-port=80/tcp --permanent
[root@master zabbix]# firewall-cmd --reload
[root@master zabbix]# semanage port -a -t http_port_t -p tcp 80
[root@master zabbix]# restorecon -R /wwwroot/zabbix/
[root@master zabbix]# setsebool -P httpd_can_network_connect_db 1`



默认账号及密码为: Admin zabbix

如果selinux拦截则执行:

cat /var/log/audit/audit.log | grep denied | audit2allow -M zabbix-server_setrlimit 
semodule -i zabbix-server_setrlimit.pp
遇到的问题

configure报错:

configure: error: Curl library not found

解决方法

[root@agent zabbix-4.4.6]# yum -y install libcurl-devel

configure报错:

configure: error: MySQL library not found

解决方法:

[root@master zabbix-4.4.6]# rpm -ivh ~/mysql-community-devel-8.0.19-1.el7.x86_64.rpm

configure报错:

configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config

解决方法:

[root@master ~]# rpm -ivh mysql-community-libs-compat-8.0.19-1.el7.x86_64.rpm
[root@master zabbix-4.4.6]# yum -y install net-snmp-devel

configure报错:

configure: error: Unable to use libevent (libevent check failed)

解决方法:

[root@master zabbix-4.4.6]# yum -y install libevent-devel
赞(1)
未经允许不得转载:工具盒子 » Zabbix v4.4.6部署