首页 » ORACLE 9i-23ai » oracle password file(口令文件) 文件名格式重要性

oracle password file(口令文件) 文件名格式重要性

今天测试dg,用sys  +tnsnames 中指定别名文件远程服务怎么也连不上,ORA-01031: insufficient privileges

查看oracle10g官方文档没发现这个格式问题(可能是我大意了),orapwd  file的格式是有限制的,今天在这记录以提醒大家

请注意我下面的实验

[oracle@orazhang ~]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 22-8月 -2011 14:00:16

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orazhang)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                22-8月 -2011 13:03:40
Uptime                    0 days 0 hr. 56 min. 36 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=orazhang)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl_XPT.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@orazhang ~]$ vi /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = orazhang)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

[oracle@orazhang sbin]$ /sbin/ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:1F:D0:1C:06:7F
          inet addr:192.168.3.243  Bcast:192.168.3.255  Mask:255.255.255.0
          inet6 addr: fe80::21f:d0ff:fe1c:67f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14687 errors:0 dropped:0 overruns:0 frame:0
          TX packets:447 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1829241 (1.7 MiB)  TX bytes:59864 (58.4 KiB)

[oracle@orazhang sbin]$ tnsping orcl

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 22-8月 -2011 14:01:45

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = orazhang)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))
OK (10 msec)

--先把原来的口令文件重命名
[oracle@orazhang dbs]$ mv orapworcl orapworcl_bak
[oracle@orazhang dbs]$ ls
20mhg8fl_1_1  6sm9jgq7_1_1  hc_+ASM.dat  init+ASM.ora  initorcl.ora  lkORCL     orapworcl_bak  spfile+ASM.ora
6rm9jgh0_1_1  ab_+ASM.dat   hc_orcl.dat  init.ora      lk+ASM        orapw+ASM  snapcf_orcl.f  spfileorcl.ora
[oracle@orazhang dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 8月 22 14:03:02 2011

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

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

sys@ORCL> show parameter remot

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_archive_enable                string      true
remote_dependencies_mode             string      TIMESTAMP
remote_listener                      string
remote_login_passwordfile            string      EXCLUSIVE
remote_os_authent                    boolean     FALSE
remote_os_roles                      boolean     FALSE

[oracle@orazhang dbs]$ cd ../network/admin
[oracle@orazhang admin]$ ls
listener.ora  samples  shrept.lst  sqlnet.ora  tnsnames.ora
[oracle@orazhang admin]$ cat sqlnet.ora

# SQLNET.AUTHENTICATION_SERVICES= (none)
# sqlnet.authentication_services=(beq, kerberos5)

NAMES.DIRECTORY_PATH=(TNSNAMES,EZCONNECT)

[oracle@orazhang admin]$ sqlplus sys/oracle@orcl as sysdba             

SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 8月 22 14:04:04 2011

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

ERROR:
ORA-01031: insufficient privileges

Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied
--没有口令文件肯定不可以,orapwd 的file 路径一定是标准路径,记的切路径
[oracle@orazhang admin]$ pwd
/u01/app/oracle/product/10.2.0/db_1/network/admin
[oracle@orazhang admin]$ cd ../../dbs
[oracle@orazhang dbs]$ ls
20mhg8fl_1_1  6sm9jgq7_1_1  hc_+ASM.dat  init+ASM.ora  initorcl.ora  lkORCL     orapworcl_bak  spfile+ASM.ora
6rm9jgh0_1_1  ab_+ASM.dat   hc_orcl.dat  init.ora      lk+ASM        orapw+ASM  snapcf_orcl.f  spfileorcl.ora
[oracle@orazhang dbs]$ orapwd
Usage: orapwd file= password=
 entries= force= 

  where
    file - name of password file (mand),
    password - password for SYS (mand),
    entries - maximum number of distinct DBA and     force - whether to overwrite existing file (opt),
OPERs (opt),
  There are no spaces around the equal-to (=) character.
--随便给个名字,试试

[oracle@orazhang dbs]$ orapwd file=PWDanbob.ora password=oracle entries=5
[oracle@orazhang dbs]$ sqlplus sys/oracle@orcl as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 8月 22 14:05:49 2011

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

ERROR:
ORA-01031: insufficient privileges

[oracle@orazhang dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 8月 22 14:07:06 2011

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

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

sys@ORCL> select * from v$pwfile_users;

no rows selected

--用orapw+<sid>试试
[oracle@orazhang dbs]$ orapwd file=orapworcl password=oracle entries=5
[oracle@orazhang dbs]$ sqlplus / as sysdba                            

SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 8月 22 14:07:23 2011

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

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

sys@ORCL> select * from v$pwfile_users;

USERNAME                       SYSDB SYSOP
------------------------------ ----- -----
SYS                            TRUE  TRUE

sys@ORCL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@orazhang dbs]$ sqlplus sys/oracle@orcl as sysdba                            

SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 8月 22 14:07:34 2011

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

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

sys@ORCL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@orazhang dbs]$

note:
1,oracle的登录验证,分os认证或口令认证,又受三个参数的制约,请看我以前的http://www.anbob.com/?p=416
2,oracle 口令文件格式在windows平台是 PWD.ORA
在linux平台是orapw

打赏

目前这篇文章有3条评论(Rss)评论关闭。

  1. 暖宝宝 | #1
    2011-08-24 at 10:51

    最喜欢这样的文章了。

  2. 邯郸seo | #2
    2011-08-23 at 18:55

    搞不懂。

    • Turk | #3
      2011-09-03 at 06:11

      Never would have thunk I would find this so indisepsnable.