Skip to content

Commit

Permalink
WMSID 11640: new instructions with SQLcl and tnsnames resolution (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcaldara-oracle authored Jul 18, 2024
1 parent 2259827 commit 78c893b
Show file tree
Hide file tree
Showing 32 changed files with 1,262 additions and 1,154 deletions.
84 changes: 45 additions & 39 deletions data-guard/active-data-guard-23ai/awr-snapshots/awr-snapshots.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Create AWR reports on the standby database

## Introduction
In real-world environments, it is common to require Automatic Workload Repository (AWR) reports for the standby databases to troubleshoot the redo apply throughput or the standby database performance in general.

Before Oracle Database 23ai, it wasn't possible to create a snapshot on the standby without configuring a SYS$UMF topology. The process was cumbersome and required manual intervention after a role change (e.g. switchover). Oracle Database 23ai greatly simplify the task by allowing the seamless creation of AWR snapshots!


Estimated Lab Time: 5 Minutes
Expand All @@ -9,7 +11,8 @@ Estimated Lab Time: 5 Minutes
To try this lab, you must have successfully completed the following labs:
* [Prepare the database hosts](../prepare-host/prepare-host.md)
* [Prepare the databases](../prepare-db/prepare-db.md)
* [Configure and Verify Data Guard](../configure-dg/configure-dg.md)
* [Configure Data Guard](../configure-dg/configure-dg.md)
* [Verify the Data Guard configuration](../verify-dg/verify-dg.md)

### Objectives
* Create two AWR snapshots
Expand All @@ -18,59 +21,62 @@ To try this lab, you must have successfully completed the following labs:

## Task 1: Create two AWR snapshost

On the host where the standby database is running (adghol1), connect as SYSDBA and create an AWR snapshot:
1. On the host where the standby database is running (adghol1), connect as SYSDBA and create an AWR snapshot:

```
<copy>
sqlplus / as sysdba
</copy>
```
```
<copy>
sql / as sysdba
</copy>
```
```
<copy>
select dbms_workload_repository.create_snapshot();
</copy>
```
```
<copy>
select dbms_workload_repository.create_snapshot();
</copy>
```
Before Oracle Database 23ai, it wasn't possible to create a snapshot on the standby without configuring a SYS$UMF topology. The process was cumbersome and error-prone. Oracle Database 23ai greatly simplify our task!
Wait 1-2 minutes and create another snapshot:
2. Wait 1-2 minutes and create another snapshot:
```
<copy>
select dbms_workload_repository.create_snapshot();
</copy>
```
```
<copy>
select dbms_workload_repository.create_snapshot();
</copy>
```
![Creation of two AWR snapshots](images/create-snapshots.png)
![Creation of two AWR snapshots](images/create-snapshots.png)
## Task 2: Create an AWR report
```
<copy>
@?/rdbms/admin/awrrpt
</copy>
```
1. Run the script `awrrpt.sql` to create an AWR report:
```
<copy>
@?/rdbms/admin/awrrpt
</copy>
```
![First part of the report creation](images/awrrpt-1.png)
![First part of the report creation](images/awrrpt-1.png)
You will notice that the DBID list shows a different DBID for the standby database. This is because the new DBID is generated syntetically to distinguish the primary snapshots from the standby snapshots.
2. Select **text** as the report_type.
You will notice that the DBID list shows a different DBID for the standby database. This is because the new DBID is generated syntetically to distinguish the primary snapshots from the standby snapshots.
The DBID and SID are pre-selected by the reporting tool, so you only need to specify the number of days, and the snapshots to generate the report (1 and 2):
3. The DBID and SID are pre-selected by the reporting tool, so you only need to specify the number of days (**1**), and the snapshots to generate the report (**1** and **2**):
![Second part of the report creation](images/awrrpt-2.png)
![Third part of the report creation](images/awrrpt-3.png)
![Second part of the report creation](images/awrrpt-2.png)
![Third part of the report creation](images/awrrpt-3.png)
## Task 3: Review the report
```
<copy>
exit
less awrrpt_1_1_2.txt
</copy>
```
1. Exit SQLcl and open the AWR report for reading:
```
<copy>
exit
less awrrpt_1_1_2.txt
</copy>
```
![The AWR report belongs to the standby database](images/view-report.png)
![The AWR report belongs to the standby database](images/view-report.png)
You will notice that the AWR report belongs to the standby database.
You have successfully created AWR reports for the standby database. This concludes the Data Guard overview workshop.
Expand All @@ -79,4 +85,4 @@ Well done!
- **Author** - Ludovico Caldara, Product Manager Data Guard, Active Data Guard and Flashback Technologies
- **Contributors** - Robert Pastijn
- **Last Updated By/Date** - Ludovico Caldara, June 2024
- **Last Updated By/Date** - Ludovico Caldara, July 2024
174 changes: 89 additions & 85 deletions data-guard/active-data-guard-23ai/configure-dg/configure-dg.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,95 +24,99 @@ To try this lab, you must have successfully completed:

You should have two Cloud Shell tabs connected to the primary and secondary hosts, adghol0 and adghol1. If you don't, follow the first steps of Lab 1 until you have both SSH connections established.

1. From a terminal (which one of the two is irrelevant for this task), connect to the primary database using the broker client command line (DGMGRL). We use the DGConnectIdentifier for that (the service named after the db_unique_name). Replace `ADGHOL0_DGCI` with the one noted down during Lab 2.

```
<copy>
dgmgrl sys/WElcome123##@ADGHOL0_DGCI
</copy>
```
For example:
```
dgmgrl sys/WElcome123##@adghol0-1234.ll1234pubsubnt.ll1234vcn.oraclevcn.com:1521/adghol_53k_lhr.ll1234pubsubnt.ll1234vcn.oraclevcn.com
```

1. Create the configuration using the `CREATE CONFIGURATION` command. Again, replace `ADGHOL0_DGCI` with the actual connect string and `ADGHOL0_UNIQUE_NAME` with the actual db_unique_name:

```
<copy>
create configuration adghol primary database is ADGHOL0_UNIQUE_NAME connect identifier is 'ADGHOL0_DGCI';
</copy>
```
For example:
```
create configuration adghol primary database is adghol_53k_lhr connect identifier is 'adghol0-1234.ll1234pubsubnt.ll1234vcn.oraclevcn.com:1521/adghol_53k_lhr.ll1234pubsubnt.ll1234vcn.oraclevcn.com';
```

1. Add the standby database to the configuration using the `ADD DATABASE` command. Replace `ADGHOL1_DGCI` and `ADGHOL1_UNIQUE_NAME` with the actual connect string and db_unique_name of the standby database:

```
<copy>
add database ADGHOL1_UNIQUE_NAME as connect identifier is 'ADGHOL1_DGCI';
</copy>
```
For example:
```
add database adghol_p4n_lhr as connect identifier is 'adghol1-1234.ll1234pubsubnt.ll1234vcn.oraclevcn.com:1521/adghol_p4n_lhr.ll1234pubsubnt.ll1234vcn.oraclevcn.com';
```

Notice that we don't specify the static service (suffixed with _DGMGRL), because, under normal operation, the broker expects the standby to be mounted, therefore the default service is available.

1. Set the `StaticConnectIdentifier` for both databases.
Although the broker builds the default static connect identifier if it's not explicitly configured, it is still a good practice to set it to ease troubleshooting. In this lab, we need to set it to specify the FQDN of the hosts, or the DNS will not solve the remote host.

Replace `ADGHOL0_UNIQUE_NAME`, `ADGHOL0_SCI`, `ADGHOL1_UNIQUE_NAME`, and `ADGHOL1_SCI` with the actual values:
```
<copy>
edit database ADGHOL0_UNIQUE_NAME set property StaticConnectIdentifier='ADGHOL0_SCI';
edit database ADGHOL1_UNIQUE_NAME set property StaticConnectIdentifier='ADGHOL1_SCI';
</copy>
```
For example:
```
<copy>
edit database adghol_53k_lhr set property StaticConnectIdentifier='adghol0-1234.ll1234pubsubnt.ll1234vcn.oraclevcn.com:1521/adghol_53k_lhr_DGMGRL.ll1234pubsubnt.ll1234vcn.oraclevcn.com';
edit database adghol_p4n_lhr set property StaticConnectIdentifier='adghol1-1234.ll1234pubsubnt.ll1234vcn.oraclevcn.com:1521/adghol_p4n_lhr_DGMGRL.ll1234pubsubnt.ll1234vcn.oraclevcn.com';
</copy>
```

1. Enable the configuration. This final command will set the required parameters and execute the required commands to start the redo shipping from the primary to the standby database and start the standby recovery:

```
<copy>
enable configuration;
</copy>
```

![Steps executed to create and enable the Data Guard configuration](images/create-configuration.png)

The command `show configuration` should report success.

```
<copy>
show configuration;
</copy>
```
If you see the following warning:
```
Warning: ORA-16854: apply lag could not be determined
```
Try using `show configuration verbose` instead, to force a refresh of the status cache.

![Show configuration shows a healthy status](images/show-configuration.png)

That means that the primary can contact the standby database with the `DGConnectIdentifier`, send the redo stream with no lag, and the standby database can apply it successfully without lag.
For this live lab, we will use the new `sql` (SQLcl) integration for Data Guard instead of the traditional `dgmgrl` command-line. Starting with Oracle 21c, it is possible to use SQLcl to run most Data Guard commands. The commands are identical, except that they require to prepend `DG` before the actual Data Guard command.

1. From a terminal (**which one of the two hosts is irrelevant for this task**), connect to the primary database using the `sql` command-line tool (SQLcl). We use the DGConnectIdentifier for that (the one that connects to the service named after the `db_unique_name`).

```
<copy>
sql sys/WElcome123##@adghol0_dgci as sysdba
</copy>
```
2. Create the configuration using the `DG CREATE CONFIGURATION` command.
**Replace `ADGHOL0_UNIQUE_NAME` with the actual `db_unique_name`**:
```
<copy>
dg create configuration adghol as primary database is ADGHOL0_UNIQUE_NAME connect identifier is 'adghol0_dgci';
</copy>
```
For example:
```
dg create configuration adghol primary database is adghol_53k_lhr connect identifier is 'adghol0_dgci';
```
3. Add the standby database to the configuration using the `DG ADD DATABASE` command.
**Replace `ADGHOL1_UNIQUE_NAME` with the actual `db_unique_name` of the standby database**:
```
<copy>
dg add database ADGHOL1_UNIQUE_NAME as connect identifier is 'adghol1_dgci';
</copy>
```
For example:
```
dg add database adghol_p4n_lhr as connect identifier is 'adghol1_dgci';
```
4. Set the `StaticConnectIdentifier` for both databases.
Although the broker builds the default static connect identifier if it's not explicitly configured, it is still a good practice to set it to ease the troubleshooting. In this lab, we need to set it to specify the FQDN of the hosts, or the DNS will not solve the remote host.
**Replace `ADGHOL0_UNIQUE_NAME` and `ADGHOL1_UNIQUE_NAME` with the actual values**:
```
<copy>
dg edit database ADGHOL0_UNIQUE_NAME set property StaticConnectIdentifier='adghol0_sci';
dg edit database ADGHOL1_UNIQUE_NAME set property StaticConnectIdentifier='adghol1_sci';
</copy>
```
For example:
```
<copy>
dg edit database adghol_53k_lhr set property StaticConnectIdentifier='adghol0_sci';
dg edit database adghol_p4n_lhr set property StaticConnectIdentifier='adghol1_sci';
</copy>
```
5. Enable the configuration. This final command will set the required parameters and execute the required commands to start the redo shipping from the primary to the standby database and start the standby recovery:
```
<copy>
dg enable configuration;
</copy>
```
![Steps executed to create and enable the Data Guard configuration](images/create-configuration.png)
The command `dg show configuration` should report success.
```
<copy>
dg show configuration;
</copy>
```
If you see the following warning:
```
Warning: ORA-16854: apply lag could not be determined
```
Try using `dg show configuration verbose` instead, to force a refresh of the status cache.
![Show configuration shows a healthy status](images/show-configuration.png)
That means that the primary can contact the standby database with the `DGConnectIdentifier`, send the redo stream with no lag, and the standby database can apply it successfully without lag.
6. Exit from the SQLcl command-line:
```
<copy>
exit
</copy>
```
You have successfully created the Oracle Data Guard configuration. In the next lab, we will see how to monitor and alter the configuration.
## Acknowledgements
- **Author** - Ludovico Caldara, Product Manager Data Guard, Active Data Guard and Flashback Technologies
- **Contributors** - Robert Pastijn
- **Last Updated By/Date** - Ludovico Caldara, June 2024
- **Last Updated By/Date** - Ludovico Caldara, July 2024
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 78c893b

Please sign in to comment.