sqlplus串連oracle失敗分析和解決

來源:互聯網
上載者:User

標籤:

背景:

  多台Linux伺服器需要安裝Oracle用戶端,實現和Oracle資料庫連接做業務處理。

  安裝完第一台後,直接將安裝的目錄壓縮並複製到其他幾台機器上,啟動sqlplus串連資料庫時,一直提示輸入使用者名稱和密碼。

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

使用strace跟蹤發現有錯誤ORA-21561: OID generation failed輸出。

  strace sqlplus user/[email protected]

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

出現錯誤ORA-21561: OID generation failed的原因是主機名稱和hosts檔案中的主機名稱不一致導致。

解決方案:

  使用命令hostname 查詢機器的主機名稱

[xxxxx]$ hostnamebillingserver001

  修改/etc/hosts檔案,將主機名稱加入到hosts檔案中。

  

[xxxxx]$ cat /etc/hosts127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4::1         localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.1.2     billingserver001

重新用sqlplus user/[email protected]串連資料庫,串連成功。

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

Done.

 

sqlplus串連oracle失敗分析和解決

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.