Oracle Database Administration

Slides:



Advertisements
Similar presentations
ITEC474 INTRODUCTION.
Advertisements

The Architecture of Oracle
4 Copyright © 2005, Oracle. All rights reserved. Managing the Oracle Instance.
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Oracle High Availability Solutions RAC and Standby Database Copyright System Managers LLC 2008.
Overview of Database Administrator (DBA) Tools
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 2 Overview of Database Administrator (DBA) Tools.
Page Footer Keed Education Oracle Database Administration Basic Copyright 2009 Keed Education BV Version Concept.
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Installation – Lecture 2 Copyright System Managers LLC 2007 all rights reserved.
Backup and recovery Basics of Backup and restoration Types of recovery Defining strategy Starting up and shutting down 80/20 rule SLA’s.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
Database Administration ISQA 436 Fall 2006 Mark Freeman
Backup The flip side of recovery. Types of Failures Transaction failure –Transaction must be aborted System failure –Hardware or software problem resulting.
Harvard University Oracle Database Administration Session 2 System Level.
Advanced Databases Basic Database Administration Guide to Oracle 10g 1.
A Guide to Oracle9i1 Introduction to Oracle9i Database Administration Chapter 11.
INTRODUCTION TO ORACLE
Backup and Recovery Part 1.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
Oracle9i Database Administrator: Implementation and Administration
Backup Concepts. Introduction Backup and recovery procedures protect your database against data loss and reconstruct the data, should loss occur. The.
VMware vCenter Server Module 4.
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 3 Administration of Users.
Managing the Oracle RDBMS Today you will look at the basics, including: –Setting up Enterprise Manager –Using Enterprise Manager –Using Server Manager.

Oracle for Software Developers. What is a relational database? Data is represented as a set of two- dimensional tables. (rows and columns) One or more.
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 3 Administration of Users.
Database Administration TableSpace & Data File Management
CHAPTER 2 Implementing a Database. Introduction to Creating Databases After you’ve installed the Oracle software, the next logical step is to create a.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
INSTALLING MICROSOFT EXCHANGE SERVER 2003 CLUSTERS AND FRONT-END AND BACK ‑ END SERVERS Chapter 4.
Sofia, Bulgaria | 9-10 October SQL Server 2005 High Availability for developers Vladimir Tchalkov Crossroad Ltd. Vladimir Tchalkov Crossroad Ltd.
Chapter 8 Implementing Disaster Recovery and High Availability Hands-On Virtual Computing.
1Introduction Objectives 1-2 Course Objectives 1-3 Oracle Products 1-4 Relational Database Systems 1-5 How the Data Is Organized 1-6 Integrity Constraints.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
The protection of the DB against intentional or unintentional threats using computer-based or non- computer-based controls. Database Security – Part 2.
1 Oracle Architectural Components. 1-2 Objectives Listing the structures involved in connecting a user to an Oracle server Listing the stages in processing.
An Oracle server:  Is a database management system that provides an open, comprehensive, integrated approach to information management.  Consists.
Oracle 10g Database Administrator: Implementation and Administration Chapter 2 Tools and Architecture.
A Guide to Oracle9i1 Database Instance startup and shutdown.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
A Brief Documentation.  Provides basic information about connection, server, and client.
IT Database Administration SECTION 01. Starting Up and Shutting Down the Database Database Administration Facilities – A number of tools are available.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Week 3 Lecture 1 The Redo Log Files and Diagnostic Files.
Introduction to Oracle. Oracle History 1979 Oracle Release client/server relational database 1989 Oracle Oracle 8 (object relational) 1999.
IT Database Administration Section 09. Backup and Recovery Backup: The available options Full Consistent (cold) Backup Database shutdown, all files.
Database Security. Multi-user database systems like Oracle include security to control how the database is accessed and used for example security Mechanisms:
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
18 Copyright © 2004, Oracle. All rights reserved. Backup and Recovery Concepts.
6 Copyright © 2007, Oracle. All rights reserved. Performing User-Managed Backup and Recovery.
QUIZ DATABASE ADMINISTRATOR. LESS 3 LESS 5 LESS 6 LESS 7.
Oracle Architecture - Structure. Oracle Architecture - Structure The Oracle Server architecture 1. Structures are well-defined objects that store the.
18 Copyright © 2004, Oracle. All rights reserved. Recovery Concepts.
Intro To Oracle :part 1 1.Save your Memory Usage & Performance. 2.Oracle Login ways. 3.Adding Database to DB Trees. 4.How to Create your own user(schema).
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
Introduction to Core Database Concepts Getting started with Databases and Structure Query Language (SQL)
Introduction to Oracle  Oracle Database XE, APEX and Oracle SQL Developer.
14 Copyright © 2007, Oracle. All rights reserved. Backup and Recovery Concepts.
4 Copyright © 2004, Oracle. All rights reserved. Managing the Oracle Instance.
9 Copyright © 2004, Oracle. All rights reserved. Getting Started with Oracle Migration Workbench.
1 Copyright © 2005, Oracle. All rights reserved. Oracle Database Administration: Overview.
 Database Administration Oracle Database Instance Management Starting Up and Shutting Down أ. ندى الغامدي, أ. ندى الطوالة.
