zoukankan      html  css  js  c++  java
  • sqlplus连接oracle失败分析和解决

    背景:

      多台Linux服务器需要安装Oracle客户端,实现和Oracle数据库连接做业务处理。

      安装完第一台后,直接将安装的目录压缩并复制到其他几台机器上,启动sqlplus连接数据库时,一直提示输入用户名和密码。

    [xxxxxxx]$ sqlplus user/pass@orcl
    
    SQL*Plus: Release 11.2.0.4.0 Production on Fri Feb 5 10:56:38 2016
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    ERROR:
    ORA-12154: TNS:could not resolve the connect identifier specified
    
    
    Enter user-name: user
    Enter password: 
    ERROR:
    ORA-12545: Connect failed because target host or object does not exist
    
    
    Enter user-name: user
    Enter password: 
    

    使用strace跟踪发现有错误ORA-21561: OID generation failed输出。

      strace sqlplus user/pass@orcl

    close(5)                                = 0
    write(1, "ERROR:
    ", 7ERROR:
    )                 = 7
    write(1, "ORA-21561: OID generation failed"..., 33ORA-21561: OID generation failed
    ) = 33
    write(1, "
    ", 1
    )                       = 1
    write(1, "
    ", 1
    )                       = 1
    write(1, "Enter user-name: ", 17Enter user-name: )       = 17
    fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
    mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feaa51c9000
    read(0, ^C <unfinished ...>
    

    出现错误ORA-21561: OID generation failed的原因是主机名和hosts文件中的主机名不一致导致。

    解决方法:

      使用命令hostname 查询机器的主机名

    [xxxxx]$ hostname
    billingserver001
    

      修改/etc/hosts文件,将主机名加入到hosts文件中。

      

    [xxxxx]$ cat /etc/hosts
    127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
    192.168.1.2     billingserver001
    

    重新用sqlplus user/pass@orcl连接数据库,连接成功。

    [xxxxx]$ sqlplus user/pass@orcl
    
    SQL*Plus: Release 11.2.0.4.0 Production on Fri Feb 5 11:05:57 2016
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL>
    

    Done.

  • 相关阅读:
    使用jMeter测试通过SAP ID Service认证的SAP Cloud API
    在SAP C4C里使用Restful服务消费SAP S/4HANA的标准功能
    SAP S/4HANA Cross Selling机制介绍
    如何用代码读取SAP CRM的Categorization Schema
    SAP Enterprise Commerce调试环境搭建
    使用jconsole监测SAP commerce运行时
    SAP Commerce开发之如何找到某个页面对应的JSP实现页面
    KubeEdge在国家工业互联网大数据中心的架构设计与应用
    从云数据迁移服务看MySQL大表抽取模式
    CSS开发过程中的20个快速提升技巧
  • 原文地址:https://www.cnblogs.com/voipman/p/5182889.html
Copyright © 2011-2022 走看看