Monday, February 2, 2015

Administering an Oracle Database Instance Using ORADIM


ORADIM is a command-line tool that is available with Oracle Database. You are required to use ORADIM only if you are manually creating, deleting, or modifying databases. Oracle Database Configuration Assistant is an easier tool to use for this purpose.
Starting with Oracle Database 12c Release 1 (12.1), ORADIM creates Oracle Database service, Oracle VSS Writer service, and Oracle Scheduler service to run under the Oracle Home User account. If this account is a Windows Local User Account or Windows Domain User Account, then ORADIM prompts for password for that account and accepts the same through stdin.
It is possible to specify both the Oracle Home User and its password using the -RUNAS osusr[/ospass] option to oradim. If the given osusr is different from the Oracle Home User, then the Oracle Home User is used instead of osusr along with the given ospass.
The following sections describe ORADIM commands and parameters. Note that each command is preceded by a dash (-). To get a list of ORADIM parameters, enter:
oradim -? | -h | -help
Note:
Specifying oradim without any options also returns a list of ORADIM parameters and descriptions.
When you use ORADIM, a log file called oradim.log opens in ORACLE_HOME\database, or in the directory specified by registry parameterORA_CWD. All operations, whether successful or failed, are logged in this file. You must check this file to verify success of an operation.
If you have installed an Oracle Database service on Windows, then when logging in as the SYSTEM user (LocalSystem), with startup mode set to Automatic, it is possible that the Oracle Database service starts but the database does not start automatically. The following error message is written to the file ORADIM.LOG in the directory ORACLE_HOME\database:
ORA-12640: Authentication adapter initialization failed
Oracle Enterprise Management Agent, Oracle Enterprise Manager Management Server, and Oracle Internet Directory might also fail, because they cannot connect to the database for the same reason. To work around this issue, perform the following tasks:
  1. Modify SQLNET.ORA
You can modify SQLNET.ORA, be doing either of the following:
·         Remove the line sqlnet.authentication_services=(NTS)
·         Change the line sqlnet.authentication_services=(NONE)
  1. Start the database after the service starts.
You can start the database manually after the Oracle Database service has started, using SQL*Plus and connecting as SYSDBA.
  1. Start the service as a specific user
See Also:
Your operating system documentation for instructions on starting services
Creating an Instance Using ORADIM
To use ORADIM to create an instance, enter:
oradim [-NEW -SID SID] | -SRVC service_name | -ASMSID SID | -ASMSRVC service_name
[-SYSPWD password][-MAXUSERS number][-STARTMODE auto | manual] [-SRVCSTART system | demand]
[-PFILE filename | -SPFILE] [-SHUTMODE normal | immediate | abort] [-TIMEOUT
secs] [-RUNAS osusr[/ospass]]
For this command, note the following:
  • -NEW indicates that you are creating a new instance. This is a mandatory parameter.
  • -SID SID is the name of the instance to create.
  • -SRVC service_name is the name of the service to create (OracleServiceSID).
  • -ASMSID SID is the name of the Oracle Automatic Storage Management instance to create.
  • -ASMSRVC service_name is the name of the Oracle Automatic Storage Management service to create.
  • -SYSPWD password is the system password.
  • -MAXUSERS number is the number of users defined in the password file. The default is 5.
  • -STARTMODE auto | manual indicates whether to start the instance when the Oracle Database service is started. The default is manual.
  • -SRVCSTART system | demand indicates whether to start the Oracle Database service upon computer restart. Default is demand. Here, systemspecifies that the service be configured to automatically start when the system boots or reboots. Demand specifies that the user has to explicitly start the service.
  • -PFILE filename is the initialization parameter file to be used with this instance. Ensure that you specify the complete path name of this file, including the drive letter.
  • -SPFILE indicates that a server parameter file (SPFILE) be used during startup instead of a PFILE.
  • -SHUTMODE specifies how to stop an instance. It requires an argument and the default is immediate. If SHUTMODE is omitted, then there is no attempt made to shutdown the instance when the service is shut down.
  • -TIMEOUT secs sets the maximum time to wait (in seconds) before the service for a particular SID stops. The default is 90 seconds. It cannot be used without the SHUTDOWN argument.
  • -RUNAS osusr[/ospass] ("run as") makes it possible to specify both the Oracle Home User and its password. If the given osusr is different from the Oracle Home User, then the Oracle Home User is used instead of the osusr along with the given ospass.