Backup and Recovery.
Is 221: Database Administration
Recovering from Noncritical Losses
Performing Database Recovery
Chapter 11 Managing Databases with SQL Server 2000
Chapter 5 The Redo Log Files.
Presentation transcript:

Oracle Database Administration Introduction Basic administration

Additional information http://technet.oracle.com - for developers and administrators, available for: Download of Oracle products Download and viewing of product documentation http://www.mini.pw.edu.pl/~maczewsk/oracle Presentations from the lecture Lab tasks

Lecture plan Part 1 – basic database administration: creating database objects: users, tables, indexes, tablespaces, datafiles etc. managing database objects networking, connecting to remote databases SQL language – SQL standard and Oracle extensions programming Oracle – PL/SQL language exporting and importing data

Lecture plan cont. Part 2 – performance tuning: database instance parameters (e.g.: memory) tuning individual database components (log buffers, undo space) tuning SQL statements (obtaining execution plan, creating indexes, using hints)

Lecture plan cont. Part 3 – backup and recovery: Physical data storage Offline and online backups Restoring database from backup Recovering database after hardware failure or user error Managing standby database

Introduction to the Oracle Database

Oracle History 1978 – Oracle V1, never officially released 1980 – Oracle V2 released, written in assembly language 1994 – Oracle 7 for PC released 1998 – Support for Linux platform 1999 – Oracle 8i with Java integration 2001 – Oracle 9i – modern Oracle 2004 – Oracle 10g 2007 – Oracle 11g 2013 – Oracle 12c

Oracle database The best database for large database systems: most reliable in terms of data safety highest availability scalable good internationalization support Oracle shortcomings: price – expensive speed – not the fastest database available amount of resources consumed

Data safety Many features that ensure safety of data: multiplexing of important database files writing changes to data files and to special log files. Log files are used to recover database after software or hardware failure archiving of log files. Archived log files can be written to backup location(s) protection from human errors: possibility to view data from some point in time in the pas possibility to use backup and perform point in time recovery

Availability Very high availability: online backups – without shutting down the database most administrative tasks can be performed while the database is running and available for users, for example: analyzing, rebuilding indexes, moving data disk failure: it is possible to turn off and recover only the part of the database that was affected by the failure, the rest of the database can continue running parameters that ensure that recovery after failure will take no more than the specified time standby database – second database that can be opened if the main database fails

Scalability Oracle can handle unlimited amount of data: no limit on number of rows, number of tables etc. no limit on total size of the database Oracle runs on various operating systems: Windows NT/XP Linux Solaris, HP-UX, AIX Oracle Cloud/Grid – single database on a cluster

Internationalization Database supports multiple languages/locales: sorting of text can be done in client language order date, time and currency is client dependent character set conversion – database running in utf8 or iso8859-2 will convert data for clients using windows-1250 Internally database can store data in Unicode

Oracle editions Express edition: Standard edition: Enterprise edition: Simple installation and administration, some features are not available (for example: Java Virtual Machine is disabled) Standard edition: Most frequently used features are available Enterprise edition: All features, very expensive

Speed of the database Oracle favors data safety over speed: it is not possible to disable some features to achieve greater speed (e.g.: transactions) some other databases (e.g. MySQL) are faster than Oracle

Resources consumed Oracle consumes large amounts of resources: new, empty database – at least 200MB, usually over 1GB at least 256MB RAM Hint: when installing Oracle on private computer (Windows): install Standard or Enterprise edition assign around 256MB RAM for Oracle install database normally change startup of Oracle services to manual when required start the database manually with: oradim –startup –sid database_sid

