Husnu Sensoy
How to Move USER_SDO_GEOM_METADATA like a Grandpa
Sometimes moving a small amount of data in Oracle database requires more work than the actual task you need to complete. DBAs always have their tools (PL/SQL Developer Text Importer is my favorite one) to move a small amount of data between databases.
But when it comes to nested tables this might be a bit challenging. USER_SDO_GEOM_METADATA table (for those of you who are not familiar with it, it is the catalog information of spatial layers in an Oracle database) has no exception to that. Here how it is easy to handle it
The structure of USER_SDO_GEOM_METADATA table has the following structure
SQL> desc user_sdo_geom_metadata Name Null? Type ----------------------------------------- -------- ---------------------------- TABLE_NAME NOT NULL VARCHAR2(32) COLUMN_NAME NOT NULL VARCHAR2(1024) DIMINFO MDSYS.SDO_DIM_ARRAY SRID NUMBER
Obviously DIMINFO column is the problematic part since it is in SDO_DIM_ARRAY type. Now create a temporary table by unfolding this nested table at the source database site.
CREATE TABLE temp_metadata AS
SELECT t.table_name,
t.column_name,
d.*,
t.srid
FROM user_sdo_geom_metadata t,
TABLE(t.diminfo) d;
Once you are done check the structure of temp_metadata table which only contains primitive SQL types for the columns
SQL> desc temp_metadata Name Null? Type ----------------------------------------- -------- ---------------------------- TABLE_NAME VARCHAR2(32) COLUMN_NAME VARCHAR2(1024) SDO_DIMNAME VARCHAR2(64) SDO_LB NUMBER SDO_UB NUMBER SDO_TOLERANCE NUMBER SRID NUMBER
Choose your favorite tool to move this table to the target database since it contains just a few rows. Then as the final step import this data into USER_SDO_GEOM_METADATA table at the target database (Ensure that there is no other record with the same table_name.column_name key on the target USER_SDO_GEOM_METADATA table otherwise trigger on it will warn you)
insert into user_sdo_geom_metadata
SELECT m.table_name, m.column_name,
CAST(MULTISET(SELECT sdo_dimname,sdo_lb,SDO_UB,sdo_tolerance
FROM temp_metadata n
WHERE n.table_name = m.table_name and n.column_name = m.column_name)
AS SDO_DIM_ARRAY) as diminfo,
m.srid
FROM (select distinct table_name,column_name,srid from temp_metadata) m;
commit;
You are done! Check everything works fine at the application site.
Physical vs Logical Blocksize on ASMLib Devices
As you all may know, ASMLib is a recommended module for Oracle databases running on Linux platforms and it is an embedded module for UEK (Oracle Unbreakable Kernel) users. Oracle announced that (two years ago or so) they will no longer maintain ASMLib for Red Hat compatible kernel but this does not mean that they abandon the project, rather it is mainly related to the effort they need to put in maintaining the module for multiple kernel versions.
A while ago, Oracle added a new feature to ASMLib allowing ASM devices to choose between physical or logical block sizes in I/O operations. This should be, I believe, a fail-back mechanism for SSD devices used as ASM disks. Many SSD devices use 4K block size however Linux still uses default 512 bytes logical block size for those devices in the same way it does for motor disks. In early releases of ASMLib (oracleasm-support-2.1.7 and earlier), ASM uses physical block size (4K for SSDs). This is still the default behavior in oracleasm-support-2.1.8 but now sysadmin can choose between physical and logical blocksize by using [-b|-p] switches in oracleasm-configure.sh script.
- -b|—logical-blocks sets logical blocksize usage
- -p|—physical-blocks set physical blocksize usage
Those switches set /sys/module/oracleasm/parameters/use_logical_block_size which is default to be false (use physical blocksize). So that asmlib module can use the value to decide which block size to use.
Upgrade to Oracle Enterprise Linux 5.9 and/so UEK2
I have upgraded one of my Oracle Linux boxes to Oracle Linux Release 5.9 which introduces several new things (Release Notes). Just to mention three of them
- java-1.7.0-openjdk
- firefox 10 (Although we have discuss to install latest version of it in Oracle Enterprise Linux for Home User: Install Latest Firefox Version )
- uek2 vanilla kernel branched from Linux Kernel Release 3.0.36
- BTRFS
- Transparent Huge Pages
Download and update yum repository file
[root@localhost yum.repos.d]$ cd /etc/yum.repos.d [root@localhost yum.repos.d]$ wget http://public-yum.oracle.com/public-yum-el5.repo [root@localhost yum.repos.d]$ mv public-yum-el5.repo.1 public-yum-el5.repo [root@localhost yum.repos.d]$ grep -B 5 enabled=1 public-yum-el5.repo [el5_latest] name=Oracle Linux $releasever Latest ($basearch) baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL5/latest/$basearch/ gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-el5 gpgcheck=1 enabled=1 -- [ol5_u9_base] name=Oracle Linux $releasever Update 9 installation media copy ($basearch) baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL5/9/base/$basearch/ gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-el5 gpgcheck=1 enabled=1 -- [ol5_UEK_latest] name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch) baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL5/UEK/latest/$basearch/ gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-el5 gpgcheck=1 enabled=1
We are ready to upgrade
[root@localhost yum.repos.d]$ yum update
Rebounce Linux
[root@localhost yum.repos.d]$ rebootBefore
Check Oracle Linux Version
[oracle@localhost ~]$ cat /etc/oracle-release Oracle Linux Server release 5.8
Check kernel version
[oracle@localhost ~]$ uname -a Linux localhost.localdomain 2.6.32-300.32.2.el5uek #1 SMP Tue Aug 28 10:15:29 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
Check your memory page size
[oracle@localhost ~]$ getconf PAGESIZE 4096After
Once you are done after reboot, check Oracle Linux Version
[oracle@localhost ~]$ cat /etc/oracle-release Oracle Linux Server release 5.9
Check kernel version
[oracle@localhost ~]$ uname -a Linux localhost.localdomain 2.6.39-300.28.1.el5uek #1 SMP Tue Feb 5 10:15:29 PST 2013 x86_64 x86_64 x86_64 GNU/Linux
Check your memory page size
[oracle@localhost ~]$ getconf PAGESIZE 4096
Ooops!!! No change ?
[root@localhost ~]$ cat /sys/kernel/mm/transparent_hugepage/enabled [always] madvise never
Actually transparent huge page allocation is enabled but it deserves a separate discussion
How to Disable Automatic SGA Management on 11g Release 2
Login database using
sqlplus / as sysdba
Dump the pfile using existing spfile
SQL> create pfile='/home/oracle/Desktop/init.ora' from spfile; File created.
Oracle will generate implicit parameters defining current sizing of the memory regions in SGA and write them at the top of generated pfile
orcl.__db_cache_size=79691776 orcl.__java_pool_size=4194304 orcl.__large_pool_size=4194304 orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment orcl.__pga_aggregate_target=142606336 orcl.__sga_target=272629760 orcl.__shared_io_pool_size=0 orcl.__shared_pool_size=167772160 orcl.__streams_pool_size=4194304 . . . *.memory_target=414187520 . . .
Edit the file to disable AMM and enable static SGA configuration by simply removing memory_target, oracle_base and shared_io_pool_size parameters and doing some make up
*.db_cache_size=79691776 *.java_pool_size=4194304 *.large_pool_size=4194304 *.pga_aggregate_target=142606336 *.sga_target=272629760 *.shared_pool_size=167772160 *.streams_pool_size=4194304 . . .
Rebounce database instance by using modified pfile.
SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup pfile='/home/oracle/Desktop/init.ora'; ORACLE instance started. Total System Global Area 271400960 bytes Fixed Size 2227544 bytes Variable Size 180355752 bytes Database Buffers 83886080 bytes Redo Buffers 4931584 bytes Database mounted. Database opened.
Once you ensure that new pfile works, recreate new spfile using this pfile (refer to How to move ASM spfile to a different disk group [ID 1082943.1] if your target is ASM diskgroup)
SQL> create spfile using pfile='/home/oracle/Desktop/init.ora'; File created.
Finally rebounce the database by using new spfile
SQL> startup force; ORACLE instance started. Total System Global Area 271400960 bytes Fixed Size 2227544 bytes Variable Size 180355752 bytes Database Buffers 83886080 bytes Redo Buffers 4931584 bytes Database mounted. Database opened.
Slides and Offline Recording of my NYOUG Webinar
I have announced my webinar on Oracle ZFS Storage Appliance for Exadata Backup & Recovery in NYOUG DBA webinar series. You can download webinar slides and voice recod from NYOUG web site



