Database Commands
Use commands with the database keyword to manage cluster database.
You can add, modify, manage environment variables for, list the configuration of, enable, disable, start, stop, and obtain the status of databases, and also to upgrade, downgrade, and remove database configuration information about databases.
srvctl add database
Adds a database configuration to Oracle Clusterware.
Note:
The policy-managed database deployment option is desupported in Oracle AI Database 26ai.
Syntax
srvctl add database -db db_unique_name -oraclehome oracle_home
[-dbtype {RACONENODE | RAC | SINGLE} [-server "server_list"] [-instance instance_name]
[-timeout timeout]] [-domain domain_name] [-spfile spfile]
[-pwfile password_file_path] [-role {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY | FAR_SYNC}]
[-startoption start_options] [-stopoption stop_options] [-startconcurrency start_concurrency]
[-stopconcurrency stop_concurrency] [-dbname db_name] [-policy {AUTOMATIC | MANUAL | NORESTART | USERONLY | RANK}]
[-node node_name] [-diskgroup "disk_group_list"] [-acfspath "acfs_path | acfs_path_list"]
[-css_critical {yes | no}] [-memorytarget memory_target] [-maxmemory max_memory]
[-defaultnetnum network_number] [-verbose] [-importfile file_name]
Parameters
Table: srvctl add database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | The unique name of the database. |
-oraclehome oracle_home | The path for the Oracle AI Database home directory. |
-dbtype {RACONENODE | RAC | SINGLE} | The type of database you are adding: Oracle RAC One Node, Oracle RAC, or single instance. The default is RAC . If you specify the -node node_name parameter, then the -dbtype parameter defaults to SINGLE . |
-server server_list | List of candidate servers for Oracle RAC One Node databases. Oracle Clusterware attempts to start Oracle RAC One instance in the order in which the servers are listed. First, it attempts to start the instance on the first server in the list. If that does not succeed for any reason, then Oracle Clusterware attempts to start the instance on the second server defined in the list, and so on. For example, for a 3-node cluster:
Oracle Clusterware refers to this list every time an instance starts, which can be either a regular start or a start that is triggered by a failure event. |
-instance instance_name | The instance name prefix for Oracle RAC One Node databases. The default value for this parameter is the first 12 characters of the global unique name of the database. |
-timeout timeout | The online database relocation timeout, in minutes, for Oracle RAC One Node databases. The default value is 30 . |
-domain db_domain | The domain for the database. Note: You must use this parameter if you set the DB_DOMAIN initialization parameter for the database. |
-spfile spfile | The path name of the database server parameter file. |
-pwfile password_file_path | The full path to the location of the password file. |
-role {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY | FAR_SYNC} | The role of the database in an Oracle Data Guard configuration. The default is PRIMARY . |
-startoption start_options | Startup options for the database, such as OPEN, MOUNT, and NOMOUNT. The default value is OPEN.Notes:
|
-stopoption stop_options | Stop options for the database, such as NORMAL , TRANSACTIONAL , IMMEDIATE , and ABORT . |
-startconcurrency start_concurrency | Number of instances to be started simultaneously, or 0 to disable this option. |
-stopconcurrency stop_concurrency | Number of instances to be stopped simultaneously, or 0 to disable this option. |
-dbname db_name | The name of the database, if it is different from the unique name given by the -db parameter. |
-policy {AUTOMATIC | MANUAL | NORESTART | USERONLY | RANK} | The management policy for the database.
|
-node node_name | The node name on which you want to register a noncluster, or single instance, Oracle AI Database. Note: This parameter can be used only with Oracle Clusterware. |
-diskgroup " disk_group_list " | A comma-delimited list of Oracle Automatic Storage Management (Oracle ASM) disk groups if database uses Oracle ASM storage. |
-acfspath " acfs_path | acfs_path_list " | You can add (/+) or remove (/-) a single Oracle ACFS path with acfs_path or multiple Oracle ACFS paths using a comma-delimited list with acfs_path_list enclosed in double quotation marks ("") where the database's dependency is set.Use this parameter to create dependencies on Oracle ACFS file systems other than
|
-css_critical {YES | NO} | You can add weight to a service by setting this parameter to YES . In the event of a node failure within the cluster, Oracle Clusterware will evict the node with the least amount of weight, ensuring that critical services remain available. |
-memorytarget memory_target | The target memory size, in MB, to be allocated for the database. The default is 0. |
-maxmemory max_memory | The maximum memory size, in MB, to be allocated for the resource. If you specify -memorytarget but not -maxmemory , then -maxmemory will default to 0. Both -maxmemory and -memorytarget are validated as long as -memorytarget is less than or equal to -maxmemory . |
-defaultnetnum network_number | Specify a network number (an integer) to which services will default in the event you do not specify a network number when you add the service. The number must match the value of the -netnum parameter you specified when you added the network. |
-importfile file_name | Specify the JSON file containing the resource configuration to use when adding or re-creating the resource. |
Examples
This example shows how to add a database named crm.example.com in a specific Oracle Home directory.
$ srvctl add database -db crm -oraclehome /u01/oracle/product/23.0.0/mydb
-domain example.com
srvctl config database
Displays the configuration for an Oracle RAC database or lists all configured databases that are registered with Oracle Clusterware.
Syntax
srvctl config database [-db db_unique_name] [-all] [-exportfile file_name] [-verbose]
Parameters
Table: srvctl config database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Unique name for the database. If you do not specify this parameter, then the utility displays the configuration of all database resources. |
-all | Print detailed configuration information. |
-verbose | Display verbose output. |
-exportfile file_name | Specify the output file to which the resource configuration will be exported in JSON format for backup or resource re-creation purposes. |
Example
This command returns output similar to the following:
$ srvctl config database -d main4
Database unique name: main
Database name:
Oracle home: /ade/mjkeenan_main4/oracle
Oracle user: mjkeenan
Spfile:
Password file:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Disk Groups:
Mount point paths:
Services: test
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: main41,main42
Configured nodes: mjkeenan_main4_0,mjkeenan_main4_1
CSS critical: no
CPU count: 0
Memory target : 0
Maximum memory: 0
CPU cap: 0
Database is administrator managed
srvctl convert database
Converts a database either to or from an Oracle RAC One Node database.
Syntax
Use this command with one of the following syntax models:
srvctl convert database -db db_unique_name -dbtype RACONENODE
[-instance instance_name] [-timeout timeout]
srvctl convert database -db db_unique_name -dbtype RAC [-node node_name]
Parameters
Table: srvctl convert database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Specify the unique name for the database. Note: If you specify a noncluster database, then command returns an error instructing you to first convert the noncluster database to Oracle RAC or Oracle RAC One Node. |
-dbtype RACONENODE | RAC | Specify the type of database to which you are converting, either Oracle RAC One Node or Oracle RAC. Note: If there is an ongoing or failed online database relocation, then the command returns an error instructing you to first complete or stop the online database relocation and then rerun the command. |
-instance instance_name | Optionally, you can specify an instance name prefix for Oracle RAC One Node databases. The default value for this parameter is the first 12 characters of the global unique name of the database. Notes:
|
-timeout timeout | Optionally, you can specify online database relocation timeout, in minutes, for Oracle RAC One Node databases. The default is 30. |
-node node_name | Optionally, you can specify the name of the node for an administrator-managed Oracle RAC database. The default is the first candidate. Note: If you do not specify a node name or you specify a node name where the database is not running, then the command returns an error instructing you specify the correct node. |
Example
An example of this command is:
$ srvctl convert database -db myDB -dbtype RACONENODE -instance myDB3
srvctl disable database
Disables a running database.
If the database is a cluster database, then its instances are also disabled.
Syntax
srvctl disable database -db db_unique_name [-node node_name]
Parameters
Table: srvctl disable database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Specify the name of the database you want to disable. |
-node node_name | Optionally, you can specify a node on which you want to disable the database. Note: You can only use this parameter only with Oracle Clusterware. |
Example
The following example disables the database mydb1:
$ srvctl disable database -db mydb1
srvctl downgrade database
Downgrades the configuration of a database and its services from its current version to a specific lower version.
Syntax
srvctl downgrade database -db db_unique_name -oraclehome Oracle_home
-targetversion to_version
Parameters
Table: srvctl downgrade database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Specify the unique name of the database you want to downgrade. |
-oraclehome Oracle_home | Specify the path to the Oracle home. |
-targetversion to_version | Specify the database version to which you want to downgrade. |
srvctl enable database
Enables a cluster database and its instances.
Syntax
srvctl enable database -db db_unique_name [-node node_name]
Parameters
Table: srvctl enable database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Specify the unique name of the database you want to enable. |
-node node_name | Optionally, you can specify the name of the node on which the database resource resides that you want to enable. Note: You can only use this parameter with Oracle Clusterware. |
Example
The following example enables a database named mydb1:
$ srvctl enable database -db mydb1
srvctl getenv database
Displays the values for environment variables associated with a database.
Syntax
srvctl getenv database -db db_unique_name [-envs "name_list"]
Parameters
Table: srvctl getenv database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Specify the unique name of the database for which you want to display the environment variable values. |
-envs " name_list " | Optionally, you can specify a comma-delimited list of the names of specific environment variables enclosed in double quotation marks ( If you do not use this parameter, then SRVCTL displays the values of all environment variables associated with the database. |
Example
The following example displays the environment configuration for a database named crm:
$ srvctl getenv database -db crm
srvctl modify database
Modifies the configuration for a database.
Note:
The policy-managed database deployment option is desupported in Oracle AI Database 26ai.
Syntax
srvctl modify database -db db_unique_name [-dbname db_name] [-instance instance_name]
[-oraclehome oracle_home_path] [-localrolling] | [-localrolling_revert] [-user user_name]
[-server "server_list"] [-timeout timeout] [-domain db_domain]
[-spfile spfile] [-pwfile password_file_path]
[-role {PRIMARY|PHYSICAL_STANDBY|LOGICAL_STANDBY|SNAPSHOT_STANDBY}]
[-startoption start_options] [-stopoption stop_options]
[-startconcurrency start_concurrency] [-stopconcurrency stop_concurrency]
[-policy {AUTOMATIC | MANUAL | NORESTART | USERONLY | RANK}]
[{-diskgroup "diskgroup_list" | -nodiskgroup}] [-acfspath "acfs_path | acfs_path_list"]
[-css_critical {YES | NO}] [-memorytarget memory_target] [-maxmemory max_memory]
[-defaultnetnum network_number] [-disabledreason {DECOMMISSIONED}] [-force]
[-verbose]
Parameters
Table: srvctl modify database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Unique name for the database. |
-dbname db_name | The name of the database, if it is different from the unique name given by the -db parameter. |
-instance instance_name | Instance name prefix; this parameter is required for administrator-managed Oracle RAC One Node databases. |
-oraclehome oracle_home | The path for the Oracle AI Database home directory. |
-localrolling | Creates a new Oracle RAC database instance to enable the local rolling feature. |
-localrolling_revert | Use this parameter to revert the Oracle RAC local rolling configuration changes. |
-user user_name | The name of the user who owns the Oracle home directory. Note: If you specify the |
-server server_list | List of candidate servers for Oracle RAC One Node databases. Oracle Clusterware attempts to start Oracle RAC One instance in the order in which the servers are listed. First, it attempts to start the instance on the first server in the list. If that does not succeed for any reason, then Oracle Clusterware attempts to start the instance on the second server defined in the list, and so on. For example, for a 3-node cluster:
Oracle Clusterware refers to this list every time an instance starts, which can be either a regular start or a start that is triggered by a failure event. |
-timeout timeout | Online database relocation timeout, in minutes, for Oracle RAC One Node databases. The default is 30. |
-domain db_domain | The domain for the database. Note: You must use this parameter if you set the |
-spfile spfile | The path name of the database server parameter file. |
-pwfile password_file_path | Enter the full path to the location of the password file. |
-role {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY} | The role of the database in an Oracle Data Guard configuration. The default is PRIMARY. |
-startoption start_options | Startup options for the database, such as Notes:
|
-stopoption stop_options | Stop options for the database, such as NORMAL, TRANSACTIONAL, IMMEDIATE, and ABORT. |
-startconcurrency start_concurrency | Number of instances to be started simultaneously, or 0 to disable this option. |
-stopconcurrency stop_concurrency | Number of instances to be stopped simultaneously, or 0 to disable this option. |
-policy {AUTOMATIC | MANUAL | NORESTART | USERONLY | RANK} | The management policy for the database.
|
-diskgroup " disk_group_list " | Comma-delimited list of Oracle ASM disk groups if database uses Oracle ASM storage. |
-acfspath " acfs_path | acfs_path_list " | You can add (/+) or remove (/-) a single Oracle ACFS path with Use this parameter to create dependencies on Oracle ACFS file systems other than
|
-css_critical {YES | NO} | You can add weight to a service by setting this parameter to YES. In the event of a node failure within the cluster, Oracle Clusterware will evict the node with the least amount of weight, ensuring that critical services remain available. |
-memorytarget memory_target | Specify the target memory, in MB, to be allocated for the database. The default is 0. |
-maxmemory max_memory | Specify the maximum memory, in MB, to be allocated for the resource. If you specify -memorytarget but not -maxmemory, then -maxmemory will be the default value of 0. Both -maxmemory and -memorytarget are validated as long as -memorytarget is less than or equal to -maxmemory. |
-defaultnetnum network_number | Specify a network number to which services will default in the event you do not specify a network number when you add a service. |
-disabledreason {DECOMMISSIONED} | Marks the database as being decommissioned, which means it cannot be started again and is not being used. This is intended for databases that will be deleted at a future date. |
Usage Notes
- When using the
srvctl modify databasecommand, for a running database, if the server list is supplied, then the node where the database is running must be on that list. - The instance name prefix cannot be modified after running the
srvctl add databasecommand. - You cannot change the management policy from
AUTOMATIC(using the-policyparameter) for Oracle RAC One Node databases. Any attempt to do so results in an error message.
Examples
The following example changes the role of a database to a logical standby:
$ srvctl modify database -db crm -role logical_standby
The following example directs the racTest database to use the SYSFILES, LOGS, and OLTP Oracle ASM disk groups:
$ srvctl modify database -db racTest -diskgroup "SYSFILES,LOGS,OLTP"
Related Topics
srvctl predict database
Predicts the consequences of the failure of a specific database.
Syntax
srvctl predict database -db db_unique_name [-verbose]
Usage Notes
- Specify the unique name of the database you want to check.
- Optionally, you can use the
-verboseparameter to display detailed output.
srvctl relocate database
Initiates the relocation of an Oracle RAC One Node database from one node to another node.
This command also cleans up after a failed relocation, and you can only use it for relocating Oracle RAC One Node databases.
Syntax
Use this command with one of the following syntax models:
To initiate the online relocation of an Oracle RAC One Node database:
srvctl relocate database -db db_unique_name {[-node target_node] [-timeout timeout]
[-stopoption NORMAL] | -abort [-revert]} [-drain_timeout drain_timeout] [-eval] [-verbose]
To stop the failed online relocation of an Oracle RAC One Node database:
srvctl relocate database -db db_unique_name -abort [-revert]
[-drain_timeout drain_timeout] [-eval] [-verbose]
Parameters
Table: srvctl relocate database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Specify the unique name of the database you want to relocate. |
-node target_node | Optionally, you can specify a target node to which to relocate the Oracle RAC One Node database. Note: You must use this parameter if you are relocating an administrator-managed Oracle RAC One Node database. |
-timeout timeout | Optionally, you can specify an online database relocation timeout, in minutes, for Oracle RAC One Node databases. The default is 30. |
-stopoption NORMAL | Use this parameter to override the default shutdown option for a running instance, such as the default of SHUTDOWN TRANSACTIONAL LOCAL for a primary database or SHUTDOWN IMMEDIATE for a standby database. The only value accepted for -stopoption is NORMAL. |
-abort | Use this parameter to stop a failed online database relocation. |
-revert | Use this parameter to remove the target node of a failed online relocation request from the candidate server list of an administrator-managed Oracle RAC One Node database. |
-drain_timeout timeout | Specify the time, in seconds, allowed for resource draining to be completed. Accepted values are an empty string (""), 0, or any positive integer. The default value is an empty string, which means that this parameter is not set. If it is set to 0, then draining occurs, immediately. The draining period is intended for planned maintenance operations. During the draining period, all current client requests are processed, but new requests are not accepted. When set on the service this value is used when the command line value is not set. |
-eval | Evaluates the effects of the operation without making any changes to the system. |
-verbose | Use this parameter to display verbose output. |
Usage Notes
- If the Oracle RAC One Node database you want to relocate is not running, then the command returns an error.
- If another online database relocation is active for this Oracle RAC One Node database, then the command returns an error.
- If the
-drain_timeoutvalue is higher than the-timeoutvalue, then SRVCTL relocates the services but does not explicitly start or stop the services on the database instances. - If an online database relocation for this Oracle RAC One Node database has failed and the target nodes are not the same for either relocation, then the command returns an error instructing you to stop the failed online database relocation and then initiate a new one.
- If an online database relocation for this Oracle RAC One Node database has failed and the target nodes are the same (or you do not specify the target), then the command attempts to relocate the database.
Example
The following example relocates an Oracle RAC One Node database named rac1 to a server called node7.
$ srvctl relocate database -db rac1 -node node7
srvctl remove database
Removes database configurations.
After running this command, ensure that the password file is in the default location if you want to connect to the database as the SYS user with the SYS user's password.
Syntax
srvctl remove database -db db_unique_name [-force] [-noprompt] [-verbose]
Parameters
Table: srvctl remove database Command Parameters
| Parameter | Description |
|---|---|
-database db_unique_name | Unique name for the database. |
-force | Forcibly remove the database and ignore any dependencies. |
-noprompt | Suppress prompts. |
-verbose | Display verbose output. |
Example
To remove a database named crm:
$ srvctl remove database -db crm
srvctl setenv database
Administers cluster database environment configurations.
Syntax
Use this command with one of the following syntax models:
srvctl setenv database -db db_unique_name -envs "name=val[,...]"
srvctl setenv database -db db_unique_name -env "name=val"
Parameters
Table: srvctl setenv database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Specify a unique name for the database for which you want to set environment variables. |
-envs " name = val [,...]" | Specify a comma-delimited list of name-value pairs of environment variables enclosed in double quotation marks ( "" ) that you want to set. |
-env " name = val " | Specify a single environment variable that you want to set to a value that contains commas or other special characters enclosed in double quotation marks ( "" ). |
Usage Notes
Add additional information about the command here.
Example
The following example sets the language environment variable for a cluster database:
$ srvctl setenv database -db crm -env LANG=en
srvctl start database
Starts a database and its enabled instances, and all listeners on nodes with database instances.
You can disable listeners that you do not want to start.
Syntax
srvctl start database -db db_unique_name [-eval] [-startoption start_options]
[-startconcurrency number_of_instances] [-node node_name]
Parameters
Table: srvctl start database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Specify the unique name of the database you want to start. |
-eval | Optionally, use this parameter to hypothetically evaluate the impact of the command on the system. |
-startoption start_options | Optionally, you can set options for the startup command (for example: Notes:
|
-startconcurrency number_of_instances | Optionally, you can specify a number of database instances to start simultaneously, or specify
|
-node node_name | Optionally, you can specify the name of a node on which you want to start the database. Notes:
|
Examples
The following example starts the crm database and sets the startup option to read only:
$ srvctl start database -db crm -startoption "read only"
srvctl status database
This command displays the current state of the of the database.
Syntax
srvctl status database {-db db_unique_name {[-sid] [-home]} | -thisversion | -thishome}
[-force] [-detail] [-verbose]
Parameters
Table: srvctl status database Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Specify a unique name for the database. |
-sid | Use this parameter to display the SID of the Oracle instance running on this node. |
-home | Use this parameter to display the Oracle home of the specified database. |
-thisversion | Use this parameter to display the status of databases that are of the same Oracle product version as SRVCTL. |
-thishome | Use this parameter to display the status of databases that are configured in this Oracle home. |
-force | Include disabled applications |
-detail | Use this parameter to display detailed database status information. |
-verbose | Displays If the If the If the |
Usage Notes
The output of this command includes information on the Oracle ASM or Oracle ASM IOServer instance for each running instance of the database.
Examples
This command displays output similar to the following:
$ srvctl status database -db db00 -detail
Instance db00_1 is connected to ASM instance +ASM3
Instance db00_2 is connected to ASM I/O server instance +IOS1
srvctl stop database
Stops a database, its instances, and its services.
Syntax
srvctl stop database -db db_unique_name [-stopoption stop_options]
[-stopconcurrency number_of_instances] [-drain_timeout timeout] [-eval]
[-force] [-verbose]
Parameters
Table: srvctl stop database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Specify the unique name for the database that you want to stop. |
-stopoption stop_options | Optionally, you can specify options for the shutdown command, such as NORMAL, TRANSACTIONAL LOCAL, IMMEDIATE, or ABORT. |
-stopconcurrency number_of_instances | Optionally, you can specify a number of database instances to stop simultaneously, or specify
|
-drain_timeout timeout | Optionally, you can specify the time, in seconds, allowed to complete the resource draining action. By default, this parameter is not set. You can specify 0 or any positive integer. An empty string unsets the parameter. If you specify zero, then the agent will perform the actions related to service draining, immediately. Drain timeout is the maximum time the service waits before exiting (in case of Note: If the |
-eval | Optionally, you can use this parameter to hypothetically evaluate the impact of the command on the system. |
-force | Optionally, you can use this parameter to stop the database, its instances, its services, and any resources that depend on those services. |
-verbose | Optionally, you can use this parameter to display detailed output. |
Example
The following command example stops a database and includes detailed output:
$ srvctl stop database -db db1 -drain_timeout 50 -verbose
Draining in progress on services svc1,svc2.
Drain complete on services svc1.
Draining in progress on services svc2.
Draining in progress on services svc2.
Drain complete on services svc2.
srvctl unsetenv database
Unsets the cluster database environment configurations.
Syntax
srvctl unsetenv database -db db_unique_name -envs "name_list"
Parameters
Table: srvctl unsetenv database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Specify the unique name of the database for which you want to unset environment variables. |
-envs " name_list " | Specify a comma-delimited list of environment variable names enclosed in double quotation marks ( "" ). |
Example
The following example unsets two cluster database environment variables:
$ srvctl unsetenv database -db crm -envs "CLASSPATH,LANG"
srvctl update database
Updates the specified database to use the new listener endpoints.
Syntax
srvctl update database -db db_unique_name [-startoption start_options [-node node_name]]
Usage Notes
- You can only use this command with Oracle Clusterware.
- Specify the unique name of the database you want to update.
srvctl upgrade database
Upgrades the configuration of a database and all of its services to the version of the database home from where this command is run.
Syntax
srvctl upgrade database -db db_unique_name -oraclehome Oracle_home
Parameters
Table: srvctl upgrade database Command Parameters
| Parameter | Description |
|---|---|
-db db_unique_name | Specify the unique name of the database you want to upgrade. |
-oraclehome Oracle_home | Specify the path to the upgraded ORACLE_HOME. |