oracle - 在 Linux 中使用 PowerShell 连接到 Oracle Autonomous db

标签 oracle powershell ubuntu odp.net

我在云中设置了一个自治 Oracle 数据库,并且可以通过许多不同的路径成功访问它,SQL 开发人员 (Linux)、PowerShell (Linux) 和 cx_python(Linux),原因我自己最清楚我想看看我是否可以在 VS Code 中使用 Linux 上的 PowerShell 连接到同一个数据库。
我有

  • 下载钱包,放在目录/home/simon/Documents/Wallet_DB202006252115。
  • Oracle.ManagedDataAccess.Core.2.19.101 已安装
  • 已安装 Microsoft.NETCore.App 5.0.2。

  • 我从 VS Code 运行的基本 PowerShell(PowerShell 集成控制台 v2020.6.0)代码是
    $connectionstring = 'User Id=' + $username + ';Connection Timeout=120 ;Password=' + $password + ';Data Source=' + $datasource
    $con = New-Object Oracle.ManagedDataAccess.Client.OracleConnection($connectionstring)
    $con.TnsAdmin='/home/simon/Documents/Wallet_DB202006252115'
    $con.WalletLocation='/home/simon/Downloads/Wallet_DB202006252115'
    $con.Open()
    
    使用用户 ID 等进行适当设置。它正在正确读取 TNS 数据,就好像我更改了它给出 TNS 错误的源名称一样。 DLL 已成功加载,因为我可以访问连接对象。
    通过此设置,我收到以下错误
    Automation.MethodInvocationException: Exception calling "Open" with "0" argument(s): "ORA-00542: Failure during SSL handshake"
     ---> Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-00542: Failure during SSL handshake
     ---> OracleInternal.Network.NetworkException (0x80004005): ORA-00542: Failure during SSL handshake
     ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
     ---> Interop+OpenSsl+SslException: SSL Handshake failed with OpenSSL error - SSL_ERROR_SSL.
     ---> Interop+Crypto+OpenSslCryptographicException: error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure
       --- End of inner exception stack trace ---
    
    有什么建议么..
    谢谢
    编辑 - 添加跟踪
    021-01-28 20:00:29.127597 TID:1   (CFG) (ENV)      Machine Name : simon-IOTA2320
    2021-01-28 20:00:29.129182 TID:1   (CFG) (ENV)      User Name : simon
    2021-01-28 20:00:29.129700 TID:1   (CFG) (ENV)      OS Version : Unix 5.8.0.40
    2021-01-28 20:00:29.129817 TID:1   (CFG) (ENV)      64-bit OS : True
    2021-01-28 20:00:29.129877 TID:1   (CFG) (ENV)      64-bit Process : True
    2021-01-28 20:00:29.130483 TID:1   (CFG) (ENV)      .NET Core Runtime Version : 5.0.2
    2021-01-28 20:00:29.130558 TID:1   (CFG) (ENV)      Application Directory : /home/simon/Documents/test/bin/Debug/net5.0
    2021-01-28 20:00:29.130583 TID:1   (CFG) (VER)      Oracle Data Provider for .NET Core Driver Version : 2.0.19.1
    2021-01-28 20:00:29.153996 TID:1   (CFG) (VER)      Oracle Data Provider for .NET Core Driver Informational Version : 2.0.19.1:20201224
    2021-01-28 20:00:29.154283 TID:1   (CFG) (.NET)     SSL_SERVER_DN_MATCH : yes
    2021-01-28 20:00:29.154342 TID:1   (CFG) (.NET)     WALLET_LOCATION : /home/simon/Documents/Wallet_DB202006252115
    2021-01-28 20:00:29.162967 TID:1   (CFG) (SQLNET)   FilePath : (null)
    2021-01-28 20:00:29.163089 TID:1   (CFG) (TNSNAMES) FilePath : /home/simon/Documents/Wallet_DB202006252115/tnsnames.ora
    2021-01-28 20:00:29.186669 TID:1   (CFG) (OCFG)     OracleConfiguration.TraceFileLocation() : /home/simon/Documents/PowerShell
    2021-01-28 20:00:29.187092 TID:1   (CFG) (OCFG)     OracleConfiguration.TraceLevel() : 7
    2021-01-28 20:00:29.187308 TID:1   (CFG) (OCFG)     OracleConfiguration.CommandTimeout() : 120
    2021-01-28 20:00:29.187354 TID:1   (CFG) (OCFG)     OracleConfiguration.TnsAdmin() : /home/simon/Documents/Wallet_DB202006252115
    2021-01-28 20:00:29.187385 TID:1   (CFG) (OCFG)     OracleConfiguration.WalletLocation() : /home/simon/Documents/Wallet_DB202006252115
    2021-01-28 20:00:29.114716 TID:1   (PUB) (ENT) OracleConnection.Open() (conid=27252167) (state=Closed) (sessid=0) (implid=0) (pooling=T) (txnid=n/a) 
    2021-01-28 20:00:29.192468 TID:1   (PRI) (ENT) (CP) OracleConnectionDispenser..cctor()
    2021-01-28 20:00:29.193968 TID:1   (PRI) (EXT) (CP) OracleConnectionDispenser..cctor()
    2021-01-28 20:00:29.194179 TID:1   (PRI) (ENT) (CP) OracleConnectionDispenser.Get()
    2021-01-28 20:00:29.198567 TID:1   (PRI) (ENT) (CP) PoolManager.ctor()
    2021-01-28 20:00:29.201716 TID:1   (PRI) (EXT) (CP) PoolManager.ctor()
    2021-01-28 20:00:29.205059 TID:1   (PRI) (ENT) (CP) PoolManager.Initialize() (constr=User Id=AOracleDMIN;Data Source=db202006252115_high;Connection Timeout=120;)
    2021-01-28 20:00:29.206900 TID:1   (PRI) (EXT) (CP) PoolManager.Initialize() (pmid=43942917) (constr=User Id=AOracleDMIN;Data Source=db202006252115_high;Connection Timeout=120;)
    2021-01-28 20:00:29.209809 TID:1   (PRI) (BUF) (OBP.CTOR) (poolid:59941933) (OracleConnectionDispenser`3.GetPM)
    2021-01-28 20:00:29.217997 TID:1   (PRI) (ENT) (CP) OraclePoolManager.Get()
    2021-01-28 20:00:29.282032 TID:1   (PRI) (ENT) (CP) PoolManager.Get() (txnid=n/a) (bForceMatch=F)
    2021-01-28 20:00:29.282979 TID:1   (PRI) (ENT) (CP) PoolManager.Get() MultiTenant : Searching for a idle connection, retryCountWithoutAffinity: 0
    2021-01-28 20:00:29.284439 TID:1   (PRI) (ENT) PoolManager.ProcessCriteriaCtx_NonEnlistedConnection()
    2021-01-28 20:00:29.284565 TID:1   (PRI) (EXT) PoolManager.ProcessCriteriaCtx_NonEnlistedConnection()
    2021-01-28 20:00:29.300606 TID:1   (PRI) (ENT) (CP) PoolManager.CreateNewPR() (txnid=n/a) 
    2021-01-28 20:00:29.310788 TID:4   (PRI) (ENT) (CP) PoolManager.CreateNewPRThreadFunc()
    2021-01-28 20:00:29.310916 TID:4   (PRI) (ENT) (CP) PoolManager.CreateNewPRThreadFunc() (initiated by TID:1)
    2021-01-28 20:00:29.325121 TID:4   (PRI) (SVC) (ENT) OracleConnectionImpl.Connect() (oper=open) (aff=n/a) (inst=) (affmatch=n/a) (pr.service=) (pr.pdb=) (pr.edition=) (sessid=-1:-1) (F;F;F;;N) (pmid=43942917) 
    2021-01-28 20:00:29.327817 TID:4   (PRI) (BUF) (COBP.CTOR) (poolid:1) (parentpoolid:59941933) (OracleConnectionImpl.Connect)
    2021-01-28 20:00:29.462051 TID:4   (NET) (ENT) TcpsTransportAdapter.Connect()
    2021-01-28 20:00:29.463189 TID:4   (NET) (ENT) TcpTransportAdapter.Connect()
    2021-01-28 20:00:29.464190 TID:4   (NET)      Trying (host=138.1.83.12) (port=1522)
    2021-01-28 20:00:29.464300 TID:4   (NET) (EXT) TcpTransportAdapter.Connect()
    2021-01-28 20:00:29.464365 TID:4   (NET) (EXT) TcpsTransportAdapter.Connect()
    2021-01-28 20:00:29.466303 TID:4   (NET) (ENT) TcpsTransportAdapter.ConnectIterate()
    2021-01-28 20:00:29.469401 TID:4   (NET) (ENT) TcpTransportAdapter.ConnectIterate()
    2021-01-28 20:00:29.478126 TID:4   (NET)      Trying (address=138.1.83.12) (port=1522)
    2021-01-28 20:00:29.526221 TID:4   (NET) (ENT) TcpsTransportAdapter.Negotiate()
    2021-01-28 20:00:29.526768 TID:4   (NET) (SQLNET) SSLVersion = 0. SSLProtocol = Tls, Tls11, Tls12.
    2021-01-28 20:00:29.527414 TID:4   (NET) (SQLNET) MY_WALLET_DIRECTORY = /home/simon/Documents/Wallet_DB202006252115
    2021-01-28 20:00:29.963897 TID:4   (NET) (ENT) TcpsTransportAdapter.ConnectIterate()
    2021-01-28 20:00:29.964789 TID:4   (NET) (ENT) TcpTransportAdapter.ConnectIterate()
    2021-01-28 20:00:29.964896 TID:4   (NET) (EXT) TcpsTransportAdapter.ConnectIterate()
    2021-01-28 20:00:29.965961 TID:4   (NET) (ENT) TcpsTransportAdapter.Connect()
    2021-01-28 20:00:29.966077 TID:4   (NET) (ENT) TcpTransportAdapter.Connect()
    2021-01-28 20:00:29.966109 TID:4   (NET)      Trying (host=147.154.234.37) (port=1522)
    
    The trace continues  like - this trying various ports? until it gives the error shown above.
    
    2021-01-28 20:01:45.183100 TID:1   (PUB) (ERR) OracleConnection.Open() (txnid=n/a) Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-00542: Failure during SSL handshake
     ---> OracleInternal.Network.NetworkException (0x80004005): ORA-00542: Failure during SSL handshake
     ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
     ---> Interop+OpenSsl+SslException: SSL Handshake failed with OpenSSL error - SSL_ERROR_SSL.
     ---> Interop+Crypto+OpenSslCryptographicException: error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure
       --- End of inner exception stack trace ---
       at Interop.OpenSsl.DoSslHandshake(SafeSslHandle context, ReadOnlySpan`1 input, Byte[]& sendBuf, Int32& sendCount)
       at System.Net.Security.SslStreamPal.HandshakeInternal(SafeFreeCredentials credential, SafeDeleteSslContext& context, ReadOnlySpan`1 inputBuffer, Byte[]& outputBuffer, SslAuthenticationOptions sslAuthenticationOptions)
       --- End of inner exception stack trace ---
       at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
       at System.Net.Security.SslStream.ProcessAuthentication(Boolean isAsync, Boolean isApm, CancellationToken cancellationToken)
       at System.Net.Security.SslStream.AuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions)
       at OracleInternal.Network.TcpsTransportAdapter.Negotiate(ConnectionOption conOption)
       at OracleInternal.Network.OracleCommunication.DoConnect(String tnsDescriptor)
       at OracleInternal.Network.OracleCommunication.Connect(String tnsDescriptor, Boolean doNAHandshake, String IName, ConnectionOption CO)
       at OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession, OracleConnection connRefForCriteria, String instanceName)
       at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
       at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
       at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria)
       at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
       --- End of inner exception stack trace ---
    

    最佳答案

    从跟踪中看不是特别明显,但问题是由于我使用的是 Net Core 5 而不是 3.1 造成的,切换到较旧的运行时可以使连接正常工作。

    关于oracle - 在 Linux 中使用 PowerShell 连接到 Oracle Autonomous db,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65850830/

    相关文章:

    java - 使用powershell下载jdk

    powershell - DscTemplate没有执行我的SetScript

    java - Oracle中基于rowid的更新

    angularjs - NodeJS OracleDB 绑定(bind)参数返回参数名称

    sql - Oracle 使用函数进行计数

    powershell - 将所有本地成员和组一起显示

    node.js - 为什么我在使用 apt-get 安装时会得到旧版本的 nodejs 和 npm?

    gcc - CUDA 和 gcc 兼容性问题

    ruby-on-rails - s3sh 命令行 ubuntu 仍然存在(EC2,s3 amazon)

    vb.net - 仅当作为服务运行时 ODP.NET ORA-12154 TNS 错误