No post anterior demonstrei como usar o Fleet Patching and Provisioning para atualizar o Grid Infrastructure em um servidor (Release Update), neste post será demonstrado como realizar o mesmo procedimento com o banco de dados.

O servidor lab01 possui uma instância de banco de dados chamada orcl executando em DB Home 19cRU3:

[oracle@lab01 ~]$ srvctl config database -d orcl
Database unique name: orcl
Database name: orcl
Oracle home: /u01/app/oracle/product/19.3.0.0/db_1
Oracle user: grid
Spfile: +DATA/ORCL/PARAMETERFILE/spfile.294.1079737471
Password file:
Domain: dibiei.com
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Disk Groups: DATA
Services:
OSDBA group:
OSOPER group:
Database instance: orcl

Patches aplicados atualmente no DB Home:

[oracle@lab01 ~]$ $ORACLE_HOME/OPatch/opatch lspatches
29585399;OCW RELEASE UPDATE 19.3.0.0.0 (29585399)
29517242;Database Release Update : 19.3.0.0.190416 (29517242)

OPatch succeeded.

Patches aplicados atualmente no banco de dados:

SQL> select
patch_id,
description,
action,
status,
to_char(action_time,'DD/MM/YYYY HH24:MI:SS') action_date
from dba_registry_sqlpatch r
order by r.action_time;
  2    3    4    5    6    7    8
  PATCH_ID DESCRIPTION                                                  ACTION       STATUS          ACTION_DATE
---------- ------------------------------------------------------------ ------------ --------------- --------------------
  29517242 Database Release Update : 19.3.0.0.190416 (29517242)         APPLY        SUCCESS         04/08/2021 23:03:44

Vou atualizar o banco de dados para a versão 19c Release Update 12 de JUL/2021, uma Working Copy já foi provisionada anteriormente no servidor lab01 com a Imagem do Oracle Database 19cRU12:

[grid@fppserver01 ~]$ rhpctl query workingcopy -workingcopy lab01_wc_db19cR12
fppserver01.dibiei.com: Audit ID: 189
Working copy name: lab01_wc_db19cR12
Image name: db19cR12
Groups configured in the working copy: OSDBA=dba,OSOPER=dba,OSBACKUP=dba,OSDG=dba,OSKM=dba,OSRAC=dba
Owner: oracle@ORACLERESTART_lab01
Site: ORACLERESTART_lab01
Access control: USER:oracle@ORACLERESTART_lab01
Access control: USER:grid@fppserver
Access control: ROLE:GH_WC_ADMIN
Software home path: /u01/app/oracle/product/19.12.0.0/db_1
Storage type: LOCAL
Image Type: ORACLEDBSOFTWARE
Gold image path:
Work path:
Additional patches compared to the image:
Additional bug fixes that are not in the image:
Complete: TRUE

O comando utilizado para aplicar o Release Update no banco de dados é similiar ao processo de aplicar atualização no Grid Infrastructure, no qual fazemos um “move” de um DB Home para o outro.

Utilizamos o comando rhpctl move database, que contém as seguintes opções:

$ rhpctl move database -h

Moves a database from source working copy to the patched working copy.

