服务器:
192.168.0.46安装go, prometheus,grafana,alertmanager
看服务器上安装的什么服务就在这台服务器上安装node_exporter(比如安装的MySQL就在这台机器上安装node_exporte和MySQL安装包,但是端口不要冲突看是否有剩余空间)
192.168.0.46上操作先普通用户登录在切换root用户:
su root
cd /data
tar zxf go1.16.7.linux-amd64.tar.gz
vim /home/unioncloud/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export GOPATH=/data/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOPATH/bin
export GOPROXY="https://goproxy.io,direct"
source /home/unioncloud/.bash_profile
go version
go version go1.16.7 linux/amd64
安装prometheus
cd /data
tar zxf prometheus-2.29.1.linux-amd64.tar.gz
mv prometheus-2.29.1.linux-amd64 prometheus
cd prometheus/
nohup ./prometheus --config.file=prometheus.yml --web.enable-lifecycle --storage.tsdb.retention.time=90d &
安装grafna
cd /data
tar zxf grafana-8.1.1.linux-amd64.tar
mv grafana-8.1.1 grafana
cd grafana
cd bin
nohup ./grafana-server &
浏览器访问Prometheus:ip+9090端口
浏览器访问grafana:ip+3000端口
Prometheus+Grafana做结合
安装MySQL的服务器上安装MySQL和node_exporter
cd /home/unioncloud
tar zxf mysqld_exporter-0.13.0.linux-amd64.tar.gz
mv mysqld_exporter-0.13.0.linux-amd64 mysqld_exporter
cd mysqld_exporter
vim .my.cnf
[client]
#port=3306
user=exporter
password=lEpMDiKi
vim start_mysqld_exporter.sh
#!/bin/bash
export exporter=/home/unioncloud/mysqld_exporter
nohup $exporter/mysqld_exporter --config.my-cnf="$exporter/.my.cnf" --web.listen-address=":9104" &
chmod +x start_mysqld_exporter.sh
cd /home/unioncloud
tar zxf node_exporter-1.2.2.linux-amd64.tar.gz
mv node_exporter-1.2.2.linux-amd64 node_exporter
cd node_exporter/
vim start_node_exporter.sh
#!/bin/bash
export exporter=/home/unioncloud/node_exporter
nohup $exporter/node_exporter --web.listen-address 0.0.0.0:9100 &
chmod +x start_node_exporter.sh
./start_node_exporter.sh
mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6812196
Server version: 5.7.29-log MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
master [(none)]>CREATE USER 'exporter'@'::1' IDENTIFIED BY 'lEpMDiKi' WITH MAX_USER_CONNECTIONS 3;
Query OK, 0 rows affected (0.00 sec)
master [(none)]>GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'::1';
Query OK, 0 rows affected, 1 warning (0.01 sec)
master [(none)]>flush privileges;
Query OK, 0 rows affected (0.00 sec)
master [(none)]>exit
Bye
在192.168.0.46上操作:
cd /data/prometheus/
vim prometheus.yml
在最下面添加:
curl -XPOST http://192.168.0.46:9090/-/reload
下面的操作和上面的一样就是端口不要冲突!!!!!!