在單機(jī)環(huán)境下,要想啟動(dòng)或關(guān)閉ORACLE系統(tǒng)必須首先切換到ORACLE用戶,如下
su - oracle
Oracle數(shù)據(jù)庫有以下幾種啟動(dòng)方式:
1、
startup nomount
非安裝啟動(dòng),這種方式啟動(dòng)下可執(zhí)行:重建控制文件、重建數(shù)據(jù)庫
讀取init.ora文件,啟動(dòng)instance,即啟動(dòng)SGA和后臺(tái)進(jìn)程,這種啟動(dòng)只需要init.ora文件。
2、
startup mount dbname
安裝啟動(dòng),這種方式啟動(dòng)下可執(zhí)行:
數(shù)據(jù)庫日志歸檔、
數(shù)據(jù)庫介質(zhì)恢復(fù)、
使數(shù)據(jù)文件聯(lián)機(jī)或脫機(jī),
重新定位數(shù)據(jù)文件、重做日志文件。
執(zhí)行“nomount”,然后打開控制文件,確認(rèn)數(shù)據(jù)文件和聯(lián)機(jī)日志文件的位置,
但此時(shí)不對(duì)數(shù)據(jù)文件和日志文件進(jìn)行校驗(yàn)檢查。
3、
startup open dbname
先執(zhí)行“nomount”,然后執(zhí)行“mount”,再打開包括Redo log文件在內(nèi)的所有數(shù)據(jù)庫文件,
這種方式下可訪問數(shù)據(jù)庫中的數(shù)據(jù)。
4、startup,等于以下三個(gè)命令
startup nomountalter database mountalter database open
5、
startup restrict
約束方式啟動(dòng)
這種方式能夠啟動(dòng)數(shù)據(jù)庫,但只允許具有一定特權(quán)的用戶訪問
非特權(quán)用戶訪問時(shí),會(huì)出現(xiàn)以下提示:
ERROR:
ORA-01035: ORACLE 只允許具有 RESTRICTED SESSION 權(quán)限的用戶使用
6、
startup force
強(qiáng)制啟動(dòng)方式
當(dāng)不能關(guān)閉數(shù)據(jù)庫時(shí),可以用startup force來完成數(shù)據(jù)庫的關(guān)閉
先關(guān)閉數(shù)據(jù)庫,再執(zhí)行正常啟動(dòng)數(shù)據(jù)庫命令
7、startup pfile=參數(shù)文件名
帶初始化參數(shù)文件的啟動(dòng)方式
先讀取參數(shù)文件,再按參數(shù)文件中的設(shè)置啟動(dòng)數(shù)據(jù)庫
例:
startup pfile=E:Oracleadminoradbpfileinit.ora
oracle數(shù)據(jù)庫幾種關(guān)閉方式:
1、
shutdown normal
正常方式關(guān)閉數(shù)據(jù)庫。
2、
shutdown immediate
立即方式關(guān)閉數(shù)據(jù)庫。
在SVRMGRL中執(zhí)行shutdown immediate,數(shù)據(jù)庫并不立即關(guān)閉,
而是在Oracle執(zhí)行某些清除工作后才關(guān)閉(終止會(huì)話、釋放會(huì)話資源),
當(dāng)使用shutdown不能關(guān)閉數(shù)據(jù)庫時(shí),shutdown immediate可以完成數(shù)據(jù)庫關(guān)閉的操作。
3、
shutdown abort
直接關(guān)閉數(shù)據(jù)庫,正在訪問數(shù)據(jù)庫的會(huì)話會(huì)被突然終止,
如果數(shù)據(jù)庫中有大量操作正在執(zhí)行,這時(shí)執(zhí)行shutdown abort后,重新啟動(dòng)數(shù)據(jù)庫需要很長時(shí)間。
啟動(dòng)錯(cuò)誤問題解決
問題描述:
[oracle@node1 dbs]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 17 16:38:03 2013Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to an idle instanceSQL> startup nomountORA-00845: MEMORY_TARGET not supported on this system
啟動(dòng)數(shù)據(jù)庫時(shí),報(bào)MEMORY_TARGET 不支持,上網(wǎng)搜索了一下,具體原因是Linux 系統(tǒng)的共享內(nèi)存比SGA 配置的小。而/dev/shm 是根據(jù)tmpfs 的配置來定義的。
[root@node1 ~]# df -h /dev/shmFilesystem Size Used Avail Use% Mounted ontmpfs 1000M 0 1000M 0% /dev/shmSQL> show parameter memory_targetNAME TYPE VALUE------------------------------------ ----------- ------------------------------memory_target big integer 1G
查了一下tmpfs 的配置,只有1000M,而SGA 配置了1G(換算系1024M),不夠大。解決問題的辦法就是改小SGA 或者改大tmpfs(這里SGA 1G 已經(jīng)小了,不建議在改小)。
解決方法1、 修改tmpfs(修改/etc/fstab 配置):
[root@node1 ~]# vim /etc/fstab# tmpfs /dev/shm tmpfs defaults 0 0tmpfs /dev/shm tmpfs defaults,size=2048M 0 0[root@node1 ~]# umount /dev/shm[root@node1 ~]# mount /dev/shm[root@node1 ~]# df -h /dev/shm Filesystem Size Used Avail Use% Mounted ontmpfs 2.0G 0 2.0G 0% /dev/shm
解決方法2、修改SGA:
SQL> show parameter sgaNAME TYPE VALUE------------------------------------ ----------- ------------------------------lock_sga boolean FALSEpre_page_sga boolean FALSEsga_max_size big integer 1Gsga_target big integer 0SQL> alter system set sga_max_size=768M scope=spfile;System altered.SQL> shutdown immediateORA-01507: database not mountedORACLE instance shut down.SQL> startup nomountORACLE instance started.Total System Global Area 801701888 bytesFixed Size 2217632 bytesVariable Size 348129632 bytesDatabase Buffers 444596224 bytesRedo Buffers 6758400 bytesSQL> show parameter sgaNAME TYPE VALUE------------------------------------ ----------- ------------------------------lock_sga boolean FALSEpre_page_sga boolean FALSEsga_max_size big integer 768Msga_target big integer 0
這里建議直接修改memory_target,讓Oracle 自己去管理SGA 的大小(memory_target=SGA+PGA)
SQL> show parameter memory_targetNAME TYPE VALUE------------------------------------ ----------- ------------------------------memory_target big integer 1GSQL> alter system set memory_target=768M scope=spfile;System altered.SQL> shutdown immediateORA-01507: database not mountedORACLE instance shut down.SQL> startup nomount;ORACLE instance started.Total System Global Area 801701888 bytesFixed Size 2217632 bytesVariable Size 469764448 bytesDatabase Buffers 322961408 bytesRedo Buffers 6758400 bytesSQL> SQL> SQL> show parameter memory_targetNAME TYPE VALUE------------------------------------ ----------- ------------------------------memory_target big integer 768M
擴(kuò)展:
這里需要注意,memory_target 不能小于SGA 或PGA,不然startup 數(shù)據(jù)庫的時(shí)候會(huì)報(bào)錯(cuò),數(shù)據(jù)庫不能啟動(dòng)。
SQL> startup nomountORA-00844: Parameter not taking MEMORY_TARGET into accountORA-00851: SGA_MAX_SIZE 1073741824 cannot be set to more than MEMORY_TARGET 805306368.
解決辦法:
[oracle@node1 dbs]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 17 17:14:38 2013Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to an idle instance.SQL> create pfile from spfile;File created.SQL> exit
修改init.ora 文件參數(shù)
[oracle@node1 dbs]$ vim initoranode1.oraoranode1.__db_cache_size=444596224oranode1.__large_pool_size=4194304oranode1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment*.audit_file_dest='/u01/app/oracle/admin/oranode1/adump'*.audit_trail='db'*.compatible='11.2.0'*.control_files='/u01/oradata/ora_control1','/u01/fast_recovery_area/ora_control2'*.db_block_size=8192*.db_domain='node1.example.com'*.db_name='oranode1'*.db_recovery_file_dest='/u01/fast_recovery_area'*.db_recovery_file_dest_size=2G*.diagnostic_dest='/u01/app/oracle'*.dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'*.memory_target=805306368*.open_cursors=300*.processes=150*.remote_login_passwordfile='EXCLUSIVE'*.sga_max_size=805306368*.undo_tablespace='UNDOTBS1'
重新生成spfile
[oracle@node1 dbs]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 17 17:15:28 2013Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to an idle instance.SQL> create spfile from pfile;File created.SQL> startup nomount;ORACLE instance started.Total System Global Area 801701888 bytesFixed Size 2217632 bytesVariable Size 469764448 bytesDatabase Buffers 322961408 bytesRedo Buffers 6758400 bytesSQL> SQL> SQL> show parameter memory_targetNAME TYPE VALUE------------------------------------ ----------- ------------------------------memory_target big integer 768M
新聞熱點(diǎn)
疑難解答
圖片精選