Oracle terminology - database Database – data stored on disk (data files and some additional files) Database instance – program (group of programs) that opens the database (disk files) and makes it available to users User connects to the database instance and retrieves data or requests changes to the database When running Oracle on a cluster, there are multiple database instances that open the same database

Oracle terminology - schema Schema – set of objects (tables, indexes, views) that belong to a database user. In Oracle SCHEMA = USER When new user is created (CREATE USER command), initially it has an empty schema When the user logs in and creates new table, the table is added to his schema When user issues: SELECT * FROM some_table Oracle looks for some_table in the user’s schema It is possible to access data in some other schema: SELECT * FROM some_user.some_table

Major differences from other database systems

Single database Many other database systems (Postgres, MSSQL) can have multiple databases opened by a single database engine each application can use separate database for its data In Oracle single Oracle Instance can open one database normally on a single database server there will be only one database each application can store its data in separate user schema

Data storage Many other database systems (Postgres, MySQL) store table data in a separate file or group of files Oracle stores table data in a tablespace. Multiple tables are normally stored in the same tablespace. Tablespace can be stored in one or more data files (physical disk files)

Transactions Oracle executes every statement in a transaction there is no command to start a transaction (like BEGIN TRANSACTION) transaction is started automatically with a first statement after COMMIT or ROLLBACK usually transaction must be finished manually with COMMIT, exceptions: it is possible to turn on AUTOCOMMIT (by default: disabled) some statements commit the transaction automatically: all CREATE, ALTER, DROP and TRUNCATE statements

Transaction example -- user connects to the database DELETE FROM table1; -- new transaction created INSERT INTO table1 VALUES (1, ‘some text’); INSERT INTO table1 VALUES (2, ‘some text’); CREATE TABLE table2 ( id NUMBER PRIMARY KEY, text VARCHAR2(256) ); ROLLBACK; -- table1 contains 2 rows, -- the rollback statement rolled -- back empty transaction

Date format, language Oracle has no fixed date and time format. When displaying dates, Oracle uses the format consistent with the connected client Language used by Oracle (for example: error messages) also depend on the language settings To use English with Oracle, set the environment variable NLS_LANG before starting SQLPlus: SET NLS_LANG=AMERICAN_AMERICA.UTF8

General database terminology Database user – login and password used to connect to the database. Each user has: set of privileges for accessing the database schema objects: objects: tables, indexes etc. Table – database object used for data storage: can have any number of rows has fixed number of columns, each column has a name and datatype can have constraints, indexes and relations to other tables Relation – defines a dependency between two tables

Index – object that organizes data in a table. Indexes are used: Constraint – rule that must be satisfied by each table row. Constraint can be: PRIMARY KEY constraint NOT NULL constraint UNIQUE constraint FOREIGN KEY constraint (relation) CHECK constraint Index – object that organizes data in a table. Indexes are used: to enforce PRIMARY KEY and UNIQUE constraints to improve query performance

Trigger – action performed when user makes changes to database data Session – single connection to the database. One user can open multiple sessions to the database Transaction – set of operations that are visible as single (atomic) operation on the database. Transaction belongs to a single open database session.

Accessing the database Oracle can be accessed from various tools: Oracle tools: SQLPlus (always available) – command line tool for executing SQL statements. All administrative statements can be executed from SQLPlus SQL Developer – free development tool, easier to use than SQLPlus Third party tools: TOAD –application for administrating Oracle database, executing SQL statements, TOAD Freeware Edition is available for free

Connecting to the database In order to connect, you need to specify: user name password connect string (optional) connect mode (optional) Connect string: determines location of the database, if not specified – local database Connect mode – specified for administrative connections (database startup and shutdown)

Starting database session The following commands will start SQLPlus and connect to the database: sqlplus test/testpass – Log in as user “test” password “testpass” to local database sqlplus test/testpass@db – Log in as user “test” to database “db” sqlplus system/orclstudent – Log in as user “system” password “orclstudent” sqlplus sys/orclstudent as sysdba – Log in as user “sys” with special SYSDBA privileges

Networking

Connecting to Oracle Connection to Oracle is possible: in local mode – when connecting to local database only via network – when connecting to some other database All non-local connections are done through the listener

The listener Oracle Listener is separate from the database In Windows it starts as service OraclexxxxTNSListener One listener can handle connections for multiple databases Listener configuration determines how clients will connect to the database. By default listener: uses TCP/IP listens on port 1521 – default Oracle port

