Zabbix 系统到底应该怎样优化?

2021-05-19  本文已影响0人  SRE运维博客

本文链接
https://cnsre.cn/posts/210303161655

Zabbix架构

在讲Zabbix优化之前,先来看看Zabbix Server 的逻辑架构图:


SRE运维博客|Linux系统运维|自动化运维|云计算|运维监控

对于上图中,架构组件的描述:

Zabbix进程

Zabbix Poller

优化内容

优化Zabbix架构

常用的架构:
说明:Zabbix最简单的架构,常用于监控主机比较少的情况下。

SRE运维博客|Linux系统运维|自动化运维|云计算|运维监控
分布式架构:
Server-Proxy-Agentd模式。
说明:Zabbix分布式架构,常用于监控主机比较多的情况下,使用Zabbix Proxy进行分布式监控,有效的减轻了Zabbix Server端的压力。
SRE运维博客|Linux系统运维|自动化运维|云计算|运维监控

Zabbix Server/Zabbix Proxy配置优化

调整配置文件:Zabbix_Server.conf
Zabbix进程参数调整:

StartPollers=80
StartPingers=10
StartPollersUnreachable=80
StartIPMIPollers=10
StartTrappers=20
StartDBSyncers=8

值得注意的是,当Zabbix的Pollers数量过多时(超过limit默认值1024),需要对系统的limit的参数大小进行修改。

shell> vi /etc/security/limit.conf
*   hard    nofile  65536
*   soft    nofile  65536
*   hard    nproc   65536
*   soft    nproc   65536

Zabbix In-Memory Cache参数优化(以下值仅做参考):

ValueCacheSize=256M
HistoryIndexCacheSize = 64M
TrendCacheSize=64M
HistoryCacheSize=128M
CacheSize=128M
VMwareCacheSize=64M

优化Zabbix的数据库(MySQL)

调整MySQL配置文件:my.cnf或my.ini,在[mysqld]酌情修改参数:

[client]
port = 3306
socket = /var/lib/mysql/mysql.sock

[mysql]
prompt="\u@mysqldb \R:\m:\s [\d]> "
no-auto-rehash

[mysqld]
user= mysql
port = 3306
datadir = /data/mysql/
socket = /var/lib/mysql/mysql.sock 
pid-file = mysqldb.pid
character-set-server = utf8mb4
skip_name_resolve = 1

# Timestamp
explicit_defaults_for_timestamp = 1

# Connections
back_log = 1024
max_connections = 512
max_connect_errors = 5120
innodb_thread_concurrency = 16

# Limit 
open_files_limit = 65535
innodb_open_files = 65535

# Query Cache
query_cache_type = 0
query_cache_size = 0

# binary logs
server-id = 3306001
binlog_format = row
log-bin = /data/mysql/mysql-binlog
expire_logs_days = 7
sync_binlog = 1
max_binlog_size = 1G
binlog_cache_size = 4m
max_binlog_cache_size = 1G

# slow query 
slow_query_log = 1
long_query_time = 2
slow_query_log_file = /data/mysql/slow.log

# Timeout
interactive_timeout = 600
wait_timeout = 600

# Engine
default-storage-engine = innodb

# Buffer
key_buffer_size = 32M
read_buffer_size = 1M
sort_buffer_size = 1M
read_rnd_buffer_size = 1M
tmp_table_size = 32M

join_buffer_size = 16M
max_heap_table_size = 32M
max_tmp_tables = 48
thread_cache_size = 32


# Time
log_timestamps = SYSTEM

# Tablespace & File I/O
innodb_data_file_path = ibdata1:1G:autoextend
innodb_file_per_table = 1

# Redo Log
innodb_flush_log_at_trx_commit = 1
innodb_log_file_size = 256M
innodb_log_files_in_group = 2
innodb_log_buffer_size = 16M

# Innodb
innodb_buffer_pool_size = 8G
innodb_buffer_pool_instances = 8 
innodb_flush_method = O_DIRECT
innodb_change_buffer_max_size = 50
innodb_max_dirty_pages_pct = 30
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_io_capacity = 500
innodb_io_capacity_max= 1000
innodb_support_xa = 0
innodb_rollback_on_timeout = 1

优化Zabbix监控项

优化监控项的数据采集方式,由被动方式改为主动模式(Passive mode -> Active mode),主动模式的优势:

上一篇 下一篇

猜你喜欢

热点阅读