Skip to content

Commit ae5164b

Browse files
Document multi-db tns admin (#269)
Document multi-db tns admin Signed-off-by: Anders Swanson <[email protected]>
1 parent 493febe commit ae5164b

File tree

1 file changed

+120
-18
lines changed

1 file changed

+120
-18
lines changed

README.md

Lines changed: 120 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,57 @@ Contributions are welcome - please see [contributing](CONTRIBUTING.md).
3131

3232
## Table of Contents
3333

34-
- [Release Notes](#release-notes)
35-
- [Roadmap](#roadmap)
36-
- [Standard metrics](#standard-metrics)
37-
- [Database permissions required](#database-permissions-required)
38-
- [Alert logs](#alert-logs)
39-
- [Installation](#installation)
40-
- [Docker, podman, etc.](#docker-podman-etc)
41-
- [Test/demo environment using Docker Compose](#testdemo-environment-with-docker-compose)
42-
- [Kubernetes](#kubernetes)
43-
- [Standalone binary](#standalone-binary)
44-
- [Using OCI Vault](#using-oci-vault)
45-
- [Using Azure Vault](#using-azure-vault)
46-
- [Custom metrics](#custom-metrics)
47-
- [Controlling memory usage](#controlling-memory-usage)
48-
- [Grafana dashboards](#grafana-dashboards)
49-
- [Monitoring Transactional Event Queues](#monitoring-transactional-event-queues)
50-
- [Developer notes](#developer-notes)
34+
35+
* [Unified Observability for Oracle Database](#unified-observability-for-oracle-database)
36+
* [Main Features](#main-features)
37+
* [Table of Contents](#table-of-contents)
38+
* [Releases](#releases)
39+
* [Roadmap](#roadmap)
40+
* [Standard metrics](#standard-metrics)
41+
* [Database permissions required](#database-permissions-required)
42+
* [Alert logs](#alert-logs)
43+
* [Installation](#installation)
44+
* [Docker, Podman, etc](#docker-podman-etc)
45+
* [Oracle Database](#oracle-database)
46+
* [Exporter](#exporter)
47+
* [Simple connection](#simple-connection)
48+
* [Using a wallet](#using-a-wallet)
49+
* [Test/demo environment with Docker Compose](#testdemo-environment-with-docker-compose)
50+
* [Kubernetes](#kubernetes)
51+
* [Create a secret with credentials for connecting to the Oracle Database](#create-a-secret-with-credentials-for-connecting-to-the-oracle-database)
52+
* [Create a config map for the exporter configuration file (recommended)](#create-a-config-map-for-the-exporter-configuration-file-recommended)
53+
* [Create a config map for the wallet (optional)](#create-a-config-map-for-the-wallet-optional)
54+
* [Create a config map for your metrics definition file (optional)](#create-a-config-map-for-your-metrics-definition-file-optional)
55+
* [Deploy the Oracle Database Observability exporter](#deploy-the-oracle-database-observability-exporter)
56+
* [Create a Kubernetes service for the exporter](#create-a-kubernetes-service-for-the-exporter)
57+
* [Create a Kubernetes service monitor](#create-a-kubernetes-service-monitor)
58+
* [Configure a Prometheus target (optional)](#configure-a-prometheus-target-optional)
59+
* [Import Grafana dashboard definition(s) (optional)](#import-grafana-dashboard-definitions-optional)
60+
* [Standalone binary](#standalone-binary)
61+
* [Scraping multiple databases](#scraping-multiple-databases)
62+
* [Configuring connections for multiple databases using Oracle Database wallet(s)](#configuring-connections-for-multiple-databases-using-oracle-database-wallets)
63+
* [Scraping metrics from specific databases](#scraping-metrics-from-specific-databases)
64+
* [Using OCI Vault](#using-oci-vault)
65+
* [OCI Vault CLI Configuration](#oci-vault-cli-configuration)
66+
* [Using Azure Vault](#using-azure-vault)
67+
* [Azure Vault CLI Configuration](#azure-vault-cli-configuration)
68+
* [Authentication](#authentication)
69+
* [Custom metrics](#custom-metrics)
70+
* [Customize metrics in a container image](#customize-metrics-in-a-container-image)
71+
* [Controlling memory usage](#controlling-memory-usage)
72+
* [Grafana dashboards](#grafana-dashboards)
73+
* [Monitoring Transactional Event Queues](#monitoring-transactional-event-queues)
74+
* [How to create some traffic with PL/SQL](#how-to-create-some-traffic-with-plsql)
75+
* [How to create some traffic with Java (Spring Boot)](#how-to-create-some-traffic-with-java-spring-boot)
76+
* [Metrics definitions](#metrics-definitions)
77+
* [Additional database permissions](#additional-database-permissions)
78+
* [Grafana dashboard](#grafana-dashboard)
79+
* [Developer notes](#developer-notes)
80+
* [Docker/container build](#dockercontainer-build)
81+
* [Building Binaries](#building-binaries)
82+
* [Contributing](#contributing)
83+
* [Security](#security)
84+
* [License](#license)
5185

5286
## Releases
5387

@@ -812,9 +846,77 @@ log:
812846
# disable: 0
813847
```
814848

849+
#### Configuring connections for multiple databases using Oracle Database wallet(s)
850+
851+
The Oracle Database Metrics exporter uses ODPI-C, which can only initalize the TNS aliases from a `tnsnames.ora` file once per process. To work around this, the exporter can be configured to read from a "combined" `tnsnames.ora` file containing all TNS aliases for connections in a multi-database configuration.
852+
853+
1. For each database the exporter will connect to, download the corresponding wallet files. If you're using ADB/ATP-S, download the regional wallet instead of the instance wallet if the databases are in the same region.
854+
855+
2. Copy the TNS aliases the `tnsnames.ora` file from each wallet, and combine them into one file, so all your database service names are in one file together
856+
857+
3. In the combined `tnsnames.ora` file, and add the following snippet to each TNS alias connection string, to tell the client where the wallet directory is:
858+
859+
```
860+
(security=(MY_WALLET_DIRECTORY=/path/to/this/database/wallet))
861+
```
862+
863+
The combined `tnsnames.ora` file, which contains the TNS aliases for both databases, and their corresponding wallet location in the `security` configuration will look something like the following:
864+
865+
```sql
866+
db1_high = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.****.oraclecloud.com))(connect_data=(service_name=****.adb.oraclecloud.com))(security=(MY_WALLET_DIRECTORY=/wallets/db1)(ssl_server_dn_match=yes)))
867+
868+
db2_high = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.****.oraclecloud.com))(connect_data=(service_name=****.adb.oraclecloud.com))(security=(MY_WALLET_DIRECTORY=/wallets/db2)(ssl_server_dn_match=yes)))
869+
```
870+
871+
4. Take wallet files (cwallet.sso, ewallet.p12, & ewallet.pem) for each database, and place them in separate directories. For example, `db1` gets its own directory, `db2` gets its own directory, and so forth.
872+
873+
The resulting directory structure should look like the following, with wallet information separate from the combined `tnsnames.ora` file:
874+
875+
```
876+
wallets
877+
├── combined
878+
│ ├── sqlnet.ora
879+
│ └── tnsnames.ora // Combined tnsnames.ora
880+
├── db1
881+
│ ├── cwallet.sso
882+
│ ├── ewallet.p12
883+
│ └── ewallet.pem
884+
└── db2
885+
├── cwallet.sso
886+
├── ewallet.p12
887+
└── ewallet.pem
888+
```
889+
890+
5. Set the `TNS_ADMIN` environment variable where the exporter is running to the directory containing your combined `tnsnames.ora` file:
891+
892+
```
893+
export TNS_ADMIN=/wallets/combined/tnsnames.ora
894+
```
895+
896+
6. Finally, update the exporter configuration file to include the TNS aliases for all databases you will be connecting to. Ensure your database configuration file does not use the `tnsAdmin` property, as we are using the global `TNS_ADMIN` environment variable to point to the combined `tnsnames.ora` file:
897+
898+
```yaml
899+
databases:
900+
db2:
901+
username: ****
902+
password: ****
903+
url: db2_high
904+
queryTimeout: 5
905+
maxOpenConns: 10
906+
maxIdleConns: 10
907+
db1:
908+
username: ****
909+
password: ****
910+
url: db1_high
911+
queryTimeout: 5
912+
maxOpenConns: 10
913+
maxIdleConns: 10
914+
```
915+
916+
Then, run the exporter with the config file:
815917
816918
```shell
817-
./oracledb_exporter --log.destination="./alert.log" --default.metrics="./default-metrics.toml"
919+
./oracledb_exporter --config.file=my-config-file.yaml
818920
```
819921
820922
#### Scraping metrics from specific databases

0 commit comments

Comments
 (0)