Search This Blog

17 October 2011

Oracle Database Administration chapter-1


1. Introduction to Oracle Database

An Oracle database is a collection of data treated as a unit. The purpose of a database is to store and retrieve related information. A database server is the key to solving the problems of information management. In general, a server reliably manages a large amount of data in a multiuser environment so that many users can concurrently access the same data. All this is accomplished while delivering high performance. A database server also prevents unauthorized access and provides efficient solutions for failure recovery.
Oracle Database is the first database designed for enterprise grid computing, the most flexible and cost effective way to manage information and applications. Enterprise grid computing creates large pools of industry-standard, modular storage and servers. With this architecture, each new system can be rapidly provisioned from the pool of components. There is no need for peak workloads, because capacity can be easily added or reallocated from the resource pools as needed.
The database has logical structures and physical structures. Because the physical and logical structures are separate, the physical storage of data can be managed without affecting the access to logical storage structures.

Overview of Oracle Grid Architecture

The Oracle grid architecture pools large numbers of servers, storage, and networks into a flexible, on-demand computing resource for enterprise computing needs. The grid computing infrastructure continually analyzes demand for resources and adjusts supply accordingly.
For example, you could run different applications on a grid of several linked database servers. When reports are due at the end of the month, the database administrator could automatically provision more servers to that application to handle the increased demand.
Grid computing uses sophisticated workload management that makes it possible for applications to share resources across many servers. Data processing capacity can be added or removed on demand, and resources within a location can be dynamically provisioned. Web services can quickly integrate applications to create new business processes.

Difference between a cluster and a grid

 Clustering is one technology used to create a grid infrastructure. Simple clusters have static resources for specific applications by specific owners. Grids, which can consist of multiple clusters, are dynamic resource pools shareable among many different applications and users. A grid does not assume that all servers in the grid are running the same set of applications. Applications can be scheduled and migrated across servers in the grid. Grids share resources from and among independent system owners.
At the highest level, the idea of grid computing is computing as a utility. In other words, you should not care where your data resides, or what computer processes your request. You should be able to request information or computation and have it delivered - as much as you want, and whenever you want. This is analogous to the way electric utilities work, in that you don't know where the generator is, or how the electric grid is wired, you just ask for electricity, and you get it. The goal is to make computing a utility, a commodity, and ubiquitous. Hence the name, The Grid. This view of utility computing is, of course, a "client side" view.
From the "server side", or behind the scenes, the grid is about resource allocation, information sharing, and high availability. Resource allocation ensures that all those that need or request resources are getting what they need, that resources are not standing idle while requests are going unserviced. Information sharing makes sure that the information users and applications need is available where and when it is needed. High availability features guarantee all the data and computation is always there, just like a utility company always provides electric power.

Responsibilities of Database Administrators

Each database requires at least one database administrator (DBA). An Oracle Database system can be large and can have many users. Therefore, database administration is sometimes not a one-person job, but a job for a group of DBAs who share responsibility.
A database administrator's responsibilities can include the following tasks:
  • Installing and upgrading the Oracle Database server and application tools
  • Allocating system storage and planning future storage requirements for the database system
  • Creating primary database storage structures (tablespaces) after application developers have designed an application
  • Creating primary objects (tables, views, indexes) once application developers have designed an application
  • Modifying the database structure, as necessary, from information given by application developers
  • Enrolling users and maintaining system security
  • Ensuring compliance with Oracle license agreements
  • Controlling and monitoring user access to the database
  • Monitoring and optimizing the performance of the database
  • Planning for backup and recovery of database information
  • Maintaining archived data on tape
  • Backing up and restoring the database
  • Contacting Oracle for technical support
This section presents the steps involved when you create a database manually. These steps should be followed in the order presented. Before you create the database make sure you have done the planning about the size of the database, number of tablespaces and redo log files you want in the database.

Regarding the size of the database you have to first find out how many tables are going to be created in the database and how much space they will be occupying for the next 1 year or 2. The best thing is to start with some specific size and later on adjust the size depending upon the requirement

Plan the layout of the underlying operating system files your database will comprise. Proper distribution of files can improve database performance dramatically by distributing the I/O during file access. You can distribute I/O in several ways when you install Oracle software and create your database. For example, you can place redo log files on separate disks or use striping. You can situate datafiles to reduce contention. And you can control data density (number of rows to a data block).


Select the standard database block size. This is specified at database creation by the DB_BLOCK_SIZE initialization parameter and cannot be changed after the database is created. For databases, block size of 4K or 8K is widely used

Before you start creating the Database it is best to write down the specification and then proceed

The examples shown in these steps create an example database my_ica_db

Let us create a database my_ica_db with the following specification

Database name and System Identifier
     SID        =    myicadb
     DB_NAME    =    myicadb

TABLESPACES
(we will have 5 tablespaces in this database. With 1 datafile in each tablespace)

     Tablespace Name Datafile                        Size
system     /u01/oracle/oradata/myica/sys.dbf    250M
users      /u01/oracle/oradata/myica/usr.dbf    100M
undotbs    /u01/oracle/oradata/myica/undo.dbf   100M
temp       /u01/oracle/oradata/myica/temp.dbf   100M
index_data /u01/oracle/oradata/myica/indx.dbf   100M
     sysaux     /u01/oracle/oradata/myica/sysaux.dbf 100M

LOGFILES
(we will have 2 log groups in the database)
           
            Logfile Group              Member                                                          Size
     Group 1    /u01/oracle/oradata/myica/log1.ora   50M
     Group 2    /u01/oracle/oradata/myica/log2.ora   50M

CONTROL FILE         /u01/oracle/oradata/myica/control.ora
PARAMETER FILE       /u01/oracle/dbs/initmyicadb.ora

(rememer the parameter file name should of the format init<sid>.ora and it should be in ORACLE_HOME/dbs  directory in Unix o/s and ORACLE_HOME/database directory in windows o/s)

Now let us start creating the database.

Step 1: Login to oracle account and make directories for  your database.

      $mkdir /u01/oracle/oradata/myica
      $mkdir /u01/oracle/oradata/myica/bdump
      $mkdir /u01/oracle/oradata/myica/udump
      $mkdir /u01/oracle/oradata/myica/cdump

Step 2: Create the parameter file by copying the default template (init.ora) and set the required parameters

      $cd /u01/oracle/dbs
      $cp init.ora  initmyicadb.ora

            Now open the parameter file and set the following parameters

$vi initmyicadb.ora

      DB_NAME=myicadb
      DB_BLOCK_SIZE=8192
      CONTROL_FILES=/u01/oracle/oradata/myica/control.ora
      BACKGROUND_DUMP_DEST=/u01/oracle/oradata/myica/bdump
      USER_DUMP_DEST=/u01/oracle/oradata/myica/udump
CORE_DUMP_DEST=/u01/oracle/oradata/myica/cdump
UNDO_TABLESPACE=undotbs
UNDO_MANAGEMENT=AUTO

            After entering the above parameters save the file by pressing Esc :wq

Step 3: Now set ORACLE_SID environment variable and start the instance.

      $export ORACLE_SID=myicadb
      $sqlplus
      Enter User: / as sysdba
      SQL>startup nomount

Step 4: Give the create database command
           
         Here I am not specfying optional setting such as language, characterset etc. For these
         settings oracle will use the default values. I am giving the barest command to create the
database to keep it simple.

            The command to create the database is


SQL>create database myicadb
datafile ‘/u01/oracle/oradata/myica/sys.dbf’ size 250M
sysaux datafile ‘/u01/oracle/oradata/myica/sysaux.dbf’ size 100m
undo tablespace undotbs
datafile ‘/u01/oracle/oradata/myica/undo.dbf’ size 100m
      default temporary tablespace temp
            tempfile ‘/u01/oracle/oradata/myica/tmp.dbf’ size 100m
      logfile
            group 1 ‘/u01/oracle/oradata/myica/log1.ora’ size 50m,
            group 2 ‘/u01/oracle/oradata/myica/log2.ora’ size 50m;


After the command fishes you will get the following message

Database created.

If you are getting any errors then see accompanying messages. If no accompanying messages are shown then you have to see the alert_myicadb.log file located in BACKGROUND_DUMP_DEST directory, which will show the exact reason why the command has failed. After you have rectified the error please delete all created files in /u01/oracle/oradata/myica directory and again give the above command.


Step 5: After the above command finishes, the database will get mounted and opened. Now
create additional tablespaces

To create USERS tablespace
SQL>create tablespace users
datafile ‘/u01/oracle/oradata/myica/usr.dbf’ size 100M;

To create INDEX_DATA tablespace
SQL>create tablespace index_data
 datafile ‘/u01/oracle/oradata/myica/indx.dbf’ size 100M


Step 6: To populate the database with data dictionaries and to install procedural options execute
            the following scripts

            First execute the CATALOG.SQL script to install data dictionaries
      SQL>@/u01/oracle/rdbms/admin/catalog.sql
           
The above script will take several minutes. After the above script is finished run the CATPROC.SQL script to install procedural option.
SQL>@/u01/oracle/rdbms/admin/catproc.sql

This script will also take several minutes to complete.

Step 7: Now change the passwords for SYS and SYSTEM account, since the default passwords
            change_on_install and manager are known by everybody.

      SQL>alter user sys identified by myica;

      SQL>alter user system identified by myica;

Step 8: Create Additional user accounts. You can create as many user account as you like. Let us create the popular account SCOTT.

      SQL>create user scott default tablespace users
identified by tiger quota 10M on users;
      SQL>grant connect to scott;

Step 9: Add this database SID in listener.ora file and restart the listener process.

      $cd /u01/oracle/network/admin
           
$vi listener.ora

            (This file will already contain sample entries. Copy and paste one sample entry and edit the SID setting)

      LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
             (ADDRESS =(PROTOCOL = TCP)(HOST=200.200.100.1)(PORT = 1521))
    )
  )
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME =/u01/oracle)
      (PROGRAM = extproc)
    )
    (SID_DESC =
       (SID_NAME=ORCL)
       (ORACLE_HOME=/u01/oracle)
    )
#Add these lines
    (SID_DESC =
       (SID_NAME=myicadb)
       (ORACLE_HOME=/u01/oracle)
    )

  )


            Save the file by pressing Esc :wq

            Now restart the listener process.

      $lsnrctl stop
      $lsnrctl start

Step 10: It is recommended to take a full database backup after you just created the database.
             How to take backup is deal in the Backup and Recovery Section.

           

Congratualtions you have just created an oracle database.

No comments:

Post a Comment