程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> ORACLE口令管理,oracle口令

ORACLE口令管理,oracle口令

編輯:Oracle教程

ORACLE口令管理,oracle口令


口令文件介紹

    在ORALCE數據庫系統中,用戶如果要以特權用戶身份(SYS/SYSDBA/SYSOPER)登錄ORALCE數據庫可以有兩種身份驗證的方法:即使用與操作系統集成的身份驗證或使用ORALCE數據庫的密碼文件進行身份驗證。因此,管理好密碼文件,對於控制授權用戶從服務器本機或遠端登錄Oracle數據庫系統,執行數據庫管理工作,具有重要的意義.

 

    ORALCE口令文件用於存儲擁有部分特權用戶(sys等用戶)的口令(注意:普通賬號密碼是不會存儲在口令文件的)。允許用戶通過口令文件驗證,在數據庫未啟動之前登陸,從而啟動數據庫。如果沒有口令文件,在數據庫未啟動之前就只能通過操作系統認證.口令文件存放在$ORACLE_HOME/dbs目錄下(linux,window放在database),默認名稱是orapw$ORACLE_SID。即密碼文件位置:

    Linux下的存放位置:$ORACLE_HOME/dbs/orapw<sid>.ora

    Windows下的存放位置:$ORACLE_HOME/database/PW%ORACLE_SID%.ora

 

口令文件管理

 

1:口令文件成員查看

SQL> SELECT * FROM V$PWFILE_USERS;
 
USERNAME                       SYSDBA SYSOPER
------------------------------ ------ -------
SYS                            TRUE   TRUE

 

如果查詢該視圖沒有的記錄的話,那麼這是什麼情況呢?出現這種情況,一般是口令文件被刪除或移走。 例如如下操作所示:

oracle@DB-Server ~]$ 
[oracle@DB-Server ~]$ cd $ORACLE_HOME/dbs
[oracle@DB-Server dbs]$ mv orapwgsp  /tmp
[oracle@DB-Server dbs]$ sqlplus / as sysdba
 
SQL*Plus: Release 11.2.0.1.0 Production on Thu Aug 4 17:43:39 2016
 
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
SQL> SELECT * FROM V$PWFILE_USERS;
 
no rows selected
 
SQL> 

 

ORACLE使用操作系統集成的身份驗證或使用密碼驗證,這個類似SQL SERVER中的Windows身份驗證和SQL Server驗證方式,那麼使用哪種方式登錄數據庫是由兩個參數控制的。

 

1:ORACLE提供的一個參數remote_login_passwordfile,remote_login_passwordfile有none,shared,exclusive3個值:

   none表示不使用口令文件;

   exclusive表示實例獨占使用口令文件,也就是各自實例使用單獨的口令文件,

   shared表示多個實例共享一個口令文件

 

2:sqlnet.ora裡面的參數SQLNET.AUTHENTICATION_SERVICES

 

SQLNET.AUTHENTICATION_SERVICES = none | all | ntf(windows)

    none : 表示關閉操作系統認證,只能密碼認證

    all : 用於linux或unix平台,關閉本機密碼文件認證,采用操作系統認證,但遠程<異機>可以使用密碼文件認證

    nts : 用於windows平台

 

 

2:使用操作系統集成的身份驗證登錄數據庫

 
[oracle@DB-Server ~]$ 
[oracle@DB-Server ~]$ cd /u01/app/network/admin/
[oracle@DB-Server admin]$ more sqlnet.ora 
# sqlnet.ora Network Configuration File: /u01/app/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
 
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
 
ADR_BASE = /u01
[oracle@DB-Server admin]$ vi sqlnet.ora 
# sqlnet.ora Network Configuration File: /u01/app/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
 
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
 
ADR_BASE = /u01
SQLNET.AUTHENTICATION_SERVICES=all

 

其實默認情況,參數文件sqlnet.ora裡面並沒有配置SQLNET.AUTHENTICATION_SERVICES這個參數,默認表示操作系統認證,如果配置文件sqlnet.ora 裡面有SQLNET.AUTHENTICATION_SERVICES=none, 那麼設置為SQLNET.AUTHENTICATION_SERVICES=all 即可啟用操作系統集成的身份驗證登錄數據庫

[oracle@DB-Server admin]$ more sqlnet.ora 
# sqlnet.ora Network Configuration File: /u01/app/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
 
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
 
ADR_BASE = /u01
SQLNET.AUTHENTICATION_SERVICES=none
[oracle@DB-Server admin]$ sqlplus / as sysdba
 
SQL*Plus: Release 11.2.0.1.0 Production on Sat Aug 6 21:30:23 2016
 
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
 
ERROR:
ORA-01031: insufficient privileges
 
 
Enter user-name: 

 

3:改變OS認證為口令認證

 

SQLNET.AUTHENTICATION_SERVICES = none | all | ntf(windows)

none : 表示關閉操作系統認證,只能密碼認證

all : 用於linux或unix平台,關閉本機密碼文件認證,采用操作系統認證,但遠程<異機>可以使用密碼文件認證

nts : 用於windows平台

在sqlnet.ora文件裡面,增加SQLNET.AUTHENTICATION_SERVICES= (none)

[oracle@DB-Server admin]$ vi sqlnet.ora 
 
# sqlnet.ora Network Configuration File: /database/product/dbhome_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
 
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
SQLNET.AUTHENTICATION_SERVICES= none

參數remote_login_passwordfile僅僅表示遠程登錄數據庫時,是否使用密碼驗證。當remote_login_passwordfile=none並且SQLNET.AUTHENTICATION_SERVICES= (none)時,遠程和本機都無法登錄數據庫。

SQL> alter system set remote_login_passwordfile=none scope=spfile;
 
System altered.
 
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
 
Total System Global Area 1090519040 bytes
Fixed Size                  1218920 bytes
Variable Size             234882712 bytes
Database Buffers          838860800 bytes
Redo Buffers               15556608 bytes
Database mounted.
Database opened.
SQL> 

此時從遠程客戶端登錄:此處實際上是無法通過口令文件驗證

C:\Users\kerry>sqlplus "sys/kkk123456@mydb as sysdba"
 
SQL*Plus: Release 11.2.0.1.0 Production on 星期五 1月 11 15:37:45 2013
 
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
 
ERROR:
ORA-01017: invalid username/password; logon denied
 
 
SQL> alter system set remote_login_passwordfile=exclusive scope=spfile;                                
 
System altered.
 
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
 
SQL> startup
ORACLE instance started.
 
Total System Global Area 1090519040 bytes
Fixed Size                  1218920 bytes
Variable Size             234882712 bytes
Database Buffers          838860800 bytes
Redo Buffers               15556608 bytes
Database mounted.
Database opened.
SQL> show parameter remote_login_password
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile            string      EXCLUSIVE
SQL> 

遠程客戶端以SYSDBA登錄數據庫時,此時遠程登錄OK了

 

 

4:查看口令文件內容

[oracle@DB-Server dbs]$ strings orapwgsp
]\[Z
ORACLE Remote Password file
INTERNAL
6813407607142FD5
2F2B362C23566AE4
E20879077A63EBEE

如果你用more命令查看,就會發現查看不到具體內容,如下所示:

[oracle@DB-Server dbs]$ more orapwgsp

ORACLE Remote Password file

 

口令文件創建

 

現在人為刪除口令文件後,從遠程客戶端以SYSDBA登錄數據庫

C:\Users\kerry>sqlplus "sys/kkk123456@mydb as sysdba"
 
SQL*Plus: Release 11.2.0.1.0 Production on 星期五 1月 11 15:53:06 2013
 
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
 
ERROR:
ORA-01031: insufficient privileges

 

 

ORACLE 10g 下orapwd命令

[oracle@wgods dbs]$ orapwd
Usage: orapwd file=<fname> password=<password> entries=<users> force=<y/n> 
 
  where
    file - name of password file (mand),
    password - password for SYS (mand),
    entries - maximum number of distinct DBA and     force - whether to overwrite existing file (opt),
OPERs (opt), 
  There are no spaces around the equal-to (=) character.

 

ORACLE 11g 下orapwd命令

[oracle@DB-Server ~]$ orapwd
Usage: orapwd file=<fname> entries=<users> force=<y/n> ignorecase=<y/n> nosysdba=<y/n>
 
  where
    file - name of password file (required),
    password - password for SYS will be prompted if not specified at command line,
    entries - maximum number of distinct DBA (optional),
    force - whether to overwrite existing file (optional),
    ignorecase - passwords are case-insensitive (optional),
    nosysdba - whether to shut out the SYSDBA logon (optional Database Vault only).
    
  There must be no spaces around the equal-to (=) character.

參數描述

file : 創建的密碼文件

password : 創建的口令(sys用戶)

entries=MAX_USER : 口令文件中可以存放的最大用戶數。即擁有sysdba和sysoper身份登陸的用戶數

force=(Y/N) : 強制覆蓋已存在的密碼文件

ignorecase : 密碼大小寫敏感

nosysdba=<y/n> : sysdba用戶不可以登陸

 

密碼文件的創建:

 

    1:確定實例的名稱、密碼文件的路徑和名稱。

    2:停止數據庫,刪除老的密碼文件

    3: 用orapwd工具創建

 

[oracle@DB-Server ~]$ cd /u01/app/dbs/
 
[oracle@DB-Server dbs]$ orapwd file=orapwgsp password=kkk123456 force=y
 
[oracle@DB-Server dbs]$ ls orapwgsp 
 
orapwgsp
 
[oracle@DB-Server dbs]$

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved