Loading

搭建Zabbix监控

一、关闭防火墙和selinux

setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld

二、使用yum安装LAMP环境

yum -y install mariadb mariadb-server httpd php php-mysql 
# 启动并设置开机自启
systemctl enable httpd
systemctl enable mariadb
systemctl start httpd
systemctl start mariadb
# 初始化数据库
mysql_secure_installation

三、安装zabbix

1.安装Zabbix仓库
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
yum clean all
2.安装Zabbix服务器,前端,代理
第一种方法:yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
第二种方法:
	wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.9-3.el7.x86_64.rpm
	wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-get-4.0.9-3.el7.x86_64.rpm
	wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-server-mysql-4.0.9-3.el7.x86_64.rpm
	wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-web-4.0.9-3.el7.noarch.rpm
	wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-web-mysql-4.0.9-3.el7.noarch.rpm
	yum install -y zabbix*
3.创建初始数据库
mysql -uroot -p
	mysql> create database zabbix character set utf8 collate utf8_bin;
	mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
	mysql> quit;
4.在Zabbix服务器主机上,导入初始架构和数据。
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix # 密码为上面设定的password
5.为Zabbix服务器配置数据库
vim /etc/zabbix/zabbix_server.conf
	DBPassword=password # 修改配置文件中的数据库密码
6.为Zabbix前端配置PHP
vim /etc/httpd/conf.d/zabbix.conf
	# 取消注释并为您设置正确的时区。
	php_value date.timezone Asia/Shanghai
7.启动Zabbix服务器和代理进程
systemctl restart zabbix-server zabbix-agent httpd
systemctl enable zabbix-server zabbix-agent httpd
8.配置Zabbix前端
连接到新安装的Zabbix前端:http://server_ip/zabbix
确认环境后登录:默认用户Admin,密码zabbix
posted @ 2020-03-27 18:51  luoxian  阅读(18)  评论(0编辑  收藏  举报