简体   繁体   English

从 sqlplus 连接到 Oracle 19C 云

[英]Connect to Oracle 19C Cloud from sqlplus

I am not able to connect to my Oracle 19C Cloud DB, I have downloaded the wallet and placed it in a secured place in my machine(windows).我无法连接到我的 Oracle 19C 云数据库,我已经下载了钱包并将其放在我的机器(Windows)中的安全位置。 I have installed Oracle 19C Client in my machine, and updated tnsnames.ora(network/admin) with connection strings from wallet zip, Not sure how whether I have missed any config like Environment variables Getting below error from sqlplus ERROR: ORA-12154: TNS:could not resolve the connect identifier specified我已经在我的机器上安装了 Oracle 19C 客户端,并使用钱包 zip 的连接字符串更新了 tnsnames.ora(network/admin),不确定我是否错过了任何配置,例如环境变量从 sqlplus 错误中获取以下错误:ORA-12154: TNS:无法解析指定的连接标识符

Note: I am able to connect to Cloud from Sql developer using the wallet file.注意:我可以使用钱包文件从 Sql 开发人员连接到云。 And I have Oracle 18c XE running in my machine.我的机器上正在运行 Oracle 18c XE。

Any help will be appreciated, thanks in advance.任何帮助将不胜感激,在此先感谢。

Your problem seems to be related with the issue that you have an Oracle XE database version installed in your own laptop.您的问题似乎与您在自己的笔记本电脑中安装了 Oracle XE 数据库版本的问题有关。

When you run sqlplus or any other OCI tool to connect to Oracle, no matter whether the database is a remote host or in the cloud, sqlplus evaluates the TNS_ADMIN environment variable to identify where your sqlnet and tnsnames files are located.当您运行 sqlplus 或任何其他 OCI 工具连接到 Oracle 时,无论数据库是远程主机还是在云中,sqlplus 都会评估 TNS_ADMIN 环境变量以确定您的 sqlnet 和 tnsnames 文件所在的位置。 If there is no variable, it uses the default values of your main Oracle registry entries, that for sure point to your XE version, as it was installed before.如果没有变量,它将使用您的主 Oracle 注册表项的默认值,该值肯定指向您的 XE 版本,因为它是之前安装的。

When you get ORA-12154: TNS:could not resolve the connect identifier specified , your session is not finding any information regarding the target in your configuration files, probably because the session is evaluating the files in your XE installation当您收到ORA-12154: TNS:could not resolve the connect identifier specified时,您的 session 在您的配置文件中找不到任何有关目标的信息,可能是因为 session 正在评估您的 XE 安装中的文件

Try to do the following尝试执行以下操作

  • Copy the wallet files provided by your Oracle Cloud to a location different to your XE installation.将 Oracle 云提供的钱包文件复制到与 XE 安装不同的位置。
  • Export the TNS_ADMIN variable in your sqlplus cmd session to this new path将 sqlplus cmd session 中的 TNS_ADMIN 变量导出到这个新路径
  • Run sqlplus using wallet使用钱包运行 sqlplus

Example ( I believe you did points 1 and 2 )示例(我相信您做了第 1 点和第 2 点)

  1. Install Oracle Client software on your computer.在您的计算机上安装 Oracle 客户端软件。 Use either the full Oracle Database Client 11.2.0.4 (or higher) or the Oracle Instant Client 12.1.0.2 (or higher).使用完整的 Oracle 数据库客户端 11.2.0.4(或更高版本)或 Oracle Instant Client 12.1.0.2(或更高版本)。 The Instant Client contains the minimal software needed to make an Oracle Call Interface connection. Instant Client 包含建立 Oracle 呼叫接口连接所需的最少软件。 The Instant Client 12.1.0.2 (or higher) is sufficient for most applications. Instant Client 12.1.0.2(或更高版本)对于大多数应用程序来说已经足够了。
  2. Download client credentials and store the file in a secure folder on your client computer.下载客户端凭据并将文件存储在客户端计算机上的安全文件夹中。 See Download Client Credentials (Wallets).请参阅下载客户端凭据(钱包)。
  3. Unzip/uncompress the credentials file into a secure folder on your client computer.将凭据文件解压缩/解压缩到客户端计算机上的安全文件夹中。
  4. Edit the sqlnet.ora file in the folder where you unzip the credentials file, replacing "?/network/admin" with the name of the folder containing the client credentials .在解压凭证文件的文件夹中编辑 sqlnet.ora 文件,将“?/network/admin”替换为包含客户端凭证的文件夹的名称

Example例子

WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY="/my_new_path")))
SSL_SERVER_DN_MATCH=yes

cmd> set tns_admin = my_new_path
cmd> sqlplus /@yourtnsentry 

I don't know whether your cloud database is using a Public IP address or not, or if you want to use SSH tunneling to connect to the database.我不知道您的云数据库是否使用公共 IP 地址,或者您是否想使用 SSH 隧道连接到数据库。 Take a look here, because then you might want to use SQLcl ( Sql Developer Command Line )看看这里,因为那时你可能想使用 SQLcl ( Sql Developer Command Line )

https://docs.cloud.oracle.com/en-us/iaas/Content/Database/Tasks/connectingDB.htm https://docs.cloud.oracle.com/en-us/iaas/Content/Database/Tasks/connectingDB.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM