0321-0324

Previous Table of Contents Next

Page 321


NOTE
You cannot issue startup and shutdown commands from a connection via the multithreaded server. You must have a dedicated session to issue these commands. If running the multithreaded server, you first must disable the TWO_TASK environment variable before starting Server Manager.

To start up a database, use the following set of commands:

  1. Start Server Manager by issuing the svrmgrl or svrmgr30 command.
  2. Issue the CONNECT INTERNAL command to connect to the database.
  3. Start the database by using any of the STARTUP commands.
  4. Exit Server Manager by typing EXIT or QUIT.

You can substitute any one of the startup options for the STARTUP command listed in step 3, such as STARTUP MOUNT or STARTUP FORCE. Later in this chapter, the startup and shutdown options are discussed in more detail.

To shut down the database from line mode, follow these steps:

  1. Start Server Manager by issuing the svrmgrl or svrmgr30 command.
  2. Issue the CONNECT INTERNAL command to connect to the database.
  3. Shut down the database by using any of the SHUTDOWN commands.
  4. Exit Server Manager by typing EXIT or QUIT.

You can substitute other shutdown options for the SHUTDOWN option listed in step 3, depending on your site's needs. Use the SHUTDOWN IMMEDIATE command, for example, if you want to log out all processes connected to the database.

Server Manager should appear similar to the screen shown in Figure 14.1. This screen was taken from a Windows NT machine running the latest version of Oracle8. Depending on the platform on which you are running Oracle, the output may differ slightly.

Figure 14.1.
Sample output from
Server Manager.


Page 322

When entering commands in Server Manager, output scrolls up the screen. As the screen is filled, new output appears at the bottom of the screen, and older output scrolls to the top (see Figure 14.2). Notice that there is no scrollbar at the right of the screen. To save output from Server Manager, use the SPOOL command to create a spool file.


Figure 14.2.
Sample output from
commands entered in
Server Manager.

Server Manager in Command Mode

Command mode enables you to place a group of commands in the same script file to be executed together. Uses of command mode include starting up or shutting down an instance and collecting data for a custom report.

The format and execution of a command file for use in Server Manager is identical to the format of command files used in SQL*Plus. The following is a list of guidelines you can use for formatting a command file:

  • Although the SQL extension is not required, using it could help you identify the file in the future.
  • If any commands in your command file require you to be connected to the database, the first line should be CONNECT INTERNAL.
  • You should terminate all single-line or multiline commands with ; or /. If the command is longer than a single line, only the last line of the command must have a ; or / terminating it.
  • You should separate command lines with a Return for readability.
  • Scripts can call other scripts, but the depth of the nesting is operating-system dependent.
  • The command mode does not require an EXIT or QUIT command.

To call a command script while executing Server Manager, you can use the following command format:

Svrmgrl @filename.sql

Page 323

Server Manager requires the @ to execute the script. If the @ is not supplied, Server Manager generates an error message. A sample startup script follows :

 REM REM startup.sql to be used to automate the startup REM of a database through Server Manager command mode REM connect internal; startup; 

With this script, you can start up your database with the following command:

 Svrmgrl @startup.sql 

The following is a sample shutdown script:

 REM REM shutdown.sql to be used to automate the shutdown REM of a database through Server Manager command mode connect internal; shutdown; 

You then can execute this script in the same way you executed startup.sql:

 Svrmgrl @shutdown.sql 

NOTE
Make sure that startup.sql and shutdown.sql reside on your current directory or somewhere in your path . If Server Manager cannot find your script, you are given an error and returned to an operating system's command prompt instead of the SVRMGR> prompt. It is a good idea to explicitly name the directory and file you want to execute.

You can further customize these scripts by adding startup and shutdown options (such as SHUTDOWN IMMEDIATE) or SQL statements that show who is currently logged on to the Oracle instance.

Automating the Startup and Shutdown Options

With a certain amount of operating system expertise, you can automate the startup and shutdown of your Oracle instance. This capability can be helpful if you have an operations staff that routinely must start and stop your database instances for basic maintenance (system reboot, offline backup, and so on).

The previous section discussed one possible way to automate startup or shutdown by using command scripts. Another, more typical, way is to embed these commands in a script that a system operator can run without any knowledge of Oracle commands or Server Manager modes. Listing 14.1 shows a sample UNIX script for starting an Oracle instance.

Page 324

Listing 14.1. A sample UNIX script to start an Oracle instance.

 #! /bin/sh ########## # filename:  oracle_start.sh ##### # As Oracle recommends, the first line is to force the script # to run in the Bourne Shell. ##### ##### # This script should be run from the Oracle DBA account. # It assumes that ORACLE_HOME has been defined.  If it has not, # this script will exit with the appropriate error message. # # Other assumptions include that your ORACLE_SID has been set before # running this script. # ##### # If ORACLE_HOME = nothing then exit with a status of 1 if [ "${ORACLE_HOME}" = "" ]   then     echo "ORACLE_HOME is undefined.  It must be defined before"     echo "continuing."     exit 1 fi # If ORACLE_SID is undefined, exit with a status of 2 if [ "${ORACLE_SID}" = "" ]   then     echo "ORACLE_SID is undefined.  It must be defined before"     echo "continuing."     exit 2 fi # Check to see if the database is up # if the sgadef(instance).dbf file is there, the instance is # running and the startup should NOT proceed if [ -f "${ORACLE_HOME}/dbs/${ORACLE_SID}.dbf" ]   then     echo "The ${ORACLE_SID} instance of Oracle is running"     echo "You must shut down before starting up."     exit 3 fi # The database is not running, so let's start it in normal mode # using the script we defined in the preceding sections. # If we cannot find sqldba, then we will exit with an error if [ -f "${ORACLE_HOME}/bin/svrmgrl" ]   then     svrmgrl @startup.sql   else     echo "Could not locate the svrmgrl executable.  Startup cannot"     echo "proceed." 
Previous Table of Contents Next


Oracle Unleashed
Oracle Development Unleashed (3rd Edition)
ISBN: 0672315750
EAN: 2147483647
Year: 1997
Pages: 391

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net