zabbix离线安装 zabbix api批量添加主机

持续更新最新版本…

全自动安装方法

  1. 下载一键安装脚本
    一键安装脚本
  2. 执行命令全自动安装
tar -zxvf zabbix-rocky_8_zabbix_6.0.x_mysql.tar.gz
cd zabbix-rocky_8_zabbix_6.0.x_mysql
sh autosetup.sh install
  1. Rocky8.9系统下载
  2. Rocky系统bug报告

手动安装方法

  1. 操作系统:Rocky8
  2. 数据库版本
[root@localhost /]# rpm -qa | grep MariaDB
MariaDB-common-11.1.2-1.el8.x86_64
MariaDB-shared-11.1.2-1.el8.x86_64
MariaDB-client-11.1.2-1.el8.x86_64
MariaDB-server-compat-11.1.2-1.el8.noarch
MariaDB-client-compat-11.1.2-1.el8.noarch
MariaDB-server-11.1.2-1.el8.x86_64
[root@localhost /]# 
  1. zabbix 版本
[root@localhost /]# rpm -qa | grep zabbix
zabbix-web-deps-6.0.25-release1.el8.noarch
zabbix-server-mysql-6.0.25-release1.el8.x86_64
zabbix-sender-6.0.25-release1.el8.x86_64
zabbix-get-6.0.25-release1.el8.x86_64
zabbix-agent2-plugin-mongodb-6.0.25-release1.el8.x86_64
zabbix-web-6.0.25-release1.el8.noarch
zabbix-web-mysql-6.0.25-release1.el8.noarch
zabbix-nginx-conf-6.0.25-release1.el8.noarch
zabbix-proxy-mysql-6.0.25-release1.el8.x86_64
zabbix-agent2-6.0.25-release1.el8.x86_64
zabbix-sql-scripts-6.0.25-release1.el8.noarch
zabbix-selinux-policy-6.0.25-release1.el8.x86_64
zabbix-js-6.0.25-release1.el8.x86_64
zabbix-agent2-plugin-postgresql-6.0.25-release2.el8.x86_64
zabbix-java-gateway-6.0.25-release1.el8.x86_64
zabbix-web-service-6.0.25-release1.el8.x86_64
zabbix-release-6.0-4.el8.noarch
[root@localhost /]# 
  1. 设置yum
sed -e 's|^mirrorlist=|#mirrorlist=|g' \-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \-i.bak \/etc/yum.repos.d/Rocky-*.repoyum clean all
yum makecache
yum -y install wget
  1. 安装MariaDB
cat > /etc/yum.repos.d/MariaDB.repo << EOF
# MariaDB 10.11.2 CentOS repository list - created 2023-03-24 01:38 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/10.11.3/centos/\$releasever/\$basearch
baseurl = https://mirrors.aliyun.com/mariadb/yum/11.1/rhel/\$releasever/\$basearch
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1
EOF
yum module disable mysql mariadb -y
sudo dnf -y install MariaDB-server MariaDB-client
systemctl start mariadb
  1. 安装snmp及部分插件
yum -y install nano net-snmp* net-tools unzip glibc-langpack-zh.x86_64 langpacks-zh_CN.noarch sysstat iotop rsyslog
  1. 安装zabbix
wget -P /tmp/ https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-latest.el8.noarch.rpm
rpm -ivhU --force /tmp/zabbix-release-latest.el8.noarch.rpm
sed -i -e "/^enabled=0/s/=.*/=1/" /etc/yum.repos.d/zabbix.repo
cat > /tmp/packages  << EOF
zabbix-agent2
zabbix-agent2-plugin-mongodb
zabbix-agent2-plugin-postgresql
zabbix-get
zabbix-java-gateway
zabbix-js
zabbix-nginx-conf
zabbix-proxy-mysql
zabbix-selinux-policy
zabbix-sender
zabbix-server-mysql
zabbix-sql-scripts
zabbix-web
zabbix-web-deps
zabbix-web-mysql
zabbix-web-service
EOF
cat /tmp/packages | xargs yum -y install
  1. 创建zabbix数据库导入create_server_6.0-latest汉化模板
