CentOS 7 搭建zabbix分布式监控系统
-
zabbix平台搭建
关闭防火墙和selinux sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config systemctl disable --now firewalld #查看firewall服务状态 systemctl status firewalld
-
安装zabbix rpm源(这里用官方源)
#zabbix官方源 rpm -Uvh https://repo.zabbix.com/zabbix/5.5/rhel/8/x86_64/zabbix-release-5.5-1.el8.noarch.rpm #安装软件包及相关依赖 dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent -y
-
安装数据库,启动数据库,并开机自启
yum install mariadb-server -y #启动数据库 systemctl enable --now mariadb #配置开机自动启动 mysql_secure_installation #初始化 mariadb 并配置 root 密码
-
创建原始数据库
mysql -uroot -p
- 数据库设置
#查看默认数据库 mysql> show databases;
#创建zabbix数据库 mysql> create database zabbix character set utf8 collate utf8_bin;
#创建zabbix用户并设置密码,这里是设置为password,自己手动更改即可 mysql> create user zabbix@localhost identified by 'password';
#分配zabbix用户权限 mysql> grant all privileges on zabbix.* to zabbix@localhost;
#刷新,然后退出 mysql>flush privileges; mysql> quit;
- 经过以上设置,zabbix数据库用户为zabbix,密码为password(如果有更改则是你自己设置的那个密码)
-
#导入zabbix数据库信息 zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix
-
为Zabbix server配置数据库
vi /etc/zabbix/zabbix_server.conf 进入zabbix_server.conf文件后,找到DBPassword DBUser=zabbix ### Option: DBPassword # Database password. # Comment this line if no password is used. # # Mandatory: no # Default: DBPassword=yankai ----这里设置密码 记得把前面那个#号给去掉
-
为Zabbix前端配置PHP文件里的时区
vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf [zabbix] user = apache group = apache listen = /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock listen.acl_users = apache listen.allowed_clients = 127.0.0.1 pm = dynamic pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35 php_value[session.save_handler] = files php_value[session.save_path] = /var/opt/rh/rh-php72/lib/php/session/ php_value[max_execution_time] = 300 php_value[memory_limit] = 128M php_value[post_max_size] = 16M php_value[upload_max_filesize] = 2M php_value[max_input_time] = 300 php_value[max_input_vars] = 10000 ; php_value[date.timezone] = Europe/Riga php_value[date.timezone] = Asia/Shanghai ----再后面加上一行设置时区
-
最后一步,启动相关服务,并配置开机自动启动
systemctl restart zabbix-server zabbix-agent httpd php-fpm systemctl enable zabbix-server zabbix-agent httpd php-fpm
-
配置zabbix网页
#打开浏览器输入http://IP/zabbix 用户名Admin,密码zabbix
-
最后因为实际需要 开启防火墙
#开启防火墙 systemctl start firewalld #放行端口 firewall-cmd --permanent --add-port=80/tcp firewall-cmd --permanent --add-port=10050/tcp firewall-cmd --permanent --add-port=10051/tcp #重新加载配置 firewall-cmd --reload