Zabbix+Grafana+睿象云监控
一、zabbix
zabbix部署(5.0+mysql5.7)
1.Install Zabbix repository
# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# yum clean all
2.安装Zabbix server,Web前端,agent
yum install zabbix-server-mysql zabbix-agent
3.Install Zabbix frontend
# yum install centos-release-scl
编辑配置文件 /etc/yum.repos.d/zabbix.repo and enable zabbix-frontend repository.
[zabbix-frontend]
...
enabled=1
...
Install Zabbix frontend packages.
# yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl
4.创建初始数据库(可以借鉴这位博主yum安装mysql5.7)
①在数据库主机上运行以下代码。创建用户并授权。
# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
mysql> quit;
②导入初始架构和数据,系统将提示您输入新创建的密码。
# find / -name create.sql.gz #找到文件路径
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
③Disable log_bin_trust_function_creators option after importing database schema.
# mysql -uroot -p
password
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;
5.为Zabbix server配置数据库,编辑配置文件 /etc/zabbix/zabbix_server.conf
DBPassword=password
6.为Zabbix前端配置PHP
①编辑配置文件 /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf uncomment and set ‘listen’ and ‘server_name’ directives.
# listen 80; #注释解开
# server_name example.com;
②编辑配置文件 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf add nginx to listen.acl_users directive.
listen.acl_users = apache,nginx
php_value[date.timezone] = Aisa/Shanghai #前面的;一定要删除
7.修改nginx配置
vim /etc/opt/rh/rh-nginx116/nginx/nginx.conf
#将配置文件中的server模块删除掉
server {
...
} # 删除
8.启动Zabbix server和agent进程
启动Zabbix server和agent进程,并为它们设置开机自启:
# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
9.agent部署
①下载yum源
# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# yum clean all
②下载agent客户端
# yum install zabbix-agent
③启动并设置开机自启
systemctl restart zabbix-agent && systemctl enable zabbix-agent
10.登录zabbix-server端时默认账户Admin,密码zabbix.
二、grafana
部署grafana
官网下载方法:https://grafana.com/grafana/download?edition=oss
选择开源版本,我这里和zabbix-server安装在一台虚拟机
[root@zabbix-server ~]# wget https://dl.grafana.com/oss/release/grafana-8.3.4-1.x86_64.rpm
[root@zabbix-server ~]# yum -y install grafana-8.3.4-1.x86_64.rpm
[root@zabbix-server ~]# systemctl start grafana-server
# 日志位置
[root@zabbix-server ~]# tail -f /var/log/grafana/grafana.log
Granfana官网文档:https://grafana.com/docs/grafana/latest/getting-started/getting-started/
首次登录 Grafana:
- 打开您的网络浏览器并转到 http://localhost:3000/。3000除非您配置了不同的端口,否则Grafana 侦听的默认 HTTP 端口是。
- 在登录页面上,输入admin用户名和密码(默认admin)。
- 单击登录。如果登录成功,您将看到更改密码的提示。
- 在提示上单击“确定”,然后更改您的密码。
下载官方zabbix插件
在官方搜索查找并根据官方教程下载安装即可,https://grafana.com/grafana/plugins/
三、部署睿象云
浏览器进入睿象云官网注册账号并登录。
根据标记双击选择zabbix.
根据教程配置相关组件
最后一步登录安装时地址要填写server端的ip
完成安装后配置相关策略即可。