DPassword="123.com"
mariadb -e "create database zabbix character set utf8mb4 collate utf8mb4_bin;"
mariadb -e "grant all privileges on zabbix.* to'zabbix'@'localhost' identified by '$DPassword';"
mariadb -e "grant all privileges on zabbix.* to'zabbix'@'%' identified by '$DPassword';"
mariadb -e "set character_set_server=utf8mb4;"
mariadb -e "flush privileges;"
cd /tmp
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/patch/my.cnf
\cp /tmp/my.cnf /etc/
touch /var/log/mariadb.log
cd /tmp
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/mysql/create_server_6.0-latest.sql.gz
\cp /tmp/create_server_6.0-latest.sql.gz /usr/share/zabbix-sql-scripts/mysql/
chmod 766 /usr/share/zabbix-sql-scripts/mysql/create_server_6.0-latest.sql.gz
zcat /usr/share/zabbix-sql-scripts/mysql/create_server_6.0-latest.sql.gz | mariadb -h 127.0.0.1 -uzabbix -p$DPassword zabbix;
  1. 关闭防火墙与selinux
setenforce 0
service firewalld stop
chkconfig firewalld off
sed -i "/SELINUX=enforcing/s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
  1. 配置nginx
cd /tmp
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/patch/nginx.conf
\cp /tmp/nginx.conf /etc/nginx/nginx.conf
cd /tmp
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/patch/zabbix.conf
\cp /tmp/zabbix.conf /etc/nginx/conf.d
DPassword="123.com"
cd /tmp
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/patch/zabbix.conf.php
\cp /tmp/zabbix.conf.php /etc/zabbix/web/
sed -i "/123.com/s/123.com/$DPassword/" /etc/zabbix/web/zabbix.conf.php
  1. 为nginx配置https访问
mkdir -p /etc/pki/nginx
cd /tmp
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/patch/server.pem
\cp /tmp/server.pem /etc/pki/nginx/
sed -i -e "/listen/d" /etc/nginx/conf.d/zabbix.conf
sed -i -e "/server {/a\ \tlisten 8080;\n\tlisten 8443 ssl;" /etc/nginx/conf.d/zabbix.conf
sed -i -e "/ssl_/d" /etc/nginx/conf.d/zabbix.conf
sed -i -e "/if /,+2d" /etc/nginx/conf.d/zabbix.conf
sed -i -e "/8443 ssl/a\ \tssl_certificate \"/etc/pki/nginx/server.pem\";\n\
\tssl_certificate_key \"/etc/pki/nginx/server.pem\";\n\
\tssl_session_cache shared:SSL:1m;\n\
\tssl_session_timeout  10m;\n\
#\tssl_ciphers PROFILE=SYSTEM;\n\
\tssl_prefer_server_ciphers on;\n\
\tif (\$server_port = 8080) {\n\
\t\trewrite ^(\.\*)\$ https://\$host:8443\$1 permanent;\n\
\t}\
" /etc/nginx/conf.d/zabbix.conf
  1. 配置php-fpm
cd /tmp
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/php-fpm.d/zabbix.conf
\cp /tmp/zabbix.conf /etc/php-fpm.d/
  1. 配置snmptrap
cd /tmp
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/snmptrap/zabbix_trap_receiver.pl
\cp /tmp/zabbix_trap_receiver.pl /usr/bin/
chmod a+x /usr/bin/zabbix_trap_receiver.pl
sed -i "/# authCommunity   log,execute,net public/s/# authCommunity   log,execute,net public/authCommunity   log,execute,net public/" /etc/snmp/snmptrapd.conf
sed -i "/zabbix_trap_receiver.pl/d" /etc/snmp/snmptrapd.conf
echo "perl do \"/usr/bin/zabbix_trap_receiver.pl\"" >> /etc/snmp/snmptrapd.conf
  1. 配置SNMPv3登录权限
systemctl start snmpd
sed -i -e "/rouser/d" /etc/snmp/snmpd.conf
sed -i -e "/zabbix/d" /var/lib/net-snmp/snmpd.conf
systemctl stop snmpd
net-snmp-create-v3-user -ro -A Admin@zabbix -a MD5 -X Admin@zabbix -x DES zabbix
  1. 汉化web ui图形界面并解决web乱码问题
cd /tmp
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/patch/frontend_6.0.mo
\cp /tmp/frontend_6.0.mo /usr/share/zabbix/locale/zh_CN/LC_MESSAGES/frontend.mo
cd /tmp
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/patch/simkai.ttf
\cp /tmp/simkai.ttf /usr/share/zabbix/assets/fonts
sed -i "/ZBX_GRAPH_FONT_NAME/s/graphfont/simkai/" /usr/share/zabbix/include/defines.inc.php
sed -i "/ZBX_FONT_NAME/s/graphfont/simkai/" /usr/share/zabbix/include/defines.inc.php
  1. 解除打开文件数限制
cd /tmp
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/patch/limits.conf
\cp /tmp/limits.conf /etc/security/
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/patch/sysctl.conf
\cp /tmp/sysctl.conf /etc/sed -i -e "/^DefaultLimitCORE=/s/=.*/=infinity/" /etc/systemd/system.conf
sed -i -e "/^#DefaultLimitNOFILE=/s/=.*/=100000/" /etc/systemd/system.conf
sed -i -e "/^#DefaultLimitNPROC=/s/=.*/=100000/" /etc/systemd/system.conf
# sed -i -e "/^LimitNOFILE=/s/=.*/=655350/" /usr/lib/systemd/system/mariadb.servicesed -i -e "/^\#DefaultLimitNOFILE=/s/^#//" /etc/systemd/system.conf
sed -i -e "/^\#DefaultLimitNPROC=/s/^#//" /etc/systemd/system.confsed -i -e "/^#DefaultLimitCORE=/s/=.*/=infinity/" /etc/systemd/user.conf
sed -i -e "/^#DefaultLimitNOFILE=/s/=.*/=100000/" /etc/systemd/user.conf
sed -i -e "/^#DefaultLimitNPROC=/s/=.*/=100000/" /etc/systemd/user.confsed -i -e "/^\#DefaultLimitCORE=/s/^#//" /etc/systemd/user.conf
sed -i -e "/^\#DefaultLimitNOFILE=/s/^#//" /etc/systemd/user.conf
sed -i -e "/^\#DefaultLimitNPROC=/s/^#//" /etc/systemd/user.conf
  1. 优化zabbix_agent2.conf配置文件
sed -i -e "/^\# Timeout/s/=.*/=30/" /etc/zabbix/zabbix_agent2.conf
sed -i -e "/^Timeout/s/=.*/=30/" /etc/zabbix/zabbix_agent2.conf
sed -i -e "/^\# Timeout/s/^# //" /etc/zabbix/zabbix_agent2.conf
  1. 优化zabbix_server.conf配置文件
