1. 程式人生 > >oracle 啟動關閉以及監聽啟動關閉命令

oracle 啟動關閉以及監聽啟動關閉命令

啟動監聽:lsnrctl start
檢視監聽:lsnrctl status
停止監聽:lsnrctl stop

1、oracle 資料伺服器包括:例項程序和資料庫;
   例項程序包括:memory structure(sga)以及background process(pmon(程序監控)、smon(系統監控system monitor,空間整理3秒)、dbwr(髒資料處理)、lgwr(將redo buffer檔案寫會log),ckpt(checkpoint,同步資料,先寫日誌、髒資料)等程序);
  資料庫包括:資料檔案、控制檔案,redo log 檔案,三者是必須的,至於 引數檔案、密碼檔案、歸檔檔案是可選的,根據資料庫的狀態而定;
2、pga:包括user process 和server process,user process通過server process來與oracle的例項進行進行通訊。
3、sga=share pool+database buffer cache+redo log buffer + other structures(large pool,java pool可選)
shared_pool
=library cache(sql共享,緩衝sql的執行計劃,採用最近最少使用演算法) + data dictionary cache(row cache,資料字典);
database buffer cache(db_cache_size):oracle以block size最為基本的資料讀寫單位
redo log buffer cache:
4、改變引數:
alter system set shared_pool_size=64m;
alter system set db_cache_size=64m;
alter system set large_pool_size=64m;
5、os驗證使用者:
create user id
create group (ora_dba,ora_databasename_dba,ora_oper,ora_databasename_oper)
add user id to group id
edit sqlnet.ora (sqlnet.authentication_services=(nts))
6、忘記system/sys的密碼:
刪掉E:\oracle\product\10.2.0\db_1\database\pwdtestdb.ora;
使用命令:orapwd file=d:\pwdtestdb.ora password=admin1 entries=10;將密碼設定為admin1;
或則:
sqlplus /@testdb as sysdba
alter user sys identified by 新密碼;
alter user system identified by 新密碼;

7、block(塊) extend(盤區) segment(段) tablespace(表空間)
8、網路服務的配置資訊在D:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\tnsnames.ora檔案中記錄
資料庫的啟動命令

1、啟動TNS監聽
C:\Documents and Settings\Administrator>lsnrctl start
2、啟動Oracle Services
C:\Documents and Settings\Administrator>net start OracleServiceOrcl
3、以sysdba身份登入
SQL> connect system as sysdba
4、啟動isqlplus
C:\Documents and Settings\Administrator>isqlplusctl start
5、啟動database control
C:\Documents and Settings\Administrator>emctl start dbconsole
如果啟動錯誤,很可能是ip地址進行了修改,可採取如下措施:
set oracle_hostname=主機名
emca -config dbcontrol db,進行相應的配置。
6、http://localhost:1158/em/


<開啟控制檯輸出>
1、show all
   serveroutput OFF
2、set serveroutput on
啟動及關閉模式
Oracle資料庫的幾種啟動和關閉方式
有以下幾種啟動方式:
1、startup nomount
   非安裝啟動,這種方式啟動下可執行:重建控制檔案、重建資料庫

   讀取init.ora檔案,啟動instance,即啟動SGA和後臺程序,這種啟動只需要init.ora檔案。
  
2、startup mount dbname
   安裝啟動,這種方式啟動下可執行:
   資料庫日誌歸檔、
   資料庫介質恢復、
   使資料檔案聯機或離線,
   重新定位資料檔案、重做日誌檔案。
   執行“nomount”,然後開啟控制檔案,確認資料檔案和聯機日誌檔案的位置,
   但此時不對資料檔案和日誌檔案進行校驗檢查。

3、startup open dbname
   先執行“nomount”,然後執行“mount”,再開啟包括Redo log檔案在內的所有資料庫檔案,
   這種方式下可訪問資料庫中的資料。

4、startup,等於以下三個命令
   startup nomount
   alter database mount
   alter database open

5、startup restrict
   約束方式啟動
   這種方式能夠啟動資料庫,但只允許具有一定特權的使用者訪問
   非特權使用者訪問時,會出現以下提示:
   ERROR:
   ORA-01035: ORACLE 只允許具有 RESTRICTED SESSION 許可權的使用者使用

6、startup force
   強制啟動方式
   當不能關閉資料庫時,可以用startup force來完成資料庫的關閉
   先關閉資料庫,再執行正常啟動資料庫命令

7、startup pfile=引數檔名
   帶初始化引數檔案的啟動方式
   先讀取引數檔案,再按引數檔案中的設定啟動資料庫
   例:startup pfile=E:\Oracle\admin\oradb\pfile\init.ora

8、startup EXCLUSIVE
============================================
有三種關閉方式:
1、shutdown normal
   正常方式關閉資料庫。

2、shutdown immediate
   立即方式關閉資料庫。
   在SVRMGRL中執行shutdown immediate,資料庫並不立即關閉,
   而是在Oracle執行某些清除工作後才關閉(終止會話、釋放會話資源),
   當使用shutdown不能關閉資料庫時,shutdown immediate可以完成資料庫關閉的操作。

3、shutdown abort
   直接關閉資料庫,正在訪問資料庫的會話會被突然終止,
   如果資料庫中有大量操作正在執行,這時執行shutdown abort後,重新啟動資料庫需要很長時間。