Como não fazer besteira em ambientes RAC

Olá pessoal, hoje irei mostrar como evitar que você cometa um erro em ambientes cluster.

Sabe aqueles dias em que você não lembra exatamente qual o comando para parar o resource X ou o que vai acontecer se você rodar o comando XYZ? Geralmente a gente sempre procura na documentação e/ou sites com exemplos do que aquele comando ou resource faz e qual seria o barulho que ele iria fazer se cometêssemos um equívoco.

Na versão 12c foi introduzido duas novas options para o CRSCTL e o SRVCTL, são elas o EVAL e o PREDICT respectivamente.

Abaixo segue o que cada uma delas faz:

[root@rac01 ~]# crsctl eval delete server rac01

Stage Group 1:

--------------------------------------------------------------------------------

Stage Number    Required        Action

--------------------------------------------------------------------------------

     1              Y           Resource 'ora.ASMNET1LSNR_ASM.lsnr' (rac01) will

                                be in state [OFFLINE]

                    Y           Resource 'ora.CONFIG.dg' (rac01) will be in

                                state [OFFLINE]

                    Y           Resource 'ora.DATA.dg' (rac01) will be in state

                                [OFFLINE]

                    Y           Resource 'ora.FRA.dg' (rac01) will be in state

                                [OFFLINE]

                    Y           Resource 'ora.LISTENER.lsnr' (rac01) will be in

                                state [OFFLINE]

                    Y           Resource 'ora.LISTENER_SCAN1.lsnr' (1/1) will be

                                in state [OFFLINE]

                    Y           Resource 'ora.LISTENER_SCAN2.lsnr' (1/1) will be

                                in state [OFFLINE]

                    Y           Resource 'ora.LISTENER_SCAN3.lsnr' (1/1) will be

                                in state [OFFLINE]

                    Y           Resource 'ora.asm' (3/1) will be in state

                                [OFFLINE]

                    Y           Resource 'ora.cvu' (1/1) will be in state

                                [OFFLINE]

                    Y           Resource 'ora.gns.vip' (1/1) will be in state

                                [OFFLINE]

                    Y           Resource 'ora.net1.network' (rac01) will be in

                                state [OFFLINE]

                    Y           Resource 'ora.oc4j' (1/1) will be in state

                                [OFFLINE]

                    Y           Resource 'ora.ons' (rac01) will be in state

                                [OFFLINE]

                    Y           Resource 'ora.orcl.db' (2/1) will be in state

                                [OFFLINE]

                    Y           Resource 'ora.orcl.gabriel.svc' (1/1) will be in

                                state [OFFLINE]

                    Y           Resource 'ora.orcl.olap.svc' (1/1) will be in

                                state [OFFLINE]

                    Y           Resource 'ora.orcl.olap_test.svc' (1/1) will be

                                in state [OFFLINE]

                    Y           Resource 'ora.orcl.oltp.svc' (1/1) will be in

                                state [OFFLINE]

                    Y           Resource 'ora.rac01.vip' (1/1) will be in state

                                [OFFLINE]

                    Y           Resource 'ora.rac02.vip' (1/1) will be in state

                                [OFFLINE]

                    Y           Resource 'ora.rac03.vip' (1/1) will be in state

                                [OFFLINE]

                    Y           Resource 'ora.scan1.vip' (1/1) will be in state

                                [OFFLINE]

                    Y           Resource 'ora.scan2.vip' (1/1) will be in state

                                [OFFLINE]

                    Y           Resource 'ora.scan3.vip' (1/1) will be in state

                                [OFFLINE]

                    Y           Server 'rac01' will be removed from pools

                                [Generic ora.ORCL ora.ORCL_GABRIEL ora.ORCL_OLAP

                                ora.ORCL_OLAP_TEST ora.ORCL_OLTP]

--------------------------------------------------------------------------------

[root@rac01 ~]#