DPassword="123.com"
sed -i "/# DBHost=localhost/s/# DBHost=localhost/DBHost=localhost/" /etc/zabbix/zabbix_server.conf
sed -i "/# DBPassword=/s/# DBPassword=/DBPassword=$DPassword/" /etc/zabbix/zabbix_server.conf
sed -i "/# DBPort=/s/# DBPort=/DBPort=5432/" /etc/zabbix/zabbix_server.conf
sed -i "/# ListenIP=0.0.0.0/s/# ListenIP=0.0.0.0/ListenIP=0.0.0.0/" /etc/zabbix/zabbix_server.conf
sed -i "/# JavaGateway=/s/# JavaGateway=/JavaGateway=127.0.0.1/" /etc/zabbix/zabbix_server.conf
sed -i "/# JavaGatewayPort=10052/s/# JavaGatewayPort=10052/JavaGatewayPort=10052/" /etc/zabbix/zabbix_server.conf
sed -i "/# StartJavaPollers=0/s/# StartJavaPollers=0/StartJavaPollers=5/" /etc/zabbix/zabbix_server.confsed -i "/# SNMPTrapperFile=\/tmp\/zabbix_traps.tmp/s/# SNMPTrapperFile=\/tmp\/zabbix_traps.tmp/SNMPTrapperFile=\/tmp\/zabbix_traps.tmp/" /etc/zabbix/zabbix_server.conf
sed -i "/^SNMPTrapperFile=\/var\/log\/snmptrap\/snmptrap.log/s/SNMPTrapperFile=\/var\/log\/snmptrap\/snmptrap.log/# SNMPTrapperFile=\/var\/log\/snmptrap\/snmptrap.log/" /etc/zabbix/zabbix_server.conf
sed -i "/# AllowUnsupportedDBVersions=0/s/# AllowUnsupportedDBVersions=0/AllowUnsupportedDBVersions=1/" /etc/zabbix/zabbix_server.conf# sed -i "/date\.timezon/s/\; php_value\[date\.timezone\] = Europe\/Riga/php_value[date.timezone] = Asia\/Shanghai/" /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
# cp /usr/share/doc/zabbix-agent-*/userparameter_mysql.conf /etc/zabbix/zabbix_agentd.d/#[zabbix-server]
sed -i -e "/^\# DebugLevel/s/=.*/=1/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartPollers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartProxyPollers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartPreprocessors/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartSNMPTrapper/s/=.*/=1/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartPollersUnreachable/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartTrappers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartVMwareCollectors/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartPingers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartDiscoverers/s/=.*/=3/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartHTTPPollers/s/=.*/=3/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartTimers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartEscalators/s/=.*/=2/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartAlerters/s/=.*/=5/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# MaxHousekeeperDelete/s/=.*/=0/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# CacheSize/s/=.*/=2G/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartHistoryPollers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# HistoryCacheSize/s/=.*/=2G/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# HistoryIndexCacheSize/s/=.*/=2G/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# HousekeepingFrequency/s/=.*/=0/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# TrendCacheSize/s/=.*/=2G/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# TrendFunctionCacheSize/s/=.*/=512M/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# ValueCacheSize/s/=.*/=64G/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# VMwareCacheSize/s/=.*/=2G/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartIPMIPollers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartLLDProcessors/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# Timeout/s/=.*/=30/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# UnreachableDelay/s/=.*/=90/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# UnreachablePeriod/s/=.*/=270/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# UnavailableDelay/s/=.*/=360/" /etc/zabbix/zabbix_server.confsed -i -e "/^DebugLevel/s/=.*/=1/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartPollers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartProxyPollers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartPreprocessors/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartSNMPTrapper/s/=.*/=1/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartPollersUnreachable/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartTrappers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartVMwareCollectors/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartPingers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartDiscoverers/s/=.*/=3/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartHTTPPollers/s/=.*/=3/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartTimers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartEscalators/s/=.*/=2/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartAlerters/s/=.*/=5/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^MaxHousekeeperDelete/s/=.*/=0/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^CacheSize/s/=.*/=2G/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartHistoryPollers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^HistoryCacheSize/s/=.*/=2G/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^HistoryIndexCacheSize/s/=.*/=2G/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^HousekeepingFrequency/s/=.*/=0/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^TrendCacheSize/s/=.*/=2G/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^TrendFunctionCacheSize/s/=.*/=512M/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^ValueCacheSize/s/=.*/=64G/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^VMwareCacheSize/s/=.*/=2G/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartIPMIPollers/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^StartLLDProcessors/s/=.*/=100/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^Timeout/s/=.*/=30/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^UnreachableDelay/s/=.*/=90/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^UnreachablePeriod/s/=.*/=270/" /etc/zabbix/zabbix_server.conf
sed -i -e "/^UnavailableDelay/s/=.*/=360/" /etc/zabbix/zabbix_server.confsed -i -e "/^\# DebugLevel/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartPollers/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartProxyPollers/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartPreprocessors/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartSNMPTrapper/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartPollersUnreachable/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartTrappers/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartVMwareCollectors/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartPingers/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartDiscoverers/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartHTTPPollers/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartTimers/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartEscalators/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartAlerters/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# MaxHousekeeperDelete/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# CacheSize/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartHistoryPollers/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# HistoryCacheSize/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# HistoryIndexCacheSize/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# HousekeepingFrequency/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# TrendCacheSize/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# TrendFunctionCacheSize/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# ValueCacheSize/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# VMwareCacheSize/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartIPMIPollers/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# StartLLDProcessors/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# Timeout/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# UnreachableDelay/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# UnreachablePeriod/s/^# //" /etc/zabbix/zabbix_server.conf
sed -i -e "/^\# UnavailableDelay/s/^# //" /etc/zabbix/zabbix_server.conf
  1. 安装grafana zabbix图形界面
