设为首页 加入收藏

TOP

Oracle的密码文件及远程SYSDBA登录(一)
2016-12-28 08:15:45 】 浏览:396
Tags:Oracle 密码 文件 远程 SYSDBA 登录

密码文件(password file)是一个可选的文件,允许远程SYSDBA或管理员访问数据库。


[root@rhel6 ~]# id mysql
uid=496(mysql) gid=495(mysql) groups=495(mysql),500(oinstall)
[root@rhel6 ~]# su - mysql
-bash-4.1$ export ORACLE_HOME=/u02/app/oracle/product/11.2.4/db1
-bash-4.1$ export ORACLE_SID=orcl
-bash-4.1$ cd $ORACLE_HOME/bin
-bash-4.1$ ./sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Dec 15 21:32:05 2016

Copyright (c) 1982, 2013, Oracle. All rights reserved.

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


Enter user-name: ^C
-bash-4.1$ su
Password:
[root@rhel6 bin]# usermod -G dba mysql
[root@rhel6 bin]# id mysql
uid=496(mysql) gid=495(mysql) groups=495(mysql),501(dba)
[root@rhel6 bin]# exit
exit
-bash-4.1$ ./sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Dec 15 21:32:36 2016

Copyright (c) 1982, 2013, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

sys@ORCL>show user
USER is "SYS"


现在可以连接数据库做管理工作,或启动关闭数据库。如果要从另外一台机器通过网络完成这个操作会怎么样呢?下面我使用@连接串来连接:


C:\Users\victor>sqlplus /@orcl as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on 星期四 12月 15 21:42:04 2016

Copyright (c) 1982, 2013, Oracle. All rights reserved.

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


在网络上,对于SYSDBA的操作系统认证不再奏效,即使把很不安全的REMOTE_OS_AUTHENT参数设置为TRUE也不例外。所以操作系统认证不可行。因此密码文件应运而生了。


密码文件保存了一个用户名和密码列表,这些用户名和密码分别对应于通过网络远程认证为SYSDBA的用户。Oracle必须使用这个文件来认证用户,而不是数据库中存储的正常密码列表。


下面验证这种情况。首先,设置REMOTE_LOGIN_PASSWORDFILE,有三个值:NONE,意味着没有密码文件,不存在“远程SYSDBA登录”、SHARED,多个数据库可以使用同样的密码文件、EXCLUSIVE,只有一个数据库使用一个给定的密码文件。这里设置为EXCLUSIVE。


alter system set remote_login_passwordfile=exclusive scope=spfile;


修改这个参数需要重启数据库。


使用orapwd创建和填写这个初始的密码文件,密码文件位于$ORACLE_HOME/dbs目录中。


[oracle@rhel6 dbs]$ which orapwd
/u02/app/oracle/product/11.2.4/db1/bin/orapwd
[oracle@rhel6 dbs]$ orapwd
Usage: orapwd file= 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.
[oracle@rhel6 dbs]$ pwd
/u02/app/oracle/product/11.2.4/db1/dbs
[oracle@rhel6 dbs]$ orapwd file=orapw$ORACLE_SID password=oracle entries=20
[oracle@rhel6 dbs]$ ls -l orapw$ORACLE_SID
-rw-r----- 1 oracle oinstall 3584 Dec 15 21:55 orapworcl


目前该文件中只有一个用户,也就是用户SYS,尽管数据库上还有其他SYSDBA账户,但它们还不在密码文件中。不过基于以上设置我们可以作为SYSDBA通过网络连接Oracle,即使Oracle没有启动,并且可以远程启动Oracle。


C:\Users\victor>sqlplus sys/oracle@orcl as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on 星期四 12月 15 22:00:24 2016

Copyright (c) 1982, 2013, Oracle. All rights reserved.

已连接到空闲例程。

SQL> startup
ORACLE 例程已经启动。

Total System Global Area 784998400 bytes
Fixed Size 2257352 bytes
Variable Size 754978360 bytes
Database Buffers 20971520 bytes
Redo Buffers 6791168 bytes
数据库装载完毕。
数据库已经打开。


注意:如果上边这一步遇到ORA-12505 "TNS:listener does not currently know of SID given in connect descriptor"说明没有配置数据库实例的静态监听。


创建了密码文件,那我们能不能看看密码文件里到底

首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Oracle里count(1)、count(*)和cou.. 下一篇Oracle dba_data_files数据字典里..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目