Goodus 기술노트 [36 회 ] 11g R1 Clusterware 를이용한 Oracle H/A 구성 Author 유광복, 조연철, 백순성 Creation Date 2008-11-31 Last Updated 2008-12-03 Version 1.0 Copyright(C) 2004 Goodus Inc. All Rights Reserved Version 변경일자 변경자 ( 작성자 ) 주요내용 1 2008-12-03 유광복, 조연철, 백순성 문서최초작성 2 3
Contents 1.1. Oracle Clusterware...3 1.1.1. Oracle Clusterware 기본동작... 3 1.1.2. 10g Release 2 is Protect 3 rd party Applications... 3 1.2. The H/A Framework...3 1.2.1. Shared Resources... 3 1.2.2. 4 Node configurations... 4 1.2.3. Oracle H/A 기본구성절차... 4 1.2.4. Using the Application Framework... 5 1.3. Oracle H/A 구성...6 1.3.1. 환경설정... 6 1.3.2. Create an VIP(RAC VIP)... 7 1.3.3. Create an action Program... 7 1.3.4. Create an application Profile... 8 1.3.5. create an application profile... 8 1.3.6. Set the permission on your application... 9 1.3.7. Check the H/A resource... 9 1.4. Oracle H/A 운용... 10 1.4.1. VIP Start... 10 1.4.2. Mount Start... 10 1.4.3. Database Start... 11 1.4.4. Listener Start... 11 1.4.5. Listener, Database, Mount, VIP STOP... 12 1.5. H/A Fail-Over Test... 13 1.5.1. Listener Process kill... 13 1.5.2. Instance Abort... 13 1.5.3. Oracle engine, Data Filesystem Fail... 14 1.5.4. System Halt... 14 1.6. 참고사항... 16 1.6.1. crs_profile 명령어 Arguments (1.3.4 절참조 )... 16 1.6.2. Sampla Script(1.3.4 절참조 )... 16-2 -
1.1. Oracle Clusterware 1.1.1. Oracle Clusterware 기본동작 kill -9 LGWR Process Restart Automatically kill -9 listener PID Restart Automatically kill oracle.exe by Windows Task Manager Restart Automatically kill tnslsnr.exe by Windows Task Manager Restart Automatically When a Node dies VIP fails over to a different node 1.1.2. 10g Release 2 is Protect 3 rd party Applications Oracle Clusterware 를사용하여 Single Instance 환경의 HA 기능도제공하며, Single Node / Local FileSystem 을 ASM 또는 Cluster FileSystem 인 OCFS 등으로전환하여 High Availability 기능을이용할수있다. 10g R1 까지지원되지않던 Non-Oracle Application 의 Failure Protect 기능이 10g R2 부터가능해졌으 므로본문서는위의기능을기반으로 Test 하였다. 1.2. The H/A Framework 오라클에서제공하는고가용성솔루션은일반적으로 RAC 를의미한다. 이는최소두개 System 을기반으로 1 개의 Databaes 를노드개수만큼의인스턴스에서서비스를할수있는장점을가지고있다. 즉특정시스템에서장애가발생해도남아있는시스템에서서비스를계속수행하기때문에무중단서비스를구현이가능하다. H/A 기반은 Active Standby 구조로고가용성솔루션을제공한다. 9i 에서는 OS Vender Cluster 를기반으로만구현이가능하였는데 10g Clusterware 에서그기능을완벽하게수행할수있다. 아래문서는서로다른두개의 Database 구성하여각각 Active Standby Database 를구성을하고실제 failover 발생시어떻게지속적으로서비스수행이가능한지를구현하였다. H/A 는 RAC 에비해서 system fault 가발생하면 service down 이조금발생함을알려드립니다. 1.2.1. Shared Resources - A common disks : OCR & Vote for Oracle clusterware system files - A common Network interconnect - Same OS - 3 -
1.2.2. 4 Node configurations - Node 1 : Running Oracle Instance & Clusterware, Protecting Application A - Node 2 : Running Oracle Clusterware, Protecting Application B - Node 3 : Running Oracle Clusterware - Node 4 : Running Oracle Clusterware, Protecting Application C & D 1.2.3. Oracle H/A 기본구성절차 Hardware 구성및 OS 구성은 10g RAC 설치와동일하게이뤄지며 Vendor Clusterware 없이구현이가능합니다. 1) install Oracle S/W Only into a new Oracle Clusterware HOME on the 2 nd Node 2) Install Cluster Filesystem both nodes 3) Modify Oracle Configurations - orapwd - init<sid>.ora - listener.ora, tnsnames.ora 4) Create / Tegister / Start / Relocate Resources - $ORA_CRS_HOME/crs/public - 4 -
1.2.4. Using the Application Framework 1) Create an VIP - required if the application is access via network clients 2) Create an Action Program - Oracle Clusterware to start, stop & query the status check - C, java or 기타 scripting language - http://otn.oracle/com/rac => RAC sample code => 3) Create an Application Profile - Describes the process and limits to protect 4) Register the Application - Register the Application Profile with Oracle Clusterware 5) Set the permission on your Application - 5 -
1.3. Oracle H/A 구성 1.3.1. 환경설정 Node 1 Node 2 Hostname goodus1 goodus2 61.250.99.232 goodus1 loghost 61.250.99.233 goodus2 61.250.99.233 goodus2 loghost 61.250.99.232 goodus1 /etc/hosts 61.250.99.234 goodus1-vip 61.250.99.236 goodus2-vip 61.250.99.234 goodus1-vip 61.250.99.236 goodus2-vip 172.16.0.129 goodus1-priv 172.16.0.130 goodus2-priv 172.16.0.129 goodus1-priv 172.16.0.130 goodus2-priv CRS, RDBMS user oracle, dba oracle, dba CRS_HOME /crs/app/oracle/product/11/crs /crs/app/oracle/product/11/crs RDBMS_HOME /oracle1/app/oracle/product/11/db /oracle2/app/oracle/product/11/db ORACLE_SID goodus1 goodus2 Vote disk Ocr disk /dev/rdsk/c1t10d0s3 /dev/rdsk/c1t10d0s4 /dev/rdsk/c1t10d0s5 /dev/rdsk/c1t10d0s0 /dev/rdsk/c1t10d0s1-6 -
1.3.2. Create an VIP(RAC VIP) 10g CRS 상태의 VIP 는 Oracle 에서서비스하는 IP 이다. 즉 client 가 listener 를통해서접속하는 IP 임. srvctl add nodeapps -n goodus1 -A goodus1-vip/255.255.255.0/hme0 srvctl add nodeapps -n goodus2 -A goodus2-vip/255.255.255.0/hme0 crsstat ora.goodus1.gsd OFFLINE OFFLINE ora.goodus1.ons OFFLINE OFFLINE ora.goodus1.vip OFFLINE OFFLINE ora.goodus2.gsd OFFLINE OFFLINE ora.goodus2.ons OFFLINE OFFLINE ora.goodus2.vip OFFLINE OFFLINE 아래 GSD, ONS 는 H/A 구성에서불필요함으로 OCR 정보에서삭제한다. $ crs_unregister ora.goodus1.gsd $ crs_unregister ora.goodus1.ons $ crs_unregister ora.goodus2.gsd $ crs_unregister ora.goodus2.ons crsstat ora.goodus1.vip OFFLINE OFFLINE ora.goodus2.vip OFFLINE OFFLINE 1.3.3. Create an action Program cd $ORA_CRS_HOME/crs/public ls -al total 44 drwxrwxrwt 2 oracle dba 512 Nov 4 16:35. drwxr-xr-x 14 root dba 512 Nov 5 19:36.. -rwxrwxrwx 1 oracle dba 1691 Nov 5 14:35 action_db1.pl -rwxrwxrwx 1 oracle dba 1691 Nov 5 14:35 action_db2.pl -rwxrwxrwx 1 oracle dba 1654 Nov 5 14:35 action_listener1.pl -rwxrwxrwx 1 oracle dba 1654 Nov 5 14:35 action_listener2.pl -rwxrwxrwx 1 oracle dba 1752 Nov 5 14:35 action_mount1.pl - 7 -
-rwxrwxrwx 1 oracle dba 1773 Nov 5 14:35 action_mount2.pl => 위파일을첨부된파일로.pl 확장자로등록해야함 start, stop, check 의 script 를정의합니다. (1.6.2 절참조 ) 1.3.4. Create an application Profile mount (/oracle, /oradata) : 모니터링할 file system list db : 모니터링할 database listener : 모니터링할 listener clusterware 가인식하고 ocr 정보에등록하는포맷형식으로 cap 파일을생성함. crs_profile -create mount1 -t application -r ora.goodus1.vip -a /crs/app/oracle/product/11/crs/crs/public/action_mount1.pl -o ci=60,ra=5 crs_profile -create db1 -t application -r mount1 -a /crs/app/oracle/product/11/crs/crs/public/action_db1.pl -o ci=60,ra=5 crs_profile -create listener1 -t application -r ora.goodus1.vip -a /crs/app/oracle/product/11/crs/crs/public/action_listener1 crs_profile -create mount2 -t application -r ora.goodus2.vip -a /crs/app/oracle/product/11/crs/crs/public/action_mount2.pl -o ci=60,ra=5 crs_profile -create db2 -t application -r mount2 -a /crs/app/oracle/product/11/crs/crs/public/action_db2.pl -o ci=60,ra=5 crs_profile -create listener2 -t application -r ora.goodus2.vip -a /crs/app/oracle/product/11/crs/crs/public/action_listener2 1.3.5. create an application profile - action program 을등록하면아래디렉토리에 cap 파일이생성됨 cd $ORA_CRS_HOME/crs/profile ls al -rw-r--r-- 1 root root 773 Nov 5 17:48 db1.cap - 8 -
-rw-r--r-- 1 root root 773 Nov 5 17:50 db2.cap -rw-r--r-- 1 root root 800 Nov 5 17:49 listener1.cap -rw-r--r-- 1 root root 800 Nov 5 17:50 listener2.cap -rw-r--r-- 1 root root 791 Nov 5 17:48 mount1.cap -rw-r--r-- 1 root root 791 Nov 5 17:50 mount2.cap crs_register mount1 crs_register db1 crs_register listener1 crs_register mount2 crs_register db2 crs_register listener2 ** 등록이완료되면다른노드로 cap, pl 파일을 copy 를해야함 ( $ORA_CRS_HOME/crs/profile, $ORA_CRS_HOME/crs/public) Clusterware 의 OCR device 에 crs 가모니터링하고 fail 이발생하면 restart 또는 failover 를수행할 resource 를등록한다. 1.3.6. Set the permission on your application action program 을수행할 user 를 oracle user 로변경 crs_setperm mount1 -u user:oracle:r-x crs_setperm db1 -u user:oracle:r-x crs_setperm listener1 -u user:oracle:r-x crs_setperm mount2 -u user:oracle:r-x crs_setperm db2 -u user:oracle:r-x crs_setperm listener2 -u user:oracle:r-x 1.3.7. Check the H/A resource crsstat db1 OFFLINE OFFLINE db2 OFFLINE OFFLINE - 9 -
listener1 OFFLINE OFFLINE listener2 OFFLINE OFFLINE mount1 OFFLINE OFFLINE mount2 OFFLINE OFFLINE ora.goodus1.vip OFFLINE OFFLINE ora.goodus2.vip OFFLINE OFFLINE 1.4. Oracle H/A 운용 1.4.1. VIP Start ora.goodus1.vip OFFLINE OFFLINE $ ifconfig -a hme0: flags=1000843<up,broadcast,running,multicast,ipv4> mtu 1500 index 3 inet 61.250.99.232 netmask ffffff00 broadcast 61.250.99.255 $ crs_start ora.goodus1.vip Attempting to start `ora.goodus1.vip` on member `goodus1` Start of `ora.goodus1.vip` on member `goodus1` succeeded. $ ifconfig -a hme0: flags=1000843<up,broadcast,running,multicast,ipv4> mtu 1500 index 3 inet 61.250.99.232 netmask ffffff00 broadcast 61.250.99.255 hme0:1: flags=1040843<up,broadcast,running,multicast,deprecated,ipv4> mtu 1500 index 3 inet 61.250.99.234 netmask ffffff00 broadcast 61.250.99.255.. ora.goodus1.vip ONLINE ONLINE on goodus1 1.4.2. Mount Start mount1 OFFLINE OFFLINE $ df k grep ora $ crs_start mount1 Attempting to start `mount1` on member `goodus1` Start of `mount1` on member `goodus1` succeeded - 10 -
$ df -k grep ora /dev/dsk/c1t1d0s0 24696312 847826 23601523 4% /oradata1 /dev/dsk/c1t1d0s7 10327834 4526651 5697905 45% /oracle1 db1 OFFLINE OFFLINE db2 OFFLINE OFFLINE listener1 OFFLINE OFFLINE listener2 OFFLINE OFFLINE mount1 ONLINE ONLINE on goodus1 mount2 OFFLINE OFFLINE ora.goodus1.vip ONLINE ONLINE on goodus1 ora.goodus2.vip OFFLINE OFFLINE 1.4.3. Database Start db1 OFFLINE OFFLINE $ ps ef grep smon $ crs_start db1 Attempting to start `mount1` on member `goodus1` Start of `mount1` on member `goodus1` succeeded $ ps -ef grep smon oracle 26126 1 1 10:09:05? 0:00 ora_smon_goodus1 oracle 26367 18158 0 10:09:28 pts/1 0:00 grep smon db1 ONLINE ONLINE on goodus1 db2 OFFLINE OFFLINE listener1 OFFLINE OFFLINE listener2 OFFLINE OFFLINE mount1 ONLINE ONLINE on goodus1 mount2 OFFLINE OFFLINE ora.goodus1.vip ONLINE ONLINE on goodus1 ora.goodus2.vip OFFLINE OFFLINE 1.4.4. Listener Start listener1 OFFLINE OFFLINE $ ps ef grep tns - 11 -
$ crs_start listener1 Attempting to start `listener1` on member `goodus1` Start of `listener1` on member `goodus1` succeeded. $ ps -ef grep tns oracle 27824 1 1 10:11:46? 0:00 /oracle1/app/oracle/product/11/db/bin/tnslsnr LISTENER1 -inherit oracle 26367 18158 0 10:09:28 pts/1 0:00 grep smon db1 ONLINE ONLINE on goodus1 db2 OFFLINE OFFLINE listener1 ONLINE ONLINE on goodus1 listener2 OFFLINE OFFLINE mount1 ONLINE ONLINE on goodus1 mount2 OFFLINE OFFLINE ora.goodus1.vip ONLINE ONLINE on goodus1 ora.goodus2.vip OFFLINE OFFLINE 1.4.5. Listener, Database, Mount, VIP STOP $ crs_stop listener1 Attempting to stop `listener1` on member `goodus1` Stop of `listener1` on member `goodus1` succeeded. $ crs_stop db1 Attempting to stop `db1` on member `goodus1` Stop of `db1` on member `goodus1` succeeded. $ crs_stop mount1 Attempting to stop `mount1` on member `goodus1` Stop of `mount1` on member `goodus1` succeeded. $ crs_stop ora.goodus1.vip Attempting to stop `ora.goodus1.vip` on member `goodus1` Stop of `ora.goodus1.vip` on member `goodus1` succeeded. db1 OFFLINE OFFLINE db2 OFFLINE OFFLINE listener1 OFFLINE OFFLINE listener2 OFFLINE OFFLINE mount1 OFFLINE OFFLINE mount2 OFFLINE OFFLINE ora.goodus1.vip OFFLINE OFFLINE ora.goodus2.vip OFFLINE OFFLINE - 12 -
1.5. H/A Fail-Over Test 1.5.1. Listener Process kill $ ps ef grep tns oracle 27824 1 0 10:11:46? 0:00 /oracle1/app/oracle/product/11/db/bin/tnslsnr LISTENER1 inherit $ kill -9 27824 while true > do > ps -ef grep tns > sleep 2 > echo "===" > done root 11647 6185 0 18:45:20 pts/4 0:00 grep tns === root 11666 6185 0 18:45:22 pts/4 0:00 grep tns === root 11702 6185 0 18:45:24 pts/4 0:00 grep tns === oracle 11724 1 1 18:45:25? 0:00 /oracle1/app/oracle/product/11/db/bin/tnslsnr LISTENER1 inherit ** Check_interval 이 60 으로설정되어있으므로최대 60 초이내에 check 하여해당프로세스가 종료되었으면 crsd daemon 이 start 함 1.5.2. Instance Abort $ ps ef grep smon oracle 26126 1 0 10:09:05? 0:01 ora_smon_goodus1 $ kill -9 26126 while true > do > ps -ef grep smon > sleep 2 > echo "===" > done === root 12861 6185 0 18:47:04 pts/4 0:00 grep smon === root 12930 6185 0 18:47:08 pts/4 0:00 grep smon === root 12957 6185 0 18:47:10 pts/4 0:00 grep smon oracle 12940 1 1 18:47:08? 0:00 ora_smon_goodus1 ** Check_interval 이 60 으로설정되어있으므로최대 60 초이내에 check 하여해당프로세스가 종료되었으면 crsd daemon 이 start 함 - 13 -
1.5.3. Oracle engine, Data Filesystem Fail fuser -ck /oradata1 /oradata1: 13616o 13041o 13002o 13000o 12944o 12942o 12940o 12938o 12936o 12934o 12913o umount /oradata1 while true > do > df k grep ora > sleep 2 > echo "===" > done ==== ==== ==== /dev/dsk/c1t1d0s0 24696312 847826 23601523 4% /oradata1 /dev/dsk/c1t1d0s7 10327834 4526081 5698475 45% /oracle1 ** Check_interval 이 60 으로설정되어있으므로최대 60 초이내에 check 하여파일시스템마운트가 되어있지않으면 crsd daemon 마운트시킴 ** db, listener 까지 start 함 1.5.4. System Halt db1 ONLINE ONLINE on goodus1 db2 ONLINE ONLINE on goodus2 listener1 ONLINE ONLINE on goodus1 listener2 ONLINE ONLINE on goodus2 mount1 ONLINE ONLINE on goodus1 mount2 ONLINE ONLINE on goodus2 ora.goodus1.vip ONLINE ONLINE on goodus1 ora.goodus2.vip ONLINE ONLINE on goodus2 halt (2 번노드를강제종료함 ) db1 ONLINE ONLINE on goodus1 db2 ONLINE OFFLINE - 14 -
listener1 ONLINE ONLINE on goodus1 listener2 ONLINE OFFLINE mount1 ONLINE ONLINE on goodus1 mount2 ONLINE OFFLINE ora.goodus1.vip ONLINE ONLINE on goodus1 ora.goodus2.vip ONLINE OFFLINE db1 ONLINE ONLINE on goodus1 db2 ONLINE ONLINE on goodus1 listener1 ONLINE ONLINE on goodus1 listener2 ONLINE ONLINE on goodus1 mount1 ONLINE ONLINE on goodus1 mount2 ONLINE ONLINE on goodus1 ora.goodus1.vip ONLINE ONLINE on goodus1 ora.goodus2.vip ONLINE ONLINE on goodus1 $ ps -ef grep smon oracle 4064 1 0 10:21:33? 0:01 ora_smon_goodus1 oracle 10427 1 1 10:31:34? 0:01 ora_smon_goodus2 oracle 10985 18158 0 10:32:13 pts/1 0:00 grep smon $ ps -ef grep tns oracle 27824 1 0 10:11:46? 0:00 /oracle1/app/oracle/product/11/db/bin/tnslsnr LISTENER1 -inherit oracle 10837 1 1 10:32:02? 0:00 /oracle2/app/oracle/product/11/db/bin/tnslsnr LISTENER2 -inherit oracle 11002 18158 0 10:32:14 pts/1 0:00 grep tns $ df -k grep ora /dev/dsk/c1t1d0s0 24696312 847826 23601523 4% /oradata1 /dev/dsk/c1t1d0s7 10327834 4526765 5697791 45% /oracle1 /dev/dsk/c1t5d0s0 24696312 848162 23601187 4% /oradata2 /dev/dsk/c1t5d0s7 10327834 4312445 5912111 43% /oracle2 $ ifconfig a... hme0: flags=1000843<up,broadcast,running,multicast,ipv4> mtu 1500 index 3 inet 61.250.99.232 netmask ffffff00 broadcast 61.250.99.255 hme0:1: flags=1040843<up,broadcast,running,multicast,deprecated,ipv4> mtu 1500 index 3 inet 61.250.99.234 netmask ffffff00 broadcast 61.250.99.255 hme0:2: flags=1040843<up,broadcast,running,multicast,deprecated,ipv4> mtu 1500 index 3 inet 61.250.99.236 netmask ffffff00 broadcast 61.250.99.255 ** Node 2 번을강제종료되면 2 번노드에실행되고있는 application resource 는 Node 1 번으로 failover 되면서계속적으로서비스를수행함. ** Node 2 번이정상적으로부팅이되면수동으로 failback 을수행해야함. - 15 -
AUTO_START=restore => 0 으로수정해야함 1.6. 참고사항 1.6.1. crs_profile 명령어 Arguments (1.3.4 절참조 ) Name Value Description -create myapp Name of the application as stored inside the OCR -t application Type of OCR entry (must be Application) -d Oracle Sample Long name of the application -r myvip Name of the Oracle Clusterware managed resource that must be in status ONLINE for our application to start. The VIP -a /tmp/myappcheck Name of the action program used to start, stop and check the application -o See following entries in tables ci=5 ra=60 Check Interval Restart Attempts 1.6.2. Sampla Script(1.3.4 절참조 ) 1) action_mount.pl -- action_mount.pl!/usr/bin/perl Copyright (c) 2002, 2006, Oracle. All rights reserved. action_db.pl This perl script is the action script for start / stop / check the Oracle Instance in a cold failover configuration. NAME action_db.pl DESCRIPTION NOTES Usage: rknapp 05/22/06 - Creation Environment settings, please modify and adapt this $ORA_CRS_HOME = "/crs/app/oracle/product/11/crs"; $CRS_HOME_BIN = "/crs/app/oracle/product/11/crs/bin"; $CRS_HOME_SCRIPT = "/crs/app/oracle/product/11/crs/crs/public"; $ORACLE_HOME_BIN = "/oracle1/app/oracle/product/11/db/bin"; $ORACLE_HOME = "/oracle1/app/oracle/product/11/db"; $ORA_SID = "goodus1"; - 16 -
$ORA_USER = "oracle"; $PASSWD = "tnstjd"; if ($ARGV!= 0 ) { print "usage: start stop check required n"; exit; $command = $ARGV[0]; Database start stop check Start File system if ($command eq "start" ) { system (" su - root tnstjd /usr/sbin/mount /dev/dsk/c1t1d0s0 /oradata1 /usr/sbin/mount /dev/dsk/c1t1d0s7 /oracle1 " ); Stop File system if ($command eq "stop" ) { system (" su - root tnstjd /usr/sbin/fuser -ck /oradata1 /usr/sbin/fuser -ck /oracle1 /usr/sbin/umount /oradata1 /usr/sbin/umount /oracle1 " ); Check filesystem if ($command eq "check" ) { check(); sub check { my($check_proc,$process) = @_; $mount_ora = "/oracle1"; $mount_oradata = "/oradata1"; $check_ora = qx(df -k grep oracle1 awk '{print $6'); $check_oradata = qx(df -k grep oradata1 awk '{print $6'); chomp($check_ora); chomp($check_oradata); if (($mount_ora eq $check_ora) && ($mount_oradata eq $check_oradata)) { exit 0; else { exit 1; - 17 -
2) action_listener.pl!/usr/bin/perl!/usr/bin/perl Copyright (c) 2002, 2006, Oracle. All rights reserved. action_listener.pl This perl script is the action script for start / stop / check the Oracle Listener in a cold failover configuration. NAME action_listener.pl DESCRIPTION NOTES Usage: rknapp 05/22/06 - Creation Environment settings, please modify and adapt this $ORA_CRS_HOME = "/crs/app/oracle/product/11/crs"; $CRS_HOME_BIN = "/crs/app/oracle/product/11/crs/bin"; $CRS_HOME_SCRIPT = "/crs/app/oracle/product/11/crs/crs/public"; $ORACLE_HOME_BIN = "/oracle1/app/oracle/product/11/db/bin"; $ORACLE_HOME = "/oracle1/app/oracle/product/11/db"; $ORA_SID = "goodus1"; $ORA_USER = "oracle"; if ($ARGV!= 0 ) { print "usage: start stop check required n"; exit; $command = $ARGV[0]; Listener start / stop check start listener if ($command eq "start") { system (" su - $ORA_USER << EOF export ORACLE_HOME=$ORACLE_HOME $ORACLE_HOME_BIN/lsnrctl start LISTENER1 EOF"); stop listener if ($command eq "stop") { system (" su - $ORA_USER << EOF export ORACLE_HOME=$ORACLE_HOME $ORACLE_HOME_BIN/lsnrctl stop LISTENER1-18 -
EOF"); check listener if ($command eq "check") { check_listener(); sub check_listener { my($check_proc_listener,$process_listener) = @_; $process_listener = "$ORACLE_HOME_BIN/tnslsnr LISTENER1"; $check_proc_listener = qx(ps -aef grep "tnslsnr LISTENER1" grep -v grep awk '{print $8, $9'); chomp($check_proc_listener); if ($process_listener eq $check_proc_listener) { exit 0; else { exit 1; 3) action_db1.pl!/usr/bin/perl Copyright (c) 2002, 2006, Oracle. All rights reserved. action_db.pl This perl script is the action script for start / stop / check the Oracle Instance in a cold failover configuration. NAME action_db.pl DESCRIPTION NOTES Usage: rknapp 05/22/06 - Creation Environment settings, please modify and adapt this $ORA_CRS_HOME = "/crs/app/oracle/product/11/crs"; $CRS_HOME_BIN = "/crs/app/oracle/product/11/crs/bin"; $CRS_HOME_SCRIPT = "/crs/app/oracle/product/11/crs/crs/public"; $ORACLE_HOME_BIN = "/oracle1/app/oracle/product/11/db/bin"; $ORACLE_HOME = "/oracle1/app/oracle/product/11/db"; $ORA_SID = "goodus1"; $ORA_USER = "oracle"; if ($ARGV!= 0 ) { - 19 -
print "usage: start stop check required n"; exit; $command = $ARGV[0]; Database start stop check Start database if ($command eq "start" ) { system (" su - $ORA_USER << EOF export ORACLE_SID=$ORA_SID export ORACLE_HOME=$ORACLE_HOME $ORACLE_HOME/bin/sqlplus /nolog connect / as sysdba startup quit EOF" ); Stop database if ($command eq "stop" ) { system (" su - $ORA_USER << EOF export ORACLE_SID=$ORA_SID export ORACLE_HOME=$ORACLE_HOME $ORACLE_HOME/bin/sqlplus /nolog connect / as sysdba shutdown immediate quit EOF" ); Check database if ($command eq "check" ) { check(); sub check { my($check_proc,$process) = @_; $process = "ora_pmon_$ora_sid"; $check_proc = qx(ps -aef grep ora_pmon_$ora_sid grep -v grep awk '{print $8'); chomp($check_proc); if ($process eq $check_proc) { exit 0; else { exit 1; 4) crs_stat script - 20 -
!/usr/bin/perl!/usr/bin/ksh Sample 10g CRS resource status query script Description: - Returns formatted version of crs_stat -t, in tabular format, with the complete rsc names and filtering keywords - The argument, $RSC_KEY, is optional and if passed to the script, will limit the output to HA resources whose names match $RSC_KEY. Requirements: - $ORA_CRS_HOME should be set in your environment RSC_KEY=$1 QSTAT=-u AWK=/usr/xpg4/bin/awk if not available use /usr/bin/awk Table header:echo "" $AWK 'BEGIN {printf "%-45s %-10s %-18s n", "HA Resource", "Target", "State"; printf "%-45s %-10s %-18s n", "-----------", "------", "-----";' Table body: $ORA_CRS_HOME/bin/crs_stat $QSTAT $AWK 'BEGIN { FS="="; state = 0; $1~/NAME/ && $2~/'$RSC_KEY'/ {appname = $2; state=1; state == 0 {next; $1~/TARGET/ && state == 1 {apptarget = $2; state=2; $1~/STATE/ && state == 2 {appstate = $2; state=3; state == 3 {printf "%-45s %-10s %-18s n", appname, apptarget, appstate; state=0;' - 21 -