2010 г.
Новые возможности Oracle TimesTen 11g – интеграция с Oracle Clusterware
Сигалаев Г.Г., OCP
Oracle CIS
Назад Содержание
5. Конфигурирование Active-Standby pair репликации и Oracle Clusterware
Ограничения: В данном примере описывается создание простой конфигурации (basic level of availability).
Вначале добавим сущность в cluster.oracle.ini, в которой пропишем узлы, на которых будет запущена репликация, и директорию для CRS-скриптов (check, start, stop) для определенной репликации).
…
[ha_ds]
MasterHosts=rac1,rac2
ScriptInstallDir=/u01/app/oracle/product/11.2.1/TimesTen/tt1/info/crs_scripts
…
Теперь нужно повторить настройки cluster.oracle.ini и sys.odbc.ini на втором узле (rac2).
Далее регистрируем TimesTen кластер в OCR.
[root@rac1 ~]$ cd /u01/app/oracle/product/11.2.1/TimesTen/tt1/bin/
[root@rac1 bin]$ ./ttCWAdmin -ocrconfig
Oracle Clusterware home = /u01/app/oracle/product/11.1.0/crs
Далее запускаем агенты кластера TimesTen на обоих узлах.
[root@rac1 bin]$ ./ttCWAdmin -init
Oracle Clusterware home = /u01/app/oracle/product/11.2.1/crs, hosts = rac1,rac2
===============================================================
Registering agent resources:... Registration complete.
===============================================================
===============================================================
Registering daemon resources:... Registration complete.
===============================================================
После этого в CRS должны появиться четыре новых сервиса.
[oracle@rac1 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
TT_A...le_RAC1 application ONLINE ONLINE rac1
TT_A...le_RAC2 application ONLINE ONLINE rac2
TT_D...le_RAC1 application ONLINE ONLINE rac1
TT_D...le_RAC2 application ONLINE ONLINE rac2
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
[oracle@rac1 ~]$
[oracle@rac1 ~]$ crs_stat
…
NAME=TT_Agent_tt1_oracle_RAC1
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1
NAME=TT_Agent_tt1_oracle_RAC2
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac2
NAME=TT_Daemon_tt1_oracle_RAC1
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1
NAME=TT_Daemon_tt1_oracle_RAC2
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac2
…
Также видим новые процессы на обоих узлах.
[oracle@rac2 ~]$ ps -ef | grep ttCRS
oracle 5007 1 0 13:18 ? 00:00:00 /u01/app/oracle/product/11.2.1/TimesTen/tt1/bin/ttCRSdaemonCmd start
oracle 5008 1 0 13:18 ? 00:00:00 /u01/app/oracle/product/11.2.1/TimesTen/tt1/bin/ttCRSAgentCmd start
Теперь создадим Active-Standby pair репликацию. Данную репликацию можно создать двумя способами: используя команду create active standby pair replication или с помощью ttCWAdmin, но не обоими одновременно! В данном случае создавать и управлять репликацией будем с помощью ttCWAdmin. При запросе имени пользователя с привилегией ADMIN вводим имя adm (создан на этапе создания базы данных и объектов).
[root@rac1 bin]$ ./ttCWAdmin -create -dsn ha_ds
Successful connection with Oracle clusterware stack
replication DDL = create active standby pair "HA_DS" on "rac1","HA_DS" on "rac2"
Enter internal UID with ADMIN privileges: adm
Enter password for the same UID:
Enter any phrase for password encryption:
Uid/Pwd verified on host rac1
Create active standby pair scheme on this host? (Y/N)Y
Waiting for confirmation from hosts...
Active Standby pair created on host rac1
==================================================================
Warning!! Data store on host(s) rac2 may be destroyed in order to be duplicated from active after the roll out.
Please back up this data store manually if necessary, before executing
ttCWAdmin -start Command
==================================================================
Registering TimesTen Cluster with Oracle Clusterware
==================================================================
Number of unregistered dsn resources = 2
Registering dsn resources:... Registration complete.
==================================================================
==================================================================
Number of unregistered service resources = 2
Registering service resources:... Registration complete.
==================================================================
[root@rac1 bin]$
После этого в CRS появятся еще четыре сервиса, связанные непосредственно с репликацией HA_DS. Также можно заметить, что два из них не запущены - имеют статусы OFFLINE.
[oracle@rac1 info]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
TT_A...e_HA_DS application ONLINE ONLINE rac1
TT_A...le_RAC1 application ONLINE ONLINE rac1
TT_A...le_RAC2 application ONLINE ONLINE rac2
TT_D...le_RAC1 application ONLINE ONLINE rac1
TT_D...le_RAC2 application ONLINE ONLINE rac2
TT_M...HA_DS_0 application OFFLINE OFFLINE
TT_M...HA_DS_1 application OFFLINE OFFLINE
TT_S...e_HA_DS application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
[oracle@rac1 info]$
[oracle@rac1 ~]$ crs_stat
…
NAME=TT_Activeservice_tt1_oracle_HA_DS
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1
NAME=TT_Master_tt1_oracle_HA_DS_0
TYPE=application
TARGET=OFFLINE
STATE=OFFLINE
NAME=TT_Master_tt1_oracle_HA_DS_1
TYPE=application
TARGET=OFFLINE
STATE=OFFLINE
NAME=TT_Subservice_tt1_oracle_HA_DS
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1
…
Также после этого в директории, прописанной в файле конфигурации репликации (cluster.oracle.ini), появится ряд CRS-файлов (start, stop, check) для определенной репликации.
[oracle@rac2 crs_scripts]$ ls
...
ora_tt_tt1_HA_DS_master_1.sh
ora_tt_tt1_HA_DS_master_0.sh
ora_tt_tt1_HA_DS_activeservice.sh
ora_tt_tt1_HA_DS_subservice.sh
Теперь посмотрим состояние репликации.
[root@rac1 bin]# ./ttCWAdmin -status
TimesTen Cluster status report as of Wed Apr 14 17:00:19 2010
====================================================================
TimesTen daemon monitors:
Host:RAC1 Status: online
Host:RAC2 Status: online
====================================================================
====================================================================
TimesTen Cluster agents
Host:RAC1 Status: online
Host:RAC2 Status: online
====================================================================
Status of Cluster related to DSN HA_DS:
====================================================================
1. Status of Cluster monitoring components:
Monitor Process for Master Datastore 1 on Host RAC1: NOT RUNNING
Monitor Process for Master Datastore 2 on Host RAC2: NOT RUNNING
Monitor Process for Active datastore:RUNNING on Host rac1
Monitor Process for Standby datastore:RUNNING on Host rac1
2.Status of Datastores comprising the cluster
Master Datastore 1:
Host:RAC1
Status:AVAILABLE
State:ACTIVE
Master Datastore 2:
Host:RAC2
Status:UNAVAILABLE
State:UNKNOWN
====================================================================
The cluster containing the replicated DSN is offline
Видим, что агенты кластера Oracle TimesTen запущены, репликация существует, но она не запущена. Теперь запустим нашу репликацию.
[root@rac1 bin]$ ./ttCWAdmin -start -dsn ha_ds
Successful connection with Oracle clusterware stack
Starting Cluster resources with Oracle clusterware
TimesTen Cluster is starting
[root@rac1 bin]$
Проверим статус репликации.
[root@rac1 bin]$ ./ttCWAdmin –status
TimesTen Cluster status report as of Sat Feb 27 14:49:00 2010
==================================================================
TimesTen daemon monitors:
Host:RAC1 Status: online
Host:RAC2 Status: online
==================================================================
==================================================================
TimesTen Cluster agents
Host:RAC1 Status: online
Host:RAC2 Status: online
==================================================================
Status of Cluster related to DSN HA_DS:
==================================================================
1. Status of Cluster monitoring components:
Monitor Process for Master Datastore 1 on Host rac1: RUNNING
Monitor Process for Master Datastore 2 on Host rac2: RUNNING
Monitor Process for Active datastore:RUNNING on Host rac1
Monitor Process for Standby datastore:RUNNING on Host rac2
2.Status of Datastores comprising the cluster
Master Datastore 1:
Host:rac1
Status:AVAILABLE
State:ACTIVE
Master Datastore 2:
Host:rac2
Status:AVAILABLE
State:STANDBY
==================================================================
The cluster containing the replicated DSN is online
Видно, что реплицируемая база данных находится в состоянии online. Узлы находятся в состояниях Active и Standby. Проверим CRS.
[oracle@rac1 info]# crs_stat -t
Name Type Target State Host
------------------------------------------------------------
TT_A...e_HA_DS application ONLINE ONLINE rac1
TT_A...le_RAC1 application ONLINE ONLINE rac1
TT_A...le_RAC2 application ONLINE ONLINE rac2
TT_D...le_RAC1 application ONLINE ONLINE rac1
TT_D...le_RAC2 application ONLINE ONLINE rac2
TT_M...HA_DS_0 application ONLINE ONLINE rac1
TT_M...HA_DS_1 application ONLINE ONLINE rac2
TT_S...e_HA_DS application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
Видно, что все сервисы находятся в рабочем состоянии. На этом конфигурация Active-Standby pair репликации завершена.
6. Проверка работы конфигурации
Посмотрим на текущее состояние конфигурации.
[root@rac1 bin]# ./ttCWAdmin -status
TimesTen Cluster status report as of Fri Sep 3 15:54:23 2010
====================================================================
TimesTen daemon monitors:
Host:RAC1 Status: online
Host:RAC2 Status: online
====================================================================
====================================================================
TimesTen Cluster agents
Host:RAC1 Status: online
Host:RAC2 Status: online
====================================================================
Status of Cluster related to DSN HA_DS:
====================================================================
1. Status of Cluster monitoring components:
Monitor Process for Master Datastore 1 on Host rac1: RUNNING
Monitor Process for Master Datastore 2 on Host rac2: RUNNING
Monitor Process for Active datastore:RUNNING on Host rac1
Monitor Process for Standby datastore:NOT RUNNING
2.Status of Datastores comprising the cluster
Master Datastore 1:
Host:rac1
Status:AVAILABLE
State:ACTIVE
Master Datastore 2:
Host:rac2
Status:AVAILABLE
State:STANDBY
====================================================================
The cluster containing the replicated DSN is offline
Подсоединимся к узлу, имеющему состояние active, и вставим ряд записей в таблицу plans.
[oracle@rac1 ~]$ ttisql "DSN=ha_ds;UID=app;PWD=app"
Copyright (c) 1996-2009, Oracle. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=ha_ds;UID=app;PWD=app";
Connection successful: DSN=ha_ds;UID=app;DataStore=/u01/app/oracle/datastore/ha_ds;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;DRIVER=/u01/app/oracle/product/11.2.1/TimesTen/tt1/lib/libtten.so;PermSize=40;TempSize=32;TypeMode=0;
(Default setting AutoCommit=1)
Command> call ttRepStateGet();
< ACTIVE >
1 row found.
Command> select count(*) from plans;
< 0 >
1 row found.
Command> declare
> i number :=1 ;
> begin
> for i in 1 .. 1000 loop
> insert into plans (ID, NAME, PRICEPERMIN, STATUS)
> values (i, 'test', 1, 'ACT');
> end loop;
> end;
> /
PL/SQL procedure successfully completed.
Command> select count(*) from plans; < 1000 >
1 row found.
Command>
Теперь посмотрим состояние базы данных на узле rac2.
[oracle@rac2 ~]$ ttisql "DSN=ha_ds;UID=app;PWD=app"
Copyright (c) 1996-2009, Oracle. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=ha_ds;UID=app;PWD=app";
Connection successful: DSN=ha_ds;UID=app;DataStore=/u01/app/oracle/datastore/ha_ds;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;DRIVER=/u01/app/oracle/product/11.2.1/TimesTen/tt1/lib/libtten.so;PermSize=40;TempSize=32;TypeMode=0;
(Default setting AutoCommit=1)
Command> call ttRepStateGet();
< STANDBY >
1 row found.
Command> select count(*) from plans;
< 1000 >
1 row found.
Command>
Видим, что узел, находящийся в состоянии Standby, принимает информацию с узла rac1 и также доступен на чтение. Попытаемся вставить строки в таблицу plans на данном узле.
Command> insert into plans (ID, NAME, PRICEPERMIN, STATUS)
> values (0, 'test', 2, 'ACT');
16265: This store is currently the STANDBY. Change to APP.PLANS not permitted.
The command failed.
Command>
При попытке изменения данных получаем ошибку 16265.
Теперь воспроизведем ситуацию выхода из строя одного из серверов. Для этого выполним на узле rac1 команду reboot
![root@rac1 ~]# reboot
Посмотрим состояние репликации на узле rac2.
[root@rac2 ~]# cd /u01/app/oracle/product/11.2.1/TimesTen/tt1/bin
[root@rac2 bin]# ./ttCWAdmin -status
TimesTen Cluster status report as of Tue Sep 14 20:25:12 2010
====================================================================
TimesTen daemon monitors:
Host:RAC1 Status: unavailable
Host:RAC2 Status: online
====================================================================
====================================================================
TimesTen Cluster agents
Host:RAC1 Status: unavailable
Host:RAC2 Status: online
====================================================================
Status of Cluster related to DSN HA_DS:
====================================================================
1. Status of Cluster monitoring components:
Monitor Process for Master Datastore 1 on Host RAC1: NOT RUNNING
(ttCWAdmin) crsctl.c(21567): TT48004: clssgspubdata failed with status = 12.
Monitor Process for Master Datastore 2 on Host rac2: RUNNING
Monitor Process for Active datastore:RUNNING on Host rac2
Monitor Process for Standby datastore:RUNNING on Host rac2
2.Status of Datastores comprising the cluster
Master Datastore 1:
Host:RAC1
Status:UNAVAILABLE
State:UNKNOWN
Master Datastore 2:
Host:rac2
Status:AVAILABLE
State:ACTIVE
====================================================================
The cluster containing the replicated DSN is offline
Следовательно, Oracle Clusterware перевело узел rac2 из состояния «Standby» в состояние «Active», и пользователи могут продолжить работу на узле rac2. Также можно заметить, что узел rac1 не доступен, так как он перезагружается. После завершения данного процесса, ситуация принимает следующий вид.
[root@rac2 bin]# ./ttCWAdmin -status
TimesTen Cluster status report as of Tue Sep 14 20:49:16 2010
====================================================================
TimesTen daemon monitors:
Host:RAC1 Status: online
Host:RAC2 Status: online
====================================================================
====================================================================
TimesTen Cluster agents
Host:RAC1 Status: online
Host:RAC2 Status: online
====================================================================
Status of Cluster related to DSN HA_DS:
====================================================================
1. Status of Cluster monitoring components:
Monitor Process for Master Datastore 1 on Host rac1: RUNNING
Monitor Process for Master Datastore 2 on Host rac2: RUNNING
Monitor Process for Active datastore:RUNNING on Host rac2
Monitor Process for Standby datastore:RUNNING on Host rac1
2.Status of Datastores comprising the cluster
Master Datastore 1:
Host:rac1
Status:AVAILABLE
State:STANDBY
Master Datastore 2:
Host:rac2
Status:AVAILABLE
State:ACTIVE
====================================================================
The cluster containing the replicated DSN is online
Кроме этого, можно делать переключения ролей между узлами.
[root@rac2 bin]# ./ttCWAdmin -switch -dsn ha_ds
Successful connection with crs clusterware stack
Swithing Active/Standby roles for the scheme of DSN HA_DS
Current active host rac2
Current standby host rac1
TimesTen Cluster is starting
Active standby roles are switched successfully
[root@rac2 bin]# ./ttCWAdmin -status
TimesTen Cluster status report as of Tue Sep 14 20:52:07 2010
====================================================================
TimesTen daemon monitors:
Host:RAC1 Status: online
Host:RAC2 Status: online
====================================================================
====================================================================
TimesTen Cluster agents
Host:RAC1 Status: online
Host:RAC2 Status: online
====================================================================
Status of Cluster related to DSN HA_DS:
====================================================================
1. Status of Cluster monitoring components:
Monitor Process for Master Datastore 1 on Host rac1: RUNNING
Monitor Process for Master Datastore 2 on Host rac2: RUNNING
Monitor Process for Active datastore:RUNNING on Host rac1
Monitor Process for Standby datastore:RUNNING on Host rac2
2.Status of Datastores comprising the cluster
Master Datastore 1:
Host:rac1
Status:AVAILABLE
State:ACTIVE
Master Datastore 2:
Host:rac2
Status:AVAILABLE
State:STANDBY
====================================================================
The cluster containing the replicated DSN is online
Следовательно, мы получили достаточно надежную и работающую конфигурацию с использованием Oracle TimesTen.
Заключение
В версии 7.0.5, Oracle TimesTen имел возможность создания active-standby pair репликации, но всю автоматизацию процесса обработки сбоя узла нужно было писать вручную или реализовывать на уровне приложения, что, согласитесь, не очень удобно. В новой версии 11.2.1, для этого необходимо только выполнить несколько команд, что существенно облегчает жизнь разработчикам и администратором данного программного обеспечения.
Литература
Назад Содержание