remote_login_passwordfile参数 2012-11-02 16:54:10
分类: Oracle
转自:http://www.dbasky.com/oracle/remote_login_passwordfile_sqlnet_ora.html
今天复习的一个知识点:
remote_login_passwordfile,一直对这个参数的认识只是停留在它控制是否sys用户能在远程使用密码文件认证登录,对于他的值设置,适用情况没有更深的研究,今天就打算做一些小实验来探索他的使用。
本次测试基于windows的oracle 10g,可能测试结果会有偏差。
首先阅读10g reference文档中的描述:
作用:这个参数控制oracle是否检查密码文件 取值范围:none,shared(默认) none:oracle会忽略任何密码文件,此时有权限的用户(比如sys)必须使用操作系统认证。 shared:一个或多个数据库可以使用密码文件,这时密码文件中可以包含sys和非sys用户 exclusive:这个参数10g中取消了,但为了向后兼容,你可以设置,与shared功能一样。 rac中多个实例应该有相同的值。
在oracle数据库没有启动之前,oracle内的用户是无法通过oracle来认证的,sys用户要启动oracle,就必须使用别的认证方式:一是密码文件认证,二是操作系统认证。
操作系统认证:通常要求该用户属于本地DBA组,然后通过操作系统认证登录到oracle,从而来启动数据库。
密码文件认证:如果是远程以sys用户登录来启动数据库,那么只有通过密码文件认证来登录了。
这个时候remote_login_passwordfile就来控制是否可以远程来登录。
1.remote_login_passwordfile = NONE
此时不能使用任何密码文件来登录数据库,只能在本地通过操作系统认证来起停数据库,远程sysdba登录是不被允许的,即使你$ORACLE_HOME/dbs下有密码文件。这样类似在别的机器上使用sqlplus sys/oracle@orcl as sysdba语句的登录都会报错。此时,即使你在本地机器上OEM database control也是会报错的,提示无效的用户名密码,实际也是不能用密码文件验证身份。
2.remote_login_passwordfile = SHARED
此时可以在远程使用密码文件认证来登录数据库,如果本地没有密码文件,或者密码文件丢失,也是不能登录成功的,此时可以使用orapwd重新创建密码文件。remote_login_passwordfile = SHARED时,更改sys用户密码是不被允许的。同时授予除sys外的其他用户sysdba权限也是不允许的。此时可以通过密码文件在本机成功登录OEM database control。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | SQL> show parameter pass
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ remote_login_passwordfile string SHARED
SQL> select * from v$pwfile_users;
USERNAME SYSDB SYSOP ------------------------------ ----- ----- SYS TRUE TRUE
SQL> alter user sys identified by oracle;
alter user sys identified by oracle * ERROR at line 1: ORA-28046: Password change for SYS disallowed
SQL> grant sysdba to test;
grant sysdba to test * ERROR at line 1: ORA-01999: password file cannot be updated in SHARED mode |
windows系统中,shared模式下打开数据库的话不能删除pwd.ora文件,看来oralce会锁定这个文件给多个数据库使用。
2.remote_login_passwordfile = EXCLUSIVE
oracle 10g文档中说exclusive与shared有相同的行为,可是我做的实验的结果并不是这样,可见oracle的文档也不能全信。11g中这个错误被修正了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 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
ORA-32004: obsolete and/or deprecated parameter(s) specified ORACLE instance started. Total System Global Area 264241152 bytes Fixed Size 1296160 bytes Variable Size 163580128 bytes Database Buffers 92274688 bytes Redo Buffers 7090176 bytes Database mounted.
Database opened. SQL> SQL> SQL> show parameter remote NAME TYPE VALUE ------------------------------------ ----------- ------------------------ remote_archive_enable string true remote_dependencies_mode string TIMESTAMP remote_listener string remote_login_passwordfile string EXCLUSIVE remote_os_authent boolean FALSE remote_os_roles boolean FALSE SQL> SQL> SQL> grant sysdba to test; Grant succeeded. SQL> SQL> show parameter compati NAME TYPE VALUE ------------------------------------ ----------- ------------------------ compatible string 10.2.0.3.0 plsql_v2_compatibility boolean FALSE |
当我又重新置会shared 模式时
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | SQL> alter system set remote_login_passwordfile =shared scope=spfile
System altered.
SQL> shutdown immediate;
Database closed. Database dismounted. ORACLE instance shut down . SQL> startup
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE instance started. Total System Global Area 264241152 bytes Fixed Size 1296160 bytes Variable Size 163580128 bytes Database Buffers 92274688 bytes Redo Buffers 7090176 bytes Database mounted. Database opened.
SQL> show parameter pass NAME TYPE VALUE ------------------------------------ ----------- --------- remote_login_passwordfile string SHARED
SQL> select * from v$pwfile_users;
USERNAME SYSDB SYSOP ------------------------------ ----- ----- SYS TRUE TRUE TEST TRUE FALSE
SQL> SQL> grant sysdba to test;
grant sysdba to test *
ERROR at line 1: ORA-01999: password file cannot be updated in SHARED mode
SQL> revoke sysdba from test;
revoke sysdba from test *
ERROR at line 1: ORA-01999: password file cannot be updated in SHARED mode |