怎麼感受oracle和sql server是一個貨色。裝個服務得裝半天,仍是mysql好,一會兒就行了!下面有一個在centos7上面安裝oracle11g的詳細步驟,感受找不到比這個更詳細的了吧!html
centos7安裝詳細步 :https://www.cnblogs.com/VoiceOfDreams/p/8308601.htmlmysql
安裝數據庫以後在使用客戶端鏈接數據庫的時候老是報以下錯誤:sql
ORA-12514: TNS:listener does not currently know of service requested in connect
而後百度+谷歌,解決辦法說是修改listener.ora文件,在文件中添加以下內容:【下面文件中標紅的表示添加的內容】數據庫
[oracle@oracle ~]$ cd /data/oracle/product/11.2.0/db_1/network/admin/ [oracle@oracle admin]$ cat listener.ora # listener.ora Network Configuration File: /data/oracle/product/11.2.0/db_1/network/admin/listener.ora # Generated by Oracle configuration tools. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 10.9.8.201)(PORT = 1521)) ) (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /data/oracle/product/11.2.0/db_1) (SID_NAME = orcl) ) ) ADR_BASE_LISTENER = /data/oracle
添加完以後從新啓動監聽器,鏈接的時候報以下錯誤:centos
ERROR: ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
又去百度+谷歌,大部分答案都是說tnsnames.ora中service_name寫成了server_name等,但是tnsnames.ora這個文件是oracle服務器本身生成的啊。服務器
這時候查看監聽器狀態會有以下提示:oracle
[oracle@oracle ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAY-2019 21:35:17 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 14-MAY-2019 19:16:38 Uptime 0 days 2 hr. 18 min. 39 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /data/oracle/product/11.2.0/db_1/network/admin/listener.ora Listener Log File /data/oracle/diag/tnslsnr/oracle/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.9.8.201)(PORT=1521))) The listener supports no services #這裏提示沒有服務 The command completed successfully
最後的解決辦法,重啓監聽器,重啓服務器。tcp
[oracle@oracle admin]$ sqlplus /nolog SQL*Plus: Release 11.2.0.1.0 Production on Tue May 14 21:57:46 2019 Copyright (c) 1982, 2009, Oracle. All rights reserved. SQL> connect sys / as sysdba Enter password: Connected. SQL> shutdown immediate #關閉oracle服務器 Database closed. Database dismounted. ORACLE instance shut down. SQL> startup #啓動oracle服務器 ORACLE instance started. Total System Global Area 759943168 bytes Fixed Size 2217224 bytes Variable Size 507513592 bytes Database Buffers 247463936 bytes Redo Buffers 2748416 bytes Database mounted. Database opened. SQL>
查看監聽器狀態:ide
[oracle@oracle admin]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAY-2019 22:18:47 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 14-MAY-2019 19:16:38 Uptime 0 days 3 hr. 2 min. 8 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /data/oracle/product/11.2.0/db_1/network/admin/listener.ora Listener Log File /data/oracle/diag/tnslsnr/oracle/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.9.8.201)(PORT=1521))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully
使用客戶端鏈接oracle數據庫:測試
[oracle@oracle admin]$ sqlplus scott/tiger@10.9.8.201/orcl SQL*Plus: Release 11.2.0.1.0 Production on Tue May 14 22:19:21 2019 Copyright (c) 1982, 2009, 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>
客戶端鏈接成功:
oracle安裝以後監聽的本地的127.0.0.1這個ip,可是在window系統鏈接很顯然不行的,更改上面提到的哪兩個文件中的localhost爲服務器的ip便可,而後重啓監聽器。
[oracle@oracle admin]$ cat listener.ora # listener.ora Network Configuration File: /data/oracle/product/11.2.0/db_1/network/admin/listener.ora # Generated by Oracle configuration tools. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 10.9.8.201)(PORT = 1521)) ) (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /data/oracle/product/11.2.0/db_1) (SID_NAME = orcl) ) ) ADR_BASE_LISTENER = /data/oracle [oracle@oracle admin]$ cat tnsnames.ora # tnsnames.ora Network Configuration File: /data/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora # Generated by Oracle configuration tools. LISTENER_ORCL = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.9.8.201)(PORT = 1521)) ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.9.8.201)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )
SQL> show parameter pass NAME TYPE VALUE ------------------------------------ ---------------------- ------------------------------ remote_login_passwordfile string EXCLUSIVE SQL>
remote_login_passwordfile有3個取值,取值以下:
這個值設置如果none,則須要經過如下語句設置爲exclusive.
SQL> alter system set remote_login_passwordfile=exclusive scope=spfile;
System altered.
而後須要從新啓動數據庫。
以上完成以後,設置sys用戶的密碼:
SQL> alter user sys identified by 123456; User altered.
在navicat中填入對應的鏈接字段,點擊測試,報以下錯誤:
這時候點擊,高級選項,把角色選爲sysdba,鏈接便可!