无法使用SID

时间:2018-12-19 16:37:58

标签: oracle

我是完全不熟悉oracle db设置的。这就是为什么我下载并运行oracle VM之后的原因。出于我的项目特定目的,我采取了一些步骤来拥有具有适当权限的表空间和用户/方案,如下所示:

  1. 创建表空间MYTABLESPACE数据文件'linux / path / MYTABLESPACE.DBF'大小为4096m,然后在下一个512m自动扩展,最大大小为8192m;
  2. 创建由MYUSER默认表空间MYTABLESPACE标识的用户MYUSER;
  3. 授予连接,资源,无限的表空间,选择任何词典给MYUSER;

有些默认配置文件存储在$ {ORACLE_HOME} / network / admin

listener.ora

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orclcdb)
      (SID_NAME = orclcdb)
      (ORACLE_HOME = /u01/app/oracle/product/version/db_1)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
    )
  )

#HOSTNAME by pluggable not working rstriction or configuration error.
DEFAULT_SERVICE_LISTENER = (orclcdb)

tnsnames.ora

ORCLCDB=localhost:1521/orclcdb ORCL=  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )   )

使用上述配置,我无法使用SID与新创建的用户建立连接,请参见下表

password

在以下情况下收到以下错误:

[72000] [1017] ORA-01017:无效的用户名/密码;登录被拒绝

由于遗留应用程序需要SID连接,因此有人可以澄清配置中缺少什么吗?

2 个答案:

答案 0 :(得分:2)

默认情况下,您无法使用SID连接到PDB。您必须启用USE_SID_AS_SERVICE_listener参数才能使其起作用(其中“ listener”是您的侦听器的名称)。 See this examplethe docs。由于您的侦听器名为“ LISTENER”,因此您应该可以将此行添加到侦听器的末尾。

USE_SID_AS_SERVICE_LISTENER=on 

答案 1 :(得分:0)

问题中的情况在逻辑上是正确的,没有错,您不应该为 SID 和服务创建相同的普通用户,因为它们是两个独立的实例。
(除非您完全确定要使用两个相同的用户名在两个数据库上执行不同的任务)

我检查了数据库安装的数据库文件,有两个独立的数据库文件组位于两个单独的目录中,一个用于数据库实例(ORACLESID),一个用于数据库服务(ORACLEPDB)。

在我的 Oracle DB 安装中,

服务名称是:
“ORACLEPDB”,

SID 是:
“ORACLESID”

以下是我的文件结构:

bash-4.2# pwd
/opt/oracle/oradata/ORACLESID
bash-4.2#  ls -hal      
total 2.5G
drwxr-x--- 1 oracle oinstall 4.0K Jan 30 02:17 .
drwxr-xr-x 1 oracle dba      4.0K Jan 30 02:26 ..
drwxr-x--- 1 oracle oinstall 4.0K Jan 30 02:26 ORACLEPDB
-rw-r----- 1 oracle oinstall  18M Jan 30 12:47 control01.ctl
-rw-r----- 1 oracle oinstall  18M Jan 30 02:53 control02.ctl
drwxr-x--- 1 oracle oinstall 4.0K Jan 30 02:19 pdbseed
-rw-r----- 1 oracle oinstall 201M Jan 30 12:47 redo01.log
-rw-r----- 1 oracle oinstall 201M Jan 30 12:41 redo02.log
-rw-r----- 1 oracle oinstall 201M Jan 30 12:41 redo03.log
-rw-r----- 1 oracle oinstall 531M Jan 30 12:46 sysaux01.dbf
-rw-r----- 1 oracle oinstall 911M Jan 30 12:46 system01.dbf
-rw-r----- 1 oracle oinstall 129M Jan 30 12:23 temp01.dbf
-rw-r----- 1 oracle oinstall 341M Jan 30 12:46 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5.1M Jan 30 12:41 users01.dbf


bash-4.2# cd ORACLEPDB/
bash-4.2# pwd
/opt/oracle/oradata/ORACLESID/ORACLEPDB
bash-4.2# ls -hal
total 742M
drwxr-x--- 1 oracle oinstall 4.0K Jan 30 02:26 .
drwxr-x--- 1 oracle oinstall 4.0K Jan 30 02:17 ..
-rw-r----- 1 oracle oinstall 331M Jan 30 12:46 sysaux01.dbf
-rw-r----- 1 oracle oinstall 271M Jan 30 12:47 system01.dbf
-rw-r----- 1 oracle oinstall  37M Jan 30 02:54 temp01.dbf
-rw-r----- 1 oracle oinstall 101M Jan 30 12:46 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5.1M Jan 30 12:41 users01.dbf

为了验证这个假设,我创建了如下用户:
使用“ORACLESID”连接的“SIDUSER” enter image description here 使用“ORACLEPDB”连接的“PDBUSER” enter image description here

因此,在“SYSTEM”作为 SYSDBA 用户在基于 SID 的连接和基于服务的连接上创建两个用户之后,“all_users”表中会发生以下情况:

在基于 SID 的连接上,PDBUSER 确实存在:

 select * from all_users where username like '%USER';
 select * from global_name;

enter image description here

在基于服务名称的连接中,SIDUSER存在:

enter image description here

结论是,即使您启用了配置:
USE_SID_AS_SERVICE_LISTENER=on

使用 SID 和 Servicename 连接的用户,即使使用相同的用户名和密码,也在不同的数据库实例上工作,用户在其中一个数据库上所做的更改不会在另一个数据库上看到。