Oracle

本地連接工作時無法遠端連接oracle 12數據庫

  • January 15, 2019

我有兩個 oracle 測試節點。在節點 2 上,我可以在沒有憑據的情況下使用命令進行連接,

su - oraabc -c "/oracle/ABC/12102/bin/sqlplus / as sysdba"

輸出:

SQL*Plus: Release 12.1.0.2.0 Production on Tue Jan 15 12:18:20 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL>

我正在嘗試從節點 1 連接。無密碼登錄已經使用節點 1 和 2 之間的密鑰建立。

命令:

ssh root@node2 su - oraabc -c "/oracle/ABC/12102/bin/sqlplus / as sysdba"

但它會提示輸入憑據,

輸出:

SQL*Plus: Release 12.1.0.2.0 Production on Tue Jan 15 12:23:07 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Enter user-name:

如果 oraabc 已經是 dba 組的一部分,為什麼它會提示輸入憑據?是否缺少配置以在沒有憑據的情況下以 oracle 使用者身份啟用遠端連接?

大約:

[root@o71 ~]# tail -5 /home/oracle/.bash_profile

export ORACLE_SID=MIN18
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/18.0.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH

當地的:

[root@o71 ~]# su - oracle -c "sqlplus / as sysdba"

SQL*Plus: Release 18.0.0.0.0 - Production on Tue Jan 15 15:54:16 2019
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL>

偏僻的:

[root@o72 ~]# ssh root@o71 su - oracle -c "sqlplus / as sysdba "

SQL*Plus: Release 18.0.0.0.0 - Production on Tue Jan 15 15:55:15 2019
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.

Enter user-name:

具有更好語法的遠端:

[root@o72 ~]# ssh root@o71 'su - oracle -c "sqlplus / as sysdba "'

SQL*Plus: Release 18.0.0.0.0 - Production on Tue Jan 15 15:55:39 2019
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL>

代替:

ssh root@node2 su - oraabc -c "/oracle/ABC/12102/bin/sqlplus / as sysdba"

用這個:

ssh root@node2 'su - oraabc -c "/oracle/ABC/12102/bin/sqlplus / as sysdba"'

此外,我發現預設情況下在配置文件中設置這些變數是非常糟糕的做法。只需使用oraenv.

例子:

[root@o72 ~]# ssh root@o71 'su - oracle -c "export ORAENV_ASK=NO; export ORACLE_SID=MIN18; . oraenv; sqlplus / as sysdba "'
The Oracle base remains unchanged with value /u01/app/oracle

SQL*Plus: Release 18.0.0.0.0 - Production on Tue Jan 15 15:56:51 2019
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL>

引用自:https://dba.stackexchange.com/questions/227183