Harvard University Oracle Database Administration Session 9 Managing the Environment.

Slides:



Advertisements
Similar presentations
CHAPTER 4 Tablespaces and Datafiles. Introduction After installing the binaries, creating a database, and configuring your environment, the next logical.
Advertisements

Introduction to Oracle
Overview of Database Administrator (DBA) Tools
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 2 Overview of Database Administrator (DBA) Tools.
3 Managing an Oracle Instance. Objectives Setting up operating system and password file authentication Creating the parameter file Starting up an instance.
Page Footer Keed Education Oracle Database Administration Basic Copyright 2009 Keed Education BV Version Concept.
Primer on Structure& Storage Analysis Primer on Structure & Storage Analysis This presentation is supposed to give a simple and brief overview for storage.
5 Copyright © Oracle Corporation, All rights reserved. Using Data Dictionary and Dynamic Performance Views Cui Zhou Oracle Certified Professional.
Basic Storage Concepts and Settings
5 Copyright © Oracle Corporation, All rights reserved. Using Data Dictionary and Dynamic Performance Views.
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Installation – Lecture 2 Copyright System Managers LLC 2007 all rights reserved.
System Administration Accounts privileges, users and roles
Harvard University Oracle Database Administration Session 2 System Level.
Harvard University Oracle Database Administration Session 5 Data Storage.
Advanced Databases Basic Database Administration Guide to Oracle 10g 1.
INTRODUCTION TO ORACLE
Backup and Recovery Part 1.
Harvard University Oracle Database Administration Session 11 Database Recovery.
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 3 Administration of Users.
Oracle Database Administration Database files Logical database structures.
Module 8: Server Management. Overview Server-level and instance-level resources such as memory and processes Database-level resources such as logical.
IT Database Administration Section 03. Tablespaces and the DBA  Important for DBAs – logical units of database storage Made up of physical operating-system.
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 3 Administration of Users.
9/11/2015ISYS366 - Week051 ISYS366 – Week 5-6 Database Tuning - User and Rollback Data Spaces, Recovery, Backup.
Database Administration TableSpace & Data File Management
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
CHAPTER 6 Users and Basic Security. Progression of Steps for Creating a Database Environment 1. Install Oracle database binaries (Chapter 1) 2. Create.
9 Copyright © 2005, Oracle. All rights reserved. Administering User Security.
7202ICT Database Administration Lecture 7 Managing Database Storage Part 2 Orale Concept Manuel Chapter 3 & 4.
Extents, segments and blocks in detail. Database structure Database Table spaces Segment Extent Oracle block O/S block Data file logical physical.
4 Copyright © 2006, Oracle. All rights reserved. Recovering from Noncritical Losses.
IS 221: DATABASE ADMINISTRATION Lecture 6:Create Users & Manage Users. Information Systems Department 1.
The protection of the DB against intentional or unintentional threats using computer-based or non- computer-based controls. Database Security – Part 2.
9 Storage Structure and Relationships. 9-2 Objectives Listing the different segment types and their uses Controlling the use of extents by segments Stating.
Transparent Data Encryption
Oracle FULL EXP/IMP 11i Database SURENDER SARA NCOAUG
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.
Introduction to Oracle. Oracle History 1979 Oracle Release client/server relational database 1989 Oracle Oracle 8 (object relational) 1999.
Week 3 Lecture 2 Basic Storage Concepts and Settings.
Week 4 Lecture 2 Advanced Table Management. Learning Objectives  Create tables with large object (LOB) columns and tables that are index-organized 
Database Storage Structures
Database Security. Multi-user database systems like Oracle include security to control how the database is accessed and used for example security Mechanisms:
#.6 Sampling Kyle Hailey
Nitin Singh,AAO/EDP,RTI Allahabad1 Troubleshooting.
Oracle 10g Database Administrator: Implementation and Administration Chapter 5 Basic Storage Concepts and Settings.
Managing Tablespaces and Data Files
55 Creating Data Dictionary Views and Standard Packages.
10 Managing Rollback Segments Objectives Planning the number and size of rollback segments Creating rollback segments using appropriate storage.
6 Copyright © 2007, Oracle. All rights reserved. Performing User-Managed Backup and Recovery.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
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).
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
8 Copyright © 2007, Oracle. All rights reserved. Implementing SecureFile LOBs.
Database Systems Slide 1 Database Systems Lecture 4 Database Security - Concept Manual : Chapter 20 - Database Security Manual : Chapters 5,10 - SQL Reference.
8 Copyright © Oracle Corporation, All rights reserved. Managing Tablespaces and Data files.
1 Chapters 19 and 20  Ch. 19: By What Authority? Users Roles Grant and revoke Synonyms  Ch. 20: Changing the Oracle Surroundings Indexes Clusters Sequences.
Table spaces.
Database structure and space Management
Using Data Dictionary and Dynamic Performance Views
Oracle 10g Database Administrator: Implementation and Administration
Database Security OER- Unit 1-Authentication
Database structure and space Management
Physical Database Structure .
Introduction To Oracle 10g
Managing Privileges.
Managing Tablespaces and Data Files
ISYS366, Oracle Disk Internals
Database administration
Presentation transcript:

