1.3.5 Oracle的口令文件(1)
继续前面的脚本,在创建和启动了实例之后,Oracle开始调用eygle.sql脚本,我们将这个脚本分开来介绍。这个脚本的最初部分是要求定义用户口令,然后使用定义的sys用户口令创建口令文件:
set verify off
ACCEPT sysPassword CHAR PROMPT 'Enter new password for SYS: ' HIDE
ACCEPT systemPassword CHAR PROMPT 'Enter new password for SYSTEM: ' HIDE
ACCEPT sysmanPassword CHAR PROMPT 'Enter new password for SYSMAN: ' HIDE
ACCEPT dbsnmpPassword CHAR PROMPT 'Enter new password for DBSNMP: ' HIDE
host D:\Oracle\11.2.0\bin\orapwd.exe
file=D:\Oracle\11.2.0\database\PWDeygle.oraforce=y
这里又引入了另一个工具orapwd,这个工具在Linux/UNIX上同样存在,当口令文件丢失或损坏之后,可以通过这个工具重建口令文件,这个工具的语法为:
D:\oracle\11.2.0\BIN>orapwd
Usage: orapwdfile=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.
注意:force参数是Oracle 10g中增加的,ignorecase参数是Oracle 11g新增加的。
Oracle在启动过程中,会在$ORACLE_HOME/dbs(Windows下相应的目录则是$ORACLE_ HOME\database)目录下查找口令文件,查找的顺序是首先检查orapw文件,如果不存在则查找orapw文件,如果orapw文件也不存在,就会报出如下错误:
SQL>startup force;
ORACLE instance started.
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@jumper dbs]$ orapwdfile=orapwhsjfpassword=oracleentries=5
在数据库没有启动之前,数据库内建用户是无法通过数据库来验证身份的,此时口令文件的作用就体现了出来。口令文件中存放了具有sysdba/sysoper身份用户的用户名及口令,Oracle允许用户通过口令文件验证,在数据库未启动之前登录,从而启动实例进而加载并打开数据库;而如果没有口令文件,在数据库未启动之前就只能通过操作系统认证方式来启动实例。在Oracle DataGuard环境中,要求主数据库和备用数据库的口令文件SYS用户密码相同,这时候经常会用到使用orapwd工具重建口令文件的技能。
Oracle通过一个初始化参数remote_login_passwordfile来限制口令文件的使用,通过这个参数可以设置用户登录时是否检查口令文件,以及有多少个数据库可以使用口令文件。这个参数有3个选项:EXCLUSIVE、SHARED和NONE。
当remote_login_passwordfile设置为NONE时,远程用户将不能通过sysdba/sysoper身份登录数据库:
SQL>show parameter pass
NAME TYPE VALUE
------------------------- ----------- ------------------------------
remote_login_passwordfile string NONE
此时通过远程连接会收到如下错误:
SQL>connect sys/oracle@hsjf as sysdba
ERROR:ORA-01017: invalid username/password; logon denied
此处实际上是无法通过口令文件验证。
缺省的remote_login_passwordfile参数设置为exclusive,支持远程sysdba的登录操作:
SQL>alter system setremote_login_passwordfile=exclusivescope=spfile;
System altered.
【责任编辑:book TEL:(010)68476606】
点赞 0