Home > Article > Backend Development > OracleFaq (OracleTAF configuration)_PHP tutorial
If you need to reprint, please indicate the source! (Thank you in advance, Diao Chan...) Configuration of Oracle TAF TAF is the abbreviation of Transparent Application FailOver. Generally, TAF is applied in the OPS/RAC environment. This function, which has been available since 8i, has a good purpose and idea, but its current application is still very limited. This article will discuss in detail TAF-related issues. The test environment of this article is Tru64 V5.1+ Oracle9.2.0.1 RAC. 1. Explanation of related parameters To be honest, Oracle's configuration parameters about the network are really messy. Many people can't figure out what is going on. The common errors are: "ORA-12514: TNS: listener could not resolve SERVICE_NAME given in connect descriptor" and "ORA-12154 :TNS: Could not resolve service name" are essentially the same. To solve this problem, we need to fiddle with several parameters: Several parameters in initsid.ora: DB_NAME --- database name, which is the name provided when creating the database. GLOBAL_NAMES --- True/false, set whether to use the database domain name. DB_DOMAIN --- database domain name, if GLOBAL_NAMES=True, this parameter is required. SERVICE_NAMES --- service names list, there can be multiple service names. INSTANCE_NAME --- instance name, like SERVICE_NAMES, is supported starting from 817, that is, starting from 817, database, instance and service names can be separated. The default value of instance_name is the SID of the instance, which is the value corresponding to the environment variable ORACLE_SID. Before 817, when there was no instance_name parameter, different instances were distinguished by SID. According to the document explanation after oracle817: SID is to distinguish the shared memory of each instance on the same host. It is not the only distinguishing mark of the instance, and instance_name is to distinguish each instance. Environment variable: ORACLE_SID --- When there was no instance_name parameter before 817, different instances were distinguished by SID (see the initsid.ora parameter explanation above for details). Several parameters in listener.ora: GLOBAL_DBNAME --- global database name, uniquely identifies different databases in a distributed environment. Its value is the combination of DB_NAME and DB_DOMAIN in initsid.ora, that is, GLOBAL_DBNAME=DB_NAME.DB_DOMAIN, where DB_DOMAIN is not needed if it is not set here. This parameter is recommended to be specified explicitly in distributed environments. SERVICE_NAME --- Service name, just select one from the service_names list in initsid.ora. SID_NAME --- The value corresponding to the environment variable ORACLE_SID. INSTANCE_NAME ---corresponds to the initialization parameter instance_name. Several parameters in tnsnames.ora: service_name --- service name, just take the service_names list in initsid.ora to one. sid_name --- can be abbreviated as: sid, corresponding to ORACLE_SID, or it can be the initialization parameter instance_name. When it is equal to instance_name and instance_name is not equal to ORACLE_SID, Oracle will automatically register a listening process to distinguish different instances. instance_name --- Starting from 817, this new parameter can be used, corresponding to the initialization parameter instance_name. In this way, the parameters become very complicated, but we will not use them in actual use. Of course, the simpler the better.2. Related parameter settings Below I will give examples to illustrate the settings of related parameters: 1. Environment variable: ORACLE_SID=rac1/2 2. initsid.ora: db_name=ora92 service_names = ora92 instance_name=rac1/2 global_names=false db_domain="" 3 , listener.ora: SID_LIST_RAC1 = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = ora92) (ORACLE_HOME = /oracle/oracle9/app/oracle/product/9.2.0) (SERVICE_NAME=ora92)(SID_NAME = rac1) ) ) SID_LIST_RAC2 = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = ora92) (ORACLE_HOME = /oracle/oracle9/app/oracle/product/9.2.0) (SERVICE_NAME=ora92)(SID_NAME = rac2) ) ) RAC1 = (DESCRIPTION_LIST = (DESCRIPTION = ( ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.3.1)(PORT = 1522)) ) ) ) RAC2 = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1. 3.2)(PORT = 1522)) ) ) ) 3. TAF settings In fact, TAF settings are very simple. Just add failover=on in tnsnames.ora. There are two different setting methods: 1. Use a common tns name method: ================================================== myrac = (description= (load_balance=on) (failover=on) (address= (protocol=tcp)(host=10.1.3.1)(port=1522)) (address= (protocol=tcp)(host=10.1.3.2 )(port=1522)) (connect_data= (service_name=ora92) (failover_mode=(type=select)(method=basic)(retries=20)(delay=20)) ) ) ========= ================================================== =============== 2. Specify the instance backup method: ============================ =================== rac1 = (description= (load_balance=on) (failover=on) (address= (protocol=tcp)(host=10.1.3.1)( port=1522)) (connect_data= (service_name=ora92) (failover_mode=(type=select)(method=basic) (backup=rac2)(retries=20)(delay=20)) ) ) rac2 = (description= ( load_balance=on) (failover=on) (address= (protocol=tcp)(host=10.1.3.2)(port=1522)) (connect_data= (service_name=ora92) (failover_mode=(type=select)(method=basic ) (backup=rac1)(retries=20)(delay=20)) ) ) =============================== =========================================== 4. TAF test method is generally acceptable Down the currently connected instance, the client will not be disconnected and will automatically switch to the backup node. On the contrary, it will automatically switch back. Of course, some people have proposed using the post_transaction method to test TAF. In fact, this sometimes does not result in the expected results. The reason is that after Oracle connects to an instance, it will first try to connect to the instance. When you disconnect, the client As soon as there is a new request on the end, it will automatically try to connect to the most recently connected instance. If unsuccessful, it will try to connect to the backup instance.