Oracle中password file orapwd的作用及说明(三)
e string SHARED
[oracle@jumper dbs]$ strings orapw
]\[Z
ORACLE Remote Password file
INTERNAL
AB27B53EDC5FEF41
8A8F025737A9097A
注意这里仅记录着INTERNAL/SYS的口令
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE 时
SQL> alter system set remote_login_passwordfile=exclusive scope=spfile;
System altered.
SQL> startup force;
ORACLE instance started.
Total System Global Area 235999908 bytes
Fixed Size 451236 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> !
[oracle@jumper bin]$ cd $ORACLE_HOME/dbs
[oracle@jumper dbs]$ strings orapw
]\[Z
ORACLE Remote Password file
HSJF
INTERNAL
AB27B53EDC5FEF41
8A8F025737A9097A
[oracle@jumper dbs]$ exit
exit
注意这里,以EXCLUSIVE 方式启动以后,实例名称信息被写入口令文件.
此时如果有其他实例以Exclusive模式启动仍然可以使用这个口令文件,口令文件中的实例名称同时被改写.
SQL> select * from v$pwfile_users;
USERNAME SYSDB SYSOP
------------------------------ ----- -----
SYS TRUE TRUE
SQL> grant sysdba to eygle;
Grant succeeded.
SQL> select * from v$pwfile_users;
USERNAME SYSDB SYSOP
------------------------------ ----- -----
SYS TRUE TRUE
EYGLE TRUE FALSE
SQL> !
[oracle@jumper bin]$ cd $ORACLE_HOME/dbs
[oracle@jumper dbs]$ strings orapw
]\[Z
ORACLE Remote Password file
HSJF
INTERNAL
AB27B53EDC5FEF41
8A8F025737A9097A
>EYGLE
B726E09FE21F8E83
一旦口令文件中增加了其他SYSDBA用户,此文件不再能够被其他Exclusive的实例共享.
实际上,口令文件对于其他用户来说就是启到了一个 sudo 的作用.
6.重建口令文件
如果口令文件丢失,可以使用orapwd可以重建口令文件,语法如下:
[oracle@jumper oracle]$ orapwd
Usage: orapwd file= password= entries=
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.
orapwd是oracle提供的创建口令文件的命令,如果口令文件不见了可以用这个命令重新创建。下面是orapwd命令的一些解释。
D:\oracle\ora92\database>orapwd
Usage: orapwd file= password= entries=
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.
例如:D:\oracle\ora92\database>orapwd file=pwdcjh.ora password=cjh entries=2
其中参数entries的含义是表示口令文件中可以存放的最大用户数,对应于允许以SYSDBA/SYSOPER权限登录数据库的最大用户数,如果用户数超过这个值只能重建口令文件,增大entries。
file后面可以指定口令文件的全路径和文件名,否则创建在当前目录下。
windows下oracle默认的位置是ora92/database目录,默认的文件名是pwdSID.ora,对于别的文件名是不认的。linux下oracle默认的位置是$ORACLE_HOME/dbs目录,默认的文件名是orapwSID,对于别的文件名是不认的。
创建完后,数据库需要重启动,新的口令文件才能生效。
但是这个口令文件对于非操作
系统认证例如网络连接的方式才有用。对于在本机登录,因为采用了操作系统认证,不管用什么口令都可以登录,实际上口令没起任何作用。如果在本机登陆不采用操作系统认证,把ora92/network/admin下的sqlnet.ora中的
SQLNET.AUTHENTICATION_SERVICES= (NTS)
改为
SQLNET.AUTHENTICATION_SERVICES= (NONE)
然后用
D:\oracle\ora92\database>sqlplus "sys/cjh@cjh as sysdba"
就可以登陆了。