Oracle 12c sales_history 示例模式安装

Posted

技术标签:

【中文标题】Oracle 12c sales_history 示例模式安装【英文标题】:Oracle 12c sales_history sample schema installation 【发布时间】:2019-02-21 09:31:08 【问题描述】:

我正在为 oracle 12c (12.2) 安装示例架构。 hr 架构安装得很好,但 sales_order 和其他架构都失败了。 故障只发生在可插拔数据库上,尤其是在

specify connect string as parameter 8:
Enter value for 8: sys/password@techfuturepdb as sysdba*

在运行示例架构脚本之前

SQL> show pdbs 
    CON_ID CON_NAME           OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
     3 TECHFUTUREPDB          READ WRITE NO

什么是连接字符串?它期望什么价值?我的 tnsnames.ora 文件在下面

-- 安装示例模式 sales_history

SQL> @?/demo/schema/sales_history/sh_main.sql

specify password for SH as parameter 1:
Enter value for 1: password
specify default tablespace for SH as parameter 2:
Enter value for 2: users
specify temporary tablespace for SH as parameter 3:
Enter value for 3: temp
specify password for SYS as parameter 4:
Enter value for 4: password
specify directory path for the data files as parameter 5:
Enter value for 5: /u01/app/oracle/product/12.2/db_1/demo/schema/sales_history
writeable directory path for the log files as parameter 6:
Enter value for 6: /u01/app/oracle/product/12.2/db_1/demo/schema/log
specify version as parameter 7:
Enter value for 7: v3
specify connect string as parameter 8:
Enter value for 8: sys/password@techfuturepdb as sysdba    
Session altered.

DROP USER sh CASCADE
         *
ERROR at line 1:

ORA-01918: user 'SH' does not exist

old   1: CREATE USER sh IDENTIFIED BY &pass
new   1: CREATE USER sh IDENTIFIED BY password
User created.

old   1: ALTER USER sh DEFAULT TABLESPACE &tbs
new   1: ALTER USER sh DEFAULT TABLESPACE users
old   2:  QUOTA UNLIMITED ON &tbs
new   2:  QUOTA UNLIMITED ON users

User altered.

old   1: ALTER USER sh TEMPORARY TABLESPACE &ttbs
new   1: ALTER USER sh TEMPORARY TABLESPACE temp
User altered.

Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.

ERROR:

ORA-12154: TNS:could not resolve the connect identifier specified

Warning: You are no longer connected to ORACLE.
SP2-0640: Not connected
SP2-0640: Not connected
SP2-0640: Not connected
SP2-0640: Not connected
SP2-0640: Not connected
SP2-0640: Not connected

ERROR:

ORA-12154: TNS:could not resolve the connect identifier specified
SP2-0640: Not connected
SP2-0640: Not connected
SP2-0310: unable to open file "__SUB__CWD__/sales_history/csh_v3.sql"
SP2-0310: unable to open file "__SUB__CWD__/sales_history/lsh_v3.sql"
SP2-0310: unable to open file "__SUB__CWD__/sales_history/psh_v3.sql"

SQL> 

这是我的 tnsnames.ora 文件

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

TECHFUTURE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = cisnet-10.elom.tg)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = techfuture.elom.tg)
    )
  )

LISTENER_TECHFUTURE =
  (ADDRESS = (PROTOCOL = TCP)(HOST = cisnet-10.elom.tg)(PORT = 1522))

TECHFUTUREPDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = cisnet-10.elom.tg)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = TECHFUTUREPDB)
    )
  )

【问题讨论】:

【参考方案1】:

根据GitHub distribution 中的 README 文件第 2.3 节:

验证数据库的连接字符串。为了说明 目的,for database pdb 的值为:

connect_string: localhost:1521/pdb

connect_string 也可能是一个有效的 tnsnames.ora 条目。

所以你只需要给它 TNS 别名:

specify connect string as parameter 8:
Enter value for 8: techfuturepdb

或者,如果您更喜欢 EasyConnect 等效项:

specify connect string as parameter 8:
Enter value for 8: cisnet-10.elom.tg:1522/techfuturepdb

【讨论】:

谢谢。我使用这个,它可以工作 cisnet-10.elom.tg:1522/techfuturepdb 现在我无法打开文件问题,尽管 sql 文件有 777 权限。连接的。会话已更改。会话已更改。 SP2-0310:无法打开文件“__SUB__CWD__/sales_history/csh_v3.sql” SP2-0310:无法打开文件“__SUB__CWD__/sales_history/lsh_v3.sql” SP2-0310:无法打开文件“__SUB__CWD__/sales_history/psh_v3.sql " SQL>【参考方案2】:

我发现了另一个错误,这可能是造成这种情况的原因

SP2-0310: unable to open file "__SUB__CWD__/sales_history/csh_v3.sql" 
SP2-0310: unable to open file "__SUB__CWD__/sales_history/lsh_v3.sql" 
SP2-0310: unable to open file "__SUB__CWD__/sales_history/psh_v3.sql"

这是

日志文件的可写目录路径作为参数6: 输入 6 的值:/u01/app/oracle/product/12.2/db_1/demo/schema/log

解决方法:日志后面需要有正斜杠,像这样:

/u01/app/oracle/product/12.2/db_1/demo/schema/log/

安装文档中提到: https://docs.oracle.com/database/121/COMSC/installation.htm#COMSC001

为您的日志目录输入目录路径,例如$ORACLE_HOME/demo/schema/log/

【讨论】:

以上是关于Oracle 12c sales_history 示例模式安装的主要内容,如果未能解决你的问题,请参考以下文章

oracle11g和12c有啥区别?

oracle weblogic 11g和 12c的区别

CenOS7 部署 数据库 Oracle 12c + 启动阶段与关闭状态 [12.2 企业版]

关于 Oracle 12c 中的用户

从 oracle 12c 升级到 oracle 19c 导致查询性能下降

linux中安装oracle12c透明网关