oracledb-exporter部署手册

目录

  • oracledb-exporter部署手册
    • 来源
    • 说明
    • 部署方式
      • docker部署:
      • 二进制文件安装
        • 设置开机自启
    • 关于与数据库的 TLS 连接

oracledb-exporter部署手册

来源

https://github.com/iamseth/oracledb_exporter

说明

  一款模仿 MySQL 导出器的 Oracle的Prometheus导出器。

目前已公开的指标:

  • oracledb_exporter_last_scrape_duration_seconds
  • oracledb_exporter_last_scrape_error
  • oracledb_exporter_scrapes_total
  • oracledb_up
  • oracledb_activity_execute_count
  • oracledb_activity_parse_count_total
  • oracledb_activity_user_commits
  • oracledb_activity_user_rollbacks
  • oracledb_sessions_activity
  • oracledb_wait_time_application
  • oracledb_wait_time_commit
  • oracledb_wait_time_concurrency
  • oracledb_wait_time_configuration
  • oracledb_wait_time_network
  • oracledb_wait_time_other
  • oracledb_wait_time_scheduler
  • oracledb_wait_time_system_io
  • oracledb_wait_time_user_io
  • oracledb_tablespace_bytes
  • oracledb_tablespace_max_bytes
  • oracledb_tablespace_free
  • oracledb_process_count
  • oracledb_resource_current_utilization
  • oracledb_resource_limit_value

部署方式

docker部署:

docker run -d --name oracle -p 1521:1521 wnameless/oracle-xe-11g-r2:18.04-apex
docker run -d --name oracledb_exporter --link=oracle -p 9161:9161 -e DATA_SOURCE_NAME=system/oracle@oracle/xe iamseth/oracledb_exporter

注:

配置项 解释
–link=oracle 与容器名为oracle的数据库建立连接
-p 9161:9161 对外开放的端口
-e DATA_SOURCE_NAME=system/oracle@oracle/xe 数据源配置信息(管理员账号/密码@数据库/库名)
iamseth/oracledb_exporter 镜像名

二进制文件安装

注:
确保在启动前正确设置环境变量 DATA_SOURCE_NAME。DATA_SOURCE_NAME 应采用 Oracle EZCONNECT 格式:
https://docs.oracle.com/en/database/oracle/oracle-database/19/netag/configuring-naming-methods.html#GUID-B0437826-43C1-49EC-A94D- B650B6A4A6EE

19c Oracle 客户端支持增强型 EZCONNECT,您可以故障转移到备用数据库或从活动备用数据库收集一些重要指标并指定一些附加参数。在 19c 客户端中,您也可以连接 12c 主/备用数据库
例如:

# export Oracle location:
export DATA_SOURCE_NAME=system/password@oracle-sid
# or using a complete url:
export DATA_SOURCE_NAME=user/password@//myhost:1521/service
# 19c client for primary/standby configuration
export DATA_SOURCE_NAME=user/password@//primaryhost:1521,standbyhost:1521/service
# 19c client for primary/standby configuration with options
export DATA_SOURCE_NAME=user/password@//primaryhost:1521,standbyhost:1521/service?connect_timeout=5&transport_connect_timeout=3&retry_count=3
# 19c client for ASM instance connection (requires SYSDBA)
export DATA_SOURCE_NAME=user/password@//primaryhost:1521,standbyhost:1521/+ASM?as=sysdba
# Then run the exporter
/path/to/binary/oracledb_exporter --log.level error --web.listen-address 0.0.0.0:9161
设置开机自启
  • 创建oracledb_exporter用户禁用登录和oracledb_exporter组
    mkdir /etc/oracledb_exporter
    chown root:oracledb_exporter /etc/oracledb_exporter
    chmod 775 /etc/oracledb_exporter
    
  • 将配置文件放入/etc/oracledb_exporter
  • 将二进制文件放入/usr/local/bin
  • 使用以下内容创建文件/etc/systemd/system/oracledb_exporter.service:
[Unit]
Description=Service for oracle telemetry client
After=network.target
[Service]
Type=oneshot
#!!! Set your values and uncomment
#User=oracledb_exporter
#Group=oracledb_exporter
#Environment="DATA_SOURCE_NAME=dbsnmp/Bercut01@//primaryhost:1521,standbyhost:1521/myservice?transport_connect_timeout=5&retry_count=3"
#Environment="LD_LIBRARY_PATH=/u01/app/oracle/product/19.0.0/dbhome_1/lib"
#Environment="ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1"
#Environment="CUSTOM_METRICS=/etc/oracledb_exporter/custom-metrics.toml"
ExecStart=/usr/local/bin/oracledb_exporter  \
  --default.metrics "/etc/oracledb_exporter/default-metrics.toml"  \
  --log.level error --web.listen-address 0.0.0.0:9161
[Install]
WantedBy=multi-user.target
  • 然后重新读取文件:
    systemctl daemon-reload
    
  • 启动这个新服务:
    systemctl start oracledb_exporter
    
  • 检查服务状态:
    systemctl status oracledb_exporter
    

上面的ExecStart=/usr/local/bin/oracledb_exporter \ 后面的其他配置可选项:

Usage of oracledb_exporter:
  --log.format value
       	If set use a syslog logger or JSON logging. Example: logger:syslog?appname=bob&local=7 or logger:stdout?json=true. Defaults to stderr.
  --log.level value
       	Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal].
  --custom.metrics string
        File that may contain various custom metrics in a TOML file.
  --default.metrics string
        Default TOML file metrics.
  --web.listen-address string
       	Address to listen on for web interface and telemetry. (default ":9161")
  --web.telemetry-path string
       	Path under which to expose metrics. (default "/metrics")
  --database.maxIdleConns string
        Number of maximum idle connections in the connection pool. (default "0")
  --database.maxOpenConns string
        Number of maximum open connections in the connection pool. (default "10")
  --web.secured-metrics  boolean
        Expose metrics using https server. (default "false")
  --web.ssl-server-cert string
        Path to the PEM encoded certificate file.
  --web.ssl-server-key string
        Path to the PEM encoded key file.

该exporter同时提供自定义指标功能,这里不展开叙述;
自定义指标

关于与数据库的 TLS 连接

  • 首先,设置以下变量:
export WALLET_PATH=/wallet/path/to/use
export TNS_ENTRY=tns_entry
export DB_USERNAME=db_username
export TNS_ADMIN=/tns/admin/path/to/use
  • 创建wallet并设置凭证:
mkstore -wrl $WALLET_PATH -create
mkstore -wrl $WALLET_PATH -createCredential $TNS_ENTRY $DB_USERNAME
  • 然后,更新 sqlnet.ora:
echo "
WALLET_LOCATION = (SOURCE = (METHOD = FILE) (METHOD_DATA = (DIRECTORY = $WALLET_PATH )))
SQLNET.WALLET_OVERRIDE = TRUE
SSL_CLIENT_AUTHENTICATION = FALSE
" >> $TNS_ADMIN/sqlnet.ora
  • 要使用wallet,请使用 wallet_location 参数。您可能需要使用 ssl_server_dn_match 参数禁用 ssl 验证。
    这是字符串连接的完整示例:
DATA_SOURCE_NAME=username/password@tcps://dbhost:port/service?ssl_server_dn_match=false&wallet_location=wallet_path

有关更多详细信息,请查看以下位置:https : //github.com/iamseth/oracledb_exporter/issues/84

你可能感兴趣的:(oracle,数据库,java)