我们当前部署Zabbix是在Centos7的基础上部署Zabbix4.4版本
我的服务器配置是双路四核CPU +8GBRAM
以下安装步骤仅供参考,大家也可以参考官方资料:https://www.zabbix.com/documentation/4.4/manual/installation/getting_zabbix
1、操作系统安装这里
就不叙述了,以最小化安装
配置网易YUM源
2、操作系统优化设置
[root@houyuxi ~]# sudo yum -y update
[root@houyuxi ~]# sudo sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
[root@houyuxi ~]# sudo systemctl stop firewalld.service && systemctl disable firewalld.service
[root@houyuxi ~]# reboot
1、安装Zabbix基本组件
[root@houyuxi ~]# sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
1、安装MySQL数据库
[root@houyuxi ~]# sudo yum install mysql-* --skip-broken 有冲突的软件跳过
2、安装Apache Web服务
[root@houyuxi ~]# sudo yum -y install httpd
[root@houyuxi ~]# systemctl start httpd.service #启动
[root@houyuxi ~]# systemctl stop httpd.service #停止
[root@houyuxi ~]# systemctl restart httpd.service #重启
[root@houyuxi ~]# systemctl enable httpd.service #开机启动
[root@houyuxi ~]# systemctl disable httpd.service #开机不启动
3、安装PHP
[root@houyuxi ~]# sudo yum install php
4、安装php扩展
[root@houyuxi ~]# sudo yum install php-mysqlnd php-gd libjpeg* php-snmp php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash php-common php-ctype php-xml php-xmlreader php-xmlwriter php-session php-mbstring php-gettext php-ldap php-mysqli --skip-broken
[root@houyuxi ~]# sudo yum install wget telnet net-tools python-paramiko gcc gcc-c++ dejavu-sans-fonts python-setuptools python-devel sendmail mailx net-snmp net-snmp-devel net-snmp-utils freetype-devel libpng-devel perl unbound libtasn1-devel p11-kit-devel OpenIPMI unixODBC
5、设置 MySQL 参数(以8GB为例)
[root@houyuxi ~]# sudo vim /etc/my.cnf
在文件最后添加以下内容并保存:
innodb_file_per_table = 1
innodb_status_file = 1
innodb_buffer_pool_size = 6G
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 64M
innodb_support_xa = 0
default-storage-engine = innodb
bulk_insert_buffer_size = 8M
join_buffer_size = 16M
max_heap_table_size = 32M
tmp_table_size = 32M
max_tmp_tables = 48
read_buffer_size = 32M
read_rnd_buffer_size = 16M
key_buffer_size = 32M
thread_cache_size = 32
innodb_thread_concurrency = 8
innodb_flush_method = O_DIRECT
innodb_rollback_on_timeout = 1
query_cache_size = 16M
query_cache_limit = 16M
collation_server = utf8_bin
character_set_server = utf8
注:原则上 innodb_buffer_pool_size 需要设置为主机内存的 80%,如果主机内存不是 8GB,以上参数可依据相应比例进行调整,例如主机内存为 16GB,则 innodb_buffer_pool_size 建议设置为 12GB,innodb_log_buffer_size 建议设置为 32M,innodb_log_file_size 建议设置为 128M,以此类推。请注意innodb_buffer_pool_size的值必须是整数,例如主机内存是4G,那么innodb_buffer_pool_size可以设置为3G,而不能设置为3.2G
6、启动 MySQL
[root@houyuxi ~]# sudo systemctl enable mysqld && systemctl start mysqld
7、获取MySQL数据库root初始密码
[root@houyuxi ~]# grep 'temporary password' /var/log/mysqld.log
8、进行 MySQL 安全配置
配置开始时会用到上面获取的初始密码,建议修改为自定义密码,其它选项选择 y 即可
mysql_secure_installation
9、重启MySQL
sudo systemctl restart mysqld
10、配置 MySQL 中 Zabbix要的库和账号权限
[root@houyuxi ~]# mysql -u root -p(需要输入第8步中设置的自定义密码)
mysql> create database zabbix character set utf8 collate utf8_bin; #创建数据库
mysql>grant all privileges on zabbix.* to zabbix@localhost identified by 'password'; #创建用户和密码
mysql>exit;
2、安装Zabbix
[root@houyuxi ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
[root@houyuxi ~]# yum clean all
安装zabbix服务器、代理、前端
[root@houyuxi ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent
[root@houyuxi ~]# cd /usr/share/doc/zabbix-server-mysql-4.4.0
[root@houyuxi ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
[root@houyuxi ~]# sudo vim /etc/zabbix/zabbix_server.conf 这个配置要一遍过
主要是以下几个选项参数需要设置(8GB 内存为例):
DBPassword 配置为mysql设置的自定义密码
CacheSize=512M
(CacheSize在411行)
HistoryCacheSize=128M
(HistoryCacheSize在436行)
HistoryIndexCacheSize=128M
(HistoryIndexCacheSize在445行)
TrendCacheSize=128M
(TrendCacheSize在454行)
ValueCacheSize=256M
(ValueCacheSize在464行)
Timeout=30
(Timeout在474)
其它参数保持默认值即可
如果需要监控VMware虚拟机,则还需要设置以下选项参数
StartVMwareCollectors=2
(StartVMwareCollectors在313行
VMwareCacheSize=256M
(VMwareCacheSize 在341行)
VMwareTimeout=349行)
[root@houyuxi ~]# sudo vim /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 600
php_value memory_limit 256M
php_value post_max_size 32M
php_value upload_max_filesize 32M
php_value max_input_time 600
php_value always_populate_raw_post_data -1
date.timezone 去掉注释符号#,并将值修改为 Asia/Shanghai
[root@houyuxi ~]# systemctl stop mysqld && reboot
[root@houyuxi ~]# systemctl restart zabbix-server zabbix-agent httpd
[root@houyuxi ~]# systemctl enable zabbix-server zabbix-agent httpd
第一次登录Zabbix监控系统,需要进行设置,配置DB连接部分密码为上面设置的MySQL数据库密码,默认用户名Admin,默认密码 zabbix,确认可正常登录系统