LInux Oracle本地可以連接遠程無法訪問解決方法-啓動實例-開啓監聽 頂 原

系統:Redhat linux

因爲服務器虛擬機是複製別一個服務器過來的,換了IP,然後我一直起監督聽與實例都無法聯接數據庫,最後查到根本的原因:

是因爲更改IP了,hostIP也需要更改。

具體需要修改兩個文件:

1、vi /etc/hosts文件,將IP修改成本機的IP

[oracle@plmdb ~]$ vi /etc/hosts
打開文件,按I進入編輯模式輸入本機IP
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.2.1.223 plm

2、vi /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

[oracle@plmdb admin]$ vi /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
打開文件,按I進入編輯模式更改HOST
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = plm)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

修改爲本機IP和上面的保持一致。如果不知道路徑,可通過先停止監聽(lsnrctl stop)再重啓(lsnrctl start)的方式查看監聽文件的所在位置。

 

首先使用oracle 用戶登錄liunx,然後在shell命令中執行下面的命令:

第1步:打開oracle 監聽

$lsnrctl start

[oracle@plmdb ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 15-AUG-2017 13:23:58

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/plmdb/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=plm)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=plm)(PORT=1521)))
STATUS of the LISTENER
註釋:
對於 Linux LSNRCTL: 版本 11.2.0.4.0-生產在 2017 年 8 月 15 日 13:23:58
版權所有 (c) 1991 年,2013 年,甲骨文。保留所有權利。
開始 /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: 請稍等...
對於 Linux TNSLSNR: 版本 11.2.0.4.0-生產
系統參數文件是 /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
日誌消息寫入 /u01/app/oracle/diag/tnslsnr/plmdb/listener/alert/log.xml
偵聽: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=plm)(PORT=1521)))
連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=plm)(PORT=1521)))
偵聽器的狀態

第2步:進入sqlplus

$sqlplus /nolog

SQL>


[oracle@plmdb ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Tue Aug 15 13:24:21 2017

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

SQL>

註釋:
SQL * Plus: 在 8 月 15 日星期二發佈 11.2.0.4.0 生產 13:24:21 2017年
版權所有 (c) 1982 年,2013 年,甲骨文。保留所有權利。

第3步:使用sysdba角色登錄sqlplus

SQL>conn /as sysdba

SQL> conn /as sysdba
Connected to an idle instance.
註釋:
連接到一個空閒的實例。

第4步:啓動數據庫

SQL>startup

經過上面四個步驟,oracle數據庫就可以聯接了。

SQL> startup
ORACLE instance started.

Total System Global Area 1.3395E+10 bytes
Fixed Size        2265904 bytes
Variable Size      6543117520 bytes
Database Buffers    6845104128 bytes
Redo Buffers          4759552 bytes
Database mounted.
Database opened.
SQL>

註釋:
啓動 ORACLE 實例。
總系統全局區 1.3395E 10 個字節
固定的大小 2265904 字節
可變大小 6543117520 字節
數據庫緩衝區 6845104128 字節
重做緩衝區 4759552 字節
已裝入的數據庫。
打開的數據庫。

總代碼:

[oracle@plmdb ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 15-AUG-2017 13:23:58

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/plmdb/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=plm)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=plm)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                15-AUG-2017 13:23:59
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/plmdb/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=plm)(PORT=1521)))
The listener supports no services
The command completed successfully

[oracle@plmdb ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Tue Aug 15 13:24:21 2017

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

SQL>

SQL> conn /as sysdba
Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 1.3395E+10 bytes
Fixed Size		    2265904 bytes
Variable Size		 6543117520 bytes
Database Buffers	 6845104128 bytes
Redo Buffers		    4759552 bytes
Database mounted.
Database opened.
SQL>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章