在Oracle 10g之前,启动到Mount状态,数据库需要具备的另外一个重要文件是口令文件,在Unix/Linux上,该文件位于$ORACLE_HOME/dbs目录下,缺省的名称为orapw<ORACLE_SID>。
而在Windows上,文件位于%ORACLE_HOME%\database目录下,缺省的名称为PWD<ORACLE_SID>.ora,注意这二者的区别,还要注意ORACLE_SID的大小写。
口令文件中存放SYSDBA/SYSOPER用户的用户名及口令,在Unix/Linux下,通过strings命令可以将口令文件中的文本串提出出来,以下是一个口令文件中的字符内容(来自Oracle 9iR2环境):
[oracle@jumper dbs]$ strings orapwconner ]\[Z ORACLE Remote Password file CONNER INTERNAL AB27B53EDC5FEF41 8A8F025737A9097A EYGLE B726E09FE21F8E83
复制
口令文件可以用于对具备SYSDBA/SYSOPER身份的用户进行登录认证,如果不存在该文件,则远程用户将无法使用这两个身份登录数据库。在Oracle 9i中,口令文件在数据库的Mount阶段被检测。
如果丢失了口令文件,在mount阶段就会出现错误,给出提示:
SQL> alter database mount; alter database mount * ERROR at line 1: ORA-01990: error opening password file '/opt/oracle/product/9.2.0/dbs/orapw' ORA-27037: unable to obtain file status Linux Error: 2: No such file or directory Additional information: 3
复制
对于口令文件,Oracle缺省查找orapw<ORACLE_SID>文件,如果该文件不存在,则继续查找orapw文件,如果两者都不存在,则数据库将会出现错误(虽然会出现错误提示,数据库仍然可以继续打开)。
如果口令文件丢失,可以通过orapw工具即可重建,所以在通常的备份策略中可以不必包含口令文件:
[oracle@jumper dbs]$ orapwd Usage: orapwd file=<fname> password=<password> entries=<users> where file - name of password file (mand), password - password for SYS (mand), entries - maximum number of distinct DBA and OPERs (opt), There are no spaces around the equal-to (=) character.
复制
初始化参数remote_login_passwordfile和口令文件的使用有关。
从Oracle 10g开始,当口令文件丢失后,在启动过程中,Oracle将不再提示错误,只是和口令文件相关的部分功能将无法使用。比如之后进行SYSDBA的授权或者尝试远程通过SYSDBA身份登录都会出现错误:
SQL> connect sys/oracle@eygle as sysdba ERROR: ORA-01031: insufficient privileges Warning: You are no longer connected to ORACLE.
复制
以下是丢失口令文件的授权示例,系统将提示无法找到口令文件的错误:
SQL> grant sysdba to test; grant sysdba to test * ERROR at line 1: ORA-01994: GRANT failed: password file missing or disabled
复制
假如以口令文件为校验登入数据库的用户,如果丢失了口令文件,则数据库会触发错误中断会话,以下是12c中的测试验证:
[oracle@enmocoredb dbs]$ sqlplus sys/oracle@core as sysdba SQL*Plus: Release 12.1.0.1.0 Production on Tue Apr 15 13:20:34 2014 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> ! mv orapwcore orapwcore.bak SQL> startup Segmentation fault
复制
数据库里具有SYSDBA/SYSOPER权限的用户可以通过v$pwfile_users视图查询得到。
评论
