怎么感受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,链接便可!