oracle数据库:数据文件_笔记11
3.8密码文件
密码文件(password file)是一个可选的文件,允许远程SYSDBA或管理员访问数据库。
启动Oracle时,还没有数据库可以用来验证密码。在“本地”系统上启动Oracle时(也就是说,不在网络上,而是从数据库实例所在的机器启动),Oracle会利用操作系统来执行这种认证。
安装Oracle时,会要求完成安装的人指定管理员“组”,在Unix/Linux上,这个组一般默认为DBA,在Windows上则默认为OSDBA。这个组很“特殊”,因为这个组中的任何用户都可以作为SYSDBA连接Oracle,而无需指定用户名或密码。
在网络上,对于SYSDBA的操作系统认证不再奏效,即使把很不安全的REMOTE_OS_AUTHENT参数设置为TRUE也不例外。所以,操作系统认证不可行。
因此密码文件“应运而生”。密码文件保存了一个用户名和密码列表,这些用户名和密码分别对应于可以通过网络远程认证为SYSDBA的用户。Oracle必须使用这个文件来认证用户,而不是数据库中存储的正常密码列表。
下面校正这种情况,首先,我们要本地启动数据库,以便设置REMOTE_LOGIN_PASSWORDFILE。其默认值为NONE,这意味着没有密码文件,不存在“远程SYSDBA登录”。这个参数还有另外两个设置:SHARED(多个数据库可以使用同样的密码文件)和EXCLUSIVE(只有一个数据库使用一个给定的密码文件)
这里设置为EXCLUSIVE,因为我们只想对一个数据库使用这个密码文件(这也是一般用法):
sys@ORCL>alter system set remote_login_passwordfile=exclusive scope=spfile;
System altered.
sys@ORCL>shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@ORCL>startup
ORACLE instance started.
Total System Global Area 855982080 bytes
Fixed Size 2233160 bytes
Variable Size 817892536 bytes
Database Buffers 29360128 bytes
Redo Buffers 6496256 bytes
Database mounted.
Database opened.
实例启动和运行时,这个设置不能动态改变,所以不得不关闭、要想让它生效必须重启实例。
下一步是使用命令行工具orapwd创建和填写这个初始的密码文件。
[oracle@vcenteroracle ~]$ orapwd
Usage: orapwd file=
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.
在登录拥有Oracle软件的操作系统账户时,使用的命令为:
[oracle@vcenteroracle ~]$ orapwd file=orapw$ORACLE_SID password=bar entries=20
目前该文件中只有一个用户,也就是用户SYS,尽管数据库上还有其他SYSDBA账户,但它们还不在密码文件中。基于以上设置,我们可以第一次作为SYSDBA通过网络连接Oracle:
[oracle@localhost ~]$ sqlplus sys/bar@172.16.40.252/orcl as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Tue Sep 10 08:50:48 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from scott.emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
20
...
我们通过了认证,所以登录成功,现在可以通过SYSDBA账户成功的启动、关闭和远程管理这个数据库了。
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> conn ops$tkyte/test@172.16.40.252/orcl as sysdba
Connected.
下面,再看另一个用户OPS$TKYTE,它已经是一个SYSDBA,但还不能远程连接,
idle>create user ops$tkyte identified by test;
User created.
idle>grant sysdba to ops$tkyte;
Grant succeeded.
原因是,OPS$TKYTE还不在密码文件中。要把OPS$TKYTE放到密码文件中,需要重新对该账户授予SYSDBA:
这样会在密码文件中创建一个条目,Oracle现在会保持密码“同步”。如果OPS$TKYTE修改了他的密码,原来的密码将无法完成远程SYSDBA连接,新密码才能启动SYSDBA连接:
sys@ORCL>alter user ops$tkyte identified by something_else;
User altered.
[oracle@localhost ~]$ sqlplus ops$tkyte/test@172.16.40.252/orcl as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Tue Sep 10 09:05:19 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
ERROR:
ORA-01031: insufficient privileges
Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied
Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
[oracle@localhost ~]$ sqlplus ops$tkyte/something_else@172.16.40.252/orcl as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Tue Sep 10 09:26:06 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
ERROR:
ORA-01031: insufficient privileges
Enter user-name: ops$tkyte/something_else@172.16.40.252/orcl as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from scott.emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
20
...http://www.52ij.com/jishu/5155.htmloracle数据库:数据文件_笔记10
本文来源 我爱IT技术网 http://www.52ij.com/jishu/5156.html 转载请保留链接。
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