Harvard University Oracle Database Administration Session 9 Managing the Environment

Harvard University DBA Goals  A proactive DBA reduces the number of weekends and off-hours worked  Setup some routines  Review the database to see what is ‘normal’  What are the growth patterns  Number of users logged in  The CPU and memory usage

Harvard University DBA Goals  The disks ‘hit’ the most  Check the alert.log for ora errors  Check for trace files  When you do these things regularly, you will notice the abnormal more easily

Harvard University Health Checks  Database  Application  System

Harvard University Release Management  Development  Test/Integration  Production  Patch  Interfaces  Conversion  Security

Harvard University Release Management  Systems  O/S  Backend  Middle Tier  Number of Users  Batch schedule  Performance Test

Harvard University Management Framework  Monitoring Framework  Automation  Batch Control  Scheduling  Production Control

Harvard University Environment Management  Wholistic Approach – Database – Middle Tier – Data Loading – Linked databases – Backups

Harvard University Environment Management  Application User perspective – Total number of Users – Max concurrent Users – Length of data loads – Uptime requirement – Must be available at……  Manage to their requirements

Harvard University DBA Tasks  Is it running……  “ps –eaf | grep dbw” tests to see if the database is up and running  “ps –eaf | grep lsnrctl” tests if the listener is running  sqlplus or some user Password ******* Tests if you can connect to the database

Harvard University Alert Log  Alert.log – Located in /$ORACLE_BASE/admin/ /diag/bdump – It shows when the database was started – When a log switch occurred – Shows the non-default parameters from the init.ora

Harvard University Alert Log – Any ddl commands to change the structure of the database – Space allocation errors – When trace files were created and where they are located – When the database was shutdown or started

Harvard University Alert Log  This file is not adjusted by Oracle, it is always appended to, until you change it.  You can rename it, edit it, or reduce it’s size  When it is renamed, Oracle will create a new file automatically

Harvard University Trace Files  When there are internal errors in a user session or with a background process, Oracle creates a trace file  They are to help in debugging a problem  Trace files, created by a background process, will have the name of the background process as part of the file name

Harvard University Trace Files  The trace file of a user process will have the process ID, in the file name  The following init.ora parameters relate to trace files – max_dump_file_sizeunlimited size – background_dump_destbackground processes – user_dump_destuser sessions traces

Harvard University Type of Views  Dba_  User_  All_  V$….  X$..

Harvard University Views  dba_segments  dba_rollback_segs  dba_objects  v$rollstat  v$rollname

Harvard University Views  dba_extents  dba_tables  dba_indexes  v$sqltext

Harvard University Instance Level  v$instance  v$database  v$sga  v$sgastat  v$parameter  v$option  v$version  v$license

Harvard University Session Level  v$session  v$transaction  v$process  v$access

Harvard University Database Structure  v$tablespace  v$datafile  v$dbfile  v$dblink  v$datafile_header

Harvard University Performance  v$waitstat  v$filestat  v$sysstat

Harvard University All V$ Views  select name from v$fixed_table where name like ‘v%' order by name

Harvard University CREATE OR REPLACE VIEW DBA_SEGMENTS ( OWNER, SEGMENT_NAME, PARTITION_NAME, SEGMENT_TYPE, TABLESPACE_NAME, HEADER_FILE, HEADER_BLOCK, BYTES, BLOCKS, EXTENTS, INITIAL_EXTENT, NEXT_EXTENT, MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE, FREELISTS, FREELIST_GROUPS, RELATIVE_FNO, BUFFER_POOL ) AS select owner, segment_name, partition_name, segment_type, tablespace_name, header_file, header_block, bytes, blocks, extents, initial_extent, next_extent, min_extents, max_extents, pct_increase, freelists,freelist_groups, relative_fno, buffer_pool from sys_dba_segs Example of a View

