大家好,又见面了,我是你们的朋友全栈君。
hostnamectl set-hostname prometheus
su
hostnamectl set-hostname agent
su
hostnamectl set-hostname grafana
su
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
vim /etc/hosts
192.168.27.136 prometheus
192.168.27.138 agent
192.168.27.139 grafana
ntpdate ntp1.aliyun.com
[root@prometheus ~]# cd /opt
[root@prometheus opt]# rz -E //将prometheus软件包上传到/opt目录下
[root@prometheus opt]# tar zxvf prometheus-2.5.0.linux-amd64.tar.gz -C /usr/local
[root@prometheus opt]# mv /usr/local/prometheus-2.5.0.linux-amd64/ /usr/local/prometheus
[root@prometheus opt]# cd /usr/local/prometheus
[root@prometheus prometheus]# ./prometheus --config.file="/usr/local/prometheus/prometheus.yml" &
ss -naltp | grep 9090
[root@agent ~]# cd /opt
[root@agent opt]# rz -E //上传node_exporter组件到/opt目录下,anget被监控端
[root@agent opt]# tar zxvf node_exporter-0.16.0.linux-amd64.tar.gz -C /usr/local/
[root@agent opt]# mv /usr/local/node_exporter-0.16.0.linux-amd64 /usr/local/node_exporter
[root@agent local]# ls /usr/local/node_exporter
[root@agent local]# nohup /usr/local/node_exporter/node_exporter &
[root@agent local]# ss -naltp | grep 9100
[root@prometheus prometheus]# vim /usr/local/prometheus/prometheus.yml
30 - job_name: 'agent' //修改被监控的主机名称
31 static_configs:
32 - targets: ['192.168.27.138:9100'] //修改为被监控机器的IP,端口设置为9100
[root@prometheus prometheus]# pkill prometheus //停止普罗米修斯这个服务
[root@prometheus prometheus]# ss -naltp | grep 9090
[root@prometheus prometheus]# ./prometheus --config.file="/usr/local/prometheus/prometheus.yml" &
[root@prometheus prometheus]# ss -anltp | grep 9090 //确认端口被占用,说明重启成功
[root@agent local]# cd /opt
[root@agent opt]# rz -E //上传mysqld_exporter组件到/opt目录下
[root@agent opt]# tar zxvf mysqld_exporter-0.11.0.linux-amd64.tar.gz -C /usr/local/
[root@agent opt]# mv /usr/local/mysqld_exporter-0.11.0.linux-amd64/ /usr/local/mysqld_exporter
[root@agent opt]# cd /usr/local/mysqld_exporter/
[root@agent mysqld_exporter]# yum install mariadb\* -y //安装mariadb数据库
[root@agent mysqld_exporter]# systemctl start mariadb //启动mariadb数据库
[root@agent mysqld_exporter]# systemctl enable mariadb
[root@agent mysqld_exporter]# ss -anltp | grep 3306
[root@agent mysqld_exporter]# mysql
MariaDB [(none)]> grant select,replication client,process ON *.* to 'mysql_monitor'@'localhost' identified by '123';
MariaDB [(none)]> flush privileges; //刷新权限
MariaDB [(none)]> exit
[root@agent mysqld_exporter]# vim /usr/local/mysqld_exporter/.my.cnf
[client]
user=mysql_monitor
password=123
[root@agent mysqld_exporter]# nohup /usr/local/mysqld_exporter/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter/.my.cnf &
[root@agent mysqld_exporter]# ss -antlp | grep 9104
- job_name: 'mariadb' //修改名称代表被监控的mariadb
static_configs:
- targets: ['192.168.27.138:9104'] /被监控的IP,后面端口为9104
//在末尾插入
[root@prometheus prometheus]# pkill prometheus
[root@prometheus prometheus]# ./prometheus --config.file="/usr/local/prometheus/prometheus.yml" &
[root@prometheus prometheus]# ss -naltp | grep 9090 //查看端口占用情况
[root@grafana ~]# cd /opt
[root@grafana opt]# rz -E
[root@grafana opt]# rpm -ivh grafana-5.3.4-1.x86_64.rpm //安装grafana软件
[root@grafana opt]# systemctl start grafana-server //启动grafana服务
[root@grafana opt]# systemctl enable grafana-server
[root@grafana opt]# ss -anltp | grep 3000 //查看端口
[root@grafana opt]# vim /etc/grafana/grafana.ini
[dashboards.json]
enable = true
path = /var/lib/grafana/dashboards //末尾插入
[root@grafana grafana]# git clone https://gitub.com/percona/grafana-dashboards.git
[root@grafana grafana]# mkdir dashboards
[root@grafana grafana]# cd dashboards/
[root@grafana dashboards]# pwd
[root@grafana dashboards]# cp -r grafanadashboards/dashboards/ /var/lib/grafana/
[root@grafana dashboards]# systemctl restart grafana-server
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/161742.html原文链接:https://javaforall.cn