Dbvisit Standby Command Line Interface (CLI)
1. Introduction
This section will provide you with more information on using the Dbvisit Standby version 9 command line interface.
2. "dbvctl" Help
The first command you need to be familiar with is the "dbvctl -h" command which will display the syntax and usage options for the Dbvisit Standby command line interface.
You might find it strange that this is the first option to discuss, but it is actually one of the most important. It is a quick and easy way for you to find out the correct command syntax before executing it.
There are a number of help options available to you:
HELP
- dbvctl -f # display system info
- dbvctl -h # display full help
- dbvctl -h -f # display functions list
- dbvctl -h -f <function> # display help on <function>
- dbvctl -h --csd # display help on CSD
- dbvctl -h --sync # display help on SYNC
- dbvctl -h -o # display help on -o options
- dbvctl -h -L # display license agreement
- dbvctl -V # display Dbvisit version
2.1. The Quick (short) help
The short or quick help option can be obtained by executing the "dbvctl" command without any arguments.
Example:
[oracle@dbv1 standby]$ ./dbvctl Dbvisit Standby Version 9.0.0_1275 USAGE: dbvctl -d <ddc> [--suppress] [-v] dbvctl -d <ddc> -i [--silent] dbvctl -d <ddc> -l [<new_license_key>] [--force] dbvctl -d <ddc> -R dbvctl -d <ddc> -r sequence# -t thread# dbvctl -d <ddc> -c dbvctl -d <ddc> -C dbvctl -d <ddc> -o status dbvctl -d <ddc> -o start|stop|restart [--database] dbvctl -d <ddc> -o open|read [--database] dbvctl -d <ddc> -o ro_test dbvctl -d <ddc> -o activate [--force] [--noprompt] dbvctl -d <ddc> -o dr_test [--backup --backup_type image|backupset --backup_location bck_dir] [--noprompt] dbvctl -d <ddc> -o reinstate [--switch] [--noprompt] dbvctl -d <ddc> -o switchover [--logswitch] dbvctl -d <ddc> -o update_ddc_file|update_dbenv_file dbvctl -d <ddc> -o upgrade [--noprompt] [--force] dbvctl [-d <ddc>] -o setup [--mode CLI|GUI] [--nolic] [--noprompt] [--action new|install|uninstall] [-j json_file] dbvctl -d <ddc> --csd [--mode CLI|BATCH|GUI] [--restart] [--noprompt] [-j json_file] [--dump_template] dbvctl -d <ddc> --sync [--mode CLI|BATCH|GUI] [--tmp_dir <tmp_dir>] [--tmp_dir_dest <tmp_dir_dest>] [--sync_lag] [--sync_nologging] [-j json_file] dbvctl -d <ddc> -D start|stop|status dbvctl [-d <ddc>] -f <function> [-a <key=value>]...[-a <key=value>] [-j <json_file_name>] dbvctl -d <ddc> -f support_package [-a pid=<pid>] HELP dbvctl -f # display system info dbvctl -h # display full help dbvctl -h -f # display functions list dbvctl -h -f <function> # display help on <function> dbvctl -h --csd # display help on CSD dbvctl -h --sync # display help on SYNC dbvctl -h -o # display help on -o options dbvctl -h -L # display license agreement dbvctl -V # display Dbvisit version
2.2. Listing the installed Dbvctl version
There are two ways to list the installed version of the Dbvisit Standby command line interface "dbvctl". The two options are:
- dbvctl -V (short version)
- dbvctl -f (detailed version)
Example:
[oracle@dbv1 standby]$ ./dbvctl -V 9.0.0_1275_g4206adfb [oracle@dbv1 standby]$ ./dbvctl -f ============================================================= Dbvisit Standby Database Technology (www.dbvisit.com) dbvctl: 9.0.0_1275_g4206adfb Dbvisit Standby time is: 201904261652 (YYYYMMDDHH24MI) Current user is: oracle Server name is: dbv1 Linux 4.9.125-linuxkit CPU count: 3 2491 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz ============================================================= dbvctl ended on dbv1: Fri Apr 26 16:52:01 2019 =============================================================
2.3. Creating a Support Package
There are multiple options to create a support package:
- Creating a general support package
- Creating a support package for a specific process (PID) - which is for a task that was already executed.
The command to execute the support package is:
dbvctl -d <ddc> -f support_package [-a pid=<pid>]
Once the support package is created, it will be located in the DBVISIT_BASE/standby/support directory.
Example:
3. Sending and Applying Logs
3.1. Sending Logs
Sending archive logs to the standby database can be done by running the following command: ./dbvctl -d <DDC>
3.1.1. Example 1: Single Instance Environment
3.1.1. Example 2: Oracle RAC Primary Environment
When running Dbvisit Standby on an Oracle RAC primary Dbvisit Standby will send logs for all Oracle RAC threads to the standby site. From Dbvisit Standby version 8, it is recommended to make use of shared storage and run Dbvisit Standby off only one of the Oracle RAC nodes.
In the example below, all Dbvisit Standby processes are running on node 1 in the cluster:
3.2. Applying Logs
Applying archive logs on the standby database run the following command: ./dbvctl -d <DDC>
Example:
IMPORTANT: Regarding Scheduling or running the Dbvisit Standby version 9 Daemon (Background process) please see Dbvisit Standby Scheduling#4.RunningDbvisitStandbyintheBackground
4. The log gap report
To ensure the primary and standby databases are up to date, you can run the Log Gap Report using the following command from the primary database server:./dbvctl -d <DDC> -i
4.1. Single Instance Environment
Below is an example of running a Log Gap report in a Single Instance Primary environment. In Dbvisit Standby Version 9 the log gap report has details like source/target SCN and timestamp specified in tabular format.
Information for only one thread will be shown.
4.2. Oracle RAC Primary Environment
Running the log gap report in an Oracle RAC environment will list information about all the threads in the Oracle RAC cluster.
The command to be executed is the same, but the result as you can see below will include information for all threads.
5. Start a Database
5.1. Start a Primary Database
To start the Primary Database in read-write mode run the command "dbvctl -d <DDC> -o start". Dbvisit uses RMAN to start a database. Example:
5.2. Start a Standby Database
To start a standby database, run the command "dbvctl -d <DDC> -o start". Dbvisit uses RMAN to start a database. The standby database will be started in a mounted state, ready for recovery, for example:
5.3. Start an Oracle RAC database
To start an Oracle RAC database run the command "dbvctl -d <DDC> -o start --database". Dbvisit uses SRVCTL utility to start an Oracle RAC database.
To start a local RAC database instance run the command "dbvctl -d <DDC> -o start".
You can also use the SRVCTL utility, for example: "srvctl start database -d DEV".
For more detail on the SRVCTL utility, please see the Oracle Documentation or the command line help of the utility by running: "srvctl start database -h"
When starting a standby Oracle RAC database using SRVCTL utility, you must specify the "-o mount" option to start the standby database in a mounted state, where it will be ready for recovery.
6. Restart a Database
6.1. Restart a Primary Database
The primary database can be restarted using the command "dbvctl -d <DDC> -o restart". Dbvisit Standby will detect based on the DDC file if the database is to be started as a primary or standby based on the SOURCE and DESTINATION values and taking into account on which system the command is being executed. This command will restart the primary database into a read/write open state.
Example:
6.2. Restart a Standby Database
To restart the standby database, use the following command: "dbvctl -d <DDC> -o restart". Dbvisit Standby will detect based on the DDC file if the database is to be started as a primary or standby based on the SOURCE and DESTINATION values and taking into account on which system the command is being executed. The standby database will be restarted into a mounted state, ready for recovery. Example:
7. Stop a Database
7.1. Stop a Primary Database
To stop the primary database, execute the command: "dbvctl -d <DDC> -o stop". A shutdown immediate command will be used to stop the database. Example:
7.2. Stop a Standby Database
To stop the standby database, execute the command: "dbvctl -d <DDC> -o stop". A shutdown abort command will be used to stop the database. Example:
7.3. Stop an Oracle RAC database
To stop an Oracle RAC database run the command "dbvctl -d <DDC> -o stop -database". Dbvisit uses SRVCTL utility to stop an Oracle RAC database.
To stop a local RAC database instance run the command "dbvctl -d <DDC> -o stop".
You can also use the SRVCTL utility, for example: "srvctl stop database -d DEV".
For more detail on the SRVCTL utility, please see the Oracle Documentation or the command line help of the utility by running: "srvctl start database -h"
8. Open Standby Database Read-only
If a standby database is in a consistent state, you should be able to open the standby database into a read-only state.
The examples below show the attempt to enable read-only when the standby database is down. This checks the database is down and bring the database up in READ-ONLY mode.
8.1. Open Read-only for Multitenant Database
When opening the multitenant standby database Dbvisit Standby doesn't interfere with PDBs, but respects the user's settings from the primary database.
Generally, when opening CDB, Oracle uses PDB's SAVE STATE option to determine the required open mode for each and every PDB. By default SAVE STATE option is not set for PDBs, hence PDBs are opened in MOUNT state. Run the following query to determine primary database settings:
SQL> select a.con_id,a.name,a.open_mode,a.restricted,b.state as saved_state from v$pdbs a, cdb_pdb_saved_states b where a.con_id=b.con_id(+); CON_ID NAME OPEN_MODE RES SAVED_STATE ---------- -------------------- ---------- --- -------------- 2 PDB$SEED READ ONLY NO 3 PDBX MOUNTED
If you require "dbvctl -d <DDC> -o open" to open certain PDB in READ ONLY you need to instruct the standby database to do so:
On primary open the PDB in READ ONLY and then run:
SQL> alter pluggable database <pdb_name> save state; SQL> select a.con_id,a.name,a.open_mode,a.restricted,b.state as saved_state from v$pdbs a, cdb_pdb_saved_states b where a.con_id=b.con_id(+); CON_ID NAME OPEN_MODE RES SAVED_STATE ---------- -------------------- ---------- --- -------------- 3 PDBX READ ONLY NO OPEN READ ONLY 2 PDB$SEED READ ONLY NO
Dbvisit Standby will apply these settings to the standby database. Next time you open the standby database using "dbvctl -d <DDC> -o open" the standby PDB will be opened in READ ONLY mode.
9. Database Status Check
There are various options to review the status of the databases. The Dbvisit Standby version 8 command is: "dbvctl -d <DDC> -o status"
9.1. Status Check Example - Primary
9.2. Status Check Example - Standby
9.3. Status Checks in an Oracle RAC configuration
Check the status of the local database instance using dbvctl:
Check the status of all database instances using SRVCTL:
Example to check the status for a Primary Oracle RAC cluster database:
oracle@kiwi81[/acfs/dbvisit/standby]: srvctl status database -d MYDEV -v Instance MYDEV1 is running on node kiwi81. Instance status: Open. Instance MYDEV2 is running on node kiwi82. Instance status: Open.
Example to check the status for a Standby Oracle RAC cluster database:
oracle@kiwi92[/acfs/dbvisit/standby]: srvctl status database -d MYDEV -v Instance MYDEV1 is running on node kiwi91. Instance status: Mounted (Closed). Instance MYDEV2 is running on node kiwi92. Instance status: Mounted (Closed).
9.2.4. Status Check for Multitenant Database
When running a status check on a 12c Multitenant database you will see a status update for the pluggable databases listed as well.
The example below is from a 12c Database running on a Linux-based system.
10. Activate a Standby Database (Failover)
Activating a standby database is also known as performing a failover. This is totally different than performing a Graceful Switchover.
During Activation an "open resetlogs" is performed on the standby database while an attempt is made to open the standby database read-write.
If the database is in a consistent state, activation should be possible. A quick way to test the state is by opening the standby database read-only. If that is possible, you will be able to activate the standby database.
The command to activate the standby database is: "dbvctl -d <DDC> -o activate"
The command to Activate a Standby database is:
11. Copy DDC file to the standby
If changes were made to the DDC file, you can run the following command on the primary system to copy the DDC file to the standby server. Remember the DDC file on the primary server is considered the "master copy" : "dbvctl -d <DDC> -c"
Example:
12. Refresh a Standby datafile from the Primary
It is possible to refresh one specific datafile on the standby database server from the primary. The command to do this is: "dbvctl -f refresh_datafile -d DEV -a file_id=<file_id>"
Example:
13. Cleanup repository
A new function is added starting from version 8.0.14 to clean up Dbvisit Standby repository tables DBV_TRANSFER_LOG and DBV_SEQUENCE_LOG. Below are the new global variables introduced and the default values set.
REPO_MAINTAIN_DAYS = 1 (default value)
REPO_KEEP_DAYS = 30 (default value)
The cleanup function is called during the first run of the day on the primary server. If any records have been deleted, it will attempt to copy the repository to the standby server. If the copy fails, processing still continues.
A new repository table DBV_MAINTAIN_REPO is introduced as well which logs the information of the cleanup function.
To run the repo maintenance function manually, use below syntax:
dbvctl -d <DDC> -f repo_maintain [-a days2keep=N]
Example:
oracle@dbvlab01[/usr/dbvisit/standby]: ./dbvctl -d DEV -f repo_maintain -a days2keep=1
14. Export DBV_TRANSFER_LOG into JSON
In Dbvisit Standby version 8.0.14 a new function was introduced to export the DBV_TRANSFER_LOG table into JSON output.
The command is:
dbvctl -d <DDC> -f repo_export_table -a table=DBV_TRANSFER_LOG -a out=json
Example:
15. Videos on how to use some of the Command Line Interface commands
Part 1
Part 2
Part 3