3.1 Oracle體系結(jié)構(gòu)之實例啟動與關(guān)閉

Oracle 實例分為四種狀態(tài)晴竞,分別為:
關(guān)閉(SHUTDOWN)亲族、非裝載(NOMOUNT 啟動)崔慧、裝載(MOUNT)拂蝎、打開(OPEN)。

1惶室、關(guān)閉(SHUTDOWN)

如果實例沒有打開温自,以普通用戶身份時玄货,會報錯。
訪問Oracle 數(shù)據(jù)庫首先要啟動數(shù)據(jù)庫捣作,管理員連接到空閑實例,然后才能發(fā)出啟動實例或數(shù)據(jù)庫的命令鹅士。
啟動Oracle 服務(wù)器券躁,每個階段會打開不同的文件并且會完成不同的管理任務(wù)。

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@ocm ~]$ sqlplus scott/oracle  

SQL*Plus: Release 11.2.0.3.0 Production on Mon Jul 24 13:27:36 2017

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

ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory
Process ID: 0
Session ID: 0 Serial number: 0


Enter user-name: 
ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name: 
ERROR:
ORA-01017: invalid username/password; logon denied


SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus

[oracle@ocm ~]$ sqlplus / as sysdba 

SQL*Plus: Release 11.2.0.3.0 Production on Mon Jul 24 13:29:19 2017

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

Connected to an idle instance.

SQL> startup 
ORACLE instance started.

Total System Global Area  368263168 bytes
Fixed Size                  1345016 bytes
Variable Size             247466504 bytes
Database Buffers          113246208 bytes
Redo Buffers                6205440 bytes
Database mounted.
Database opened.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@ocm ~]$ sqlplus scott/oracle

SQL*Plus: Release 11.2.0.3.0 Production on Mon Jul 24 13:30:04 2017

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

執(zhí)行命令STARTUP掉盅,要求用戶必須具有SYSDBA 或SYSOPER 系統(tǒng)權(quán)限也拜,另外,如果要建立數(shù)據(jù)庫趾痘,則必須以SYSDBA 身份登錄慢哈。

2、非裝載(NOMOUNT 啟動)

shutdown->nomount
分配了內(nèi)存永票,啟動了進程

SQL> startup nomount

ORACLE instance started.

Total System Global Area  368263168 bytes
Fixed Size                  1345016 bytes
Variable Size             239077896 bytes
Database Buffers          121634816 bytes
Redo Buffers                6205440 bytes

分配內(nèi)存使用參數(shù)文件/u01/app/oracle/product/11.2.0/db_1/dbs/spfileorcl.ora

Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Mon Jul 24 03:56:39 2017
Picked latch-free SCN scheme 2
Using LOG_ARCHIVE_DEST_1 parameter default value as /u01/app/oracle/product/11.2.0/db_1/dbs/arch
Autotune of undo retention is turned on. 
IMODE=BR
ILAT =27
LICENSE_MAX_USERS = 0
SYS auditing is disabled
Starting up:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options.
ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1
System name:    Linux
Node name:      ocm.example.com
Release:        2.6.18-164.el5
Version:        #1 SMP Thu Sep 3 02:16:47 EDT 2009
Machine:        i686
VM name:        VMWare Version: 6
Using parameter settings in server-side spfile /u01/app/oracle/product/11.2.0/db_1/dbs/spfileorcl.ora
System parameters with non-default values:
  processes                = 150
  memory_target            = 352M
  control_files            = "/u01/app/oracle/oradata/orcl/control01.ctl"
  control_files            = "/u01/app/oracle/oradata/orcl/control02.ctl"
  db_block_size            = 8192
  compatible               = "11.2.0.0.0"
  undo_tablespace          = "UNDOTBS1"
  remote_login_passwordfile= "EXCLUSIVE"
  db_domain                = ""
  dispatchers              = "(PROTOCOL=TCP) (SERVICE=orclXDB)"
  audit_file_dest          = "/u01/app/oracle/admin/orcl/adump"
  audit_trail              = "DB"
  db_name                  = "orcl"
  open_cursors             = 300
  diagnostic_dest          = "/u01/app/oracle"
