centos8安装zabbix监控系统

2022-04-08 18:30:25 浏览数 (1)

前言

CentOS Linux release 8.3.2011 zambix 5.4 MariaDB 10.3.28 nginx 1.14.1 php-fpm 7.2.24

centos8 基本管理命令

网卡管理

代码语言:javascript复制
nmcli    #显示网卡信息
nmcli connection show
nmcli connection show ens33
nmcli connection show --active
nmcli connection reload
systemctl restart network.

nmtui. #通过界面配置网络

关闭安全模式

代码语言:javascript复制
vi /etc/selinux/config
setenforce 0

安装

zabbix

代码语言:javascript复制
rpm -Uvh https://repo.zabbix.com/zabbix/5.4/rhel/8/x86_64/zabbix-release-5.4-1.el8.noarch.rpm
dnf clean all
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent

安装数据库

安装

代码语言:javascript复制
dnf -y install mariadb-server
systemctl enable --now mariadb

创建表

代码语言:javascript复制
mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;

数据库授权

代码语言:javascript复制
create user zabbix@localhost identified by 'zabbix@123';
grant all privileges on zabbix.* to zabbix@localhost;

#针对docker
create user zabbix@172.17.0.2 identified by 'zabbix@123';
grant all privileges on zabbix.* to zabbix@172.17.0.2;

导入数据

代码语言:javascript复制
zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | mysql -uzabbix -p zabbix

配置

优化zabbix_server配置

代码语言:javascript复制
vi /etc/zabbix/zabbix_server.conf
代码语言:javascript复制
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix@123
StartPollers=30
StartPollersUnreachable=20
StartTrappers=15
StartPingers=4
StartDiscoverers=5
MaxHousekeeperDelete=5000
CacheSize=1024M
CacheUpdateFrequency=180
StartDBSyncers=8
HistoryCacheSize=1024M
HistoryIndexCacheSize=64M
TrendCacheSize=512M
ValueCacheSize=512M
Timeout=25
AlertScriptsPath=/usr/lib/zabbix/alertscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1

nginx配置

代码语言:javascript复制
vi /etc/nginx/conf.d/zabbix.conf
代码语言:javascript复制
server {
        listen          80;
        server_name     myzabbix.com; #换成自己的域名

        root    /usr/share/zabbix;

        index   index.php;

        location = /favicon.ico {
                log_not_found   off;
        }

        location / {
                try_files       $uri $uri/ =404;
        }

        location /assets {
                access_log      off;
                expires         10d;
        }

        location ~ /.ht {
                deny            all;
        }

        location ~ /(api/|conf[^.]|include|locale|vendor) {
                deny            all;
                return          404;
        }

        location ~ [^/].php(/|$) {
                fastcgi_pass    unix:/run/php-fpm/zabbix.sock;
                fastcgi_split_path_info ^(. .php)(/. )$;
                fastcgi_index   index.php;

                fastcgi_param   DOCUMENT_ROOT   /usr/share/zabbix;
                fastcgi_param   SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;
                fastcgi_param   PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name;

                include fastcgi_params;
                fastcgi_param   QUERY_STRING    $query_string;
                fastcgi_param   REQUEST_METHOD  $request_method;
                fastcgi_param   CONTENT_TYPE    $content_type;
                fastcgi_param   CONTENT_LENGTH  $content_length;

                fastcgi_intercept_errors        on;
                fastcgi_ignore_client_abort     off;
                fastcgi_connect_timeout         60;
                fastcgi_send_timeout            180;
                fastcgi_read_timeout            180;
                fastcgi_buffer_size             128k;
                fastcgi_buffers                 4 256k;
                fastcgi_busy_buffers_size       256k;
                fastcgi_temp_file_write_size    256k;
        }
}

zabbix-agent

代码语言:javascript复制
vi /etc/zabbix/zabbix_agentd.conf
代码语言:javascript复制
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
Timeout=25
Include=/etc/zabbix/zabbix_agentd.d/*.conf
UnsafeUserParameters=1

启动

代码语言:javascript复制
systemctl enable --now zabbix-server zabbix-agent nginx php-fpm

访问

http://myzabbix.com

默认用户:Admin 默认密码:zabbix

FAQ

修改zabbix字体

代码语言:javascript复制
cd /usr/share/zabbix/assets/fonts
mv graphfont.ttf graphfont.ttf.bak
mv MSYH.TTC graphfont.ttf

centos8 软件源

代码语言:javascript复制
wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

本文共 92 个字数,平均阅读时长 ≈ 1分钟

0 人点赞