centos8安装zabbix监控系统

行云流水
2022-04-06 / 1 评论 / 591 阅读 / 正在检测是否收录...

前言

centos8 基本管理命令

网卡管理

nmcli    #显示网卡信息
nmcli connection show
nmcli connection show ens33
nmcli connection show --active
nmcli connection reload
systemctl restart network.

nmtui. #通过界面配置网络

关闭安全模式

vi /etc/selinux/config
setenforce 0

安装

zabbix

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

安装数据库

安装

dnf -y install mariadb-server
systemctl enable --now mariadb

创建表

mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;

数据库授权

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;

导入数据

zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | mysql -uzabbix -p zabbix

配置

优化zabbix_server配置

vi /etc/zabbix/zabbix_server.conf

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配置

vi /etc/nginx/conf.d/zabbix.conf

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

vi /etc/zabbix/zabbix_agentd.conf

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

启动

systemctl enable --now zabbix-server zabbix-agent nginx php-fpm

访问

http://myzabbix.com

FAQ

修改zabbix字体

cd /usr/share/zabbix/assets/fonts
mv graphfont.ttf graphfont.ttf.bak
mv MSYH.TTC graphfont.ttf

centos8 软件源

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

评论 (1)

取消
只有登录/注册用户才可评论
  1. 头像
    zx
    · Windows 10 · Google Chrome
    沙发

    看看

    回复