【监控】zabbix


前言

本博客内容仅为记录博主思路,仅供参考,一切以自己实践结果为准。


一、搭建

1.1 直接上步骤

#zabbix服务端
systemctl disable --now firewalld
setenforce 0
hostnamectl set-hostname zbx-server
su

rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

cd /etc/yum.repos.d
sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' zabbix.repo

yum clean all && yum makecache
yum install -y zabbix-server-mysql zabbix-agent
yum install -y centos-release-scl

vim zabbix.repo
	11行:enable=1

yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl

#安装mariadb数据库并设置开机自启
yum install -y mariadb-server mariadb
systemctl enable --now mariadb

#配置数据库密码
mysql_secure_installation
	回车
	y
	设置数据库密码
	确认密码
	一路回车到最后

#进入数据库为zabbix授权
mysql -u root -pabc123
	CREATE DATABASE zabbix character set utf8 collate utf8_bin;
	GRANT all ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY 'zabbix';
	flush privileges;

#查询数据库sql文件的位置,是个.gz结尾的压缩包
rpm -ql zabbix-server-mysql
	#我的版本号是下面这个
	/usr/share/doc/zabbix-server-mysql-5.0.24/create.sql.gz

#用zcat查询压缩包内容,并传参给数据库进行导入
zcat //usr/share/doc/zabbix-server-mysql-5.0.24/create.sql.gz | mysql -uroot -pabc123 zabbix

vim /etc/zabbix/zabbix_server.conf
	124行:DBPassword=zabbix
	
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
	php_value[date.timezone] = Asia/Shanghai

systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

浏览器访问:192.168.13.10/zabbix
	只需要设置数据库的密码 zabbix
	登陆账号:Admin 密码:zabbix

页面配置:
	左下方:user settings
	选项:language -> Chinese -> update(语言修改为中文)


#当客户端配置完毕后,可执行以下命令验证客户端时候启动成功,查询客户端名称
yum install -y zabbix-get
zabbix_get -s '192.168.13.20' -p 10050 -k 'agent.ping'
zabbix_get -s '192.168.13.20' -p 10050 -k 'system.hostname'

#zabbix客户端配置
systemctl disable --now firewalld
setenforce 0
hostnamectl set-hostname zbx-agent01
su

yum install -y ntpdate
ntpdate -u ntp.aliyun.com

cp -p /etc/localtime{
    
    ,.bak}
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
cd /etc/yum.repos.d
sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo

yum install -y zabbix-agent2

vim /etc/zabbix/zabbix_agent2.conf
	80行:Server=192.168.13.10
	120行:ServerActive=192.168.13.10
	131行:Hostname=zbx-agent01

systemctl start zabbix-agent2
systemctl enable zabbix-agent2

netstat -natp | grep zabbix

进入服务端web界面进行配置
	配置->主机->创建主机
	主机:
		主机名称:zbx-agent01
		可见的名称:zbx-agent01-192.168.80.30
		群组:Linux servers
		客户端:192.168.80.30
	模板:
		Link new templates:Template OS Linux by Zabbix agent

#随意切换下左侧的选项,再切换回来,zbx已经启动

二、结语

  • 搭建很简单,没啥好说的,主要是会看图形界面

猜你喜欢

转载自blog.csdn.net/H875035681/article/details/125590793