Harvard University dba_segments Name Null? Type OWNER VARCHAR2(30) SEGMENT_NAME VARCHAR2(81) PARTITION_NAME VARCHAR2(30) SEGMENT_TYPE VARCHAR2(18) TABLESPACE_NAME VARCHAR2(30) HEADER_FILE NUMBER HEADER_BLOCK NUMBER BYTES NUMBER BLOCKS NUMBER EXTENTS NUMBER INITIAL_EXTENT NUMBER NEXT_EXTENT NUMBER MIN_EXTENTS NUMBER MAX_EXTENTS NUMBER PCT_INCREASE NUMBER FREELISTS NUMBER FREELIST_GROUPS NUMBER RELATIVE_FNO NUMBER BUFFER_POOL VARCHAR2(7)

Harvard University Examples  select substr(segment_name,1,19) segment_name, extents from dba_segments where tablespace_name = ‘TS‘  select substr(table_name,1,19) table_name, freelists from dba_tables where tablespace_name = ‘TS'

Harvard University DBA Views set pagesize 9999 col owner format a10 col object_name format a40 select owner,object_name,object_type from dba_objects where (object_name like 'DBA_%' or object_name like 'V$%' ) and owner in ('SYS', 'SYSTEM', 'PUBLIC') order by owner,object_name

Harvard University Space Management  A database stores data  We must have enough free space available, to ensure that will continue to occur  Tablespace available  Segment space available inside the tablespace  Can we extend each segment

Harvard University Storage Information  select segment_name, segment_type,extents from dba_segments where tablespace_name = ‘DATA‘ and segment_type = ‘TABLE'  This will tell you what number of extents each table has, in a specific tablespace

Harvard University Storage Information  Change table to index and get the values for indexes

Harvard University Use this command to alter an existing tablespace in one of the following ways: * to add datafile(s) * to rename datafiles * to change default storage parameters * to take the tablespace online or offline * to begin or end a backup * to allow or disallow writing to a tablespace * to change the default logging attribute of the tablespace * to change the minimum tablespace extent length ALTER TABLESPACE

Harvard University ALTER TABLESPACE tablespace {ADD DATAFILE 'filespec‘ [AUTOEXTEND {OFF | ON [NEXT integer [K | M] ] [MAXSIZE { UNLIMITED | integer [K | M] } ] } ] [, 'filespec' [AUTOEXTEND {OFF | ON [NEXT integer [K | M] ] [MAXSIZE {UNLIMITED | integer [K | M] } ] } ] ]... Tablespace management

Harvard University | RENAME DATAFILE 'filename' [, 'filename']... TO 'filename' ['filename']... | COALESCE | DEFAULT STORAGE storage_clause | MINIMUM EXTENT integer [K | M] | ONLINE | OFFLINE [NORMAL | TEMPORARY | IMMEDIATE] | {BEGIN | END} BACKUP | READ {ONLY | WRITE} | PERMANENT | TEMPORARY} Tablespace management

Harvard University Tablespace management example  CREATE TABLESPACE TOOLS DATAFILE '/u51/oradata/dev/tools01.dbf' SIZE 50M AUTOEXTEND OFF EXTENT MANAGEMENT LOCAL AUTOALLOCATE LOGGING ONLINE

Harvard University Tablespace management example  ALTER TABLESPACE TOOLS ADD DATAFILE '/u51/oradata/dev/tools02.dbf' SIZE 200M /  ALTER DATABASE DATAFILE '/u51/oradata/dev/tools01.dbf' RESIZE 100M /

Harvard University Tablespace management example  ALTER DATABASE DATAFILE '/u08/oradata/test/datafile01.dbf' RESIZE 200M;  ALTER DATABASE DATAFILE '/u08/oradata/test/datafile01.dbf' AUTOEXTEND ON  ALTER DATABASE DATAFILE '/u08/oradata/test/tools01.dbf' AUTOEXTEND ON NEXT 200M MAXSIZE 1000M

