Oracle eGDB SDE Repo Upgrade Using Oracle Restore Point

1104
0
07-07-2022 12:14 PM
MarceloMarques
Esri Regular Contributor
0 0 1,104

 _________________________________________________________________________________________________

Oracle Enterprise Geodatabase SDE Repository Upgrade using an

Oracle Restore Point to Rollback the changes in case of problems.

Download PDF Version

 _________________________________________________________________________________________________

 _________________________________________________________________________________________________

1. ArcGIS Documentation - Before you upgrade

 

Read the ArcGIS documentation before you attempt to upgrade the geodatabase repository.  

Upgrade a Geodatabase in Oracle - Before you Upgrade

Read the ArcGIS requirements for Oracle to confirm that Esri supports the Oracle and ArcGIS version combination you want to use.

 _________________________________________________________________________________________________

2. Oracle Archiving and Oracle Flashback

 

a. Oracle Archiving must be enabled

b. Oracle Flashkback must be enabled

c. Oracle RMAN Incremental Level 0 ( Full ) Backup must be created

d. Oracle RMAN Incremental Level 1 ( Incremental ) Backup must be created

e. Oracle RMAN archivelog Backup must be created

f. Pluggable Database Logging must be enabled

sqlplus /nolog
SQL> connect /as sysdba
SQL> ALTER SESSION SET CONTAINER = cdb$root;
SQL> SHOW CON_NAME

*******************************************************************************************
SQL> show parameter db_recovery_file_dest

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string +FRA
db_recovery_file_dest_size big integer 100G

*******************************************************************************************
SQL> show parameter undo_retention

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_retention integer 86400                 <== 24 hours

( note: the undo tablespace size needs to be large )
*******************************************************************************************
SQL> show parameter db_flashback_retention_target

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_flashback_retention_target integer 1440               <== default in minutes = 24hours

*******************************************************************************************
SQL> show parameter log_archive_

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1 string LOCATION=USE_DB_RECOVERY_FILE_DEST
log_archive_format string mcs1_log_%r_%t_%s.arc

*******************************************************************************************
SQL> archive log list

Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 3739
Next log sequence to archive 3741
Current log sequence 3741

*******************************************************************************************
SQL> select name,open_mode,log_mode,flashback_on from v$database;

NAME OPEN_MODE LOG_MODE FLASHBACK_ON
--------- -------------------- ------------ ------------------
MCS1 READ WRITE ARCHIVELOG YES

*******************************************************************************************
--Pluggable Database Logging must be enabled
SQL> SELECT * FROM dba_pdbs ORDER BY pdb_name;
--if logging is disabled
SQL> ALTER SESSION SET CONTAINER = cdb$root;
SQL> SHOW CON_NAME
SQL> ALTER PLUGGABLE DATABASE <PDB_NAME> CLOSE IMMEDIATE;
SQL> ALTER PLUGGABLE DATABASE <PDB_NAME> OPEN RESTRICTED;
SQL> ALTER PLUGGABLE DATABASE <PDB_NAME> LOGGING;
SQL> ALTER PLUGGABLE DATABASE <PDB_NAME> CLOSE IMMEDIATE;
SQL> ALTER PLUGGABLE DATABASE <PDB_NAME> OPEN READ WRITE;
SQL> SELECT * FROM dba_pdbs ORDER BY pdb_name;
SQL> SELECT * FROM v$pdbs ORDER BY name;
*******************************************************************************************

_________________________________________________________________________________________________

3. Create the Restore Point

 

sqlplus /nolog
SQL> connect /as sysdba
SQL> ALTER SESSION SET CONTAINER = <PDB_NAME>;
SQL> SHOW CON_NAME

SQL> CREATE RESTORE POINT before_gdb_upgrade GUARANTEE FLASHBACK DATABASE;

SQL> SELECT * FROM V$RESTORE_POINT;

_________________________________________________________________________________________________

4. Check Invalid Objects

 

