REMOTE_LOGIN_PASSWORDFILE引數和ORAPW密碼檔案

gaopengtttt發表於2014-09-02
俗話說 萬丈高樓從地起,從業ORACLE 7年多後,我重新開始看基礎類容,將列出一些DBA容易忽視的類容,並且做一些筆記和實驗和大家共享。
關於REMOTE_LOGIN_PASSWORDFILE引數檔案:
REMOTE_LOGIN_PASSWORDFILEare:
■ NONE: Setting this parameter to NONE causes Oracle Database to behave as if the
password file does not exist. That is, no privileged connections are allowed over
nonsecure connections.
■ EXCLUSIVE: (The default) An EXCLUSIVE password file can be used with only one
instance of one database. Only an EXCLUSIVE file can be modified. Using an
EXCLUSIVE password file enables you to add, modify, and delete users. It also
enables you to change the SYS password with the ALTER USER command.
■ SHARED: A SHARED password file can be used by multiple databases running on the
same server, or multiple instances of an Oracle Real Application Clusters (Oracle
RAC) database. A SHARED password file cannot be modified. Therefore, you cannot
add users to a SHARED password file. Any attempt to do so or to change the password
of SYS or other users with the SYSDBA or SYSOPER privileges generates an error.
   All users needing SYSDBA or SYSOPER system privileges must be added to the
password file when REMOTE_LOGIN_PASSWORDFILE is set to EXCLUSIVE. After all
users are added, you can change REMOTE_LOGIN_PASSWORDFILEto SHARED, and then
share the file.
  If REMOTE_LOGIN_PASSWORDFILEis set to EXCLUSIVE or SHAREDand the password file is
missing, this is equivalent to setting REMOTE_LOGIN_PASSWORDFILE to NONE.

  If you change the REMOTE_LOGIN_PASSWORDFILEinitialization parameter from NONEto
EXCLUSIVEor SHARED, or if you re-create the password file with a different SYS
password, then you must ensure that the passwords in the data dictionary and
password file for the SYSuser are the same.
  To synchronize the SYS passwords, use the ALTER USER statement to change the SYS
password. The ALTER USERstatement updates and synchronizes both the dictionary
and password file passwords.
  To synchronize the passwords for non-SYS users who log in using the SYSDBA or
SYSOPERprivilege, you must revoke and then regrant the privilege to the user
   After you remove this file, only those users who can be authenticated by
the operating system can perform SYSDBA or SYSOPER database administration operations.
首先文件給出了REMOTE_LOGIN_PASSWORDFILE的定義,其實這裡注意REMOTE視乎有些迷惑性
本引數值控制了是否可以使用ORAPWD檔案,即使本機非DBA組的使用者同樣適用。同時注意一下
ORAPWD檔案除了儲存SYS密碼外其實也會儲存其他非SYS使用者擁有SYSDBA許可權的使用者密碼。如果
缺少檔案或者設定為NONE則只有作業系統認證使用者才能使用SYSDBA許可權

NONE        代表不使用ORAPWD檔案進行SYSDBA許可權的認證。
EXCLUSIVE 代表ORAPWD檔案只共一個例項使用,可以進行修改,當然也支援使用ALTER USER來修改
                 ORAPWD檔案,言外之意SHARED是不支援ALTER USER修改的
SHARED    代表ORAPWD檔案能夠供多個資料庫或者多個例項共享,所以是不能新的賦予SYSDBA和回收
               SYSDBA的操作都會失敗,同時修改密碼也會失敗。
文件指出:
如果如果使用ALTER USER SYS修改了SYS密碼,那麼這個操作會自動同步資料字典和ORAPWD檔案,而
如果是非SYS使用者,必須要使用REVOKE和GRANT重新賦權才能同步,但是測試中發現並不需要重新
revoke和GRANT。

          
實驗如下:
NONE方式
SQL>  alter system set remote_login_passwordfile='none' scope=spfile;

System altered.

重啟
SQL> show parameter remote

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_dependencies_mode             string      TIMESTAMP
remote_listener                      string
remote_login_passwordfile            string      NONE
實驗是否可以使用ORAPWD檔案登陸(LLL使用者非DBA組,使用ORWPWD認證)
[lll@tasm ~]$ sqlplus sys/gelc123 as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Tue Apr 15 09:44:08 2014

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

ERROR:
ORA-01031: insufficient privileges


Enter user-name:
EXCLUSIVE 方式
同樣修改引數使用LLL使用者登入(LLL使用者非DBA組,使用ORWPWD認證)
[lll@tasm ~]$ sqlplus sys/gelc123 as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Tue Apr 15 09:49:31 2014

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


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

SQL>

嘗試增加特權使用者
 grant sysdba to ppzhu;
 然後檢視一下
 SQL> select * from V$PWFILE_USERS;

USERNAME                       SYSDB SYSOP SYSAS
------------------------------ ----- ----- -----
SYS                            TRUE  TRUE  FALSE
PPZHU                          TRUE  FALSE FALSE
增加成功,如果我們修改了PPZHU使用者的密碼如下:
SQL> alter user ppzhu identified by test123;
然後試圖LLL使用者登入(LLL使用者非DBA組,使用ORWPWD認證):
[lll@tasm ~]$ sqlplus ppzhu/test123 as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Tue Apr 15 10:10:15 2014

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


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

SQL>
可以登入,所以我說非SYS使用者實際ALTER USER修改密碼也會進行同步。

[oracle@tasm dbs]$ date
Tue Apr 15 09:59:55 CST 2014
[oracle@tasm dbs]$ ls -lrt|grep orapw
-rw-r----- 1 oracle oinstall       1536 Apr 15 09:59 orapwora11g
這裡也可能看一下時間,alter 非sys使用者orapwd檔案也進行了更新這也從側面表示ORAPWD檔案時
儲存非SYS使用者密碼的。同時也說明ALTER USER修改密碼也會進行同步。

最後修改SHARED方式
alter system set remote_login_passwordfile='shared' scope=spfile
重啟
測試如下:
SQL> alter user sys identified by kkk;
alter user sys identified by kkk
*
ERROR at line 1:
ORA-28046: Password change for SYS disallowed


SQL> grant sysdba to ppzhu;
grant sysdba to ppzhu
*
ERROR at line 1:
ORA-01999: password file cannot be updated in SHARED mode


SQL> alter user ppzhu identified by kkk;
alter user ppzhu identified by kkk
*
ERROR at line 1:
ORA-01999: password file cannot be updated in SHARED mode
可以看到一切關於會設涉及到RAPWD修改操作都禁止了。

總結一下關於密碼檔案:
1、ORAPWD檔案用於儲存擁有SYSDBA(SYSOPER)許可權使用者的密碼,SYS是一定儲存的,還有一些GRANT SYSDBA許可權的使用者
2、當REMOTE_LOGIN_PASSWORDFILE設定為EXCLUSIVE的情況下,可以透過ALTER USER的方式增加和刪除 SYSDBA(SYSOPER)許可權使用者,並且同步到ORAPWD檔案,SHARED不能增加和刪除使用者
3、當REMOTE_LOGIN_PASSWORDFILE設定為EXCLUSIVE的情況下,可以修改SYSDBA(SYSOPER)許可權使用者密碼,並且同步到ORAPWD檔案,SHARED不能修改
4、設定REMOTE_LOGIN_PASSWORDFILE 為NONE和缺失ORAPWD檔案一樣,不能使用ORAPWD檔案驗證使用者的SYSDBA(SYSOPER)許可權
5、設定REMOTE_LOGIN_PASSWORDFILE 為NONE或者缺失ORAPWD檔案一樣,只能透過作業系統認證(作業系統DBA組的方式)來驗證SYSDBA許可權

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7728585/viewspace-1262106/,如需轉載,請註明出處,否則將追究法律責任。

相關文章