Usage: rhpctl move database -patchedwc <workingcopy_name>
        {{-sourcewc <workingcopy_name> |
                 -sourcehome <oracle_home_path>
                 [-oraclebase <oraclebase_path>]
                 [-client <cluster_name>]}
         [-dbname <db_name_list> |
                 -excludedblist <db_name_list>]
         [-nonrolling |
                 -forcerolling |
                 -batches <list of batches> |
                 -smartmove
                 [-saf <availability>]
                 [-separate]]
         [-eval]
         [-schedule <timer_value>]
         [-ignoremissingpatches <patch_name1>
                 [,<patch_name2>...]]
         [-ignorewcpatches]
         [-keepplacement]
         [-disconnect
                 [-noreplay]]
         [-drain_timeout <time>]
         [-stopoption <stop option>]
         [-nodatapatch]
         [-targetnode <target_node_name>]
         [-notify
                 [-cc <users_list>]] |
         -continue
         [-skip] |
         -revert |
         -abort}
        [-sudouser <sudo_user_name> -sudopath <sudo_binary_location> |
         -root |
         -cred <cred_name> |
         -auth <plugin_name>
                [-arg1 <name1>:<value1>
                        [-arg2 <name2>:<value2>...]]]
        [-useractiondata <user_action_data>]
        [-dbsinparallel <number_of_instances>]
        [-raconetimeout <timeout>]

    -patchedwc <workingcopy_name>           Name of the new working copy to which the database needs to be moved
    -sourcewc <workingcopy_name>            Name of the old working copy from which the database needs to be moved
    -sourcehome <oracle_home_path>          Source Oracle home path
    -oraclebase <oraclebase_path>           ORACLE_BASE path for provisioning Oracle database home
    -client <cluster_name>                  Client cluster name
    -dbname <db_name_list>                  Comma-separated list of names of databases (DB_UNIQUE_NAME) to be moved
    -excludedblist <db_name_list>           Patch all databases except the specified databases
    -forcerolling                           Force the Oracle home to move in rolling mode
    -nonrolling                             Move the Oracle home in non-rolling mode
    -skipprereq                             skip the pre-req checks and start the database in upgrade mode for patching
    -batches <list_of_batches>              List of batches of nodes in the format: "(Ba),...,(Bz)"
    -smartmove                              Auto-generate the list of batches of nodes and move databases by restarting instances batch after batch
    -saf <availability>                     Service availability factor, the minimum percentage of instances on which a service must remain running during the move
    -separate                               Process batches separately. Move operation pauses for user intervention before continuing with the next batch
    -eval                                   Evaluate without executing the command. For Smart Move, print the auto-generated batches of nodes and sequence of moves
    -ignorewcpatches                        Ignores if the patched working copy is missing some patches which are present in the source path or working copy
    -keepplacement                          Ensure that services of administrator-managed Oracle RAC or Oracle RAC One databases are running on the same instances before and after the move operation
    -disconnect                             Disconnect all sessions before stopping or relocating services
    -noreplay                               Disable session replay during disconnection
    -drain_timeout <session drain time>     Service drain timeout specified in seconds
    -stopoption <stop_option>               Stop option for database: ABORT, IMMEDIATE, NORMAL, TRANSACTIONAL, TRANSACTIONAL_LOCAL
    -nodatapatch                            Indicates that 'datapatch' should not be executed for databases being moved
    -targetnode <node_name>                 Node on which operation needs to be executed
    -notify                                 Send email notification
    -cc <users_list>                        List of users to whom email notifications will be sent, in addition to owner of working copy
    -continue                               Continue restarting databases on the next batch of nodes
    -skip                                   Skip current batch of nodes and restart databases on the next batch of nodes
    -revert                                 Revert to source Oracle home or working copy in case of batch-move or smartmove
    -abort                                  Abort the ongoing 'move' operation
    -sudouser <username>                    perform super user operations as sudo user name
    -sudopath <sudo_binary_path>            location of sudo binary
    -root                                   Use root credentials to access the remote node
    -cred <cred_name>                       Credential name to associate the user/password credentials to access a remote node
    -auth <plugin_name> [<plugin_args>]     Use an authentication plugin to access the remote node
    -useractiondata <user_action_data>      Value to be passed to useractiondata parameter of useraction script
    -schedule { <timer_value> | NOW }       Preferred time to execute the operation. If an absolute timer_value is specified, it should be in ISO-8601 format. For example: 2016-12-21T19:13:17+05. If offset is specified as the timer value, it should be in the format +dd:mm:yy:hh:mm:ss. For example: +02:22:22. If NOW is specified, job will be scheduled immediately.
    -ignoremissingpatches                   Proceed with the move/upgrade even though the specified patches, which are present in the source path or working copy, might be missing from the destination path or working copy
    -dbsinparallel <number_of_instances>    Number of database instances that can be started in parallel on a given node.
    -raconetimeout <timeout>                RAC One Node database relocation timeout in minutes.
    -help [EXISTING_PATCHEDWC|SRCHOME|SINGLEINSTANCEDB|ROLLING|NONROLLING|BATCHES|SMARTMOVE]
                                            Context sensitive options for various use cases. Examples of usage may not include all non-mandatory options.

Neste exemplo vamos usar o seguintes parâmetros:

  • -sourcewc: Indica o nome da Working Copy em que o banco de dados está executando atualmente. Caso esteja rodando em um DB Home que não foi criado pelo FPP, então usamos o parâmetro -sourcehome.
  • -patchedwc: Indica o nome da Working Copy que já está atualizado com o Release Update, a instância do banco de dados será movida para esse novo DB Home.
  • -dbname: Indica o nome do banco de dados que será movido para o DB Home atualizado. Caso o servidor tenha múltiplas instâncias, também pode ser informado uma lista de nomes separados por vírgula.
  • -root: Para indicar o FPP que a operação deve ocorrer através de uma conexão SSH com usuário root.
  • -eval: Usado para executar uma pré validação antes de aplicar o update no banco, isso ajuda a atencipar possíveis problemas durante a operação.

Note que estamos realizando a operação mais básica possível, mas o comando tem várias opções para cenários mais avançados.

Quando a origem é uma Working Copy

Comando utilizado para executar uma pré validação:

rhpctl move database -dbname orcl -sourcewc lab01_wc_db19cR3 -patchedwc lab01_wc_db19cR12 -root -eval

Executando a pré validação (OPICIONAL):

[grid@fppserver01 ~]$ rhpctl move database -dbname orcl -sourcewc lab01_wc_db19cR3 -patchedwc lab01_wc_db19cR12 -root -eval
Enter user "root" password:
fppserver01.dibiei.com: Audit ID: 191
fppserver01.dibiei.com: Evaluation in progress for "move database" ...
fppserver01.dibiei.com: verifying versions of Oracle homes ...
fppserver01.dibiei.com: verifying owners of Oracle homes ...
fppserver01.dibiei.com: verifying groups of Oracle homes ...
fppserver01.dibiei.com: Evaluation finished successfully for "move database".

Aplicando a atualização no banco de dados orcl:

[grid@fppserver01 rhp]$ rhpctl move database -dbname orcl -sourcewc lab01_wc_db19cR3 -patchedwc lab01_wc_db19cR12 -root
Enter user "root" password:
fppserver01.dibiei.com: Audit ID: 194
fppserver01.dibiei.com: verifying versions of Oracle homes ...
fppserver01.dibiei.com: verifying owners of Oracle homes ...
fppserver01.dibiei.com: verifying groups of Oracle homes ...
fppserver01.dibiei.com: starting to move the following databases: "orcl"
fppserver01.dibiei.com: restarting databases: "orcl" ...
lab01: trying datapatch run for orcl, attempt### 1 ###
lab01: datapatch completed successfully for database : orcl
fppserver01.dibiei.com: Completed the 'move database' operation for databases: "orcl"

Verificando o banco de dados orcl no servidor lab01, Oracle Home alterado:

[oracle@lab01 ~]$ srvctl config database -d orcl
Database unique name: orcl
Database name: orcl
Oracle home: /u01/app/oracle/product/19.12.0.0/db_1
Oracle user: oracle
Spfile: +DATA/ORCL/PARAMETERFILE/spfile.294.1079737471
Password file:
Domain: dibiei.com
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Disk Groups: DATA
Services:
OSDBA group:
OSOPER group:
Database instance: orcl

Patches aplicados no banco de dados (datapatch):

SQL&gt; select
patch_id,
description,
action,
status,
to_char(action_time,'DD/MM/YYYY HH24:MI:SS') action_date
from dba_registry_sqlpatch r
order by r.action_time;
  
PATCH_ID DESCRIPTION                                                  ACTION       STATUS          ACTION_DATE
---------- ------------------------------------------------------------ ------------ --------------- --------------------
  29517242 Database Release Update : 19.3.0.0.190416 (29517242)         APPLY        SUCCESS         04/08/2021 23:03:44
  32904851 Database Release Update : 19.12.0.0.210720 (32904851)        APPLY        SUCCESS         05/08/2021 23:11:17

Verificando downtime do banco de dados:

2021-08-05T23:04:53.878189-03:00
Shutting down instance: further logons disabled

2021-08-05T23:05:43.680200-03:00

Completed: ALTER DATABASE OPEN /* db agent *//* {0:0:947} */

De acordo ao horário que o shutdown foi iniciado e o horário que o banco de dados foi aberto novamente, o downtime foi de 50 segundos.

Quando a origem não é uma Working Copy

Quando o banco de dados está executando em um DB Home que não foi provisionado como uma Working Copy, usamos ao parâmetro -oraclehome e o caminho do DB Home.

Neste exemplo estamos movendo o banco de dados “venis” do DB Home 19cRU11 para 19cRU12:

[grid@fppserver01 ~]$ rhpctl move database -dbname venus -sourcehome /u01/app/oracle/product/19.11.0.0/db_1 -patchedwc lab01_wc_db19cR12 -root
Enter user "root" password:
fppserver01.dibiei.com: Audit ID: 239
fppserver01.dibiei.com: verifying versions of Oracle homes ...
fppserver01.dibiei.com: verifying owners of Oracle homes ...
fppserver01.dibiei.com: verifying groups of Oracle homes ...
fppserver01.dibiei.com: starting to move the following databases: "venus"
fppserver01.dibiei.com: restarting databases: "venus" ...
lab01: trying datapatch run for venus, attempt### 1 ###
lab01: datapatch completed successfully for database : venus
fppserver01.dibiei.com: Completed the 'move database' operation for databases: "venus"

Leave a Reply

Discover more from Blog do Dibiei

Subscribe now to keep reading and get access to the full archive.

Continue reading