Oracle 2 days DBA student guide

63 425 0
Oracle 2 days DBA student guide

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Oracle Database 10g: Days DBA Volume I • Student Guide D22057GC10 Production 1.0 June 2006 D46524 Authors Donna Keesling Maria Billings Technical Contributors and Reviewers Christopher Andrews Tammy Bednar Tom Best Harald van Breederode Mary Jane Bryksa Marielle Canning Tim Chien Donna Cooksey Judy Ferstenberg Gerlinde Frenzen Joel Goodman Pete Jones Isabelle Marchand Sabiha Miri Manish Pawar Jim Spiller George Stabler Anthony Woodell Editor Daniel Milne Graphic Designer Satish Bettegowda Publisher Jobi Varghese Copyright © 2006, Oracle All rights reserved Disclaimer This docum ent contains proprietary information and is protected by copyright and other intellectual property laws You may copy and print this docum ent solely for your own use in an Oracle training course The document may not be modified or altered in any way Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization of Oracle The information contained in this docum ent is subject to change without notice If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA This document is not warranted to be error-free Restricted Rights Notice If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United States Government, the following notice is applicable: U.S GOVERNMENT RIGHTS The U.S Government’s rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S Government contract Trademark Notice Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle Corporation and/or its affiliates Other names may be trademarks of their respective owners Flower Shop Database Table Descriptions CUSTOMERS CUSTOMER_ID CUST_FIRST_NAME CUST_LAST_NAME STREET_ADDRESS CITY STATE POSTAL_CODE PHONE_NUMBER NUMBER(6) VARCHAR2(20) VARCHAR2(20) VARCHAR2(40) VARCHAR2(30) VARCHAR2(10) VARCHAR2(10) VARCHAR2(20) EMPLOYEES EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL_ADDRESS PHONE_NUMBER HIRE_DATE JOB_ID SALARY MANAGER_ID NUMBER(6) VARCHAR2(20) VARCHAR2(25) VARCHAR2(25) VARCHAR2(20) DATE VARCHAR2(10) NUMBER(8) NUMBER(6) JOBS JOB_ID JOB_TITLE MIN_SALARY MAX_SALARY VARCHAR2(10) VARCHAR2(35) NUMBER(6) NUMBER(6) JOB_HISTORY EMPLOYEE_ID START_DATE END_DATE JOB_ID NUMBER(6) DATE DATE VARCHAR2(10) ORDERS ORDER_ID ORDER_DATE ORDER_MODE CUSTOMER_ID DELIVERY_MODE ORDER_STATUS SALES_CLERK_ID ORDER_TOTAL NUMBER(12) DATE VARCHAR2(8) NUMBER(6) VARCHAR2(8) NUMBER(2) NUMBER(6) NUMBER(8,2) ORD_ITEMS ORDER_ID PRODUCT_ID UNIT_PRICE QUANTITY NUMBER(12) NUMBER(6) NUMBER(8) NUMBER(8) PRODUCTS PRODUCT_ID PRODUCT_NAME PRODUCT_DESC CATEGORY SUPPLIER_ID LIST_PRICE MIN_PRICE QTY_ON_HAND NUMBER(6) VARCHAR2(50) VARCHAR2(200) NUMBER(2) NUMBER(6) NUMBER(8,2) NUMBER(8,2) NUMBER(8) Practice 2: Installing the Oracle Database Software Background: In the practices of this course, you assume the role of a DBA The OS accounts on your computer are:  The oracle user with a password of oracle  The root user with a password of oracle The system administrator has set up the OS so that it is ready for the installation, and the installation media is staged at /stage/Disk1 Perform the following tasks as the default oracle OS user, unless otherwise indicated Your Tasks Use Oracle Universal Installer (OUI) to begin your software installation of the Enterprise Edition of Oracle Database 10g Release This is a “Basic Installation” of the Oracle software with a “starter” database In the database, you unlock the HR schema that is used throughout the following practice sessions Select your installation method by entering and accepting the following settings: Object Setting Database Home Location /u01/app/oracle/product/10.2.0/db_1 Installation Type Basic UNIX DBA Group oinstall Create Starter Database Selected Global Database Name orcl Database Password oracle Confirm Password oracle When the prerequisite checks are finished, install the Oracle software and enable the configuration assistants to create and configure your first database Unlock the HR schema When prompted, execute configuration scripts as the root user Accept the default for the local bin directory When finished, exit the root OS user, close the XTerm window, and finish your installation with OUI Please make a note of your End of Installation URLs You will use them in later practice sessions iSQL*PlusURL: iSQL*Plus DBA URL: _ EM URL: _ Note: Completing this practice is critical for all following practice sessions Install the Oracle database software as the oracle user Navigate to the /stage/Disk1 directory, and start the Oracle Universal Installer a Double-click the XTerm icon on your desktop, and then enter: $ cd /stage/Disk1 $ /runInstaller Select your installation method for OUI a Select Basic Installation, and confirm the following settings: Object Setting Database Home Location /u01/app/oracle/product/10.2.0/db_1 Installation Type Enterprise Edition UNIX DBA Group oinstall Create Starter Database Selected Global Database Name Orcl b Enter oracle as Database Password and Confirm Password Then click Next OUI is checking product-specific prerequisites c Click Next, when OUI has finished its prerequisite checks Click Next again When the prerequisite checks are finished, the Summary page is displayed a Click Install to begin your installation After the installation, the Database Configuration Assistant (DBCA) begins to configure your database Unlock the HR schema a Click the Password Management button, when prompted The Password Management page appears b Scroll until you find the HR username, deselect Lock Account?, and enter hr in the New Password and Confirm Password fields c Click OK on the Password Management page, and then again on the Database Configuration Assistant page (The OK button is below the Password Management button.) The next Configuration Assistant begins its work When the Execute Configuration scripts page appears, follow the instructions on that page, and then finish your installation with OUI a Double-click the XTerm icon on your desktop b Run the orainstRoot.sh and root.sh scripts as root, and then click Continue 10 SQL> SELECT * FROM fsowner.customers; … rows selected SQL> SELECT systimestamp FROM dual; SYSTIMESTAMP 24-MAY-05 10.58.17.725282 AM -07:00 Record your system time: _ Delete the FSOWNER.CUSTOMERS table and verify your change a Log in to Database Control as the FSOWNER user with a normal connection (password is fsowner) b Click Tables in the Schema region of the Administration property page c Enter FSOWNER in the schema field, CUSTOMERS in the object name field, and click Go d Click Delete With Options e Click “Delete the table definition, all its data and dependent objects (DROP)”and click Yes 49 f Verify that the FSOWNER.CUSTOMERS table is no longer there SQL> SELECT * FROM fsowner.customers; SELECT * FROM fsowner.orders * ERROR at line 1: ORA-00942: table or view does not exist Use the Flashback Drop feature to recover your CUSTOMERS table a Click Tables in the Schema region of the Administration property page b Click Recycle Bin 50 c Select the CUSTOMERS table and click Flashback Drop d Leave the new name for the restored table as CUSTOMERS, and click Next Click Next e Click Submit to confirm the tables to be flashed back 51 f Click OK to confirm the flashback operation Verify whether the dropped table was restored SQL> SELECT * FROM fsowner.customers; … rows selected 52 Practice 10-1: Monitoring the Database and Using the Advisors In this practice, you use Enterprise Manager to define notification rules and metric thresholds Ensure that you are notified when your FSDATA tablespace is 80% full Log in to Database Control as the SYS user with a SYSDBA connection Modify the Tablespace Space Used (%) metric for the FSDATA tablespace a Click Manage Metrics in the Related Links region at the bottom of Database Control b Click Edit Thresholds and scroll down to select Tablespace Space Used (%) c Click Specify Multiple Thresholds 53 d Enter FSDATA in the Tablespace Name field e Enter 80 in the Warning Threshold field, enter 90 in the Critical Threshold field f Leave the Response Action field blank and click OK g Click OK Set the notification rules so that you will be notified by e-mail when your tablespace usage exceeds the threshold that you have specified 54 a Click Setup from the links at the top of Database Control b Click Notification Methods c Enter e-mail notification information: - Enter smtp.mailhost.ou.com in the outgoing mail server field - Enter Database Control in the Identify Sender field - Enter dbcontrol@ou.com in the Sender’s E-Mail field Note: This is a fictitious mail server Testing it will fail d Click Apply Configure an address to receive e-mail notifications a Click Setup from the links at the top of Database Control 55 b Click Administrators c Select FSOWNER and click Edit d Enter an e-mail address to receive database alerts Click Finish and click Finish again Simulate a table that has grown excessively by manually extending the FSOWNER.EMPLOYEES table a Open a terminal window b Connect to the database as FSOWNER by using SQL*Plus # sqlplus fsowner/fsowner c Manually extend the EMPLOYEES table thrice SQL> ALTER TABLE fsowner.employees ALLOCATE EXTENT; Table altered SQL> / Table altered SQL> / Table altered Note: Each time this SQL command was executed, the table grew by an additional 64 KB In a production database, segments can possess unnecessary space naturally when a table has grown and rows have been deleted Use the Segment Advisor to determine if you need to make any modifications to objects in the FSDATA and FSINDX tablespaces a Click Advisor Central from the Related Links region of Database Control b Click Segment Advisor c Select Tablespaces Click Next d Click Add and select the FSDATA and FSINDX tablespaces e Click OK and then Next f Select Standard from the Schedule Type drop-down list g Click Immediately in the Start region, and click Next 56 57 Practice 10-2: Monitoring the Database and Using the Advisors Proactively Tuning High-Load SQL Statements Unless specified otherwise, you should log in as SYSDBA through either Database Control or SQL*Plus Connect as SYSDBA through Database Control and navigate to the Performance tab of the Database Control home page On the Performance tabbed page, make sure that the View Data field is set to Real Time: 15 second Refresh When done, open a terminal emulator window connected as the oracle user When done, change your current directory to your labs directory: cd $HOME/labs Then, enter the following command from the OS prompt: /setup_dina.sh After this is executed, execute the start_dinas.sh script by using the following command: /start_dinas.sh When the start_dinas.sh script completes, observe the Performance tabbed page for six minutes What are your conclusions? How can you quickly fix the problem? a Using the Database Control home page, there are basically two different ways to identify the correct ADDM analysis task: If the time corresponding to the problematic time period corresponds with the latest ADDM run detected by Database Control, then you should find the link corresponding to the correct performance analysis directly in the Diagnostic Summary section of the Database Control home page b Using the Database Control home page, there are basically two different ways to identify the correct ADDM analysis task:  If the time corresponding to the problematic time period corresponds with the latest ADDM run detected by Database Control, you should find the link corresponding to the correct performance analysis directly in the Diagnostic Summary section of the Database Control home page  If not, you should open the Advisor Central page and search for the correct ADDM task This is how you can retrieve the task from the Advisor Central page: o On the Database Control home page, click the Advisor Central link o On the Advisor Central page, select ADDM in the Advisory Type drop-down list, and select Last 24 Hours in the Advisor Runs drop-down list o When done, click the Go button o Then, select the ADDM task corresponding to the time of the problematic period 58 c This displays the Automatic Database Diagnostic Monitor (ADDM) page, where you can see the results of the Performance Analysis in question Fix the problem From the corresponding Performance Analysis section, click the finding with the highest impact on the database time It should correspond to a SQL Tuning recommendation This displays the Performance Finding Details page On this page, you should see the highload SQL statement captured by the ADDM analysis As you can see, the benefit on the database time will be very high if you tune this statement Click the SQL ID link corresponding to the SELECT statement This takes you to the SQL Details page from where you click the Schedule SQL Tuning Advisor button On the Schedule Advisor page, click OK 59 This starts the execution of a SQL Tuning Advisor task 60 In this case, the recommendation is to create a SQL profile in order to get a better execution plan If you click the eyeglasses icon in the New Explain Plan column, then you can see both the original plan and the possible future plan Because the potential benefit of using the proposed SQL profile is very high, you implement the SQL profile To implement this tuning recommendation, go back to the recommendations page by clicking the Recommendations link, and from there, click the Implement button after selecting the appropriate SQL profile from the Recommendations table 61 After you fix the problem, how can you quickly verify that the problem was solved? a On the Database Control home page, click the Performance tab On the Performance tabbed page, you should see a dramatic drop for Concurrency wait class on the Average Active Sessions graph However, looking at the graph, nothing is apparently changing Note: Depending on when you run the workload, you may see differences between your graph and the one provided in this solution How you interpret the result, and how would you ensure that the new profile is taken into account? $ /stop_dinas.sh $ /start_dinas.sh 62 a On the Database Control home page, click the Performance tab b On the Performance tabbed page, you should now see the benefit of the SQL Profile To clean up your environment, execute the following commands from your commandline window: /stop_dinas.sh /cleanup_dina.sh 63 ... MANAGER_ID NUMBER(6) VARCHAR2 (20 ) VARCHAR2 (25 ) VARCHAR2 (25 ) VARCHAR2 (20 ) DATE VARCHAR2(10) NUMBER(8) NUMBER(6) JOBS JOB_ID JOB_TITLE MIN_SALARY MAX_SALARY VARCHAR2(10) VARCHAR2(35) NUMBER(6) NUMBER(6)... STREET_ADDRESS CITY STATE POSTAL_CODE PHONE_NUMBER NUMBER(6) VARCHAR2 (20 ) VARCHAR2 (20 ) VARCHAR2(40) VARCHAR2(30) VARCHAR2(10) VARCHAR2(10) VARCHAR2 (20 ) EMPLOYEES EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL_ADDRESS... STREET_ADDRESS VARCHAR2(40) CUST_LAST_NAME VARCHAR2 (20 ) CUST_FIRST_NAME VARCHAR2 (20 ) CUSTOMER_ID NUMBER(6) PHONE_NUMBER VARCHAR2 (20 ) POSTAL_CODE VARCHAR2(10) STATE VARCHAR2(10) CITY VARCHAR2 Create the

Ngày đăng: 27/10/2015, 15:09

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan