[Oracle]-[TWO_TASK]-roles of TWO_TASK Environment Variables

Source: Internet
Author: User

[Oracle]-[TWO_TASK]-The Role Of The TWO_TASK environment variable is the two connection strings currently configured (one local database and one remote database ):

[oracle@liu admin]$ more tnsnames.oraBISAL =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = bisal)    )  )TEST =  (DESCRIPTION =    (ADDRESS_LIST =      (ADDRESS = (PROTOCOL = TCP)(HOST = x.x.x.x)(PORT = 1524))    )    (CONNECT_DATA =      (SERVICE_NAME = star)    )  )

 

The current TWO_TASK environment variable is empty:
[oracle@liu Desktop]$ echo $TWO_TASK[oracle@liu Desktop]$

 

When no service name is specified to connect to the database, the local database bisal is used by default, which is specified by ORACLE_SID of the system:
[oracle@liu Desktop]$ echo $ORACLE_SIDbisal[oracle@liu Desktop]$ env | grep SIDORACLE_SID=bisal[oracle@liu Desktop]$ 

 

/Connection:
[oracle@liu Desktop]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.1.0 - Production on Sun Aug 11 14:38:08 2013Copyright (c) 1982, 2005, Oracle.  All rights reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining optionsSQL> select * from global_name;GLOBAL_NAME--------------------------------------------------------------------------------BISALSQL> 

 

Set TWO_TASK = TESTTKT:
[oracle@liu Desktop]$ export TWO_TASK=TESTTKT[oracle@liu Desktop]$ echo $TWO_TASKTESTTKT[oracle@liu Desktop]$ [oracle@liu Desktop]$ 

 

Use the username of TESTTKT to log on, but do not specify the service name:
[oracle@liu Desktop]$ sqlplus star/starSQL*Plus: Release 10.2.0.1.0 - Production on Sun Aug 11 14:39:31 2013Copyright (c) 1982, 2005, Oracle.  All rights reserved.Connected to:Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit ProductionWith the Partitioning, OLAP and Oracle Data Mining optionsJServer Release 9.2.0.7.0 - ProductionSQL> select * from global_name;GLOBAL_NAME--------------------------------------------------------------------------------ALL9IT2SQL> 

 

The remote database TESTTKT is connected by default. In this case, disable the listening of the local database bisal: LSNRCTL> stop bisal to verify the listening status:
[oracle@liu Desktop]$ tnsping bisalTNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 11-AUG-2013 15:06:18Copyright (c) 1997, 2005, Oracle.  All rights reserved.Used parameter files:/opt/oracle/102/network/admin/sqlnet.oraUsed TNSNAMES adapter to resolve the aliasAttempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = bisal)))TNS-12541: TNS:no listener

 

Connect to the bisal database again:
[oracle@liu Desktop]$ sqlplus bisal/xxx@bisalSQL*Plus: Release 10.2.0.1.0 - Production on Sun Aug 11 15:04:54 2013Copyright (c) 1982, 2005, Oracle.  All rights reserved.ERROR:ORA-12541: TNS:no listenerEnter user-name: 

 

Enable the listener and connect to the local bisal database using @ bisal:
[oracle@liu Desktop]$ sqlplus bisal/xxx@bisalSQL*Plus: Release 10.2.0.1.0 - Production on Sun Aug 11 14:40:08 2013Copyright (c) 1982, 2005, Oracle.  All rights reserved.Error accessing PRODUCT_USER_PROFILEWarning:  Product user profile information not loaded!You may need to run PUPBLD.SQL as SYSTEMConnected to:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining optionsSQL> select * from global_name;GLOBAL_NAME--------------------------------------------------------------------------------BISALSQL> 

 

However, you can use the operating system to verify the local database sys account you have logged on:
[oracle@liu Desktop]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.1.0 - Production on Sun Aug 11 14:40:37 2013Copyright (c) 1982, 2005, Oracle.  All rights reserved.ERROR:ORA-01031: insufficient privilegesEnter user-name: 

 

Access is forbidden. You can only access the previous local database sys account as follows:
[oracle@liu Desktop]$ sqlplus bisal/bisal@bisalSQL*Plus: Release 10.2.0.1.0 - Production on Sun Aug 11 14:43:52 2013Copyright (c) 1982, 2005, Oracle.  All rights reserved.Error accessing PRODUCT_USER_PROFILEWarning:  Product user profile information not loaded!You may need to run PUPBLD.SQL as SYSTEMConnected to:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining optionsSQL> conn sys/oracle as sysdbaConnected.SQL> show userUSER is "SYS"SQL> 

 

Conclusion: 1. If the TWO_TASK environment variable is not set, the default value of ORACLE_SID is used if the service name is not specified. 2. When TWO_TASK environment variables are set, the default value of TWO_TASK for connection without specifying the service name is TWO_TASK. 3. When @ service name is used for connection, the value of ORACLE_SID or TWO_TASK is ignored. 4. When TWO_TASK environment variable is used, the operating system authentication login database method is forbidden, prompt ORA-01031: insufficient privileges. 5. Because the role of ORACLE_SID is blocked after TWO_TASK is set, you must connect to the local database through SQLNet, that is, you need to listen, generally, you may not enable the listener when accessing the local database from the local machine. However, you must enable the listener to connect to the local database by @ service name. 6. Supplement: the default path of the tnsnames. ora file is as follows:
$HOME(~)/.tnsnames.ora$TNS_ADMIN/tnsnames.ora/var/opt/oracle/tnsnames.ora or /etc/tnsnames.ora (depending on platform)$ORACLE_HOME/network/admin/tnsnames.ora

 

7. Regarding the source of TWO and TASK, the word "two task" came from 1980s. two task indicates the meaning of TWO tasks working together. It is only an intent, not limited to TWO. 8. In my personal understanding, setting TWO_TASK can overwrite ORACLE_SID and change the database (local or remote) connected by default without the @ service name ), all sqlplus connections are required to use SQLNet to disable operating system verification. That's all.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.