Mon Jul 24 03:56:42 2017
PMON started with pid=2, OS id=18767 
Mon Jul 24 03:56:42 2017
PSP0 started with pid=3, OS id=18769 
Mon Jul 24 03:56:43 2017
VKTM started with pid=4, OS id=18771 at elevated priority
VKTM running at (1)millisec precision with DBRM quantum (100)ms
Mon Jul 24 03:56:44 2017
GEN0 started with pid=5, OS id=18775 
Mon Jul 24 03:56:45 2017
DIAG started with pid=6, OS id=18777 
Mon Jul 24 03:56:45 2017
DBRM started with pid=7, OS id=18779 
Mon Jul 24 03:56:46 2017
DIA0 started with pid=8, OS id=18781 
Mon Jul 24 03:56:46 2017
MMAN started with pid=9, OS id=18783 
Mon Jul 24 03:56:48 2017
DBW0 started with pid=10, OS id=18785 
Mon Jul 24 03:56:48 2017
LGWR started with pid=11, OS id=18787 
Mon Jul 24 03:56:48 2017
CKPT started with pid=12, OS id=18789 
Mon Jul 24 03:56:49 2017
SMON started with pid=13, OS id=18791 
Mon Jul 24 03:56:49 2017
RECO started with pid=14, OS id=18793 
Mon Jul 24 03:56:50 2017
MMON started with pid=15, OS id=18795 
starting up 1 dispatcher(s) for network address '(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))'...
Mon Jul 24 03:56:50 2017
MMNL started with pid=16, OS id=18797 
starting up 1 shared server(s) ...
ORACLE_BASE from environment = /u01/app/oracle

查看進程

oracle@ocm orcl]$ ps -ef | grep ora_
oracle   21954     1  0 13:42 ?        00:00:00 ora_pmon_orcl
oracle   21956     1  0 13:42 ?        00:00:00 ora_psp0_orcl
oracle   21958     1  0 13:42 ?        00:00:00 ora_vktm_orcl
oracle   21962     1  0 13:42 ?        00:00:00 ora_gen0_orcl
oracle   21964     1  0 13:42 ?        00:00:00 ora_diag_orcl
oracle   21966     1  0 13:42 ?        00:00:00 ora_dbrm_orcl
oracle   21968     1  0 13:42 ?        00:00:00 ora_dia0_orcl
oracle   21970     1  1 13:42 ?        00:00:00 ora_mman_orcl
oracle   21972     1  0 13:42 ?        00:00:00 ora_dbw0_orcl
oracle   21974     1  0 13:42 ?        00:00:00 ora_lgwr_orcl
oracle   21976     1  0 13:42 ?        00:00:00 ora_ckpt_orcl
oracle   21978     1  0 13:42 ?        00:00:00 ora_smon_orcl
oracle   21980     1  0 13:42 ?        00:00:00 ora_reco_orcl
oracle   21982     1  0 13:42 ?        00:00:00 ora_mmon_orcl
oracle   21984     1  0 13:42 ?        00:00:00 ora_mmnl_orcl
oracle   21986     1  0 13:42 ?        00:00:00 ora_d000_orcl
oracle   21988     1  0 13:42 ?        00:00:00 ora_s000_orcl
oracle   22020 20904  0 13:43 pts/4    00:00:00 grep ora_

Oracle 默認打開初始化參數(shù)文件的順序是:spfilesid.ora→spfile.ora→ initsid.ora
如果三個文件都不存在卵贱,則報錯。

在NOMOUNT 狀態(tài)下無法備份控制文件侣集,MOUNT 狀態(tài)下備份成功键俱,說明數(shù)據(jù)庫從NOMOUNT 到MOUNT 狀態(tài)讀取了控制文件。
裝載數(shù)據(jù)庫階段世分,系統(tǒng)會按照初始化參數(shù)文件中control_files 參數(shù)的設(shè)置查找并打開控制文件编振。
Oracle 是通過控制文件在實例和數(shù)據(jù)庫之間建立關(guān)聯(lián)的,通過控制文件可以取得數(shù)據(jù)文件和重做日志的名稱和所處狀態(tài)臭埋。但對數(shù)據(jù)文件和日志文件是否存在不作檢查踪央。

SQL> alter database backup controlfile to '/u01/app/oracle/oradata/orcl/control_bak.ctl';    
alter database backup controlfile to '/u01/app/oracle/oradata/orcl/control_bak.ctl'
*
ERROR at line 1:
ORA-01507: database not mounted
SQL> alter database mount;                     
Database altered.
SQL>  alter database backup controlfile to '/u01/app/oracle/oradata/orcl/control_bak.ctl';
Database altered.

3、裝載(MOUNT)

SQL> select count(*)from scott.emp;
select count(*)from scott.emp
                          *
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only
SQL> alter database open;
Database altered.
SQL> select count(*) from scott.emp;
  COUNT(*)
----------
        14

在MOUNT 狀態(tài)下瓢阴,我們無法讀取到數(shù)據(jù)畅蹂,說明數(shù)據(jù)文件沒有被讀取。當(dāng)數(shù)據(jù)庫OPEN后荣恐,我們可以讀取到數(shù)據(jù)魁莉,說明數(shù)據(jù)庫從MOUNT 到OPEN 加載了數(shù)據(jù)文件。