# wget -P /tmp/ https://mirrors.huaweicloud.com/grafana/10.2.3/grafana-enterprise-10.2.3-1.x86_64.rpm
cd /tmp/
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/grafana/grafana-enterprise-10.1.0-1.x86_64_00.rpm
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/grafana/grafana-enterprise-10.1.0-1.x86_64_01.rpm
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/grafana/grafana-enterprise-10.1.0-1.x86_64_02.rpm
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/grafana/grafana-enterprise-10.1.0-1.x86_64_03.rpm
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/grafana/grafana-enterprise-10.1.0-1.x86_64_04.rpm
cat ./grafana-enterprise-10.1.0-1.x86_64.rpm_0* > ./grafana-enterprise-10.1.0-1.x86_64.rpm
yum -y install /tmp/grafana-enterprise-10.1.0-1.x86_64.rpm
# wget -P /tmp/ https://github.com/grafana/grafana-zabbix/releases/download/v4.4.4/alexanderzobnin-zabbix-app-4.4.4.linux_amd64.zip
cd /tmp/
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/grafana/alexanderzobnin-zabbix-app-4.4.1.linux_amd64.zip
unzip -qo /tmp/alexanderzobnin-zabbix-app-*.zip -d /var/lib/grafana/plugins
chown grafana:grafana -R /var/lib/grafana/plugins/*
  1. 为grafana配置https访问
sed -i -e "/^;protocol =/s/=.*/= https/" /etc/grafana/grafana.ini
sed -i -e "/^;cert_file =/s/=.*/= \/etc\/grafana\/ssl\/server.pem/" /etc/grafana/grafana.ini
sed -i -e "/^;cert_key =/s/=.*/= \/etc\/grafana\/ssl\/server.pem/" /etc/grafana/grafana.inised -i -e "/^;protocol =/s/^;//" /etc/grafana/grafana.ini
sed -i -e "/^;cert_file =/s/^;//" /etc/grafana/grafana.ini
sed -i -e "/^;cert_key =/s/^;//" /etc/grafana/grafana.ini
mkdir -p /etc/grafana/ssl
cd /tmp/
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/patch/server.pem
\cp /tmp/server.pem /etc/grafana/ssl
  1. 配置日志服务rsyslog
cd /tmp/
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/patch/loki.conf
\cp /tmp/loki.conf /etc/rsyslog.d/
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/patch/loki
\cp /tmp/loki /etc/logrotate.d/loki
sed -i -e "/^\# module(load=\"imudp\")/s/^# //" /etc/rsyslog.conf
sed -i -e "/^\# input(type=\"imudp\"/s/^# //" /etc/rsyslog.conf
sed -i -e "/^\# module(load=\"imtcp\")/s/^# //" /etc/rsyslog.conf
sed -i -e "/^\# input(type=\"imtcp\"/s/^# //" /etc/rsyslog.conf
sed -i -e "/^\module(load=\"builtin:omfile\"/s/^\(.*\)$/# \1/" /etc/rsyslog.conf
systemctl restart rsyslog
  1. 安装grafana loki日志分析服务