SQL> ALTER SESSION SET CONTAINER = <PDB_NAME>;
SQL> SHOW CON_NAME
SQL>  SELECT * FROM DBA_OBJECTS
WHERE STATUS!= 'VALID'
ORDER BY OWNER, OBJECT_TYPE, OBJECT_NAME;

_________________________________________________________________________________________________

5. Privileges Required for Geodatabase Upgrade

 

SQL> ALTER SESSION SET CONTAINER = <PDB_NAME>;
SQL> SHOW CON_NAME

SQL> CREATE ROLE GIS_SDE_MASTER;

SQL> GRANT CREATE SESSION,
CREATE TABLE,
CREATE VIEW,
CREATE PROCEDURE,
CREATE SEQUENCE,
CREATE TRIGGER,
CREATE TYPE,
CREATE INDEXTYPE,
CREATE LIBRARY,
CREATE PUBLIC SYNONYM,
DROP PUBLIC SYNONYM,
ADMINISTER DATABASE TRIGGER,
CREATE OPERATOR
TO GIS_SDE_MASTER;

SQL> GRANT SELECT_CATALOG_ROLE TO SDE;
SQL> GRANT SELECT_CATALOG_ROLE TO GIS_SDE_MASTER;

SQL> GRANT EXECUTE ON DBMS_CRYPTO TO GIS_SDE_MASTER;

SQL> GRANT GIS_SDE_MASTER TO SDE;

--Execute privileges on required Oracle builtin package DBMS_CRYPTO
--must be granted directly to the SDE DBA user,
--granting them to a ROLE with execute access is insufficient.
SQL> GRANT EXECUTE ON DBMS_CRYPTO TO SDE;
SQL> GRANT EXECUTE ON DBMS_PIPE TO SDE;
SQL> CREATE ROLE GIS_SDE_MASTER_UPGRADE;

SQL> GRANT CREATE SESSION,
CREATE TABLE,
CREATE PROCEDURE,
CREATE SEQUENCE,
CREATE TRIGGER,
CREATE TYPE,
CREATE LIBRARY,
CREATE PUBLIC SYNONYM,
DROP PUBLIC SYNONYM,
ALTER ANY INDEX,
CREATE ANY INDEX,
DROP ANY INDEX,
CREATE ANY TRIGGER,
CREATE ANY VIEW,
DROP ANY VIEW,
SELECT ANY TABLE,
CREATE OPERATOR,
ADMINISTER DATABASE TRIGGER,
CREATE INDEXTYPE
TO GIS_SDE_MASTER_UPGRADE;

SQL> GRANT GIS_SDE_MASTER_UPGRADE TO SDE;

For more information read - Privileges required for geodatabase creation or upgrade

_________________________________________________________________________________________________

6. Active Connections

Make sure all user connections are closed.

Tip: ArcGIS Pro > Right Click Geodatabase Connection File for the "sde" user > Properties > Database Properties > Connections > Show connected user and locks...

This includes ArcMap, ArcCatalog and ArcGIS Pro.

You will need to ask users to close the applications and/or have the Oracle Database Administrator to kill the user connections.

Also, stop all ArcGIS Server Services that connect to the Enterprise Geodatabase.

Tip: when you open ArcCatalog or ArcGIS Pro to perform the Geodatabase Repository Upgrade make sure to click only on the Geodatabase Connection File for the "sde" user, if you click on any other connection file (e.g. data owner user, editor/viewer users) then you create a geodatabase lock that will prevent the upgrade to proceed, you must close ArcCatalog or ArcGIS Pro and re-open, only the "sde" user can perform the upgrade.

After all users and services connections are closed  you can disable geodatabase connections to prevent any new connections to the geodatabase, of course only the "sde" user is allowed to connect.

Tip: ArcGIS Pro > Right Click Geodatabase Connection File for the "sde" user > Properties > Database Properties > Connections > turn off "Geodatabase is accepting connections" > Click Ok

MarceloMarques_1-1657303397294.png

_________________________________________________________________________________________________

7. Upgrade Geodatabase Repository

 

Follow the steps described in the documentation to upgrade the geodatabase repository.

Upgrade a geodatabase in Oracle

Use the Upgrade Geodatabase Geoprocessing tool

Upgrade Geodatabase (Data Management)

MarceloMarques_0-1657220745638.png

MarceloMarques_1-1657220783435.png

Right Click Geodatabase Connection File for the "sde" user > Properties > Database Properties > Upgrade Status

MarceloMarques_0-1657302176130.png

Tip: if you turned off the option "Geodatabase is accepting connections", then after the upgrade the option is turned on automatically

ArcGIS Pro > Right Click Geodatabase Connection File for the "sde" user > Properties > Database Properties > Connections > "Geodatabase is accepting connections" >

_________________________________________________________________________________________________

!!! Note: If there are any problems with the geodatabase repository upgrade and you want to roll back the changes then see below "Appendix - Restore using flashback database".

_________________________________________________________________________________________________

8. Check Invalid Objects

 

SQL> ALTER SESSION SET CONTAINER = <PDB_NAME>;
SQL> SHOW CON_NAME
SQL>  SELECT * FROM DBA_OBJECTS
WHERE STATUS!= 'VALID'
ORDER BY OWNER, OBJECT_TYPE, OBJECT_NAME;

_________________________________________________________________________________________________

9. Recompile Invalid Objects

 

Recompile any invalid objects in the SDE user and data owner users, then check again for invalid objects.

SQL> ALTER SESSION SET CONTAINER = <PDB_NAME>;
SQL> SHOW CON_NAME
SQL> EXEC dbms_utility.compile_schema( 'SDE', compile_all => FALSE );
SQL> EXEC dbms_utility.compile_schema( 'GIS', compile_all => FALSE );

_________________________________________________________________________________________________

10. Check Invalid Indexes

 

SQL> ALTER SESSION SET CONTAINER = <PDB_NAME>;
SQL> SHOW CON_NAME
SQL> SELECT * FROM ALL_INDEXES d WHERE d.status NOT IN ('VALID','N/A');

_________________________________________________________________________________________________

11. Revoke Privileges Required for Geodatabase Upgrade

 

SQL> ALTER SESSION SET CONTAINER = <PDB_NAME>;
SQL> SHOW CON_NAME
SQL> REVOKE GIS_SDE_MASTER_UPGRADE FROM SDE;

Repeat the steps 8, 9, 10 above to check Invalid Objects and Invalid Indexes

_________________________________________________________________________________________________

12. Update the ST_GEOMETRY library

 

Copy the new version of the ST_GEOMETRY library to the Oracle Database Server.

For more information read - Configure extproc to access ST_Geometry in Oracle

a. Update the sde.st_shapelib library if the path changed.

SQL> ALTER SESSION SET CONTAINER = <PDB_NAME>;
SQL> SHOW CON_NAME

SQL> CREATE OR REPLACE LIBRARY sde.st_shapelib
AS '/orahome1/dbbase1/esrilibs/pro_30/libst_shapelib.so';

b. Check the library

SELECT * FROM ALL_LIBRARIES WHERE OWNER = 'SDE' ORDER BY OWNER, LIBRARY_NAME;

c. Check Invalid Objects

SQL>  SELECT * FROM DBA_OBJECTS 
WHERE STATUS!= 'VALID'
ORDER BY OWNER, OBJECT_TYPE, OBJECT_NAME;

d. Recompile Invalid Objects and then check again for invalid objects.

SQL> EXEC dbms_utility.compile_schema( 'SDE', compile_all => FALSE );

e. Validate the extproc configuration

Note: connect as the sde user or as the data owner user !!!

SQL> SELECT sde.st_geometry(1,1,1,1,0) FROM dual;
SQL> SELECT sde.st_geometry('point (1 1)', 0) FROM dual;
SQL> SELECT sde.ST_AsText(SDE.ST_Geometry('POINT (10 10)', 0)) FROM dual;

_________________________________________________________________________________________________

13. Check Invalid Objects

 

SQL> ALTER SESSION SET CONTAINER = <PDB_NAME>;
SQL> SHOW CON_NAME
SQL>  SELECT * FROM DBA_OBJECTS
WHERE STATUS!= 'VALID'
ORDER BY OWNER, OBJECT_TYPE, OBJECT_NAME;

_________________________________________________________________________________________________

14. Check Invalid Indexes

 

SQL> ALTER SESSION SET CONTAINER = <PDB_NAME>;
SQL> SHOW CON_NAME
SQL> SELECT * FROM ALL_INDEXES d WHERE d.status NOT IN ('VALID','N/A');

_________________________________________________________________________________________________

!!! Note: If there are any problems with the geodatabase repository upgrade and you want to roll back the changes then see below "Appendix - Restore using flashback database".

_________________________________________________________________________________________________

15. Gather new Statistics

 

SQL> ALTER SESSION SET CONTAINER = <PDB_NAME>;
SQL> SHOW CON_NAME

SQL> BEGIN
SYS.DBMS_STATS.GATHER_SCHEMA_STATS (
OwnName => 'SDE'
,Granularity => 'ALL'
,Options => 'GATHER'
,Gather_Temp => FALSE
,Degree => 4
,Cascade => TRUE
,No_Invalidate => FALSE);
END;

SQL> BEGIN
SYS.DBMS_STATS.GATHER_SCHEMA_STATS (
OwnName => 'GIS'
,Granularity => 'ALL'
,Options => 'GATHER'
,Gather_Temp => FALSE
,Degree => 4
,Cascade => TRUE
,No_Invalidate => FALSE);
END;

_________________________________________________________________________________________________

16. Drop the Restore Point

 

SQL> ALTER SESSION SET CONTAINER = <PDB_NAME>;
SQL> SHOW CON_NAME
SQL> SELECT * FROM V$RESTORE_POINT;
SQL> DROP RESTORE POINT before_gdb_upgrade;
SQL> SELECT * FROM V$RESTORE_POINT;

_________________________________________________________________________________________________

17. Execute RMAN Backup

 

Execute a RMAN Incremental Level 0 ( Full ) Backup and/or RMAN Incremental Level 1 ( Incremental ) Backup and also execute a RMAN archivelog backup to free space in the FRA - Fast Recovery Area.

_________________________________________________________________________________________________

Appendix - Restore using flashback database

 

sqlplus /nolog

SQL> connect /as sysdba

SQL> ALTER SESSION SET CONTAINER = cdb$root;

SQL> SHOW CON_NAME

SQL> SELECT * FROM V$RESTORE_POINT;

SQL> SELECT pdb_name, status FROM dba_pdbs ORDER BY pdb_name;

SQL> SELECT name, open_mode, restricted FROM v$pdbs ORDER BY name;

SQL> ALTER PLUGGABLE DATABASE <PDB_NAME> CLOSE;

SQL> FLASHBACK PLUGGABLE DATABASE <PDB_NAME> TO RESTORE POINT before_gdb_upgrade;

SQL> ALTER PLUGGABLE DATABASE <PDB_NAME> OPEN RESETLOGS;

SQL> SELECT pdb_name, status FROM dba_pdbs ORDER BY pdb_name;

SQL> SELECT name, open_mode, restricted FROM v$pdbs ORDER BY name;

 _________________________________________________________________________________________________

FAQ - Frequent Asked Questions

 

1. Can I upgrade the Geodatabase Repository if the Geodatabase has Traditional Versions or Branch Versions?

Answer: Yes, you can. There is no problem to upgrade.

2. Is necessary to Reconcile and Post the Geodatabase Versions before the Geodatabase Repository Upgrade?

Answer: No, it is not necessary.

 _________________________________________________________________________________________________

About the Author
| Marcelo Marques | Principal Product Engineer | Esri | Cloud & Database Administrator | OCP - Oracle Certified Professional | 30 years experience | www.linkedin.com/in/mmarquesbr | I have worked with Esri Technology since 1992 and I have been working with Enterprise Geodatabases since 1997 when the Geodatabase was first released. | " a successful Enterprise ArcGIS application deployment starts with a strong physical database design and best database administration practices" | " I do not fear computers. I fear the lack of them." - Isaac Asimov |