使用 SSH 和 Bequeath 协议连接到数据库

此方法允许您在不使用网络监听程序的情况下连接到数据库。它应用于仅用于管理目的。

连接到多节点数据库系统时,您将通过 SSH 连接到集群中的每个单个节点。

从 UNIX 式系统连接

使用以下 SSH 命令访问数据库系统:

ssh -i <private_key> opc@<DB_system_IP_address>

<private_key> 是包含与要访问的数据库系统关联的私钥的文件的完整路径和名称。

根据您的网络配置,使用数据库系统的专用或公共 IP 地址。

有关更多信息,请参见 Overview of Connecting to a DB System 中的先决条件。

从 Windows 系统连接

  1. 打开 putty.exe。
  2. 在类别窗格中,选择会话并输入以下字段:

    • Host Name(主机名)(或 IP 地址):opc@<DB_system_IP_address>

      根据您的网络配置,使用数据库系统的专用或公共 IP 地址。

    • 连接类型: SSH
    • 端口: 22
  3. 在 Category(类别)窗格中,展开 Connection(连接),展开 SSH ,然后单击 Auth ,然后浏览以选择私钥。
  4. (可选)返回到 Session(会话)类别屏幕并保存此会话信息以供以后重用。
  5. 单击打开以启动会话。

有关更多信息,请参见 Overview of Connecting to a DB System 中的先决条件。

连接后访问数据库

  1. 以 opc 身份登录。

    login as: opc
  2. sudo 至网格用户。

    sudo su - grid
  3. 列出系统上的所有数据库。

    srvctl config database -v

    输出:

    cdbm01 /u02/app/oracle/product/12.1.0/dbhome_2 12.1.0.2.0
    exadb /u02/app/oracle/product/11.2.0/dbhome_2 11.2.0.4.0
    mmdb /u02/app/oracle/product/12.1.0/dbhome_3 12.1.0.2.0
  4. 以 oracle 用户身份进行连接。

    [root@ed1db01 ~]# su - oracle
    [oracle@ed1db01 ~]$ . oraenv
    ORACLE_SID = [oracle] ? cdbm01
    The Oracle base has been set to /u02/app/oracle
  5. 使用 srvctl 命令获取有关其中一个数据库的详细信息。

    srvctl config database -d cdbm01

    输出:

    Database unique name: cdbm01 <<== DB unique name
    Database name:
    Oracle home: /u02/app/oracle/product/12.1.0/dbhome_2
    Oracle user: oracle
    Spfile: +DATAC1/cdbm01/spfilecdbm01.ora
    Password file: +DATAC1/cdbm01/PASSWORD/passwd
    Domain: data.customer1.oraclevcn.com
    Start options: open
    Stop options: immediate
    Database role: PRIMARY
    Management policy: AUTOMATIC
    Server pools:
    Disk Groups: DATAC1,RECOC1
    Mount point paths:
    Services:
    Type: RAC
    Start concurrency:
    Stop concurrency:
    OSDBA group: dba
    OSOPER group: racoper
    Database instances: cdbm011,cdbm012 <<== SID
    Configured nodes: ed1db01,ed1db02
    Database is administrator managed
  6. 使用上一步中的值设置 ORACLE_SID 和 ORACLE_UNIQUE_NAME。

    export ORACLE_SID=cdbm011
    export ORACLE_UNIQUE_NAME=cdbm01
    sqlplus / as sysdba
    SQL*Plus: Release 12.1.0.2.0 Production on Wed Apr 19 04:10:12 2017
    
    Copyright (c) 1982, 2014, Oracle. All rights reserved.
    
    Connected to:
    Oracle Database 12c EE Extreme Perf Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle Label Security,
    OLAP, Advanced Analytics and Real Application Testing options