您好,登錄后才能下訂單哦!
客戶端工具plsql developer 鏈接Windows上的tnsname - NEW ,再通過NEW去鏈接linux上的監(jiān)聽。去鏈接數(shù)據(jù)庫
1 查看監(jiān)聽狀態(tài)
[oracle@dan ~]$ lsnrctl status
監(jiān)聽中3個必不可少的:ip、端口號、service。說明linux監(jiān)聽正常。所以我們通過xshall是通過密碼文件可以鏈接進入數(shù)據(jù)庫的
[oracle@dan ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 8 20:59:48 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
如果要走網(wǎng)絡的話,就需要下面的tnsnames.ora
2 查看linux上的listener.ora
[oracle@dan admin]$ pwd
/u01/app/oracle/product/11.2/db_1/network/admin/
[oracle@dan admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)
(HOST = dan)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
從listener.ora可以看出ip和端口號,但是看不到服務
2 查看linux上的tnsnames.ora,沒有的話,可以手工添加
NEW=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
192.168.56.56)(PORT =
1521))
)
(CONNECT_DATA =
(SERVICE_NAME =
orcl)
)
)
走網(wǎng)絡驗證:
[oracle@dan admin]$ sqlplus system/oracle@NEW
SQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 8 21:22:53 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
能進入 ,說明tnsnames.ora沒有問題。
如果不能進入,先查看防火墻,
service iptables status
sestatus
如果都關閉了,再就需要驗證ip、端口、服務
[oracle@dan admin]$ pin
g 192.168.56.56
[oracle@dan admin]$ telnet 192.168.56.56 1521
服務的話,就通過查看監(jiān)聽lsnrctl stauts 中的service 查看。
同樣也可以驗證串名:
[oracle@dan admin]$ tnspin g NEW
最后的最后。文件名一定要記住是tnsnames.ora 。。。。。。是有s的。這個搞了很傻
1 在本地的E:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN 也有個tnsnames.ora文件??蛻舳斯ぞ呔褪峭ㄟ^Windows的tnsnames去鏈接的linux的監(jiān)聽,再 去鏈接數(shù)據(jù)庫
2 查看Windows的tnsnames
NEW=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.56)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
這里其實和linux上的一致,其實要鏈接psd的話,沒有l(wèi)inux上的tnsnames也可以,因為Windows是鏈接的linu上的監(jiān)聽。監(jiān)聽的3要素:ip、端口、service
3 如果psd鏈接不通,就要驗證ip、端口、service
a)驗證ip。沒有問題
b)驗證端口號,從上面linux上的監(jiān)聽狀態(tài)lsnrctl status,知道端口號是1521。能進入說明端口號1521也沒有問題。
c)服務
本地中的(SERVICE_NAME = orcl) 和linux上的監(jiān)聽狀態(tài)中的series是一致的。
這時候,psd就能通過本地的鏈接串NEW鏈接到數(shù)據(jù)庫了
但是sys用戶始終是不能鏈接
[oracle@dan admin]$ sqlplus sys/oracle@NEW as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 8 21:46:41 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
Enter user-name: EXIT
Enter password:
ERROR:
ORA-01017: invalid username/password; logon denied
難道是sys密碼錯誤?
SQL> alter user sys identified by oracle;
User altered.
[oracle@dan admin]$ sqlplus sys/oracle@NEW as sysdba
但是還是同樣的錯誤,后來,sys用戶是特殊的用戶。是需要特殊的密碼文件,在$ORALE_HOME/dbs里
[oracle@dan admin]$ cd $ORACLE_HOME/dbs
[oracle@dan dbs]$ ll
total 97884
-rw-rw----. 1 oracle dba 1544 Mar 8 16:56 hc_orcl.dat
-rw-r--r--. 1 oracle dba 2851 May 15 2009 init.ora
-rw-r-----. 1 oracle dba 24 Mar 8 12:06 lkORCL
-rw-r-----. 1 oracle dba 3584 Mar 8 16:26 spfileorcl.ora
里面就沒有orapw文件。所以通過網(wǎng)絡一直登陸不上
[oracle@dan dbs]$ orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle force=y;
驗證
[oracle@dan dbs]$ sqlplus sys/oracle@NEW as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 8 21:55:05 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
應該是沒有問題了,去psd驗證一下
也可以用 ip:端口號/service name
完成
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。