Environment Requirements to Start and Stop Oracle 12c Databases
Before starting or stopping an Oracle 12c database instance, a few environmental requirements must be met. These environment requirements get you logged in to the server as the correct user with the right environment variables so that you can do your DBA work.
Log in to the database server in Oracle 12c
Log in to the server where the database resides to do your key database administrator (DBA) work. Yes, you can do some of this via Enterprise Manager but only after you’ve set up your environment and created your database in the first place.
Most critical DBA work occurs on the database server itself because it provides the most flexibility and is the simplest for starting DBAs.
Log in as the Oracle DBA account in Oracle 12c
You should be in the operating system DBA account that owns the Oracle software to start and stop the database. Commonly this is the oracle user account and is in the DBA group:
$ id uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba))
The oracle user is in groups oinstall and dba.
Set up your environment variables in Oracle 12c
Many environment variables exist for your oracle use. However, at a minimum you want to have these variables set:
$ echo $ORACLE_BASE /u01/app/oracle $ echo $ORACLE_HOME /u01/app/oracle/product/12.1.0/dbhome_1 $ echo $ORACLE_SID dev12c
Be sure to verify the ORACLE_BASE, ORACLE_HOME, and ORACLE_SID variables before you do any type of DBA work. It is very easy to define the wrong ORACLE_HOME, in which case you work with the wrong database software. Worse yet, it’s even easier to incorrectly define ORACLE_SID and stop the wrong database!
Start SQL*Plus as a DBA in Oracle 12c
The command-line interface into Oracle databases is SQL*Plus. To do serious DBA work such as startup or shutdown, you need to be logged in as SYSDBA.
To log in this way, you must be the oracle operating system user. Then start SQL*Plus with the / as sysdba option:
$ sqlplus "/ as sysdba" SQL*Plus: Release 126.96.36.199.0 - Production on Sun May 19 07:46:53 2013 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 188.8.131.52.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL>
An alternative: When you’re in SQL*Plus, issue connect as sysdba to log in as SYSDBA, provided you’re on the database server as the oracle operating system user.
SQL> connect / as sysdba Connected. SQL>
When you’re connected as SYSDBA, you can begin your DBA work.
Database parameter file in Oracle 12c
Before starting the database, you must have a parameter file listing all the different runtime parameters, such as SGA configuration. However, let’s assume you have your SPFILE created and in a default location so that Oracle can find it. If it isn’t in a default location, or you want to use a different parameter file, you may use the pfile=′PATH TO SPFILE/FILENAME′ syntax with your startup commands.
Improper environment setup is a common error and is something you should correct before beginning your database work. Doing so will save you time and frustration troubleshooting unnecessary errors.