Oracle 學習之RAC(九) 叢集負載平衡及容錯移轉

來源:互聯網
上載者:User

標籤:rac 容錯移轉

  1. 查看監聽,使用grid使用者

11grac1:

11grac1-> lsnrctl statusLSNRCTL for Linux: Version 11.2.0.3.0 - Production on 14-AUG-2015 00:30:26Copyright (c) 1991, 2011, Oracle.  All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))STATUS of the LISTENER------------------------Alias                     LISTENERVersion                   TNSLSNR for Linux: Version 11.2.0.3.0 - ProductionStart Date                13-AUG-2015 22:17:25Uptime                    0 days 2 hr. 13 min. 1 secTrace Level               offSecurity                  ON: Local OS AuthenticationSNMP                      OFFListener Parameter File   /u01/app/11.2.0/grid/network/admin/listener.oraListener Log File         /u01/app/grid/diag/tnslsnr/11grac1/listener/alert/log.xmlListening Endpoints Summary...  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.199.10)(PORT=1521)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.199.20)(PORT=1521)))Services Summary...Service "+ASM" has 1 instance(s).  Instance "+ASM1", status READY, has 1 handler(s) for this service...Service "devdb" has 1 instance(s).  Instance "devdb1", status READY, has 1 handler(s) for this service...Service "devdbXDB" has 1 instance(s).  Instance "devdb1", status READY, has 1 handler(s) for this service...The command completed successfully

11grac2:

11grac2-> lsnrctl statusLSNRCTL for Linux: Version 11.2.0.3.0 - Production on 14-AUG-2015 00:28:31Copyright (c) 1991, 2011, Oracle.  All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))STATUS of the LISTENER------------------------Alias                     LISTENERVersion                   TNSLSNR for Linux: Version 11.2.0.3.0 - ProductionStart Date                13-AUG-2015 22:21:38Uptime                    0 days 2 hr. 6 min. 52 secTrace Level               offSecurity                  ON: Local OS AuthenticationSNMP                      OFFListener Parameter File   /u01/app/11.2.0/grid/network/admin/listener.oraListener Log File         /u01/app/grid/diag/tnslsnr/11grac2/listener/alert/log.xmlListening Endpoints Summary...  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.199.11)(PORT=1521)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.199.21)(PORT=1521)))Services Summary...Service "+ASM" has 1 instance(s).  Instance "+ASM2", status READY, has 1 handler(s) for this service...Service "devdb" has 1 instance(s).  Instance "devdb2", status READY, has 1 handler(s) for this service...Service "devdbXDB" has 1 instance(s).  Instance "devdb2", status READY, has 1 handler(s) for this service...The command completed successfully

11grac3:

11grac3-> lsnrctl statusLSNRCTL for Linux: Version 11.2.0.3.0 - Production on 14-AUG-2015 00:29:21Copyright (c) 1991, 2011, Oracle.  All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))STATUS of the LISTENER------------------------Alias                     LISTENERVersion                   TNSLSNR for Linux: Version 11.2.0.3.0 - ProductionStart Date                13-AUG-2015 22:53:28Uptime                    0 days 1 hr. 35 min. 53 secTrace Level               offSecurity                  ON: Local OS AuthenticationSNMP                      OFFListener Parameter File   /u01/app/11.2.0/grid/network/admin/listener.oraListener Log File         /u01/app/grid/diag/tnslsnr/11grac3/listener/alert/log.xmlListening Endpoints Summary...  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.199.12)(PORT=1521)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.199.22)(PORT=1521)))Services Summary...Service "+ASM" has 1 instance(s).  Instance "+ASM3", status READY, has 1 handler(s) for this service...Service "devdb" has 1 instance(s).  Instance "devdb3", status READY, has 1 handler(s) for this service...Service "devdbXDB" has 1 instance(s).  Instance "devdb3", status READY, has 1 handler(s) for this service...The command completed successfully

每台機器的監聽,都監聽了自己的public-ip和vip 。

沒有一台是監聽scanip的。

那麼我們使用scanip串連資料庫試試看。

查看tnsname的配置