O comando EVAL no CRSCTL é a abreviação para EVALUATE que em uma tradução literal seria calcule, avalie, estime o que esse comando faria. No exemplo acima eu verifique o que aconteceria se eu deletasse o nó 1 do meu cluster.

Já no SRVCTL o comando predict é, ao pé da letra, o predizer, prever o que aconteceria se eu executasse um comando, por exemplo:

[oracle@rac01 ~]$ srvctl predict database -d orcl -v

Database orcl will be stopped on node rac01

Service gabriel will be stopped on node rac01

Service olap will be stopped on node rac01

Service olap_test will be stopped on node rac01

Service oltp will be stopped on node rac01

[oracle@rac01 ~]$ srvctl predict listener -n rac01

Listener LISTENER will be stopped

[oracle@rac01 ~]$ srvctl predict scan -scannumber 1

VIP scan1 will be stopped

Listener LISTENER_SCAN1 will be stopped

Você também pode usar a option eval no srvctl, mas você precisa usar o policy-managed database configurado senão você sempre receberá o erro PRKO-2712.

[oracle@rac01 ~]$ srvctl stop database -db orcl -eval

PRKO-2712 : Administrator-managed database orcl is not supported with -eval option

Para isso efetuei o seguinte procedimento:

[oracle@rac01 ~]$ srvctl config database -d orcl

Database unique name: ORCL

Database name: ORCL

Oracle home: /u01/app/oracle/product/12.1.0.2/dbhome_1

Oracle user: oracle

Spfile: +DATA/ORCL/PARAMETERFILE/spfile.273.891037069

Password file: +DATA/ORCL/PASSWORD/pwdorcl.256.891036345

Domain:

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC

Server pools: (não existe nenhum)

Disk Groups: DATA,FRA

Mount point paths:

Services: GABRIEL,OLAP,OLAP_TEST,OLTP

Type: RAC

Start concurrency:

Stop concurrency:

OSDBA group: dba

OSOPER group: oper

Database instances: ORCL1,ORCL2,ORCL3

Configured nodes: rac01,rac02,rac03

Database is administrator managed

[oracle@rac01 ~]$ srvctl add srvpool -g TESTSRVLPOOL -l 2 -u 2

No nó 2 (ou quantos nós o seu cluter possuir)

[oracle@rac02 ~]$ srvctl modify database -d orcl -g TESTSRVLPOOL -f

[oracle@rac02 ~]$ srvctl config database -d orcl

Database unique name: ORCL

Database name: ORCL

Oracle home: /u01/app/oracle/product/12.1.0.2/dbhome_1

Oracle user: oracle

Spfile: +DATA/ORCL/PARAMETERFILE/spfile.273.891037069

Password file: +DATA/ORCL/PASSWORD/pwdorcl.256.891036345

Domain:

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC

Server pools: TESTSRVLPOOL

Disk Groups: DATA,FRA

Mount point paths:

Services: GABRIEL,OLAP,OLAP_TEST,OLTP

Type: RAC

Start concurrency:

Stop concurrency:

OSDBA group: dba

OSOPER group: oper

Database instances:

Configured nodes:

Database is policy managed

Faça o teste:

[oracle@rac01 ~]$ srvctl stop database -db orcl -eval

Service gabriel will be stopped on node rac01

Service olap will be stopped on node rac01

Service olap_test will be stopped on node rac01

Service oltp will be stopped on node rac01

Database orcl will be stopped on node rac01

[oracle@rac01 ~]$ srvctl start database -db orcl -eval

Resource ora.gns will be started on node rac02

Database orcl will be started on node rac02

Agora, sempre que você tiver uma dúvida do que algum comando do crsctl ou srvctl pode causar no seu ambiente já sabe como não fazer besteira.

Espero ter ajudado, até logo.

Referências

https://bit.ly/2ZjfHdc

https://bit.ly/2PkFyNo

https://bit.ly/2L0Z0ub