Starting and Stopping Oracle Database XE

Sunday, 14 November 2010 ·

Starting and Stopping Oracle

Starting and Stopping Oracle Database XE
When you install Oracle Database XE, one of your options is to start the database automatically when the operating system starts. When you shut down your server, the shutdown process runs scripts to automatically shut down the database as well. Whether you start the database automatically using this method, or start it manually using the menu commands or SQL*Plus, there are situations where you need to stop the database manually without shutting down your server. For example,you may want to move some of your table spaces from one disk drive to another, or you may want to change some system parameters that can only be changed after you shut down the database.
Note Under Linux, Oracle starts up automatically when the paramete rORACLE_DBENABLED is set toTRUEin the file/etc/sysconfig/oracle-xe. Under Windows operating systems, the installer sets the autostartoption by setting the registry keyHKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_XE\
ORA_XE_AUTOSTARTtoTRUE.
Starting Oracle Database XE
The manual startup and shutdown procedures are identical on Linux and Windows. You can use SQL*Plus from the command line, the SQL Command GUI equivalent from the Windows or Linux start menu, or the StartDatabase and Stop Database menu items in the Windows or Linux start menu. The following shows how to start up SQL*Plus from the command lineif you did not configure Oracle to start up automatically on your Linux server:
[oracle@phpxe ~]$ sqlplus system as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on FriJul 14 00:17:53 2006
Copyright (c) 1982, 2005, Oracle. All right sreserved.
Enter password:
Connected to an idle instance.

SQL> startupORACLE instance started.
Total System Global Area 146800640 bytes FixedSize 1257668 bytes Variable Size 79695676 bytes Database Buffers 62914560 bytes RedoBuffers 2932736 bytes Database mounted.
Database opened.
SQL>
Notice the keywordsAS SYSDBAin theSQLPLUScommand. Because the database is down, you cannot authenticate your useraccount using the database.AS SYSDBAauthenticates your user account with a password file stored in theOracle directory structure. The password you supply is the same passwordyou use to connect when the database is up. Oracle automatically keepsthe passwords stored in the database in sync with the passwords storedin the password file for user accounts that you grant theSYSDBAprivilege. We discuss user privileges, security, and roles in greaterdetail in Chapter 30.
Note The password file is located in%ORACLE_HOME%\server\database\PWDXE.oraon Windows and$ORACLE_HOME/dbs/orapwXEon Linux.
If you are logged into the server using the user account you used toinstall the Oracle software, you can start up the database byauthenticating with the operating system. You need not specify a useraccount or a password. To use operating system authentication to startup the database, you use the/keyword as follows:
[oracle@phpxe ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on FriJul 14 00:18:20 2006
Copyright (c) 1982, 2005, Oracle. All rightsreserved.
Connected to an idle instance.

SQL> startupORACLE instance started.
Total System Global Area 146800640 bytes FixedSize 1257668 bytes Variable Size 79695676bytes Database Buffers 62914560 bytes RedoBuffers 2932736 bytes Database mounted.
Database opened.
SQL>
Notice that you specify neither a username nor a password, since theauthentication takes place when you log into the operating systemaccount that owns the Oracle software.
If you are using Windows XP as your host operating system, you don’tneed to see the command line. Click Start ? All Programs ? OracleDatabase 10g Express Edition ? Start Database to, as you mightexpect, start the database. A DOS command window will appear to confirmthat you started the database successfully.
Stopping Oracle Database XE
Ideally, you want all users logged off before you shut down thedatabase. If you cannot contact the users that are still logged in anddo not have time to disconnect each session manually using the MonitorSessions function under the Administration icon on the Oracle DatabaseXE home page, you can still shut down the database quickly with the SHUTDOWN IMMEDIATEcommand. This command performs the following operations:

1. Prevents any new connections
2. Prevents any new transactions from starting
* Rolls back any uncommitted transactions
* Immediately disconnects all users and applications

To shut down the database, connect to the database using the commandSQLPLUS / AS SYSDBA, and use theSHUTDOWN IMMEDIATEcommand:
SQL> shutdown immediateDatabase closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
If theSHUTDOWNcommand does not respond after several minutes, you can force ashutdown. The database may not be responding for a number of reasons,including a background process that is no longer responding, a corrupteddatafile, or a network failure. Use theSHUTDOWN ABORTcommand to force a shutdown:

SQL> shutdown abortORACLE instance shut down.
SQL>

Since the database is in an inconsistent state, Oracle recommends thatyou start up the database to perform a recovery process, and then shutdown the database gracefully using theSHUTDOWN IMMEDIATEcommand:

SQL> startupORACLE instance started.
Total System Global Area 146800640 bytes FixedSize 1257668 bytes Variable Size 79695676bytes Database Buffers 62914560 bytes RedoBuffers 2932736 bytes Database mounted.
Database opened.
SQL> shutdown immediateDatabase closed.
Database dismounted.
ORACLE instance shut down.
SQL>

If you are using Windows XP as your host operating system, you don’t need to see the command line in this case either. Click Start ? AllPrograms ? Oracle Database 10g Express Edition ? Stop Database to stop the database. A DOS command window will appear to confirm that youstopped the database successfully.

0 comments:

About this blog

Site Sponsors