centos7下安装zabbix
(1)环境
[root@localhost ~]# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
[zabbix@localhost ~]$ id
uid=1000(zabbix) gid=1000(zabbix) 组=1000(zabbix) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
(2)安装
(2.1)安装源码库配置部署包。这个部署包包含了yum配置文件。
# sudo rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
获取http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64//zabbix-release-3.2-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.xvLHq6: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:zabbix-release-3.2-1.el7 ################################# [100%]
(2.2)安装Zabbix部署包
安装Zabbix部署包。这里使用Mysql数据库安装Zabbix server、WEB前端。
# yum install zabbix-server-mysql zabbix-web-mysql
安装Zabbix Agent的示例.
# yum install zabbix-agent
(2.3)安装初始化数据库
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server
安装成功后重启mysql服务。
# service mysqld restart
设置开机启动
# sudo systemctl enable mysqld
启动服务
# systemctl start mysqld
设置初始密码:
# /usr/bin/mysqladmin -u root password 'root'
进入mysql:
#mysql -uroot -proot
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
(2.4)进入到这个目录
[zabbix@linuxidc zabbix-server-mysql-3.0.1]$ pwd
/usr/share/doc/zabbix-server-mysql-3.0.1
[zabbix@linuxidc zabbix-server-mysql-3.0.1]$ ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
运行命令
[zabbix@linuxidc zabbix-server-mysql-3.0.1]$ # zcat create.sql.gz | mysql -uroot -p zabbix
(3)启动zabbix server服务
(3.0)修改配置文件:
[zabbix@linuxidc ~]$ vim /etc/zabbix/zabbix_server.conf
DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix
(3.1)启动zabbix服务,设置开机自启动,报错
[root@localhost zabbix]# sudo systemctl start zabbix-server
Job for zabbix-server.service failed because a configured resource limit was exceeded. See "systemctl status zabbix-server.service" aournalctl -xe" for details.
查看selinux
[root@localhost zabbix]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
(3.2)禁用selinux
[root@localhost zabbix]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@localhost zabbix]# reboot
再次查看selinux状态
[root@localhost ~]# sestatus
SELinux status: disabled
(3.3)再次启动zabbix服务,设置开机自启动
[root@localhost ~]# systemctl start zabbix-server
[root@localhost ~]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
(4)编辑zabbix前端的PHP配置
(4.1)修改时间设置,默认欧洲时间,改为上海时间
# sudo vim /etc/httpd/conf.d/zabbix.conf
<IfModule mod_php5.c>
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 always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
php_value date.timezone Asia/Shanghai
</IfModule>
(4.2)启动apache服务,设置开机自启动
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@localhost ~]#
(4.3)登陆zabbix web配置界面,发现在Server上可以打开,在其他电脑上打不开,关闭防火墙
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
(5)配置web界面
[root@localhost ~]# vim /etc/httpd/conf.d/zabbix.conf
# php_value date.timezone Asia/Shanghai
[root@localhost ~]# systemctl restart zabbix-server
[root@localhost ~]# systemctl restart httpd
登陆到zabbix web监控界面
zabbix web默认用户名及密码:Admin/zabbix
(6)添加主机
[root@localhost ~]# systemctl start zabbix-agent
【完】
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?