45IT.COM- 电脑学习从此开始!
DIY硬件教程攒机经验装机配置
设计Photoshop网页设计特效
系统注册表DOS系统命令其它
存储主板显卡外设键鼠内存
维修显卡CPU内存打印机
WinXPVistaWin7unix/linux
CPU光驱电源/散热显示器其它
修技主板硬盘键鼠显示器光驱
办公ExcelWordPowerPointWPS
编程数据库CSS脚本PHP
网络局域网QQ服务器
软件网络系统图像安全
页面导航: 首页 > 设计学院 > 网络编程 > 数据库 >

正确认识password file的作用

电脑软硬件应用网 45IT.COM 时间:2008-04-25 10:03 作者:Henry

许多人都知道,在数据库没有正式启动前,数据库的内建用户是无法通过数据库来验证身份的,但口令文件中存放sysdba/sysoper用户的用户名及口令却允许用户通过口令文件验来证,它可以在数据库未启动之前登录,然后再启动数据库。

(假如没有口令文件,在数据库未启动之前就只能通过操作系统认证)


在我们使用Rman时,许多情况下需要在nomount,mount等状态下对数据库进行处理,因此这就要求sysdba权限如果属于本地DBA组,才可以通过操作系统认证登录。

(假如是远程sysdba登录,需要通过passwordfile认证)


1.remote_login_passwordfile = NONE


在此处我们需要停用口令文件验证,因为Oracle不允许远程SYSDBA/SYSOPER身份登录。

local:


[oracle@jumper oracle]$ sqlplus "/ as sysdba"


SQL*Plus: Release 9.2.0.3.0 - Production on Thu Apr 15 09:58:45 2004


Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

 

Connected to:

Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.3.0 - Production


SQL> alter user sys identified by oracle;


User altered.


SQL> show parameter pass


NAME TYPE VALUE

--------------------- ----------- ------------------------------

remote_login_passwordfile string NONE

remote:

E:\Oracle\ora92\bin>sqlplus /nologSQL*Plus: Release 9.2.0.4.0 -

Production on 星期四 4月 15 09:39:22 2004Copyright (c) 1982, 2002, Oracle

Corporation. All rights reserved.SQL> connect sys/oracle@hsjf as

sysdbaERROR:ORA-01017: invalid username/password; logon denied


大家可以发现,此处是无法通过口令文件验证的。


2.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 131142648 bytes

Fixed Size 451576 bytes

Variable Size 104857600 bytes

Database Buffers 25165824 bytes

Redo Buffers 667648 bytes

Database mounted.

Database opened.

SQL> show parameter pass


NAME TYPE VALUE

------------------------------ ----------- --------------

remote_login_passwordfile string EXCLUSIVE

SQL> alter user sys identified by oracle;

User altered.

remote:

E:\Oracle\ora92\bin>sqlplus /nologSQL*Plus: Release 9.2.0.4.0 -

Production on 星期四 4月 15 09:47:11 2004Copyright (c) 1982, 2002, Oracle

Corporation. All rights reserved.SQL> connect sys/oracle@hsjf as

sysdba已连接。SQL> show userUSER 为"SYS"SQL>


此处等同于通过口令文件验证登录。

 

 

3.继续测试


假如此时我们删除passwdfile,sysdba/sysoper将会无法认证,从而无法登录数据库。

Server:

SQL> !

[oracle@jumper oracle]$ cd $ORACLE_HOME/dbs

[oracle@jumper dbs]$ ls orapwhsjf

orapwhsjf

[oracle@jumper dbs]$ mv orapwhsjf orapwhsjf.bak

[oracle@jumper dbs]$


Remote:

E:\Oracle\ora92\bin>sqlplus /nolog


SQL*Plus: Release 9.2.0.4.0 - Production on 星期四 4月 15 09:50:14 2004


Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


SQL> connect sys/oracle@hsjf as sysdba

ERROR:

ORA-01031: insufficient privileges

 

SQL>


这实际上就是无法通过口令文件验证身份

 


4.假如丢失了passwdfile


假如你使用passwdfile后却意外丢失,那么此时将不能启动数据库。


SQL> startup force;

ORACLE instance started.


Total System Global Area 131142648 bytes

Fixed Size 451576 bytes

Variable Size 104857600 bytes

Database Buffers 25165824 bytes

Redo Buffers 667648 bytes

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

我们可以通过orapwd重建口令文件来解决此问题

此处我们恢复口令文件就可以了


SQL> !

[oracle@jumper oracle]$ mv $ORACLE_HOME/dbs/orapwhsjf.bak orapwhsjf

[oracle@jumper oracle]$ exit

exit


SQL> alter database open;


Database altered.


SQL>


5. remote_login_passwordfile = shared


Oracle9i文档说明:


SHARED


More than one database can use a password file. However, the only user recognized by the password file is SYS.

 

--多个数据库可以共享一个口令文件,但是只可以识别一个用户:SYS

 


SQL> select * from v$pwfile_users;


USERNAME SYSDB SYSOP

------------------------------ ----- -----

SYS TRUE TRUE


SQL> grant sysdba to eygle;

grant sysdba to eygle

*

ERROR at line 1:

ORA-01994: GRANT failed: cannot add users to public password file

 

SQL> show parameter password


NAME TYPE VALUE

---------------------- ----------- ----------------------------

remote_login_passwordfile string SHARED

顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
无法在这个位置找到: baidushare.htm
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
验证码:点击我更换图片
推荐知识