11grac2-> cd /u01/app/oracle/product/11.2.0/db_1/network/admin/  11grac2-> cat tnsnames.ora # tnsnames.ora.11grac2 Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora.11grac2# Generated by Oracle configuration tools.DEVDB =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = scan-cluster)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = devdb)    )  )

使用DEVDB連接字串登入資料庫

1.

11grac2-> sqlplus sys/[email protected] as sysdbaSQL> select instance_name from v$instance;INSTANCE_NAME------------------------------------------------devdb3

2.

11grac2-> sqlplus sys/[email protected] as sysdbaSQL> select instance_name from v$instance;INSTANCE_NAME------------------------------------------------devdb1SQL>

3.

11grac2-> sqlplus sys/[email protected] as sysdbaSQL> select instance_name from v$instance;INSTANCE_NAME------------------------------------------------devdb3SQL>

4. 

11grac2-> sqlplus sys/[email protected] as sysdbaSQL> select instance_name from v$instance;INSTANCE_NAME------------------------------------------------devdb2SQL>

可見,在11g RAC中Oracle引入了SCAN的概念。自動實現了負載平衡。你只需串連到SCAN上,SCAN再將串連轉交給資料庫。並實現負載平衡。


那麼我們看看如何?容錯移轉。及當用戶端串連的執行個體崩潰後,該串連會自動漂移到其他執行個體上。

要實現容錯移轉,我們要做如下配置

[[email protected] bin]# su - oracle11grac2->  srvctl add service -d devdb -s DEVDB_TAF -r devdb1,devdb2,devdb311grac2->  srvctl start service -d devdb -s DEVDB_TAF11grac2->  srvctl modify service -d devdb -s DEVDB_TAF -q TRUE -P BASIC -e SELECT

修改tnsname.ora,添加一個串連到DEVDB_TAF的連接字串

11grac2-> cat tnsnames.ora # tnsnames.ora.11grac2 Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora.11grac2# Generated by Oracle configuration tools.DEVDB =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = scan-cluster)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = devdb)    )  )DEVDB_TAF =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = scan-cluster)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = devdb_taf)    )  )

驗證容錯移轉

  1. 在11grac1上使用sys登入資料庫

11grac1-> sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 14 01:01:54 2015Copyright (c) 1982, 2011, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Data Mining and Real Application Testing optionsSQL> select instance_name from v$instance;INSTANCE_NAME------------------------------------------------devdb1SQL> grant select any table to scott;Grant succeeded.SQL>


2. 在11grac2上使用scott使用者以DEVDB_TAF連接字串登入資料庫。

11grac2-> sqlplus scott/[email protected]_TAFSQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 14 01:03:28 2015Copyright (c) 1982, 2011, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Data Mining and Real Application Testing optionsSQL>


3.在11grac1的sqlplus中查看scott串連的情況

SQL> select inst_id,sid from gv$session where username=‘SCOTT‘;   INST_ID  SID---------- ---------- 2   56

4. scott使用者執行一個比較耗時的查詢,在執行期間,將11grac2上的執行個體shutdown abort

SQL> select count(*) from (  2  select * from dba_source union   3   select * from dba_source union   4   select * from dba_source union   5   select * from dba_source union   6   select * from dba_source union   7   select * from dba_source union   8   select * from dba_source union   9   select * from dba_source union  10   select * from dba_source union  11   select * from dba_source);
SQL> shutdown abortORACLE instance shut down.


5. 我們再去11grac1上,查看第3步執行的結果

SQL>  select inst_id,sid from gv$session where username=‘SCOTT‘;   INST_ID  SID---------- ---------- 1   64

scott 的串連已經從執行個體2轉移到執行個體1上了。

並且第4步的查詢,結果也出來了。

SQL> select count(*) from (  2  select * from dba_source union   3   select * from dba_source union   4   select * from dba_source union   5   select * from dba_source union   6   select * from dba_source union   7   select * from dba_source union   8   select * from dba_source union   9   select * from dba_source union  10   select * from dba_source union  11   select * from dba_source);       COUNT(*)----------    632805



本文出自 “叮咚” 部落格,請務必保留此出處http://lqding.blog.51cto.com/9123978/1684774

Oracle 學習之RAC(九) 叢集負載平衡及容錯移轉

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.