本文转自:http://www.dbforums.com/oracle/1635283-how-connect-idle-instance-ora10gr1-windows2k.html,原文作者:dayneo.
现在有一个oracle数据库还未启动,但我要手动地启动它。因此,按理说可以通过连接到一个idle的数据库,但是却发生了以下的错误(这些错误在linux下是不会发生的)
1) sqlplus sys/password@sid as sysdba which gives ORA-12514: TNS: listener does not currently know of service requested in connect descriptor 2) set ORACLE_SID=SID sqlplus sys/password as sysdba which gives ORA-12560: TNSrotocol adapter error 3) set ORACLE_SID=SID sqlplus / as sysdba which gives ORA-12560: TNSrotocol adapter error That one works on my Linux server by the way.... 4) sqlplus "/ as sysdba" which gives ORA-12560: TNSrotocol adapter error
非常让人奇怪的是监听器根本不知道还没有启动的oracle服务,那么如何让监听器知道这个服务呢,或者通过什么样的方式注册这个sid信息?
以上信息是原文作者发的一个帖子,本来想求教的,最后还是自己解决了,解决的方法如下所示。
最后发现了,好像在windows上,你必须要启动oracle服务之后才能访问信息。不过,如果一旦启动oracle服务,它就自动地把数据库已启动了。当然,如果数据库都已经启动了,那么我之前的问题就不存在了,所以我现在需要手动地启动我的数据库。
假设你还没有启动oracle服务。那么进行以下的各项操作。
1 找到并修改ORA_SID_AUTOSTART = FALSE。这个可以禁止oracle服务启动之后自动启动数据库。可以通过以下方法来修改:
oradim -EDIT -SID yoursid -STARTMODE m
2 启动oracle服务。这样oracle数据库服务就启动了,并且已经向监听器注册信息了。但是数据库本身还没有启动起来。
3 在命令行里输入以下信息:
set oracle_sid=SID//这句话是可选的 sqlplus sys(或/) as sysdba //输入密码
4 这样就可以通过startup等命令来启动数据库了。但是实际上,你可能根本不需要用这种方式来启动数据库,因为一般情况下,可能就是数据库本来就启动不了,或者发生了什么错误信息等。
当然,如果确实是数据库出错了,那么可以通过重建控制文件来进行修复。通过控制文件,可以获得启动oracle数据库的一切信息,可以通过修改控制文件来修复数据库,并使数据库启动起来。
以上信息是笔者的简单翻译,原文如下所示:
I am really battling with this. I have a database that is not starting and need to start it up manually. I am trying to connect to the now idle instance, but I get TNS listener errors every time.
I have tried:
1) sqlplus sys/password@sid as sysdba
which gives
ORA-12514: TNS: listener does not currently know of service requested in connect descriptor
2) set ORACLE_SID=SID
sqlplus sys/password as sysdba
which gives
ORA-12560: TNSrotocol adapter error
3) set ORACLE_SID=SID
sqlplus / as sysdba
which gives
ORA-12560: TNSrotocol adapter error
That one works on my Linux server by the way….
4) sqlplus "/ as sysdba"
which gives
ORA-12560: TNSrotocol adapter error
Obviously the listener is not going to know about the service since it isn't running. So how do you bypass the listener (or pre-register the SID with the listener before the SID is started)?
Ok, solved my own problem.
It seems that on Windows, you HAVE TO HAVE the Oracle Service started in order to access anything. However, when the Oracle Service starts up, it also attempts to start the database by default. In my case, this resulted in an error for reasons I won't get into. So I needed to start my database manually.
Assuming that you don't have the Oracle service running (Note: SID should be replaced with the name of your SID):
1) Find and change the registry entry ORA_SID_AUTOSTART = FALSE
This will prevent the Service from starting the database
2) Start the Oracle Service (usually named OracleServiceSID)
You can use the Computer Management console or use the "net start" command line to do this
The Oracle Service will now be running and registered with the TNS Listener, but your database will not be started.
3) from the command line, do:
set oracle_sid=SID
sqlplus sys as sysdba
Enter the password when prompted.
4) Then use startup command to start the database.
In actual fact, you will probably not use the simple startup command because if you are starting your database via this method, it is probably because something is wrong…
I find that:
alter database backup controlfile to trace
is a handy line to know. This will get the startup commands required to start your database (effectively what is run when issueing startup). You can then edit the file to your needs and execute from sqlplus to bring your database online.
转载请标明出处:i flym
本文地址:https://www.iflym.com/index.php/english-translate/201204060001.html