使用 SSH 和 Bequeath 协议连接到数据库
从 UNIX 样式系统进行连接
使用以下 SSH 命令访问数据库系统:
ssh –i <private_key> opc@<DB_system_IP_address>
<private_key>
是文件的完整路径和名称,其中包含与要访问的数据库系统关联的私有密钥。
根据您的网络配置,使用数据库系统的专用或公共 IP 地址。
有关更多信息,请参见连接到数据库系统的概览中的先决条件。
从 Windows 系统连接
- 打开
putty.exe
。 - 在类别窗格中,选择会话并输入以下字段:
-
主机名(或 IP 地址):
opc@<DB_system_IP_address>
根据您的网络配置,使用数据库系统的专用或公共 IP 地址。
- 连接类型: SSH
- 端口: 22
-
- 在类别窗格中,展开连接,展开 SSH ,然后单击验证,然后浏览以选择您的私钥。
- (可选)返回到 Session(会话)类别屏幕并保存此会话信息以供以后重用。
- 单击打开启动会话。
有关更多信息,请参见连接到数据库系统的概览中的先决条件。
连接后访问数据库
- 以
opc
身份登录。login as: opc
sudo
到网格用户。sudo su - grid
- 列出系统上的所有数据库。
输出: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
- 以 oracle 用户身份连接。
[root@ed1db01 ~]# su - oracle [oracle@ed1db01 ~]$ . oraenv ORACLE_SID = [oracle] ? cdbm01 The Oracle base has been set to /u02/app/oracle
- 使用
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
- 使用上一步中的值设置
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