对REMOTE_LOGIN_PASSWORDFILE参数的探讨

密码文件,是仅用来限制具有sysdba或者sysoper权限的用户以远程的方式连接数据库的密码校验文件。如果不存在密码文件或者密码文件丢失,那么以sysdba或者sysoper权限的用户将无法登陆并返回错误:

[oracle@home2 dbs]$ mv orapwthinkbase orapwthinkbase.bak

[oracle@home1 ~]$ sqlplus sys/oracle@thinkbase as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Sep 20 16:39:39 2017

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

ERROR:
ORA-01031: insufficient privileges

重新创建或者恢复密码文件,用户才能重新连接:

[oracle@home2 dbs]$ mv orapwthinkbase.bak orapwthinkbase

[oracle@home1 ~]$ sqlplus sys/oracle@thinkbase as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Sep 20 17:06:28 2017

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

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

SYS@thinkbase> 



而REMOTE_LOGIN_PASSWORDFILE参数是对密码文件使用的限定,下面就对REMOTE_LOGIN_PASSWORDFILE参数的各项参数进行探讨

REMOTE_LOGIN_PASSWORDFILE = NONE
当REMOTE_LOGIN_PASSWORDFILE参数为NONE时,密码文件被禁用,用户无法以管理员级别用户远程登录到数据库,如下:

SYS@thinkbase> show parameter pass

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile            string      EXCLUSIVE

SYS@thinkbase> alter system set remote_login_passwordfile=NONE scope=spfile;

System altered.

SYS@thinkbase> startup force;
ORACLE instance started.

Total System Global Area  941600768 bytes
Fixed Size                  1348860 bytes
Variable Size             549456644 bytes
Database Buffers          385875968 bytes
Redo Buffers                4919296 bytes
Database mounted.
Database opened.
SYS@thinkbase> show parameter pass

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile            string      NONE

[oracle@home1 ~]$ sqlplus sys/oracle@thinkbase as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Sep 20 17:10:01 2017

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

ERROR:
ORA-01017: invalid username/password; logon denied
需要留意到设置REMOTE_LOGIN_PASSWORDFILE参数为NONE,与密码文件缺失时用户登录的返回错误差异,实际上“ORA-01017: invalid username/password; logon denied”此时表达的是密码文件被禁用了。



REMOTE_LOGIN_PASSWORDFILE = EXCLUSIVE(系统默认值)
此参数下数据库可以添加系统管理员级别的用户,可以允许使用alter user 命令修改sys用户的密码,并将此类修改记录到密码文件当中。

SYS@thinkbase> show parameter pass

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile            string      NONE
SYS@thinkbase> grant sysdba to hr;
grant sysdba to hr
*
ERROR at line 1:
ORA-01994: GRANT failed: password file missing or disabled

SYS@thinkbase> alter system set remote_login_passwordfile=exclusive scope=spfile;

System altered.

SYS@thinkbase> startup force;
ORACLE instance started.

Total System Global Area  941600768 bytes
Fixed Size                  1348860 bytes
Variable Size             549456644 bytes
Database Buffers          385875968 bytes
Redo Buffers                4919296 bytes
Database mounted.
Database opened.

SYS@thinkbase> show parameter pass

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile            string      EXCLUSIVE

SYS@thinkbase> grant sysdba to hr;

Grant succeeded.

SYS@thinkbase> alter user sys identified by oracle123;

User altered.



REMOTE_LOGIN_PASSWORDFILE = SHARED
SHARED参数可以允许多个数据库共享一个口令文件,但是只可以识别一个用户:SYS。但是SHARED参数下的密码文件不能被修改。也就是没法添加用户为系统管理员级别,也无法写入到密码文件中。

SYS@thinkbase> show parameter pass

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile            string      EXCLUSIVE
SYS@thinkbase> alter system set remote_login_passwordfile=shared scope=spfile;

System altered.

SYS@thinkbase> startup force;
ORACLE instance started.

Total System Global Area  941600768 bytes
Fixed Size                  1348860 bytes
Variable Size             549456644 bytes
Database Buffers          385875968 bytes
Redo Buffers                4919296 bytes
Database mounted.
Database opened.
SYS@thinkbase> show parameter pass

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile            string      SHARED

SYS@thinkbase> grant sysdba to sh;
grant sysdba to sh
*
ERROR at line 1:
ORA-01999: password file cannot be updated in SHARED mode

SYS@thinkbase> alter user sys identified by oracle;
alter user sys identified by oracle
*
ERROR at line 1:
ORA-28046: Password change for SYS disallowed
同时oracle建议如果既要给用户添加系统管理员级别权限又要使用shared模式,最好是先在exclusive模式下设置好管理员权限的用户,再将REMOTE_LOGIN_PASSWORDFILE参数修改为shared共享口令文件。



实验小结:
1.密码文件类似于参数文件,只有在登录或者有信息要写入或者进行修改时才会用到,其他时候即使丢失也不会影响到数据库的运行。
2.由于上面的特点,备份时候通常不会对密码文件进行备份,如果丢失也可以使用如下的语句重新创建密码文件:
[oracle@home2 dbs]$ orapwd
Usage: orapwd file= entries= force= ignorecase= nosysdba=

  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.


  
大家加油!



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31457562/viewspace-2145236/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/31457562/viewspace-2145236/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值