Listener configuration Listener configuration is in $ORACLE_HOME/network/admin/listener.ora Example configuration: LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = host_name)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) )

Listener startup and shutdown Listener can be started manually from the command line: lsnrctl start Other commands: lsnrctl stop – stops the listener lsnrctl status – shows list of services that this listener supports

Naming configuration When connecting to database using SQLPlus you specify: user name password database name When the database name is empty – connection to the local database When the database name is not empty – lookup of the database name. By default database names are looked up in tnsnames.ora file

tnsnames.ora Location: This file is used to lookup names of databases: $ORACLE_HOME/network/admin/tnsnames.ora This file is used to lookup names of databases: IP address of the database listener port number name of the Oracle instance

tnsnames.ora - example Typical entry in the tnsnames.ora file: TEST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = name_or_ip) (PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = database_instance_name)

tnsnames.ora - example Entries in tnsnames.ora enable: specifying multiple addresses for a connection (connect time failover) request load balancing between the list of available addresses TEST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = name_or_ip) (PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = other_host) ) (CONNECT_DATA = (SERVICE_NAME = database_instance_name)

tnsnames.ora - example Load balancing example TEST = (DESCRIPTION = (ADDRESS_LIST = (LOAD_BALANCE=on) (FAILOVER=off) (ADDRESS = (PROTOCOL = TCP)(HOST = name_or_ip) (PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = other_host) ) (CONNECT_DATA = (SERVICE_NAME = database_instance_name)

Database administration

Administrative privileges Database administration requires strong privileges: SYSDBA – the most powerful database privilege, enables database startup, shutdown and access to all data in the database SYSOPER – enables database startup and shutdown without access to database data DBA – role (a group of privileges) giving user full administrative access, but without the right to start and shut down the database

Administrator accounts Each Oracle database has two accounts: SYS – owner of the administrative objects, created with DBA role, has SYSDBA and SYSOPER privileges SYSTEM – automatically created with DBA role SYS and SYSTEM users should not be used to create any tables

DBA, SYSDBA and SYSOPER DBA role grants administrator access to the database when the database is running DBA role is not enough to startup and shutdown the database SYSDBA and SYSOPER enable database startup and shutdown In order to use the SYSDBA or SYSOPER privilege, the connection must be in special mode: connect sys/sys_password as sysdba

Important! SYSDBA is not database user name – it is a privilege and special connect mode. When connecting to the database: connect sys/sys_password as sysdba special connection with in SYSDBA mode is requested.

SYSDBA and SYSOPER DBA user can be granted SYSDBA or SYSOPER privilege SYSDBA privilege enables you to Perform STARTUP and SHUTDOWN operations ALTER DATABASE: open, mount, back up, or change character set CREATE DATABASE DROP DATABASE CREATE SPFILE ALTER DATABASE ARCHIVELOG ALTER DATABASE RECOVER Includes the RESTRICTED SESSION privilege SYSDBA lets you look at any user’s data

Database shutdown SHUTDOWN NORMAL – waits for all users to disconnect, not recommended – can take a long time SHUTDOWN TRANSACTIONAL – waits for all users to finish their transactions SHUTDOWN IMMEDIATE – rolls back all uncommitted transactions, closes all sessions, closes the database and shuts down the instance SHUTDOWN ABORT – aborts the instance, does not close the database properly. Requires automatic recovery after startup.

Database startup Database startup involves 3 steps: starting the instance mounting the database opening the database – opened database is available for use STARTUP – executes those 3 steps When performing administrative actions, those steps can be performed one by one: STARTUP NOMOUNT – only start the instance, useful when creating the database STARTUP MOUNT – start the instance and mount the database (open database control files)

Database startup Example startup (rarely used): STARTUP NOMOUNT ALTER DATABASE MOUNT ALTER DATABASE OPEN Example startup (used for many administrative actions): STARTUP MOUNT perform some administrative actions, e.g. recover the database, change archiving mode ALTER DATABASE OPEN – opens database for use

System views Oracle provides many system views that provide information about the database: v$session – all open sessions v$datafile – all data files v$logfile – all log files v$database – general information about the database v$instance – general information about the instance Some of those views are available when the database is closed

Example scenario The database cannot start, error message is that file number 4 is corrupt. Recovery: STARTUP MOUNT SELECT name FROM v$datafile WHERE file# = 4 fix the problem with the file, e.g. restore it from backup recover the database ALTER DATABASE OPEN