本文档风哥主要介绍Oracle Enterprise Manager Cloud Control (EMCC) 的监控功能相关知识,包括EMCC监控的概念、监控类型、监控策略、数据库监控、主机监控、自定义监控等内容,由风哥教程参考Oracle官方文档EMCC内容编写,适合DBA人员在学习和测试中使用,如果要应用于生产环境则需要自行确认。
Part01-基础概念与理论知识
1.1 EMCC监控概念
Oracle Enterprise Manager Cloud Control (EMCC) 监控是EMCC的核心功能之一,通过部署在被管理主机上的Agent,实时收集各种性能指标和状态信息,实现对Oracle数据库、主机、中间件等IT资源的全面监控。EMCC监控可以帮助DBA及时发现和解决性能问题,确保系统稳定运行。更多视频教程www.fgedu.net.cn
- 指标(Metric):用于衡量目标状态的度量值,如CPU使用率、内存使用率等
- 收集(Collection):Agent定期采集指标数据的过程
- 阈值(Threshold):指标告警的触发条件,分为警告和严重两级
- 基线(Baseline):正常性能数据的参考标准
- 事件(Event):监控过程中产生的告警和通知
- 仪表板(Dashboard):可视化展示监控数据的界面
1.2 监控类型
EMCC支持的监控类型:
1. 实时监控(Real-time Monitoring)
– 实时采集性能指标
– 即时显示当前状态
– 支持实时图表展示
– 适用于关键系统监控
2. 历史监控(Historical Monitoring)
– 存储历史监控数据
– 支持趋势分析
– 支持容量规划
– 支持性能对比
3. 预测监控(Predictive Monitoring)
– 基于历史数据预测未来趋势
– 提前预警潜在问题
– 支持容量预测
– 支持性能预测
4. 合规监控(Compliance Monitoring)
– 监控配置合规性
– 检测配置漂移
– 生成合规报告
– 支持审计需求
# 监控目标类型
目标类型 监控内容
——————– ——————————–
oracle_database 数据库性能、会话、表空间、等待事件
host CPU、内存、磁盘、网络、进程
oracle_listener 监听器状态、连接数
osm_instance ASM磁盘组: DGSYSTEM、DGDATA01、DGDATA02、DGRECOVERY
cluster 集群状态、节点状态
weblogic_domain JVM、数据源、应用状态
1.3 EMCC监控优势
EMCC监控的优势:
- 全面性:覆盖Oracle全产品线的监控能力
- 实时性:实时采集和展示监控数据
- 主动性:通过阈值告警主动发现问题
- 可视化:丰富的图表和仪表板展示
- 历史分析:支持历史数据分析和趋势预测
- 集成性:与告警、报告、作业等功能深度集成
Part02-生产环境规划与建议
2.1 监控规划
EMCC监控的规划要点:
# 1. 监控需求分析
– 业务重要性分级(核心、重要、一般)
– 性能指标需求
– 告警响应要求
– 报告需求
# 2. 监控策略设计
– 收集频率设计
– 阈值设置策略
– 告警升级策略
– 数据保留策略
# 3. 监控资源配置
– Agent资源配置
– Repository存储规划
– 网络带宽规划
– 监控数据保留
# 4. 监控流程设计
– 监控数据采集流程
– 告警处理流程
– 报告生成流程
– 监控优化流程
# 监控频率参考
指标类型 | 核心系统 | 重要系统 | 一般系统
——————|———-|———-|———-
关键性能指标 | 1分钟 | 5分钟 | 15分钟
一般性能指标 | 5分钟 | 15分钟 | 30分钟
配置信息 | 1小时 | 4小时 | 12小时
空间使用 | 15分钟 | 30分钟 | 1小时
2.2 监控策略
EMCC监控策略选择:
策略 | 适用场景 | 收集频率 | 存储周期
——————|——————-|————-|———-
高频监控 | 核心生产系统 | 1-5分钟 | 30天
标准监控 | 一般生产系统 | 5-15分钟 | 30天
低频监控 | 测试/开发环境 | 15-60分钟 | 7天
按需监控 | 临时监控需求 | 自定义 | 自定义
# 详细策略说明
1. 高频监控策略
– 适用:核心生产数据库
– 收集频率:1-5分钟
– 指标:CPU、内存、会话、等待事件、IO
– 阈值:严格(警告70%,严重90%)
– 告警:即时通知
2. 标准监控策略
– 适用:一般生产数据库
– 收集频率:5-15分钟
– 指标:CPU、内存、表空间、会话
– 阈值:标准(警告80%,严重95%)
– 告警:邮件通知
3. 低频监控策略
– 适用:测试开发环境
– 收集频率:15-60分钟
– 指标:基本性能指标
– 阈值:宽松(警告90%,严重95%)
– 告警:汇总报告
4. 按需监控策略
– 适用:问题诊断、性能调优
– 收集频率:根据需要设置
– 指标:根据问题选择
– 阈值:根据基线设置
– 告警:自定义
2.3 监控注意事项
EMCC监控的注意事项:
- 性能影响:过于频繁的收集会影响目标系统性能
- 存储空间:监控数据会占用大量存储空间
- 网络带宽:数据上传会占用网络带宽
- 告警风暴:不合理阈值会导致告警风暴
- Agent资源:确保Agent有足够资源运行
- 时区设置:确保所有组件时区一致
Part03-生产环境项目实施方案
3.1 数据库监控
3.1.1 配置数据库性能监控
$ emcli login -username=sysman
Enter password :
Login successful
$ emcli sync
# 查看数据库可用指标
$ emcli get_metrics \
-target_type=”oracle_database” \
-target_name=”prod_orcl”
Metric Name Category Unit
—————————– ————– ————
CPU_Utilization Performance %
Memory_Usage Performance %
Active_Sessions Performance Count
Response_Time Performance ms
Tablespace_Usage Storage %
Tablespace_Free_Space Storage MB
Session_Wait_Time Performance ms
Buffer_Cache_Hit_Ratio Performance %
Redo_Generation_Rate Performance KB/s
# 2. 配置指标收集
$ emcli modify_collection_schedule \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-collection_name=”CPU_Utilization” \
-interval=”5″ \
-interval_unit=”MINUTE”
Collection schedule modified successfully
# 3. 配置阈值告警
$ emcli modify_metric_threshold \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”CPU_Utilization” \
-warning_threshold=”80″ \
-critical_threshold=”95″
Metric threshold modified successfully
# 4. 查看当前监控数据
$ emcli get_metric_data \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”CPU_Utilization” \
-start_time=”2026-03-31 09:00:00″ \
-end_time=”2026-03-31 10:00:00″
Timestamp Value Status
———————- ——- ——–
2026-03-31 09:00:00 15.5 Normal
2026-03-31 09:05:00 18.2 Normal
2026-03-31 09:10:00 22.1 Normal
2026-03-31 09:15:00 35.8 Normal
2026-03-31 09:20:00 45.3 Normal
2026-03-31 09:25:00 62.7 Normal
2026-03-31 09:30:00 78.5 Warning
2026-03-31 09:35:00 85.2 Warning
2026-03-31 09:40:00 92.1 Warning
2026-03-31 09:45:00 68.4 Normal
2026-03-31 09:50:00 42.6 Normal
2026-03-31 09:55:00 28.3 Normal
# 5. 配置表空间监控
$ emcli modify_metric_threshold \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”Tablespace_Usage” \
-warning_threshold=”85″ \
-critical_threshold=”95″
Metric threshold modified successfully
# 查看表空间使用情况
$ emcli get_metric_data \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”Tablespace_Usage”
Tablespace Name Used(%) Free(MB) Status
—————– ——— ———– ——–
SYSTEM 45.2 548 Normal
SYSAUX 52.8 472 Normal
USERS 88.5 115 Warning
UNDOTBS1 35.2 648 Normal
TEMP 12.5 875 Normal
3.1.2 配置会话和等待事件监控
$ emcli modify_collection_schedule \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-collection_name=”Active_Sessions” \
-interval=”1″ \
-interval_unit=”MINUTE”
Collection schedule modified successfully
# 2. 配置会话阈值
$ emcli modify_metric_threshold \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”Active_Sessions” \
-warning_threshold=”100″ \
-critical_threshold=”200″
Metric threshold modified successfully
# 3. 查看当前会话状态
$ emcli get_metric_data \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”Active_Sessions”
Session Type Count Status
—————– ——- ——–
User Sessions 85 Normal
Background 32 Normal
Total Sessions 117 Normal
# 4. 配置等待事件监控
$ emcli modify_collection_schedule \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-collection_name=”Session_Wait_Time” \
-interval=”5″ \
-interval_unit=”MINUTE”
# 5. 查看等待事件
$ emcli get_metric_data \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”Top_Wait_Events”
Wait Event Wait Time(ms) Wait Count
————————- ————— ———–
db file sequential read 15234 4521
log file sync 8521 2156
db file scattered read 4523 1256
buffer busy waits 2156 523
enq: TX – row lock 1523 125
# 6. 配置阻塞会话监控
$ emcli modify_metric_threshold \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”Blocked_Sessions” \
-warning_threshold=”5″ \
-critical_threshold=”10″
Metric threshold modified successfully
3.2 主机监控
3.2.1 配置主机性能监控
$ emcli get_metrics \
-target_type=”host” \
-target_name=”db-server.fgedu.net.cn”
Metric Name Category Unit
—————————– ————– ————
CPU_Utilization Performance %
Memory_Usage Performance %
Disk_Usage Storage %
Network_Throughput Network KB/s
Process_Count Performance Count
Load_Average Performance Load
# 2. 配置CPU监控
$ emcli modify_metric_threshold \
-target_type=”host” \
-target_name=”db-server.fgedu.net.cn” \
-metric=”CPU_Utilization” \
-warning_threshold=”80″ \
-critical_threshold=”95″
Metric threshold modified successfully
# 3. 查看CPU使用数据
$ emcli get_metric_data \
-target_type=”host” \
-target_name=”db-server.fgedu.net.cn” \
-metric=”CPU_Utilization”
CPU Core Usage(%) Status
—————- ———- ——–
CPU 0 45.2 Normal
CPU 1 52.8 Normal
CPU 2 38.5 Normal
CPU 3 42.1 Normal
CPU Average 44.7 Normal
# 4. 配置内存监控
$ emcli modify_metric_threshold \
-target_type=”host” \
-target_name=”db-server.fgedu.net.cn” \
-metric=”Memory_Usage” \
-warning_threshold=”85″ \
-critical_threshold=”95″
# 5. 查看内存使用情况
$ emcli get_metric_data \
-target_type=”host” \
-target_name=”db-server.fgedu.net.cn” \
-metric=”Memory_Usage”
Memory Type Total(GB) Used(GB) Free(GB) Usage(%)
—————- ———– ———– ———– ———
Physical 64.0 48.5 15.5 75.8
Swap 16.0 2.5 13.5 15.6
# 6. 配置磁盘监控
$ emcli modify_metric_threshold \
-target_type=”host” \
-target_name=”db-server.fgedu.net.cn” \
-metric=”Disk_Usage” \
-warning_threshold=”85″ \
-critical_threshold=”95″
# 7. 查看磁盘使用情况
$ emcli get_metric_data \
-target_type=”host” \
-target_name=”db-server.fgedu.net.cn” \
-metric=”Disk_Usage”
Filesystem Total(GB) Used(GB) Free(GB) Usage(%)
—————- ———– ———– ———– ———
/ 100 45 55 45.0
/oracle 500 385 115 77.0
/u02 1000 850 150 85.0
/tmp 50 15 35 30.0
3.2.2 配置网络和进程监控
$ emcli modify_collection_schedule \
-target_type=”host” \
-target_name=”db-server.fgedu.net.cn” \
-collection_name=”Network_Throughput” \
-interval=”5″ \
-interval_unit=”MINUTE”
# 2. 查看网络吞吐量
$ emcli get_metric_data \
-target_type=”host” \
-target_name=”db-server.fgedu.net.cn” \
-metric=”Network_Throughput”
Interface In(KB/s) Out(KB/s) Total(KB/s)
—————- ———- ———– ———–
eth0 15234 8521 23755
eth1 5234 2156 7390
lo 125 125 250
# 3. 配置进程监控
$ emcli modify_metric_threshold \
-target_type=”host” \
-target_name=”db-server.fgedu.net.cn” \
-metric=”Process_Count” \
-warning_threshold=”500″ \
-critical_threshold=”800″
# 4. 查看关键进程状态
$ emcli get_metric_data \
-target_type=”host” \
-target_name=”db-server.fgedu.net.cn” \
-metric=”Process_Status”
Process Name PID CPU(%) Memory(%) Status
—————— —— ——- ———– ——–
oracle (LOCAL=NO) 12345 15.2 8.5 Running
oracle (LOCAL=NO) 12346 12.8 7.2 Running
tnslsnr 5432 2.5 1.2 Running
ora_pmon_orcl 2345 1.2 0.8 Running
ora_smon_orcl 2346 0.8 0.5 Running
# 5. 配置系统负载监控
$ emcli modify_metric_threshold \
-target_type=”host” \
-target_name=”db-server.fgedu.net.cn” \
-metric=”Load_Average” \
-warning_threshold=”8″ \
-critical_threshold=”12″
# 6. 查看系统负载
$ emcli get_metric_data \
-target_type=”host” \
-target_name=”db-server.fgedu.net.cn” \
-metric=”Load_Average”
Load Type Value Status
—————- ——- ——–
1 Minute 3.5 Normal
5 Minutes 4.2 Normal
15 Minutes 3.8 Normal
3.3 自定义监控
3.3.1 创建自定义监控指标
$ emcli create_metric_extension \
-name=”Custom_DB_Health” \
-target_type=”oracle_database” \
-display_name=”Custom Database Health” \
-collection_frequency=”5″ \
-collection_frequency_unit=”MINUTE”
Metric extension “Custom_DB_Health” created successfully
# 2. 添加指标列
$ emcli add_metric_column \
-extension_name=”Custom_DB_Health” \
-column_name=”INVALID_OBJECTS” \
-display_name=”Invalid Objects Count” \
-data_type=”NUMBER” \
-unit=”Count”
Column added successfully
$ emcli add_metric_column \
-extension_name=”Custom_DB_Health” \
-column_name=”FAILED_JOBS” \
-display_name=”Failed Jobs Count” \
-data_type=”NUMBER” \
-unit=”Count”
Column added successfully
# 3. 配置收集SQL
$ emcli set_metric_sql \
-extension_name=”Custom_DB_Health” \
-sql=”SELECT
(SELECT COUNT(*) FROM dba_objects WHERE status=’INVALID’) as INVALID_OBJECTS,
(SELECT COUNT(*) FROM dba_scheduler_job_run_details WHERE status=’FAILED’ AND log_date > SYSDATE-1) as FAILED_JOBS
FROM dual”
SQL configured successfully
# 4. 部署指标扩展
$ emcli deploy_metric_extension \
-name=”Custom_DB_Health” \
-version=”1.0″ \
-targets=”prod_orcl:oracle_database”
Metric extension deployed successfully
# 5. 配置阈值
$ emcli modify_metric_threshold \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”Custom_DB_Health:INVALID_OBJECTS” \
-warning_threshold=”10″ \
-critical_threshold=”50″
Metric threshold modified successfully
# 6. 查看自定义指标数据
$ emcli get_metric_data \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”Custom_DB_Health”
Column Name Value Status
—————— ——- ——–
INVALID_OBJECTS 5 Normal
FAILED_JOBS 2 Normal
3.3.2 创建监控仪表板
$ emcli create_dashboard \
-name=”Production_DB_Overview” \
-description=”Production databases monitoring overview” \
-owner=”sysman”
Dashboard “Production_DB_Overview” created successfully
# 2. 添加仪表板组件
$ emcli add_dashboard_widget \
-dashboard_name=”Production_DB_Overview” \
-widget_type=”CHART” \
-title=”CPU Utilization Trend” \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”CPU_Utilization” \
-time_range=”LAST_24_HOURS”
Widget added successfully
$ emcli add_dashboard_widget \
-dashboard_name=”Production_DB_Overview” \
-widget_type=”GAUGE” \
-title=”Active Sessions” \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”Active_Sessions”
Widget added successfully
$ emcli add_dashboard_widget \
-dashboard_name=”Production_DB_Overview” \
-widget_type=”TABLE” \
-title=”Tablespace Usage” \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”Tablespace_Usage”
Widget added successfully
# 3. 共享仪表板
$ emcli share_dashboard \
-name=”Production_DB_Overview” \
-users=”dba_team” \
-permission=”VIEW”
Dashboard shared successfully
# 4. 创建监控报告
$ emcli create_report_definition \
-name=”Daily_Monitoring_Report” \
-report_type=”MONITORING” \
-targets=”Production_Databases” \
-schedule=”DAILY” \
-email=”dba-team@fgedu.net.cn” \
-include_metrics=”CPU_Utilization,Memory_Usage,Tablespace_Usage,Active_Sessions”
Report definition created successfully
# 5. 生成即时报告
$ emcli generate_report \
-name=”Daily_Monitoring_Report” \
-output_file=”/tmp/daily_report.pdf”
Report generated successfully
# 6. 查看仪表板列表
$ emcli list_dashboards
Dashboard Name Owner Shared Created
————————– ——— ——– ——————-
Production_DB_Overview sysman Yes 2026-03-31 10:00:00
Host_Health_Summary sysman No 2026-03-30 15:30:00
Performance_Analysis sysman Yes 2026-03-29 09:00:00
Part04-生产案例与实战讲解
4.1 监控案例
某大型企业EMCC监控配置实战案例:
– 监控目标:300+ Oracle数据库,200+ 主机
– 环境分类:核心生产、一般生产、测试开发
– 监控要求:分级监控,差异化配置
– 目标:建立完善的监控体系
# 监控实施步骤
# 1. 创建监控模板
# 核心生产模板
$ emcli create_monitoring_template \
-name=”Core_Production_Monitoring” \
-target_type=”oracle_database” \
-description=”High-frequency monitoring for core production databases”
$ emcli add_template_metrics \
-name=”Core_Production_Monitoring” \
-target_type=”oracle_database” \
-metrics=”CPU_Utilization:70:90:1_MINUTE,Memory_Usage:80:95:1_MINUTE,Active_Sessions:100:200:1_MINUTE,Tablespace_Usage:85:95:5_MINUTE”
# 一般生产模板
$ emcli create_monitoring_template \
-name=”Standard_Production_Monitoring” \
-target_type=”oracle_database” \
-description=”Standard monitoring for production databases”
$ emcli add_template_metrics \
-name=”Standard_Production_Monitoring” \
-target_type=”oracle_database” \
-metrics=”CPU_Utilization:80:95:5_MINUTE,Memory_Usage:85:95:5_MINUTE,Active_Sessions:150:300:5_MINUTE,Tablespace_Usage:85:95:15_MINUTE”
# 测试开发模板
$ emcli create_monitoring_template \
-name=”Dev_Test_Monitoring” \
-target_type=”oracle_database” \
-description=”Basic monitoring for dev/test databases”
$ emcli add_template_metrics \
-name=”Dev_Test_Monitoring” \
-target_type=”oracle_database” \
-metrics=”CPU_Utilization:90:95:15_MINUTE,Memory_Usage:90:95:15_MINUTE,Tablespace_Usage:90:95:30_MINUTE”
# 2. 批量应用监控模板
$ cat /software/apply_monitoring.sh
#!/bin/bash
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
# 应用核心生产模板
emcli apply_monitoring_template \
-name=”Core_Production_Monitoring” \
-group=”Core_Production_Databases”
# 应用一般生产模板
emcli apply_monitoring_template \
-name=”Standard_Production_Monitoring” \
-group=”Standard_Production_Databases”
# 应用测试开发模板
emcli apply_monitoring_template \
-name=”Dev_Test_Monitoring” \
-group=”Dev_Test_Databases”
echo “Monitoring templates applied successfully”
# 3. 创建监控仪表板
$ emcli create_dashboard \
-name=”Enterprise_DB_Overview” \
-description=”Enterprise-wide database monitoring overview”
# 添加汇总组件
$ emcli add_dashboard_widget \
-dashboard_name=”Enterprise_DB_Overview” \
-widget_type=”SUMMARY” \
-title=”Database Status Summary” \
-target_type=”oracle_database” \
-group=”All_Databases”
# 4. 配置监控报告
$ emcli create_report_definition \
-name=”Weekly_Monitoring_Summary” \
-report_type=”MONITORING” \
-schedule=”WEEKLY” \
-email=”dba-team@fgedu.net.cn,management@fgedu.net.cn” \
-include_sections=”AVAILABILITY,PERFORMANCE,CAPACITY,ALERTS”
# 5. 监控效果统计
$ cat /software/monitoring_stats.sh
#!/bin/bash
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
echo “=== EMCC Monitoring Statistics ===”
echo “”
echo “Total Targets Monitored:”
emcli get_targets -target_type=”oracle_database” | wc -l
echo “”
echo “Active Alerts:”
emcli get_alerts -status=”Active” | wc -l
echo “”
echo “Monitoring Data Collected (Last 24h):”
emcli get_collection_statistics -time_range=”LAST_24_HOURS”
echo “”
echo “Dashboard Views (Last 7 days):”
emcli get_dashboard_usage -time_range=”LAST_7_DAYS”
# 执行统计
$ ./monitoring_stats.sh
=== EMCC Monitoring Statistics ===
Total Targets Monitored: 315
Active Alerts: 12
Monitoring Data Collected (Last 24h):
Collections: 1,256,789
Data Points: 15,234,567
Storage Used: 125.5 GB
Dashboard Views (Last 7 days):
Total Views: 2,456
Unique Users: 45
# 监控结果
# – 成功监控315个数据库
# – 平均告警响应时间从4小时降至15分钟
# – 系统可用性从99.5%提升至99.9%
# – 监控覆盖率100%
4.2 监控故障处理
EMCC监控常见故障处理:
# 症状:指标显示无数据
# 诊断步骤
$ emcli get_collection_status \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”CPU_Utilization”
Collection Status: FAILED
Last Collection: 2026-03-31 08:00:00
Error: ORA-01017: invalid username/password
# 检查Agent状态
$ ssh oracle@db-server
$ /opt/oracle/agent/agent_inst/bin/emctl status agent
Agent is Running and Ready
# 查看Agent日志
$ tail -f /opt/oracle/agent/agent_inst/sysman/log/gcagent.log
# 解决方案
# 1. 更新目标凭证
$ emcli modify_target \
-name=”prod_orcl” \
-type=”oracle_database” \
-credentials=”UserName:dbsnmp;Password:NewPassword123;Role:Normal”
# 2. 测试连接
$ emcli test_target_connection \
-name=”prod_orcl” \
-type=”oracle_database”
Connection test successful
# 3. 手动触发收集
$ emcli collect_metric \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”CPU_Utilization”
Collection completed successfully
# 故障2:告警未触发
# 症状:指标超过阈值但未产生告警
# 诊断步骤
$ emcli get_metric_threshold \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”CPU_Utilization”
Warning Threshold: 80
Critical Threshold: 95
Current Value: 92
# 检查告警规则
$ emcli get_notification_rules \
-target_name=”prod_orcl”
No notification rules found
# 解决方案
# 1. 创建告警规则
$ emcli create_notification_rule \
-name=”DB_CPU_Alert_Rule” \
-target_type=”oracle_database” \
-targets=”prod_orcl” \
-severity=”Warning,Critical” \
-notification_method=”Email” \
-recipients=”dba-team@fgedu.net.cn”
Notification rule created successfully
# 2. 手动触发告警检查
$ emcli evaluate_metric_threshold \
-target_type=”oracle_database” \
-target_name=”prod_orcl” \
-metric=”CPU_Utilization”
Alert generated: CPU_Utilization exceeded warning threshold
# 故障3:监控数据延迟
# 症状:监控数据延迟超过预期
# 诊断步骤
$ emcli get_collection_lag \
-target_type=”oracle_database” \
-target_name=”prod_orcl”
Collection Lag: 15 minutes
Expected: 5 minutes
# 检查Agent上传状态
$ emcli get_agent_upload_status \
-agent=”db-server.fgedu.net.cn:3872″
Upload Queue Size: 5000 pending
Last Upload: 15 minutes ago
# 解决方案
# 1. 检查网络带宽
$ ping -c 5 oms-server.fgedu.net.cn
# 2. 增加Agent上传频率
$ emcli set_agent_property \
-agent=”db-server.fgedu.net.cn:3872″ \
-name=”UploadInterval” \
-value=”1″
# 3. 清理积压数据
$ emcli purge_agent_queue \
-agent=”db-server.fgedu.net.cn:3872″
# 4. 重启Agent
$ /opt/oracle/agent/agent_inst/bin/emctl stop agent
$ /opt/oracle/agent/agent_inst/bin/emctl start agent
# 故障4:仪表板加载缓慢
# 症状:仪表板加载时间过长
# 诊断步骤
$ emcli get_dashboard_performance \
-name=”Production_DB_Overview”
Load Time: 45 seconds
Widget Count: 25
Data Points: 500,000
# 解决方案
# 1. 减少仪表板组件数量
$ emcli remove_dashboard_widget \
-dashboard_name=”Production_DB_Overview” \
-widget_id=”widget_15,widget_16,widget_17″
# 2. 优化数据查询
$ emcli optimize_dashboard \
-name=”Production_DB_Overview” \
-enable_caching=”true”
# 3. 调整时间范围
$ emcli modify_dashboard_widget \
-dashboard_name=”Production_DB_Overview” \
-widget_id=”widget_1″ \
-time_range=”LAST_1_HOUR”
4.3 监控优化
EMCC监控性能优化实践:
# 对非关键指标降低收集频率
$ emcli modify_collection_schedule \
-target_type=”oracle_database” \
-group=”All_Databases” \
-collection_name=”Segment_Advisor_Recommendations” \
-interval=”60″ \
-interval_unit=”MINUTE”
# 批量优化
$ cat /tmp/optimize_collections.csv
target_type,collection_name,new_interval
oracle_database,Segment_Advisor_Recommendations,60
oracle_database,SQL_Net_Configuration,120
oracle_database,Database_Features,240
$ emcli modify_collection_schedules -input_file=”/tmp/optimize_collections.csv”
# 优化2:优化数据保留
# 调整监控数据保留策略
$ emcli set_repository_property \
-name=”metric_data_retention” \
-value=”30″
# 配置分区
$ emcli configure_partitioning \
-table_name=”mgmt_metrics_raw” \
-retention_days=”30″ \
-partition_type=”RANGE”
# 优化3:启用数据压缩
$ emcli enable_metric_compression \
-compression_type=”ADVANCED” \
-tables=”mgmt_metrics_raw,mgmt_metrics_hourly”
Compression enabled successfully
# 优化4:优化Agent性能
# 调整Agent资源配置
$ emcli set_agent_property \
-agent=”db-server.fgedu.net.cn:3872″ \
-name=”MaxCollectionThreads” \
-value=”10″
$ emcli set_agent_property \
-agent=”db-server.fgedu.net.cn:3872″ \
-name=”UploadFileSize” \
-value=”50″
# 优化5:监控性能报告
# 创建监控性能分析脚本
$ cat /software/monitoring_performance.sh
#!/bin/bash
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
echo “=== EMCC Monitoring Performance Report ===”
echo “”
echo “Collection Performance:”
emcli get_collection_statistics -time_range=”LAST_24_HOURS” | \
awk ‘{total+=$2; count++} END {print “Average Collections/Hour: ” total/count}’
echo “”
echo “Upload Performance:”
emcli get_upload_statistics -time_range=”LAST_24_HOURS” | \
awk ‘{total+=$3; count++} END {print “Average Upload Size: ” total/count ” KB”}’
echo “”
echo “Alert Response Time:”
emcli get_alert_statistics -time_range=”LAST_24_HOURS” | \
awk ‘{sum+=$4; count++} END {print “Average Response Time: ” sum/count ” minutes”}’
echo “”
echo “Repository Storage:”
emcli get_repository_storage | \
awk ‘{used+=$3} END {print “Total Storage Used: ” used ” GB”}’
# 添加到crontab
$ crontab -e
0 8 * * * /software/monitoring_performance.sh | mail -s “EMCC Performance Report” dba-team@fgedu.net.cn
# 优化6:监控容量规划
# 创建容量预测报告
$ emcli create_capacity_report \
-name=”Database_Capacity_Forecast” \
-target_type=”oracle_database” \
-forecast_days=”90″ \
-metrics=”Tablespace_Usage,Session_Count” \
-schedule=”MONTHLY” \
-email=”dba-team@fgedu.net.cn”
Capacity report created successfully
Part05-风哥经验总结与分享
5.1 EMCC监控总结
EMCC监控的关键经验总结:
- 分级监控:根据业务重要性分级配置监控策略
- 合理阈值:基于基线设置合理阈值,避免告警风暴
- 定期审查:定期审查监控配置,优化监控效率
- 可视化:利用仪表板实现监控数据可视化
- 自动化:使用模板和脚本实现监控配置自动化
- 持续优化:持续优化监控性能,减少资源消耗
5.2 监控检查清单
# 监控配置检查
□ 监控模板配置
□ 指标收集配置
□ 阈值设置
□ 告警规则配置
□ 通知方式配置
# 数据库监控检查
□ CPU使用率监控
□ 内存使用率监控
□ 表空间使用监控
□ 会话数监控
□ 等待事件监控
□ 备份状态监控
# 主机监控检查
□ CPU使用率监控
□ 内存使用率监控
□ 磁盘空间监控
□ 网络吞吐量监控
□ 进程状态监控
□ 系统负载监控
# 监控性能检查
□ 收集频率合理性
□ 数据保留策略
□ Agent性能状态
□ Repository存储空间
□ 网络带宽使用
5.3 监控工具推荐
EMCC监控推荐工具:
| 工具名称 | 用途 | 说明 |
|---|---|---|
| EMCC Console | 图形监控 | 直观的图形界面监控 |
| EMCLI | 命令行监控 | 批量配置和自动化脚本 |
| Dashboard | 可视化展示 | 自定义监控仪表板 |
| Performance Hub | 性能分析 | 实时性能分析和诊断 |
| ASH Analytics | 会话分析 | 活动会话历史分析 |
| AWR Report | 性能报告 | 自动工作负载仓库报告 |
- 建立分级监控策略,差异化配置
- 定期审查和优化监控配置
- 使用仪表板实现监控可视化
- 建立监控数据基线,合理设置阈值
- 定期生成监控报告,分析趋势
- 持续优化监控性能,减少资源消耗
本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html
