Pages

Showing posts with label database. Show all posts
Showing posts with label database. Show all posts

Tuesday, April 19, 2011

Oracle Database 10g - Lesson 1


 

學習目標

Install、create、administer Oracle Database 10g (企業版)

為應用程式configure資料庫、創建使用者、定義storage structures和設置安全性

Monitor資料庫

實施備份和恢復策略

在資料庫和文件檔之間移動資料

Explain the Oracle Database 10g architecture


 

學習順序

1. 簡介

2. Installation

3. DB Creation

4. Instance (實例)

5. Storage

6. Users

7. Schema

8. Data & Concurrency

9. Undo

10. Security

11. Network

12. Proactive Maintenance(主動維護)

13. Performance

14. Backup & Recovery Concepts

15. Backup

16. Recovery

17. Flashback

18. Moving Data

ORACLE資料庫的啟動


 


啟動ORACLE

  • 第一步是啟動實例本身(nomount)。實例(instance)指的就是已分配的記憶體(SGA)和各種後臺進程(process)的集合。此時可進行一些修復作業,如重建控制檔、重建資料庫。

    SQL> STARTUP NOMOUNT

  • 第二步是掛載(mount)資料庫,此時可訪問資料庫檔。該階段可執行的一些操作:資料庫日誌歸檔、資料庫恢復、重新命名一些資料庫檔(如:系統表空間和日誌檔),此時使用者仍然不可訪問資料庫。。

    SQL> STARTUP MOUNT

    or

    SQL> ALTER DATABASE MOUNT;

  • 最後一步是打開(open)資料,此時使用者可訪問資料庫中的資料。 

    SQL> STARTUP

    Or

    SQL> ALTER DATABASE OPEN;

  • 正常啟動資料庫需要完成這三個步驟。你可以把資料庫停留在以上任一步驟,如果你需要進行一些DBA工作,還可以把資料庫開在限制模式(restricted mode)

SQL> STARTUP RESTRICT

--

SQL> alter system enable restricted session;

--

SQL> alter system disable restricted session;


 


startup

[oracle@dyora01 ~]$ sqlplus /nolog


 

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jan 21 07:04:30 2002


 

Copyright (c) 1982, 2005, Oracle. All rights reserved.


 

SQL> connect / as sysdba

Connected.

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup nomount

ORACLE instance started.


 

Total System Global Area 356515840 bytes

Fixed Size 1219376 bytes

Variable Size 100664528 bytes

Database Buffers 247463936 bytes

Redo Buffers 7168000 bytes

SQL> alter database mount;


 

Database altered.


 

SQL> alter database open;


 

Database altered.


 

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.


 

Total System Global Area 356515840 bytes

Fixed Size 1219376 bytes

Variable Size 100664528 bytes

Database Buffers 247463936 bytes

Redo Buffers 7168000 bytes

Database mounted.

SQL> startup

ORA-01081: cannot start already-running ORACLE - shut it down first

SQL> shutdown immediate

ORA-01109: database not open


 


 

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.


 

Total System Global Area 356515840 bytes

Fixed Size 1219376 bytes

Variable Size 100664528 bytes

Database Buffers 247463936 bytes

Redo Buffers 7168000 bytes

Database mounted.

Database opened.

SQL>


 

延伸內容

Problems during Oracle Startup

ORACLE資料庫的關閉:

Oracle Database 10g:“g” 代表什麼?

Oracle Database 10g:“g”代表 "Grid Computing"

Oracle 的 Grid Computing 技術包括:
• Automatic Storage Management (ASM)
• Real Application Clusters (RAC)
• Oracle Streams
• Enterprise Manager Grid Control

同理 Oracle 11g 也代表使用了 Grid Computing


p.s. Oracle 9i 中的 i 是表示 internet 。



Monday, February 23, 2009

Study Oracle : 使用 PFILE/SPFILE

Oracle 使用兩種型式的檔案來儲存參數: PFILE 或 SPFILE。

PFILE 是使用notepad等編輯器即可修改的純文字檔。PFILE 內儲存的 Oracle的各項啟動參數、記憶體配置、檔案位置等。大部份情況下,PFILE可以在 ORACLE_HOME\database 或 ORACLE_HOME\dbs 裡找到。如果你的 ORACLE_SID 名是 test1,PFILE的檔名應該就是 inittest1.ora。

SPFILE使用二進位格式檔案,因此我們不能直接用vi等文字編輯器來修改它。使用SPFILE的最大好處是,一但我們修改它,它將會被永久保存。這代表即使重啟資料庫,它的內容也不會跑掉。這對於一些自動調整的功能來說相當適合,反之,若不用SPFILE是無法使用自動調整的功能的。同樣的,如果你的 ORACLE_SID 名是 test1,SPFILE的檔名會是 spfiletest1.ora。

備份你的PFILE和SPFILE,其中SPFILE還可以用RMAN備份。要將 SPFILE 轉成 PFILE,可用以下指令:
SQL> create pfile from spfile;

檔案將會用預設的檔名和位置產生,然後你就可以用一般檔案備份方式備份PFILE了。當然你也可以用PFILE來產生SPFILE:
SQL> create pfile=/path/initSID.ora from spfile;

如果你使用 SPFILE來設定你的資料庫,那你得先關閉資料庫才能使用這個指令,否則SPFILE將無法被覆寫。

Oracle 會優先使用 SPFILE再來才是 PFILE,當你啟動資料庫,Oracle是以以下順序來使用設定檔的:
- spfileSID.ora
- spfile.ora
- initSID.ora
- init.ora

其中預設的目錄是 ORACLE_HOME\database 或 ORACLE_HOME\dbs,SID代表 ORACLE_SID,你也可以指定使用這個方式指定PFILE:
SQL> startup
pfile=/path/initSID.ora

如果找不到適合的 PFILE/SPFILE ,資料庫將不會啟動。