cd /tmp/
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/grafana/loki-2.8.4.x86_64.rpm
yum -y install /tmp/loki-2.8.4.x86_64.rpm
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/grafana/promtail-2.8.4.x86_64.rpm
yum -y install /tmp/promtail-2.8.4.x86_64.rpm
mkdir -p /var/log/loki
chmod 755 /var/log/loki
cd /tmp/
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/patch/echo.sh
\cp /tmp/echo.sh /usr/lib/zabbix/alertscripts/
chmod +x /usr/lib/zabbix/alertscripts/echo.sh
chown zabbix:zabbix /usr/lib/zabbix/alertscripts/echo.sh
touch /var/log/loki/alert.log
chmod 666 /var/log/loki/alert.log
sed -i -e "/^\      __path__:/s/:.*/: \/var\/log\/loki\/\*log/" /etc/promtail/config.yml
  1. 为mysql分区
cd /tmp/
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/mysql/mysql.sh
curl -# -O https://gitcode.net/1284524409/zabbix/-/raw/rocky_8_zabbix_6.0.x_mysql/mysql/zbx_db_partitiong.sql
sh mysql.sh
  1. 配置开机启动服务
sysctl -p 
systemctl daemon-reload
systemctl daemon-reexec
chown root:zabbix /usr/sbin/fping
chmod 755 /usr/sbin/fping
chmod +s /usr/sbin/fping
systemctl start zabbix-agent2
systemctl enable zabbix-agent2
systemctl start zabbix-java-gateway
systemctl enable zabbix-java-gateway
systemctl start zabbix-proxy
systemctl enable zabbix-proxy
systemctl start php-fpm
systemctl enable php-fpm
systemctl start nginx
systemctl enable nginx
systemctl enable mariadb
systemctl restart mariadb
systemctl daemon-reload
systemctl restart grafana-server
systemctl enable grafana-server.service
systemctl restart loki
systemctl enable loki.service
systemctl restart promtail
systemctl enable promtail.service
systemctl start snmptrapd
systemctl enable snmptrapd
systemctl start snmpd
systemctl enable snmpd
systemctl start zabbix-server
systemctl enable zabbix-server
netstat -nltp | grep '10050\|10051\|10052\|3306\|80\|3000'

打开网页输入服务器IP地址访问zabbix
http://IP:8080 或 https://IP:8443
用户名: Admin
密码: zabbix

打开网页输入服务器IP地址访问grafana
https://IP:3000
用户名: admin
密码: admin

将grafana界面设置成中文

**启用zabbix插件

连接zabbix数据库插件

新建zabbix数据库连接
https://zabbix-web-nginx-mysql:8443/api_jsonrpc.php

输入正确的用户名密码
Admin/zabbix

zabbix-server服务器同时优化成了rsyslog日志服务器,rsyslog日志端口为514
日志存储路径为 /var/log/loki/

grafana优化集成了zabbix与Loki插件
请将任意.log后缀日志存入 /var/log/loki/即可连接到loki
URL为http://IP:3100
在这里插入图片描述

感谢打赏

微信支付宝
微信打赏微信打赏

全文完结

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/317893.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Java 语言概述

Java 概述 是 SUN&#xff08;Stanford University Network&#xff0c;斯坦福大学网络公司&#xff09;1995年推出的一门高级编程语言 是一种面向 Internet 的编程语言。Java 一开始富有吸引力是因为 Java 程序可以在 Web 浏览器中运行。这些 Java 程序被称为 Java 小程序&am…

知识付费平台搭建?找明理信息科技,专业且高效

明理信息科技知识付费saas租户平台 在当今数字化时代&#xff0c;知识付费已经成为一种趋势&#xff0c;越来越多的人愿意为有价值的知识付费。然而&#xff0c;公共知识付费平台虽然内容丰富&#xff0c;但难以满足个人或企业个性化的需求和品牌打造。同时&#xff0c;开发和…

Stable Diffusion模型概述

Stable Diffusion 1. Stable Diffusion能做什么&#xff1f;2. 扩散模型2.1 正向扩散2.2 反向扩散 3. 训练如何进行3.1 反向扩散3.2 Stable Diffusion模型3.3 潜在扩散模型3.4 变分自动编码器3.5 图像分辨率3.6 图像放大 4. 为什么潜在空间是可能的&#xff1f;4.1 在潜在空间中…

HTTP限流控制:Go语言中的精细把关

开场白&#xff1a;在Web应用中&#xff0c;流量控制是一个关键的防护措施&#xff0c;用于防止资源过度消耗和潜在的安全威胁。特别是在面对DDoS攻击或异常请求时&#xff0c;限流显得尤为重要。今天&#xff0c;我们将探讨如何在Go语言中实现HTTP的限流控制。 知识点一&…

【网络技术】【Kali Linux】Wireshark嗅探(五)文件传输协议(FTP)

一、实验目的 本次实验使用Wireshark流量分析工具进行网络嗅探&#xff0c;旨在了解文件传输协议&#xff08;FTP&#xff09;的工作原理。 二、FTP协议概述 文件传输协议&#xff08;File Transfer Protocol&#xff09;是互联网上使用得最广泛的文件传输协议&#xff0c;用…

ArduPilot开源代码之MatekSys Optical Flow 3901-L0X

ArduPilot开源代码之MatekSys Optical Flow 3901-L0X 1. 源由2. 安装3. 参数配置3.1 配置光流定位3.2 配置激光测距3.3 辅助配置 4. 测试4.1 光流数据测试4.2 测距数据测试4.3 室内飞行注意事项4.4 实际飞行测试 5. 参考资料 1. 源由 之前介绍过MatekSys Optical Flow 3901-L0…

Python open函数详解:打开指定文件与 readline和readlines函数:按行读取文件

Python open函数详解&#xff1a;打开指定文件 掌握了各种操作目录字符串或目录的函数之后&#xff0c;接下来可以准备读写文件了。在进行文件读写之前&#xff0c;首先要打开文件。 Python 提供了一个内置的 open() 函数&#xff0c;该函数用于打开指定文件。 open() 函数的…

STM32 学习(三)OLED 调试工具

目录 一、简介 二、使用方法 2.1 接线图 2.2 配置引脚 2.3 编写代码 三、Keil 工具调试 一、简介 在进行单片机开发时&#xff0c;有很多调试方法&#xff0c;如下图&#xff1a; 其中 OLED 就是一种比较好用的调试工具&#xff1a; OLED 硬件电路如下&#xff0c…

魔改Stable Diffusion,开源创新“单目深度估计”模型

单目深度估计一直是计算机视觉领域的难点。仅凭一张 RGB 图像,想要还原出场景的三维结构,在几何结构上非常不确定,必须依赖复杂的场景理解能力。 即便使用更强大的深度学习模型来实现&#xff0c;也面临算力需求高、图像数据注释量大、泛化能力弱等缺点。 为了解决这些难题&a…

OEE如何为制造企业实施ISO50001提供支持

ISO50001是一项旨在帮助企业建立和实施能源管理体系的国际标准&#xff0c;以提高能源效率、降低能源消耗和减少环境影响。而设备OEE&#xff08;设备综合效率&#xff09;作为一个关键的生产效率指标&#xff0c;可以为企业实施ISO50001提供重要的支持。本文将介绍ISO50001能源…

【LeetCode-剑指offer】-- 9.乘积小于K的子数组

9.乘积小于K的子数组 方法&#xff1a;滑动窗口 关于为什么子数组数目为j-11。这时候就要理解采用滑动窗口的思路其实是枚举子数组的右端点&#xff0c;然后来找到满足条件的最小左端点。也即当得到满足条件的窗口时&#xff0c;就意味着得到了以 j 作为右端点时满足条件的左端…

精彩回顾 I DatenLord Hackathon 2023圆满结束!

DatenLord Hackathon 2023已经顺利完赛。达坦科技基于其跨云分布式文件系统DatenLord项目&#xff0c;结合AI大模型时代背景&#xff0c;搭建了擂台。我们邀请参赛者为DatenLord的极端场景设计并实现缓存 p2p 传输和同步模块。 本届赛题为“Explore the Possibilities”&#…