Harvard University Sql creating sql  select ' alter database datafile ''' || file_name || ''' resize ' || to_char ( bytes/1024/ &Size ) || 'M ; ' from dba_data_files where tablespace_name = upper ( '&tablespace_name' ) and rownum < 2

Harvard University Create tablespace set heading off set verify off select distinct ( substr ( name, 1, 4 ) ) from v$datafile / select '&Press any key to continue... ' from dual / Prompt Enter Tablespace_name : Accept Tablespace_name select ' create tablespace &&tablespace_name datafile ''/u&filename/oradata/'|| value || '/&&tablespace_name' || '01.dbf'' size &Size M; ' from dual, v$parameter where name = 'instance_name' /

Harvard University Object Status Examples  select count(*) from dba_objects where status = 'INVALID‘  select object_name, object_type from dba_objects where status = 'INVALID'

Harvard University Object Modifications  select owner,object_name, object_type, status, timestamp from dba_objects where substr(timestamp,1,10) = to_char(sysdate-1, 'YYYY-MM-DD') order by owner,object_name  This will tell what objects changed since the day before

Harvard University User Sessions  desc v$session  SQL> select status, count(*) from v$session group by status; STATUS COUNT(*) ACTIVE 18 INACTIVE 16

Harvard University User Sessions  A value of inactive means that no SQL statement is running at the moment  The total number of users connected is the addition of both count values  What is each user doing, etc

Harvard University Users  CREATE USER You can assign the following properties to the user: * default tablespace * temporary tablespace * quotas for allocating space in tablespaces

Harvard University CREATE USER user IDENTIFIED {BY password | EXTERNALLY } [ DEFAULT TABLESPACE tablespace | TEMPORARY TABLESPACE tablespace | QUOTA { integer [K | M] | UNLIMITED } ON tablespace [ QUOTA { integer [K | M] | UNLIMITED } ON tablespace ] Create User

Harvard University ALTER USER user { IDENTIFIED {BY password | EXTERNALLY} | DEFAULT TABLESPACE tablespace | TEMPORARY TABLESPACE tablespace | QUOTA { integer [K | M] | UNLIMITED} ON tablespace [ QUOTA { integer [K | M] | UNLIMITED} ON tablespace]... | DEFAULT ROLE { role [, role]... | ALL [EXCEPT role [, role]...] | NONE} }... Alter User

Harvard University Roles  Connect role  Resource role  DBA role  Object privileges  System Privileges

Harvard University Connect  select * from dba_sys_privs where grantee = ‘connect’  CONNECTCREATE VIEWNO  CONNECTCREATE TABLENO  CONNECTALTER SESSIONNO  CONNECTCREATE CLUSTERNO  CONNECTCREATE SESSIONNO  CONNECTCREATE SYNONYMNO  CONNECTCREATE SEQUENCENO  CONNECTCREATE DATABASE LINKNO

Harvard University RESOURCE Role  select * from dba_sys_privs where grantee = ‘RESOURCE’  RESOURCECREATE TYPENO  RESOURCECREATE TABLENO  RESOURCECREATE CLUSTERNO  RESOURCECREATE TRIGGERNO  RESOURCECREATE OPERATORNO  RESOURCECREATE SEQUENCENO  RESOURCECREATE INDEXTYPENO  RESOURCECREATE PROCEDURENO

Harvard University DBA Role  select * from dba_sys_privs where grantee = ‘DBA’

Harvard University GRANT { object_priv | ALL [PRIVILEGES] } [ ( column [, column]...) ] [, { object_priv | ALL [PRIVILEGES] } [ ( column [, column]...) ] ]... ON [ schema.| DIRECTORY] object TO { user | role | PUBLIC}... [ WITH GRANT OPTION] GRANT (Object Privileges) Roles

Harvard University GRANT { system_priv | role} [, { system_priv | role} ]... TO { user | role | PUBLIC} [, { user | role | PUBLIC} ]... [ WITH ADMIN OPTION] GRANT (System Privileges and Roles) Roles

Harvard University Rebuild Indexes  Rebuild indexes using the following  Alter index index_name rebuild storage (initial 10M, next 10M, pctincrease 0) tablespace indexes  We can move indexes to another tablespace  There must be enough space to hold the old index and the new index, in the tablespace

Harvard University Rebuild Indexes  It can be used to reclaim unusable space  This occurs when there are a large amounts of deletions from a table

Harvard University Shared Memory  ipcs - report inter-process communication facilities status  ipcrm - remove a message queue, semaphore set, or shared memory ID  Oradebug – be very careful using this

Harvard University Suggestions  Create a script that will document your database  Run it regularly. It will give you a quick overview and provide a baseline, if things change

Harvard University Assignment 3  Create a database documentation script. Include the following – Tablespaces – Tablespace free space – Datafiles – Redo logs – Database objects – Segments

Harvard University Assignment 3 – Other areas of interest – Process information – Session information – Extents used by tables/indexes – Free space in tablespace