ORACLE服务器TAF配置说明书.docx
KingdeeORACLE服务器TAF配置说明书目录ORACLE服务器端TAF的配置说明书1一、说明1二、服务端配置方法1三、客户端的配置方法3四、手动模拟转移测试验证.4五、故障转移验证验证5手工关闭某个实例5自身故障6六、注意事项7一、说明一TAF (TRANSPORT APPLICATION FAILOVER 简称透明应用故障转移)是在优化系统架 构的同时,提高系统的可用性。对比在客户端,在服务器端配置TAF,可以简化TAF的使用方法。本文介绍在ORACLE RAC服务器端/客户端上TAF的配置方法、及测试验证、及注意事项。二、服务端配置方法环境说明:ORACLE 11204,RAC双节点,1. 查看数据库上已配置的服务(名)。oracle tlmbdb1/home/oracle$srvctl config service -d tlmborclService name: srv10Service is enabledServer pool: tlmborcl_srv10Cardinality: 1Disconnect: falseService role: PRIMARYManagement policy: AUTOMATICDTP transaction: falseAQ HA notifications: falseFailover type: SELECTFailover method: NONETAF failover retries: 0TAF failover delay: 0Connection Load Balancing Goal: LONGRuntime Load Balancing Goal: NONETAF policy specification: BASICEdition:Preferred instances: tlmborcllAvailable instances: tlmborcl2Service name: srv20Service is enabledServer pool: tlmborcl_srv20Cardinality: 1Disconnect: falseService role: PRIMARYManagement policy: AUTOMATICDTP transaction: falseAQ HA notifications: falseFailover type: SELECTFailover method: NONETAF failover retries: 0TAF failover delay: 0Connection Load Balancing Goal: LONGRuntime Load Balancing Goal: NONETAF policy specification: BASICEdition:Preferred instances: tlmborcl2Available instances: tlmborcl1说明: tlmbdb1,节点1的服务器名称,节点2名称为tlmbdb2。 d tlmborcl,目标数据库服务名称,用于登录数据库。配置后,当使用该服 务名登录数据库时,不论登录到哪个实例(节点),都是登录到该数据库(一 个节点上可以存在多个数据库)。 节点1的实例名为tlmborcl1,节点2的实例名为tlmborcl2。 srv10,srv20,服务名(文章中提及的服务和服务名,本质都是一个意思。服 务是指功能,服务名是指该功能的表现名称)。2. 删除原来的服务,重新配置。2.1停止原服务。oracletlmbdb1/home/oracle$srvctl stop service -d tlmborcl -s srv10 oracletlmbdb1/home/oracle$srvctl stop service -d tlmborcl -s srv202.2删除原服务。oracletlmbdb1/home/oracle$srvctl remove service -d tlmborcl -s srv10 oracletlmbdb1/home/oracle$srvctl remove service -d tlmborcl -s srv202.3重新配置服务,这里用回原来的名称。oracletlmbdb1/home/oracle$srvctl add service -d tlmborcl -s srv10 -r tlmborcll -a tlmborcl2 -P basic -e selectoracletlmbdb1/home/oracle$srvctl add service -d tlmborcl -s srv20 -r tlmborcl2 -a tlmborcll -P basic -e select说明:-d指明是哪个数据库的服务-s服务名-r首选实例-a备选实例-P故障转移类型-e允许的故障转移操作2.4查看服务状态。oracletlmbdb1/home/oracle$srvctl status service -d tlmborclService srv10 is not running.Service srv20 is not running.说明:创建服务后,服务的状态为关闭。必须得启动服务才能使用。2.5启动服务。oracletlmbdb1/home/oracle$srvctl start service -d tlmborclService srv10 is running on instance(s) tlmborcllService srv20 is running on instance(s) tlmborcl2oracletlmbdb1/home/oracle$说明:服务在哪个实例上running,使用该服务名登录时,将登录到该实例。3. 连接测试当使用srv10服务名时,将连接/登录到实例1(tlmborcl1)。若被重新转移/ 重新分配到实例2时,将连接/登录到实例2( tlmborcl2)。使用srv20时同理。oracletlmbdb1/home/oracle$sqlplus cloudzs/cloudzssrv10 SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 18 16:34:03 2018 Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing optionsCLOUDZSsrv10>select instance_name from v$instance;INSTANCE_NAME tlmborcl1Elapsed: 00:00:00.00CLOUDZSsrv10>connect cloudzs/cloudzssrv20、 Connected.CLOUDZSsrv20>select instance_name from v$instance;INSTANCE_NAME tlmborcl2Elapsed: 00:00:00.02三、客户端的配置方法修改oracle下的tnsnames.ora文件,增加实例名称配置。 rac 1 e(&tlmbdb2/oracte/app/dblLgfnetwork/adniin$nnore tnsnames. orafi- Lrisnaries ora Networ_k Configuration File: /racle/app/dbllg/'network/ajdmin/tnsndnies .ora 若 Generated by Oracle ronHguration too I"TLMBORCL =tImbdb-Stan)PORT 1521)Llmbdb-sc an) (PORT = 1521)Lliribdb-scan)(POFLT - 1521)(DESCRIPTION =CADDRESS > (PROTOCOL = TCP)(HOST =CCONNECT.DATA -(SERVER = DEDT3TF。(SERVICE_NAML = tlfflborcl)一 >RVIO =CRIPTION (ADDRESS = (PROTOCOL = TCP)(HOST =CONNECT DATA =(SERVER = DEDLCATED1(SERVICE.NAME - .rvlCi)5RV?0 -(DESCRIPTION =CADDRES5 - (PROTOCOL - KP)(HO5T -CCOMECT_DATA -(SERVER - DEDICATED)(SERVICE_NAMt = STVZO)orac1e(&tliiibdb2/arac1 e/app/dblig/netork/adoiinS说明:椭圆标记的srv10,是上述命令srvctl add service-d tlmborcl-s srv10里指定的名称。方框标记的SRV10,是连接串的名称,可以任意命名。四、手动模拟转移测试验证把服务名srv10的首实例,从tlmborcll转到tlmborcl2。oracletlmbdb1/home/oracle$srvctl relocate service -d tlmborcl -s srv10 -i tlmborcl1 -t tlmborcl2 说明:relocate转移/重新分配-i服务原先的首实例-t服务新的首实例1. 查看转移后服务名所在实例oracletlmbdb1/home/oracle$srvctl status service -d tlmborclService srv10 is running on instance(s) tlmborcl2Service srv20 is running on instance(s) tlmborcl22. 手动转移服务名的首实例,只是临时性的操作,不会改变配置中最初的首实例oracletlmbdb1/home/oracle$srvctl config service -d tlmborcl -s srv10Service name: srv10Service is enabledServer pool: tlmborcl_srv10Cardinality: 1Disconnect: falseService role: PRIMARYManagement policy: AUTOMATICDTP transaction: falseAQ HA notifications: falseFailover type: SELECTFailover method: NONETAF failover retries: 0TAF failover delay: 0Connection Load Balancing Goal: LONGRuntime Load Balancing Goal: NONETAF policy specification: BASICEdition:Preferred instances: tlmborcllAvailable instances: tlmborcl2oracletlmbdb1/home/oracle$3. 测试手动转移服务首实例后的效果oracletlmbdb1/home/oracle$sqlplus cloudzs/cloudzssrv10SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 18 16:40:52 2018Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing optionsCLOUDZSsrv10>select instance_name from v$instance;INSTANCE_NAME tlmborcl2Elapsed: 00:00:00.004. 当关闭/重启该服务后,查看服务名的首实例,依然是原来配置的值oracletlmbdb1/home/oracle$srvctl stop service -d tlmborcl -s srv10oracletlmbdb1/home/oracle$srvctl start service -d tlmborcl -s srv10oracletlmbdb1/home/oracle$srvctl status service -d tlmborclService srv10 is running on instance(s) tlmborcl1Service srv20 is running on instance(s) tlmborcl2 >oracletlmbdb1/home/oracle$五、故障转移验证验证手工关闭某个实例1.使用服务名srv20,登录到实例2;rora.clet'liibdbl/home/oraclelsqlplus cloudz5/CLOUDZ5&Srv20SQLPlus: Re lease 11.2.0.4.0 Production on Fri 3ul 20 10:59:45 201SCopyr ight198?. 2013T Oracle. All ri ghts reserved.cortnticted to:Oracle Database llg Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith tlie Partitioning, Real Application duel ers3 Autcunatic Storage Management, CLAP,Data Mining and Real Application Testint; options-CLOUDZSfisrk/2O>&elecL instance_nane frorarance;:l MSTAMCER1AMEtlmborcl 2Elapsed: 00:00:00.0DCL0UUE如s rv20>2.关闭实例2;TVSTAKLE NAMEtlnnhnrcl?SQL Sms:yjins1NSTAMLE NAMEtlnibtircl24: non connected to ORA.CLEton ID: 108? £select instance name from vSinstanlLE5¥5(&t Inrborcl 2>00:00-00.00Elapsed: 00:00:00,CLOUDZSfflsrv20>select -iffi?t£ance_niame fromERROR:ORA-。5114: not/c-ora£Cted JL) MALLEConnectedConnecteriCopyrightOrac1e Database 11g Enterprise Edi口cm Release 11,2-0.4.0 - Product!or tafith the Partitioringr Rea"l Application clustersr Automatic storage Management, clap, Data Mining and Real Application Testing optionsSVS(&tlmbarclElect instanceElapsed: 00:00:DO.00SYSt 1 nborcl2>shutdon nirimediate;Database closed.Database dismounted.ORACLE instamce shut down.Copyrightfrom v$-instancy:11.2.0.4.0 Produrtion on Fri lul 20 1.0:59:Cc) 1982, 2013? Oracle.Oracle Database 11g EnterpriWith the Partiti-omng ,. Real Appl ication Clusters.Data wining and Real pnlication resting oprionsCLOUDZ S©5 rkr20> select instdncenanie fromCLOUDZSftsrv20>select instancejuamtRROR at 11ne I:OR.4-05113: end-of-+iProcess IIJ: 10 5 513El apseci.00 'Sraqe Wanagement, OLAPdvjinstance:icted from Oracle Database 11g Enterprise Edition Release 11,20-4.0 - 64bit Production e Partitioning Real Application clusters. Automatic storage Manageitient, OLAP, Data Mining and Real App1ication Testing optiService srvlO is running an instancetsJ tlmborcll Service srvZD is not runniing.通过shutdown方式关闭的实例,如果采用服务名的方式,系统不会自动转移,需要手工重新 启动后,才能正常使用。自身故障1.使用kill -9命令,杀掉数据库的关键进程smon,模拟数据库实例故障;smon36:/qrn J/qrid_home/bin/osysmond. bin0: OB a5iii_smon_+ASM20:00 grep smonoracl eTlnibdb2/honieAracle$p5 -ef I grep srronM7356§61t)J Lil D6-36: 30/gri d/grid_hofii&/bi n/osysmond.bin832 531210Jul 06-0:0Sa§m_&rtiQn_*ASMN86509944653566011:21:40pts/I0:00qrep smanI &安脆鬟10 II,伯:皿rootgridoracl e.oracle _ 槌一 一一ra.c I I mbdb2J /home/orac lejki 11 -9 B978828'racl e&tluibdbZ' /hom e/oracle $ps -eflgreproot 373S69610Jul06grid 83233121。Jul 06orH(le 1。9446。&网535&G011 : ? : 1.0pts/loraclet'l(iibdb2/honie/oracleidateFfi 3ul 20 11:22:12 HtT 201flCoracl etlmbclb2/honre/oracle$|2.查看测试进程的实例,发现从原来的实例2,自动跳转到实例1。说明当实例 自身发生故障时,可以自动转移;oracleStlnibdblJ/home/oracleSsqlplus cloudzs/CLOUDsfisrv20SQL-Plus: Release 11.2.0.4.0 Production on kri Jul 20 11:18:47 201SCopyright (c) 1982, 2013, Oracle. Al 1 rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0.- 64bit Product!onwith thehPartitnoning» Real Application clusters, Automatic Storage Management, OLAP,Data Mining 占nd Real Application Testi ng optiansclouDZ50srv20>select instance_name from vSinstance;TN5TAMCF NAMFLlapsed: 00:00:00,01CLOUDZSer</20>select sysdate from dual;5Y5DATE2O18-D7-19 22:20:39Elapsed: 00:00:00.00 cloudzs&srv20>seleel instance_namti from vSinstance;:l NSTAMCE_NAMEElapsed: 00:00:00.26CL0UDZSsrv20>pts/1StllQTI8一ib2honie/oracetk ill -9 897&8?8 sninn|b2 /honte/orarl flips| grep569610Jul0623n21(JJul06,e1Q941&084 653566011:22:10Ltlmbdb2 /home/orac 1 eidate 20 1127:12 HKT 2018me/9acleSp5 -ef I grep k r10Jul 06>1。Jul 06<653566011:51:401011:16:04nraclefitlmbdroot 4ugrid 艰nrarl _ S6Sorac辿旬rogridoracleLpra.c1/&':oracletixl fnbdb2/hon/oracTe3p£ -ef I greproot373569&10Jul 06gridS323312 10Jul 06loraclellflS141011:22:16 mcle46535 拓0 11:28:51 ptW_Loracl e&tl mbdb2/honie/or0c 1/grid/gridJicme/bin/osyEfflond .binasm_sman_+ASM2"qrep s:n»nQra_5mon_tl irbarc 12./grid/grid_home/bin/o£y£jinond .bin asnr_s man_+ASM 2"grop srfton/grid/grid_home/bin/Q£y£mond .binasnr_sn)on_+ASMZ"Qra_$ntQn_tTmb3rcl2 |grep snxnn36:30 0:08 0: DO36:31 0: 1)8 _o:tx)tlmborcl?hzlmbarcH说明由于实例自己故障导致的关闭,会自动跳转到其他节点的实例,并且自动恢复相关进程。3.查看实例2之前被杀掉的关键进程smon,系统自动恢复。六、注意事项在 Oracle 11.2.0.4, 12.1.0.2版本中,当人为手动关闭数据库(shutdown immediate/abort)时, 使用taf方式登录数据库的进程,不会自动跳转到其他节点的实例,重新启动后才能连接。在12.2.0.1版本,即便是手工关闭数据库,使用taf方式登录数据库的进程,也会自动跳转 到其他节点的实例。七、利用集群特性的部署方案在RAC的两个节点$ORACLE_HOME/network/admin目录下的tnsname.ora文件增加:SRV1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = cloud-scan)(PORT = 1521) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = SRV1)SRV2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = cloud-scan)(PORT = 1521) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = SRV2)数据库注册地址:地址:scanip ; Oracle实例名:srv10查询库注册地址:地址:scanip ; Oracle实例名:srv20说明:SRV10, SRV20为安装RAC后,两个节点的服务名称