CentOS7部署Zabbix5.0
部署环境
- CentOS 7.9
- Zabbix5.0.23
- CPU*4,内存8G
关闭防火墙和selinux
bashsystemctl stop firewalld
systemctl disable firewalld
setenforce 0
安装yum源
rpm -Uvh [https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm](https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm)
yum clean all
安装zabbix server和agent
yum install -y zabbix-server-mysql zabbix-agent
安装zabbix frontend
yum install -y centos-release-scl
编辑配置文件
vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
…
enabled=1
…
安装 Zabbix frontend packages
yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl
安装数据库
yum -y install mariadb mariadb-server #安装
systemctl start mariadb #启动
systemctl enable mariadb #开启开机自启动
mysqladmin -u root password '新密码' #初始化密码
创建zabbix用户
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by '设置密码';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
在zabbix服务器主机上导入初始模式和数据
root@localhost yum.repos.d]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: #输入新创建密码
配置zabbix
链接数据库
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost #数据库服务器IP地址
DBName=zabbix #库名
DBUser=zabbix #数据库用户名
DBPassword=123456 #数据库用户密码
修改时区
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
; php_value[date.timezone] = Europe/Riga
修改为
php_value[date.timezone] = Asia/Shanghai
启动zabbix服务和代理进程
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm #重启服务
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm #开机自启动
访问
[http://IP/zabbix](http://ip/zabbix)
web页面配置
默认账密(default username and password)
Admin
zabbix
中文乱码解决
找到字体文件夹
[root@localhost ~]# find / -name fonts
/boot/grub2/fonts
/etc/fonts
/usr/share/fonts
/usr/share/zabbix/assets/fonts
/usr/share/httpd/noindex/css/fonts
将字体上传到/usr/share/zabbix/assets/fonts
修改zabbix文件调用新字体
find / -name defines.inc.php
/usr/share/zabbix/include/defines.inc.php
vim /usr/share/zabbix/include/defines.inc.php
# 修改如下变量
define('ZBX_GRAPH_FONT_NAME', 'simkai');
define('ZBX_FONT_NAME', 'simkai');
zabbix_server.conf参数调整
各种故障对应的参数
Zabbix busy trapper processes, in % StartTrappshellers=5
Zabbix busy poller processes, in % StartPollers=5
Zabbix busy ipmi poller processes, in StartIPMIPollers=0
Zabbix busy discoverer processes, in StartDiscoverers=1
Zabbix busy icmp pinger processes, in StartPingers=1
Zabbix busy http poller processes, in StartHTTPPollers=1
Zabbix busy proxy poller processes, in StartProxyPollers=1
Zabbix busy unreachable poller processes, in % StartPollersUnreachable=1
Zabbix busy java poller processes, in StartJavaPollers=0
Zabbix busy snmp trapper processes, in % StartSNMPTrapper=0
Zabbix busy vmware collector processes, in % StartVMwareCollectors=0
常见的参数调整
根据实际情况进行调整
StartPollers=500
StartPollersUnreachable=50
StartTrappers=30
StartDiscoverers=6
CacheSize=1G
CacheUpdateFrequency=300
StartDBSyncers=20
HistoryCacheSize=512M
TrendCacheSize=256M
HistoryTextCacheSize=80M
ValueCacheSize=1G
其他调整
修改数据库最大连接数
zabbix_server.log错误日志提示:
[Z3001] connection to database 'zabbix' failed: [1040] Too many connections
进入数据库
show variables like 'max_connections'; # (查可以看当前的最大连接数)
set global max_connections=1000; # (设置最大连接数为1000,可以再次查看是否设置成功)
exit # (退出)
如果不够,修改my.ini文件
增加或修改 max_connections=(根据需要填写连接数)
保存退出后,重启mysql的服务
重启Zabbix-server,系统启动正常