Prometheus + Grafana 安装及配置指南
监控 Oracle 和 GaussDB 数据库服务器的各项指标
在现代 IT 基础架构中,Prometheus 和 Grafana 是两款广泛使用的开源监控和可视化工具。Prometheus 负责数据的抓取、存储和查询,而 Grafana 则提供强大的可视化界面,用于展示和分析这些监控数据。本指南将详细介绍如何在 Ubuntu 20.04 LTS 环境下安装和配置 Prometheus 与 Grafana,并通过 Exporter 监控 Oracle 和 GaussDB 数据库服务器的各项指标。
目录
- 系统准备
- 安装 Prometheus
- 安装 Grafana
- 配置 Exporters 以监控 Oracle 和 GaussDB
- 在 Grafana 中配置数据源和仪表盘
- 部署和优化
- 监控与维护
- 常见问题与故障排除
- 总结
- 附录
1. 系统准备
1.1 操作系统
本指南以 Ubuntu 20.04 LTS 为例,适用于其他基于 Debian 的系统(如 Debian 10)。对于基于 RPM 的发行版(如 CentOS、Fedora),安装命令和服务管理可能有所不同。
1.2 更新系统
在开始安装前,确保系统的包索引和已安装的软件包是最新的。
sudo apt update
sudo apt upgrade -y
1.3 安装必要的工具
确保系统已安装常用的工具,如 wget
和 curl
。
sudo apt install wget curl -y
2. 安装 Prometheus
Prometheus 是一个开源的系统监控和警报工具包,主要用于收集和存储时间序列数据。
2.1 创建 Prometheus 用户
出于安全考虑,建议使用专用用户运行 Prometheus。
sudo useradd --no-create-home --shell /bin/false prometheus
2.2 下载并安装 Prometheus
- 创建目录结构
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
- 下载 Prometheus
前往 Prometheus 官方下载页面 查找最新版本信息。以下示例使用 Prometheus 2.45.0 版本,请根据实际情况调整版本号。
cd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz
tar -xvf prometheus-2.45.0.linux-amd64.tar.gz
sudo mv prometheus-2.45.0.linux-amd64/prometheus /usr/local/bin/
sudo mv prometheus-2.45.0.linux-amd64/promtool /usr/local/bin/
sudo mv prometheus-2.45.0.linux-amd64/consoles /etc/prometheus
sudo mv prometheus-2.45.0.linux-amd64/console_libraries /etc/prometheus
- 设置文件权限
sudo chown prometheus:prometheus /usr/local/bin/prometheus
sudo chown prometheus:prometheus /usr/local/bin/promtool
sudo chown -R prometheus:prometheus /etc/prometheus/consoles
sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries
2.3 配置 Prometheus
创建 Prometheus 配置文件 /etc/prometheus/prometheus.yml
。
sudo nano /etc/prometheus/prometheus.yml
示例配置文件:
global:
scrape_interval: 15s # 全局抓取间隔
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
# 以后可添加其他 Exporters 的抓取配置
保存并退出(Ctrl + O
,Enter
,Ctrl + X
)。
2.4 设置 Prometheus 系统服务
创建一个 systemd 服务文件 /etc/systemd/system/prometheus.service
。
sudo nano /etc/systemd/system/prometheus.service
内容如下:
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries
Restart=always
[Install]
WantedBy=multi-user.target
保存并退出。
2.5 启动并验证 Prometheus
- 重新加载 systemd 配置
sudo systemctl daemon-reload
- 启动 Prometheus 服务
sudo systemctl start prometheus
- 设置 Prometheus 开机自启
sudo systemctl enable prometheus
- 验证 Prometheus 是否运行正常
访问 http://<服务器IP>:9090
,应看到 Prometheus 的 Web 界面。
curl http://localhost:9090/metrics
应返回大量 Prometheus 的指标数据。
3. 安装 Grafana
Grafana 是一个开源的数据可视化和监控平台,支持多种数据源,包括 Prometheus。
3.1 添加 Grafana APT 仓库
- 安装所需的依赖
sudo apt install -y software-properties-common
- 添加 Grafana GPG 密钥
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
- 添加 Grafana APT 仓库
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
- 更新包索引
sudo apt update
3.2 安装 Grafana
sudo apt install grafana -y
3.3 启动并配置 Grafana
- 启动 Grafana 服务
sudo systemctl start grafana-server
- 设置 Grafana 开机自启
sudo systemctl enable grafana-server
3.4 验证 Grafana 安装
访问 http://<服务器IP>:3000
,应看到 Grafana 的登录页面。默认用户名和密码均为 admin
。首次登录时,系统会提示更改密码。
curl http://localhost:3000/api/health
应返回类似如下内容,表示 Grafana 正在运行:
{"status":"ok"}
4. 配置 Exporters 以监控 Oracle 和 GaussDB
Prometheus 通过 Exporters 收集不同系统和服务的指标数据。本文将介绍如何安装和配置常用的 Exporters,包括 Node Exporter、Oracle Exporter 和 GaussDB Exporter。
4.1 安装 Node Exporter
Node Exporter 用于收集服务器的硬件和操作系统指标。
- 下载 Node Exporter
访问 Node Exporter Releases 页面,下载最新版本。例如:
cd /tmp
wget https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz
tar -xvf node_exporter-1.6.1.linux-amd64.tar.gz
sudo mv node_exporter-1.6.1.linux-amd64/node_exporter /usr/local/bin/
- 创建 Node Exporter 用户
sudo useradd --no-create-home --shell /bin/false node_exporter
- 设置文件权限
sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter
- 创建系统服务文件
sudo nano /etc/systemd/system/node_exporter.service
内容如下:
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter
Restart=always
[Install]
WantedBy=default.target
- 重新加载 systemd 配置并启动服务
sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter
- 验证 Node Exporter 是否运行
访问 http://<服务器IP>:9100/metrics
,应看到大量指标数据。
curl http://localhost:9100/metrics
4.2 安装 Oracle Exporter
Oracle Exporter 用于从 Oracle 数据库收集性能指标。这里使用社区支持的 oracle_exporter。
4.2.1 安装必要依赖
首先,确保系统安装了 go
语言环境。
sudo apt install golang-go -y
4.2.2 下载并编译 Oracle Exporter
cd /tmp
git clone https://github.com/iamseth/oracle_exporter.git
cd oracle_exporter
make
sudo mv oracle_exporter /usr/local/bin/
4.2.3 配置 Oracle 连接
为了安全起见,创建一个用于 Oracle Exporter 的 Oracle 用户,并授予其必要的权限。
- 登录 Oracle 数据库
sqlplus sys@//localhost:1521/ORCLPDB1 AS SYSDBA
- 创建 Exporter 用户并授予权限
CREATE USER exporter IDENTIFIED BY strongpassword;
GRANT CONNECT, SELECT ANY DICTIONARY TO exporter;
GRANT EXECUTE ON DBMS_MONITOR TO exporter;
GRANT EXECUTE ON DBMS_XPLAN TO exporter;
GRANT SELECT ON V_$INSTANCE TO exporter;
GRANT SELECT ON V_$ACTIVE_SESSION_HISTORY TO exporter;
GRANT SELECT ON V_$SYSTEM_EVENT TO exporter;
GRANT SELECT ON V_$SYSSTAT TO exporter;
GRANT SELECT ON V_$SESSION TO exporter;
GRANT SELECT ON V_$SQLAREA TO exporter;
GRANT SELECT ON V_$SQL TO exporter;
GRANT SELECT ON V_$SEGMENT_STATISTICS TO exporter;
GRANT SELECT ON V_$SESSION_WAIT TO exporter;
GRANT SELECT ON V_$VALUE TO exporter;
GRANT SELECT ON LOCK$ TO exporter;
GRANT SELECT ON METER$ TO exporter;
FLUSH PRIVILEGES;
EXIT;
4.2.4 配置 Oracle Exporter
创建配置文件 /etc/oracle_exporter.conf
。
sudo nano /etc/oracle_exporter.conf
示例内容:
oracle_user=exporter
oracle_password=strongpassword
oracle_sid=ORCLPDB1
oracle_host=localhost
oracle_port=1521
注意:根据实际的 Oracle 配置调整 oracle_sid
、oracle_host
和 oracle_port
。
4.2.5 创建 Oracle Exporter 用户并设置权限
sudo useradd --no-create-home --shell /bin/false oracle_exporter
sudo chown oracle_exporter:oracle_exporter /usr/local/bin/oracle_exporter
sudo chown oracle_exporter:oracle_exporter /etc/oracle_exporter.conf
sudo chmod 600 /etc/oracle_exporter.conf
4.2.6 创建系统服务文件
sudo nano /etc/systemd/system/oracle_exporter.service
内容如下:
[Unit]
Description=Oracle Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=oracle_exporter
Group=oracle_exporter
Type=simple
ExecStart=/usr/local/bin/oracle_exporter --config.file /etc/oracle_exporter.conf
Restart=always
[Install]
WantedBy=default.target
4.2.7 重新加载 systemd 配置并启动服务
sudo systemctl daemon-reload
sudo systemctl start oracle_exporter
sudo systemctl enable oracle_exporter
4.2.8 验证 Oracle Exporter 是否运行
访问 http://<服务器IP>:9161/metrics
,应看到 Oracle 的指标数据。
curl http://localhost:9161/metrics
4.3 安装 GaussDB Exporter
GaussDB 是华为推出的分布式数据库,类似于 PostgreSQL。可以使用 PostgreSQL Exporter 来监控 GaussDB。这里使用开源的 postgres_exporter。
4.3.1 安装必要依赖
确保系统安装了 go
语言环境。
sudo apt install golang-go -y
4.3.2 下载并编译 PostgreSQL Exporter
cd /tmp
git clone https://github.com/prometheus-community/postgres_exporter.git
cd postgres_exporter
make build
sudo mv postgres_exporter /usr/local/bin/
4.3.3 配置 GaussDB 用户权限
在 GaussDB 中创建一个用于 Exporter 的用户,并授予必要的权限。
- 登录 GaussDB 数据库
psql -U postgres -d postgres
- 创建 Exporter 用户并授予权限
CREATE USER exporter WITH PASSWORD 'strongpassword';
GRANT CONNECT ON DATABASE postgres TO exporter;
GRANT USAGE ON SCHEMA public TO exporter;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO exporter;
ALTER USER exporter SET search_path TO public;
注意:根据实际需求调整权限,确保 Exporter 用户拥有读取指标所需的权限。
4.3.4 配置 PostgreSQL Exporter
创建配置文件 /etc/postgres_exporter/.pgpass
以存储数据库凭证。
sudo mkdir /etc/postgres_exporter
sudo nano /etc/postgres_exporter/.pgpass
内容如下:
localhost:5432:postgres:exporter:strongpassword
设置文件权限:
sudo chown exporter:exporter /etc/postgres_exporter/.pgpass
sudo chmod 600 /etc/postgres_exporter/.pgpass
设置环境变量 DATA_SOURCE_NAME
。创建一个环境变量文件 /etc/postgres_exporter.env
。
sudo nano /etc/postgres_exporter.env
内容如下:
DATA_SOURCE_NAME=exporter:strongpassword@localhost:5432/postgres?sslmode=disable
4.3.5 创建 PostgreSQL Exporter 用户并设置权限
sudo useradd --no-create-home --shell /bin/false postgres_exporter
sudo chown postgres_exporter:postgres_exporter /usr/local/bin/postgres_exporter
sudo chown -R postgres_exporter:postgres_exporter /etc/postgres_exporter
sudo chmod 600 /etc/postgres_exporter/.pgpass
4.3.6 创建系统服务文件
sudo nano /etc/systemd/system/postgres_exporter.service
内容如下:
[Unit]
Description=PostgreSQL Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=postgres_exporter
Group=postgres_exporter
Type=simple
EnvironmentFile=/etc/postgres_exporter.env
ExecStart=/usr/local/bin/postgres_exporter
Restart=always
[Install]
WantedBy=default.target
4.3.7 重新加载 systemd 配置并启动服务
sudo systemctl daemon-reload
sudo systemctl start postgres_exporter
sudo systemctl enable postgres_exporter
4.3.8 验证 PostgreSQL Exporter 是否运行
访问 http://<服务器IP>:9187/metrics
,应看到 GaussDB 的指标数据。
curl http://localhost:9187/metrics
4.4 配置 Prometheus 抓取 Exporters
编辑 Prometheus 的配置文件,添加 Exporters 的抓取任务。
sudo nano /etc/prometheus/prometheus.yml
添加以下内容:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
- job_name: 'oracle_exporter'
static_configs:
- targets: ['localhost:9161']
- job_name: 'gaussdb_exporter'
static_configs:
- targets: ['localhost:9187']
注意:根据 Exporters 运行在不同服务器的情况调整 targets
。
保存并退出。
4.5 重启 Prometheus
sudo systemctl restart prometheus
4.6 验证 Prometheus 是否成功抓取 Exporters 的数据
访问 Prometheus 的 Web 界面 http://<服务器IP>:9090/targets
,应看到所有抓取目标的状态为 “UP”。
5. 在 Grafana 中配置数据源和仪表盘
Grafana 通过数据源连接 Prometheus,并通过仪表盘展示指标数据。
5.1 添加 Prometheus 为数据源
- 访问 Grafana Web 界面
在浏览器中访问 http://<服务器IP>:3000
,使用默认用户名和密码(admin/admin
)登录。首次登录会要求更改密码。
- 添加数据源
- 点击左侧菜单的 “设置”(齿轮图标)。
- 选择 “数据源”。
- 点击 “添加数据源” 按钮。
- 从列表中选择 “Prometheus”。
- 配置 Prometheus 数据源
- 名称:默认为
Prometheus
,可根据需要修改。 - URL:
http://localhost:9090
(如果 Prometheus 与 Grafana 在同一台服务器上)。 - 其他选项可保持默认。
- 保存并测试
点击 “保存并测试” 按钮。如果配置正确,Grafana 会显示 “Data source is working”。
5.2 导入现有仪表盘
Grafana 提供了大量预设的仪表盘,可快速展示常见服务的监控信息。
5.2.1 导入 Node Exporter 仪表盘
- 获取仪表盘 ID
访问 Grafana Dashboards 网站,查找合适的仪表盘。例如:
- Node Exporter Full:ID
1860
- 导入仪表盘
- 点击左侧菜单的 “+”,选择 “导入”。
- 输入仪表盘 ID(例如
1860
),然后点击 “加载”。 - 选择关联的数据源(Prometheus)。
- 点击 “导入”。
5.2.2 导入 Oracle Exporter 仪表盘
由于社区支持较少,建议使用自定义仪表盘,或查找现有社区共享的仪表盘。
以下示例使用自定义仪表盘添加 Oracle 监控指标。
5.2.3 导入 GaussDB Exporter 仪表盘
同样,社区提供的仪表盘可能有限,建议使用 PostgreSQL Exporter 的仪表盘,稍作调整即可适用于 GaussDB。
例如:
- PostgreSQL Exporter Full:ID
9628
- 导入仪表盘
- 点击左侧菜单的 “+”,选择 “导入”。
- 输入仪表盘 ID(例如
9628
),然后点击 “加载”。 - 选择关联的数据源(Prometheus)。
- 点击 “导入”。
5.3 创建自定义仪表盘
根据具体需求,可以创建自定义的仪表盘来展示特定的指标。
5.3.1 创建新仪表盘
- 创建新仪表盘
- 点击左侧菜单的 “+”,选择 “仪表盘”。
- 点击 “添加新面板”。
- 配置查询
-
在 “查询” 选项卡中,选择 Prometheus 作为数据源。
-
输入 PromQL 查询表达式。例如,监控 Oracle 数据库的活跃会话数:
oracle_exporter_active_sessions
-
或监控 GaussDB 的连接数:
gaussdb_exporter_connections
- 配置可视化
- 选择合适的可视化类型(图表、单一值、饼图等)。
- 配置图表的标题、单位、颜色等。
- 保存仪表盘
- 点击右上角的 “保存” 图标,输入仪表盘名称并保存。
6. 部署和优化
6.1 设置服务开机自启
确保所有服务在系统重启后自动启动。
# Prometheus
sudo systemctl enable prometheus
# Grafana
sudo systemctl enable grafana-server
# Exporters
sudo systemctl enable node_exporter
sudo systemctl enable oracle_exporter
sudo systemctl enable postgres_exporter
6.2 Prometheus 性能优化
- 调整存储保留策略
编辑 Prometheus 启动参数,设置存储保留时间。
编辑 /etc/systemd/system/prometheus.service
文件,修改 ExecStart
行:
ExecStart=/usr/local/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--storage.tsdb.retention.time=30d \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries
上述配置将数据保留时间设置为 30 天。
- 调整抓取间隔
根据实际需求调整 scrape_interval
,减少过高的抓取频率以降低资源消耗。
- 使用远程存储
对于大规模数据,可以配置 Prometheus 使用远程存储解决方案(如 Thanos 或 Cortex),以扩展存储容量和实现高可用性。
6.3 Grafana 性能优化
- 优化缓存配置
调整 Grafana 缓存设置,提升仪表盘加载速度。
编辑 /etc/grafana/grafana.ini
文件,根据需要调整缓存相关参数。
- 启用压缩
在 Grafana 配置文件中启用 Gzip 压缩,以减少网络传输负载。
[server]
# ...
enable_gzip = true
- 分离数据库
使用外部数据库(如 MySQL、PostgreSQL)存储 Grafana 数据,而不是默认的 SQLite,提高数据处理能力。
编辑 /etc/grafana/grafana.ini
,在 [database]
部分配置数据库连接信息。
[database]
type = mysql
host = <数据库服务器>:3306
name = grafana
user = grafana_user
password = secure_password
7. 监控与维护
7.1 监控 Prometheus
- Prometheus 自身指标
Prometheus 提供自己的指标,可以监控其性能和健康状态。访问 http://<服务器IP>:9090/metrics
。
- 使用 Grafana 监控 Prometheus
导入适用于 Prometheus 的 Grafana 仪表盘(如 ID 10831
),实时监控 Prometheus 的运行状态。
7.2 监控 Grafana
- Grafana 自身指标
访问 http://<服务器IP>:3000/api/metrics
,获取 Grafana 的指标数据。可以使用 Prometheus 抓取并在 Grafana 中展示。
- 使用 Grafana 专用仪表盘
导入针对 Grafana 的现有仪表盘,实时监控 Grafana 的性能。
8. 常见问题与故障排除
8.1 Prometheus 无法启动
症状:systemctl status prometheus
显示错误,无法启动。
解决方法:
- 检查配置文件语法错误
使用 promtool
验证配置:
promtool check config /etc/prometheus/prometheus.yml
- 查看日志
sudo journalctl -u prometheus -f
- 确认 Prometheus 拥有
/var/lib/prometheus
目录的读写权限
sudo chown -R prometheus:prometheus /var/lib/prometheus
- 检查端口是否被占用
sudo lsof -i :9090
8.2 Grafana 无法访问
症状:访问 http://<服务器IP>:3000
无响应。
解决方法:
- 检查 Grafana 服务状态
sudo systemctl status grafana-server
- 查看 Grafana 日志
sudo journalctl -u grafana-server -f
- 确认防火墙允许 3000 端口的流量
sudo ufw allow 3000/tcp
8.3 Exporters 数据未被 Prometheus 抓取
症状:Prometheus Web 界面中的 Targets 状态为 DOWN。
解决方法:
- 确认 Exporters 服务是否正在运行
sudo systemctl status node_exporter
sudo systemctl status oracle_exporter
sudo systemctl status postgres_exporter
-
确认 Prometheus 配置文件中的抓取目标地址和端口是否正确
-
检查 Exporters 的防火墙设置,确保 Prometheus 服务器能够访问 Exporters 的端口
8.4 Grafana 数据源连接失败
症状:在 Grafana 中添加 Prometheus 数据源时,测试连接失败。
解决方法:
- 确认 Prometheus 正在运行,并且可以从 Grafana 服务器访问
curl http://localhost:9090/metrics
-
检查 Prometheus 的
prometheus.yml
配置文件中是否正确配置了抓取目标 -
查看 Grafana 日志获取更多错误信息
sudo journalctl -u grafana-server -f
8.5 Oracle Exporter 无法抓取数据
症状:Prometheus 中 Oracle Exporter 的 Target 状态为 DOWN。
解决方法:
- 检查 Oracle Exporter 服务状态
sudo systemctl status oracle_exporter
-
确认 Oracle 数据库可用,并且 Exporter 用户具备足够权限
-
检查配置文件
/etc/oracle_exporter.conf
是否正确 -
查看 Oracle Exporter 日志获取更多信息
sudo journalctl -u oracle_exporter -f
8.6 GaussDB Exporter 无法抓取数据
症状:Prometheus 中 GaussDB Exporter 的 Target 状态为 DOWN。
解决方法:
- 检查 PostgreSQL Exporter 服务状态
sudo systemctl status postgres_exporter
-
确认 GaussDB 数据库可用,并且 Exporter 用户具备足够权限
-
检查配置文件
/etc/postgres_exporter.env
是否正确 -
查看 PostgreSQL Exporter 日志获取更多信息
sudo journalctl -u postgres_exporter -f
9. 总结
通过本文的指南,你已经学习了如何在 Ubuntu 20.04 LTS 系统上安装和配置 Prometheus 与 Grafana,并通过 Exporters 监控 Oracle 和 GaussDB 数据库服务器的各项指标。以下是关键要点的回顾:
- Prometheus 作为数据收集和存储系统,通过配置抓取任务从不同的 Exporters 获取指标数据。
- Grafana 提供强大的数据可视化功能,通过配置数据源和导入/创建仪表盘,将 Prometheus 的数据以图表形式展示。
- Exporters(如 Node Exporter、Oracle Exporter 和 GaussDB Exporter)是 Prometheus 监控的关键,负责从不同系统和服务收集指标数据。
- 优化与维护:合理配置 Prometheus 和 Grafana 的参数,确保系统在高负载下仍能高效运行,并定期监控和维护服务的健康状态。
通过有效的 Prometheus + Grafana 监控体系,可以实时掌握系统和应用的性能状况,及时发现和解决潜在问题,提升整体运维效率和系统稳定性。
10. 附录
A. 参考资源
- Prometheus 官方文档
- Grafana 官方文档
- Node Exporter
- Oracle Exporter GitHub 页面
- PostgreSQL Exporter
- Prometheus 社区仪表盘
B. 术语解释
- Exporter:Prometheus 用于从各种服务和系统收集指标数据的组件。
- Scrape:Prometheus 定期从 Exporters 获取指标数据的过程。
- Data Source:Grafana 中的数据来源,本例中为 Prometheus。
- Dashboard(仪表盘):Grafana 中用于展示和可视化监控数据的界面。
- PromQL:Prometheus 的查询语言,用于查询和聚合时间序列数据。
C. 常用命令速查
-
Prometheus:
- 启动:
sudo systemctl start prometheus
- 停止:
sudo systemctl stop prometheus
- 重启:
sudo systemctl restart prometheus
- 查看状态:
sudo systemctl status prometheus
- 启动:
-
Grafana:
- 启动:
sudo systemctl start grafana-server
- 停止:
sudo systemctl stop grafana-server
- 重启:
sudo systemctl restart grafana-server
- 查看状态:
sudo systemctl status grafana-server
- 启动:
-
Node Exporter:
- 启动:
sudo systemctl start node_exporter
- 停止:
sudo systemctl stop node_exporter
- 重启:
sudo systemctl restart node_exporter
- 查看状态:
sudo systemctl status node_exporter
- 启动:
-
Oracle Exporter:
- 启动:
sudo systemctl start oracle_exporter
- 停止:
sudo systemctl stop oracle_exporter
- 重启:
sudo systemctl restart oracle_exporter
- 查看状态:
sudo systemctl status oracle_exporter
- 启动:
-
GaussDB Exporter (PostgreSQL Exporter):
- 启动:
sudo systemctl start postgres_exporter
- 停止:
sudo systemctl stop postgres_exporter
- 重启:
sudo systemctl restart postgres_exporter
- 查看状态:
sudo systemctl status postgres_exporter
- 启动:
希望此指南能帮助你顺利搭建并优化 Prometheus + Grafana 监控环境,以有效监控 Oracle 和 GaussDB 数据库服务器的各项指标。如有进一步的问题或需要更详细的指导,请参考相关官方文档或下方留言。