SQL> select status from v$instance;
STATUS
------------
MOUNTED
SQL> alter system switch logfile;
alter system switch logfile
*
ERROR at line 1:
ORA-01109: database not open
SQL> alter database open;
Database altered.
SQL>  alter system switch logfile;
System altered.

在MOUNT 狀態(tài)下募胃,我們無法手工切換日志文件組旗唁,說明聯(lián)機重做日志文件沒有被讀取。當(dāng)數(shù)據(jù)庫OPEN 后痹束,可以切換检疫,說明數(shù)據(jù)庫從MOUNT 到OPEN 加載了日志文件。

4祷嘶、打開(OPEN)

在這階段啟動實例恢復(fù)SMON屎媳,在這一階段讀取了日志文件和數(shù)據(jù)文件

alter database open
Mon Jul 24 04:15:24 2017
Thread 1 opened at log sequence 14
  Current log# 2 seq# 14 mem# 0: /u01/app/oracle/oradata/orcl/redo02.log
Successful open of redo thread 1
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Mon Jul 24 04:15:24 2017
SMON: enabling cache recovery
[19461] Successfully onlined Undo Tablespace 2.
Undo initialization finished serial:0 start:32216454 end:32216624 diff:170 (1 seconds)
Verifying file header compatibility for 11g tablespace encryption..
Verifying 11g file header compatibility for tablespace encryption completed
SMON: enabling tx recovery
Database Characterset is AL32UTF8
No Resource Manager plan active
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
Mon Jul 24 04:15:29 2017
QMNC started with pid=20, OS id=19465 
Completed: alter database open
Mon Jul 24 04:15:38 2017
Starting background process CJQ0
Mon Jul 24 04:15:39 2017
CJQ0 started with pid=22, OS id=19477 

修改scott狀態(tài)并登陸

SQL> alter user scott identified by oracle account unlock;

User altered.

SQL> conn scott/oracle;
Connected.
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末夺溢,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子烛谊,更是在濱河造成了極大的恐慌风响,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,366評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件丹禀,死亡現(xiàn)場離奇詭異状勤,居然都是意外死亡,警方通過查閱死者的電腦和手機双泪,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,521評論 3 395
  • 文/潘曉璐 我一進店門持搜,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人焙矛,你說我怎么就攤上這事葫盼。” “怎么了村斟?”我有些...
    開封第一講書人閱讀 165,689評論 0 356
  • 文/不壞的土叔 我叫張陵贫导,是天一觀的道長。 經(jīng)常有香客問我蟆盹,道長脱盲,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,925評論 1 295
  • 正文 為了忘掉前任日缨,我火速辦了婚禮钱反,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘匣距。我一直安慰自己面哥,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 67,942評論 6 392
  • 文/花漫 我一把揭開白布毅待。 她就那樣靜靜地躺著尚卫,像睡著了一般。 火紅的嫁衣襯著肌膚如雪尸红。 梳的紋絲不亂的頭發(fā)上吱涉,一...
    開封第一講書人閱讀 51,727評論 1 305
  • 那天,我揣著相機與錄音外里,去河邊找鬼怎爵。 笑死,一個胖子當(dāng)著我的面吹牛盅蝗,可吹牛的內(nèi)容都是我干的鳖链。 我是一名探鬼主播,決...
    沈念sama閱讀 40,447評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼墩莫,長吁一口氣:“原來是場噩夢啊……” “哼芙委!你這毒婦竟也來了逞敷?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,349評論 0 276
  • 序言:老撾萬榮一對情侶失蹤灌侣,失蹤者是張志新(化名)和其女友劉穎推捐,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體侧啼,經(jīng)...
    沈念sama閱讀 45,820評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡牛柒,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,990評論 3 337
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了慨菱。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片焰络。...
    茶點故事閱讀 40,127評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡戴甩,死狀恐怖符喝,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情甜孤,我是刑警寧澤协饲,帶...
    沈念sama閱讀 35,812評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站缴川,受9級特大地震影響茉稠,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜把夸,卻給世界環(huán)境...
    茶點故事閱讀 41,471評論 3 331
  • 文/蒙蒙 一而线、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧恋日,春花似錦膀篮、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,017評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至谈截,卻和暖如春筷屡,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背簸喂。 一陣腳步聲響...
    開封第一講書人閱讀 33,142評論 1 272
  • 我被黑心中介騙來泰國打工毙死, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人喻鳄。 一個月前我還...
    沈念sama閱讀 48,388評論 3 373
  • 正文 我出身青樓规哲,卻偏偏與公主長得像,于是被迫代替她去往敵國和親诽表。 傳聞我的和親對象是個殘疾皇子唉锌,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,066評論 2 355

推薦閱讀更多精彩內(nèi)容