虚拟机安装Oracle备忘:ORA-12514错误的解决

红尘浪子 2011-08-02

[Oracle@oracle_taowei_RedHat~]$ lsnrctl status  查看监听器是否启动
如果没有启动监听,则运行命令:lsnrctl start启动监听(lsnrctl stop关闭监听)
启动监听后可以用sqlplus登录数据库,查看数据库信息:如sqlplus emcd/[email protected]:1521/orcl
这种方式存在安全隐患,密码以明文出现,容易被别人窃取;所以建议:sqlplus  emcd@oracle_taowei回车
按提示输入密码,这样就保证了密码不被别人看见;
以数据库管理员登录:sqlplus sys/oracle as sysdba  登录后可以执行关闭或启动数据库命令:
SQL> shutdown immediate  (关闭数据库)
SQL> startup  (启动数据库)
当数据库处于关闭状态时,要启动数据库:首先启动监听器 lsnrctl start;然后sqlplus  sys/oracle  as  sysdba
回车后会显示Connected to an  idle instance,并出现提示符SQL>,此时输入命令startup启动数据库,输入 shutdown immediate
则可关闭数据库;
(1).遇到的问题:
      在虚拟机的redhat 5上安装了Oracle10g 在本地的XP系统上,在配置好tnsnames.ora的情况下却无法访问虚拟机里面的Oracle,提示
不能解析链接串;但是本地命令行下tnsping 虚拟机又是可以ping通的,而在虚拟机里面用sqlplus访问远程主机的Oracle数据库也可以的;
后来发现:关闭虚拟机的防火墙和SELinux后,就可以在本地访问了,#chkconfig --list  iptables 查看防火墙是否关闭,运行命令
#chkconfig iptables off关闭防火墙;
(2).在处理了(1)的问题后,在本地命令行用sqlplus链接远程Linux的Oracle:
C:\Documents and Settings\hawk>sqlplus emcd/[email protected]:1521/orcl,出现如下错误:
    ERROR:
    ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务
    请输入用户名:  emcd
    输入口令:
    ERROR:
    ORA-12560: TNS: 协议适配器错误
      这个问题经过一番折腾,在配置文件listener.ora里面添加SID_DESC后重启监听,问题得到解决;
配置文件所添加内容如下所示:
                                        # listener.ora Network Configuration File: /home/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
                                      # Generated by Oracle configuration tools.
                                     
                                      SID_LIST_LISTENER =
                                        (SID_LIST =
                                          (SID_DESC =
                                            (SID_NAME = PLSExtProc)
                                            (ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)
                                            (PROGRAM = extproc)
                                          )
                                       
                                          (SID_DESC =                                              #为添加的内容:相应得数据库服务   
                                                                                                   #为添加的内容:相应得数据库服务
                                            (GLOBAL_DBNAME = orcl)                                 #为添加的内容:相应得数据库服务
                                                                                                   #为添加的内容:相应得数据库服务
                                            (ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)#为添加的内容:相应得数据库服务
                                                                                                   #为添加的内容:相应得数据库服务
                                            (SID_NAME = orcl)                                      #为添加的内容:相应得数据库服务
                                                                                                   #为添加的内容:相应得数据库服务
                                          )                                                        #为添加的内容:相应得数据库服务
                                        )
                                     
                                      LISTENER =
                                        (DESCRIPTION_LIST =
                                          (DESCRIPTION =
                                            (ADDRESS = (PROTOCOL = IPC)(KEY = oracle_IPC))
                                            (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.120)(PORT = 1521))
                                          )
                                        )
                                     
重要的配置文件和参数文件:
      /home/oracle/oracle/product/10.2.0/db_1/dbs/initorcl.ora
      /home/oracle/oracle/product/10.2.0/db_1/dbs/initorcl.ora
     /home/oracle/oracle/product/10.2.0/db_1/admin/orcl/bdump/alert_orcl.log警告日志信息
     /home/oracle/oracle/product/10.2.0/db_1/dbs/spfileorcl.ora可读不可写,为启动参数文件,命令strings spfileorcl.ora可查看其内容;
重新配置监听器:netca,若果中文显示异常,则可以先运行命令export  LC_ALL=C,再运行netca则可以英文显示窗口出现。

相关推荐