Though the ospass can be specified on the command line, Oracle recommends accepting ospass through stdin
Starting with Oracle Database 12c Release 1 (12.1), ORADIM creates Oracle Database service, Oracle VSS Writer service, and Oracle Scheduler service to run under the Oracle Home User account. If this account is a Windows Local User Account or Windows Domain User Account, then ORADIM prompts for the password for that account and accepts the same through stdin.
Note:
For simplicity in demonstrating this feature, this example does not perform the password management techniques that a deployed system typically uses. In a production environment, follow the Oracle Database password management guidelines, and disable any sample accounts.
See Oracle Database Security Guide for password management guidelines and other security recommendations.
To create an instance called PROD, for example, you can enter:
C:\> oradim -NEW -SID prod -STARTMODE auto -PFILE C:\app\username\admin\prod\pfile\init.ora
Starting an Instance and Services Using ORADIM
To use ORADIM to start an instance and services, enter:
oradim -STARTUP -SID SID | -ASMSID SID [-SYSPWD password] [-STARTTYPE srvc |
inst | srvc,inst] [-PFILE filename | -SPFILE]
For this command, note the following:
  • -STARTUP indicates that you are starting an instance that already exists. This is a mandatory parameter.
  • -SID SID is the name of the instance to start.
  • -ASMSID SID is the name of the Oracle Automatic Storage Management instance to start.
  • -STARTTYPE srvcinst indicates whether to start the service or the instance. One or both values can be specified. If it is not specified, then the registry is checked for the current setting.
-STARTTYPE srvc is equivalent to running net start oracleservicesid from the command line.
-STARTTYPE inst is equivalent of running startup within SQL*Plus.
  • -PFILE filename is the initialization parameter file to be used with this instance. Ensure that you specify the complete path name of this file, including drive letter.
  • -SPFILE indicates that a server parameter file (SPFILE) be used during startup instead of a PFILE.
To start an instance called puma, for example, you can enter:
C:\> oradim -STARTUP -SID puma -STARTTYPE inst -PFILE C:\app\username\admin\prod\pfile\init.ora
Stopping an Instance and Services Using ORADIM
To use ORADIM to stop an instance, enter:
oradim -SHUTDOWN -SID SID | -ASMSID SID [-SYSPWD password]
[-SHUTTYPE srvc | inst | srvc,inst] [-SHUTMODE normal | immediate | abort]
For this command, note the following:
  • -SHUTDOWN indicates that you are stopping an instance. This is a mandatory parameter.
  • -SID SID specifies the name of the instance to stop.
  • -ASMSID SID is the name of the Oracle Automatic Storage Management instance to stop.
  • -SHUTTYPE srvcinst indicates whether to stop the service or the instance. One or both values can be specified. If it is not specified, then the registry is checked for the current setting.
  • -SHUTMODE specifies how to stop an instance. This is an optional parameter. If you do not specify how to stop an instance, then immediate is the default mode.
To stop an instance called puma, for example, you can enter:
C:\> oradim -SHUTDOWN -SID puma -SHUTTYPE srvc,inst
Editing an Instance Using ORADIM
You can edit an existing instance to change such values as instance name, startup mode, shutdown mode, and shutdown type. To use ORADIM to modify an instance, enter:
oradim -EDIT -SID SID | -ASMSID SID [-SYSPWD password] [-STARTMODE auto |
manual] [-SRVCSTART system | demand] [-PFILE filename | -SPFILE][SHUTMODE normal
| immediate | abort] [SHUTTYPE srvc | inst | srvc,inst]
For this command, note the following:
  • -EDIT indicates that you are modifying an instance. This is a mandatory parameter.
  • -SID SID specifies the name of the instance to modify. This is a mandatory parameter.
  • -ASMSID SID is the name of the Oracle Automatic Storage Management instance to modify.
  • -STARTMODE indicates whether to start the instance when the Oracle Database service is started. The default is manual.
  • -SRVCSTART system | demand indicates whether to start the Oracle Database service on computer restart. The default is demand.
  • -PFILE filename specifies the initialization parameter file to be used with this instance. Ensure that you specify the complete path name of this file, including the drive letter.
  • -SPFILE indicates that a server parameter file (SPFILE) be used during startup instead of a PFILE.
  • -SHUTMODE specifies how to stop an instance. This is an optional parameter. If you do not specify how to stop an instance, then immediate is the default mode.
  • -SHUTTYPE indicates whether to stop the service or the instance. One or both values can be specified. If it is not specified, then the registry is checked for the current setting.
To specify a new initialization parameter file for the instance prod, for example, you can enter:
C:\> oradim -EDIT -SID prod -PFILE C:\app\username\product\11.2.0\admin\lynx\pfile\init.ora
Deleting an Instance Using ORADIM
To use ORADIM to delete an instance, enter:
oradim -DELETE -SID SID | -ASMSID SID | -SRVC service_name | -ASMSRVC service_name
For this command, note the following:
  • -DELETE indicates that you are deleting an instance or service. This is a mandatory parameter.
  • -SID SID specifies the name of the SID to delete.
  • -SRVC service_name specifies the name of the service to delete (OracleServiceSID). The user should specify either SID or SRVC.
  • -ASMSID SID is the name of the Oracle Automatic Storage Management instance to delete.
  • -ASMSRVC service_name is the name of the Oracle Automatic Storage Management service to delete.
To delete an instance called prod, for example, you can enter:
C:\> oradim -DELETE -SID prod