October 14, 2020

How to install Oracle Application Express(APEX) 20.1 in Linux

 

Oracle Application Express 20.1 Installation Steps 


Before installing Oracle Application Express, you must verify your configuration meets the minimum installation requirements.

• Oracle Database Requirements

Oracle Application Express release 20.1 requires an Oracle Database release 11.2.0.4 or later, including Enterprise Edition and Express Edition (Oracle Database XE). Oracle Application Express can be installed in single-instance database and in Oracle Real Application Clusters (Oracle RAC) database.

• MEMORY_TARGET of the Target Database

Oracle Application Express requires the system global area (SGA) and program global area (PGA) to be at least 300 MB.

• Oracle XML DB Requirement

Oracle XML DB must be installed in the Oracle database that you want to use if you are installing a full development environment. Oracle XML DB is not required for runtime only installations. If you are using a preconfigured database created either during an installation or by Database Configuration Assistant (DBCA), Oracle XML DB is already installed and configured.


Download Link: -

Oracle Application Express can be downloaded from HERE


Environment details:-

OS

RHEL 6.4

IP

192.168.0.106

Hostname

server3.soumya.com

Apex Version

20.1

DB Version

12.1.0.2


October 12, 2020

How to find out which Enterprise Edition features are being used in your oracle database ?

 How to find out which Enterprise Edition features are being used in your oracle database ?


I have seen many customer uses Enterprise Edition features unknowingly. They fall into trouble when Oracle performs an audit into their database and find out what are features they have using without their knowledge. As many of those features require extra cost.


A few of EE features that require extra licensing such as 


  • Oracle Partitioning
  • Oracle Label Security
  • Oracle On-Line Analytical Processing (OLAP)
  • Oracle Advanced Security
  • Oracle Advanced Compression
  • Oracle Database Vault
  • Oracle Database In-Memory
  • Oracle Active Data Guard
  • Oracle Multitenant 
  • Oracle Spatial and Graph


We can use following query to find out if any features that are being used cost extra.


 

spool DB_features_usage.lst

Set feedback off

Set lines 222

Col name  format a50 heading "Feature"

Col version  format a10 heading "Version"

Col detected_usages  format 999,990 heading "Detected|usages"

Col currently_used    format a06     heading "Curr.|used?"

Col first_usage_date  format a10     heading "First use"

Col last_usage_date   format a10     heading "Last use"

Col nop noprint

Break on nop skip 1 on name

SQL> Select decode(detected_usages,0,2,1) nop,

 name, version, detected_usages, currently_used,

  to_char(first_usage_date,'DD/MM/YYYY') first_usage_date, 

   to_char(last_usage_date,'DD/MM/YYYY') last_usage_date

   from dba_feature_usage_statistics

    order by nop, 1, 2;

 

 



This would save the output in a file by name DB_features_usage.lst.

Reference: https://docs.oracle.com/en/database/oracle/oracle-database/12.2/dblic/Licensing-Information.html#GUID-AB354617-6614-487E-A022-7FC9A5A08472   

   

October 5, 2020

Oracle WebLogic Server 12cR2 (12.2.1.4) Installation on Oracle Linux 6

 

Assumptions

It is assumed that you have an existing server with either Oracle Linux 6.x or 7.x installed on it. 

 Software

Download the Weblogic Server 12c software from Oracle Technology Network.

Oracle Fusion Middleware 12c Infrastructure 12.2.1.4.0

We would use the fustion middleware infrastructure pack as we would be installing forms and reports 12c services later.

Make sure Java is installed properly .Check exact java version using

$ alternatives --config java

Selection Command

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

1 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java

2 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

+ 3 /usr/java/jdk1.8.0_05/bin/java


Setup

The following actions should be performed by the "root" user.

Make sure the "/etc/hosts" file contains correct entries for both the "localhost" and real host names.

127.0.0.1      localhost localhost.localdomain localhost4 localhost4.localdomain4
10.0.95.10 test.soumya.com test

 

Create a new group and user.

groupadd -g 54321 oinstall
useradd -u 54321 -g oinstall oracle
passwd oracle

 

Create the directories in which the Oracle software will be installed.

mkdir -p /d01/app/oracle/product/12.2.1.4
chown -R oracle:oinstall /d01
chmod -R 775 /d01/


Create an environment file named app_env

Add the following line in .bash_profile

alias app_env='. /home/oracle/app_env'


vi /home/oracle/app_env

ORACLE_BASE=/d01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.2.1.4; export ORACLE_HOME
MW_HOME=$ORACLE_HOME ; export MW_HOME
WLS_HOME=$MW_HOME/wlserver; export WLS_HOME
WL_HOME=$WLS_HOME  ;export WLS_HOME
DOMAIN_HOME=/d01/app/oracle/product/12.2.1.4/user_projects/domains/prod_domain; export DOMAIN_HOME
JAVA_HOME=/usr/java/jdk1.8.0_231-amd64; export JAVA_HOME
export OHS_INST=/d01/app/oracle/product/12.2.1.4/user_projects/domains/prod_domain/config/fmwconfig/components/OHS/instances/ohs1 ;export OHS_INST
PATH=$JAVA_HOME/bin:$PATH ; export PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export FORMS_PATH=/d01/app/oracle/product/12.2.1.4/forms; export FORMS_PATH

[root@mesappprod u01]# rpm -Uvh jdk-8u241-linux-x64.rpm

Preparing...                          ################################# [100%]

Updating / installing...

   1:jdk1.8-2000:1.8.0_241-fcs        ################################# [100%]

Unpacking JAR files...

        tools.jar...

        plugin.jar...

        javaws.jar...

        deploy.jar...

        rt.jar...

        jsse.jar...

        charsets.jar...

        localedata.jar...

[root@mesappprod u01]# java -version

openjdk version "1.8.0_242"

OpenJDK Runtime Environment (build 1.8.0_242-b08)

OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

[root@mesappprod u01]# alternatives --config java


 There are 2 programs which provide 'java'.

   Selection    Command

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

*+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/bin/java)

   2           /usr/java/jdk1.8.0_241-amd64/jre/bin/java

 

Enter to keep the current selection[+], or type selection number: 2

 

For Oracle Linux 6, as specified in MOS Note [ID 1487773.1], amend the "/etc/security/limits.d/90-nproc.conf" file, making the following change.


# From
*          soft    nproc     1024
 #To
* - nproc 16384


Run the installer as the "oracle" user.

[oracle@weblogic_sw]$ unzip fmw_12.2.1.4.0_infrastructure_Disk1_1of1.zip

$ $JAVA_HOME/bin/java -jar fmw_12.2.1.4.0_infrastructure.jar

 

If this is is the first installation on the machine you will need to specify an inventory location. Enter the inventory location, like "/u01/app/oraInventory" and click the "OK" button. In our case we had database installed previously on the same machine hence it didn’t ask for inventory location.

 



Select the "Skip Auto Updates" options, then click the "next" button.


Enter the middleware home ("/u01/app/oracle/product/12.2.1") and click the "Next" button.



Accept the "Fusion Middleware Infrastructure" option by clicking the "Next" button.





Wait for the prerequisite checks to complete. If there are failures, correct them and rerun the checks. If there are no failures, click the "Next" button.


Enter your support details, or leave it unchecked the security updates checkbox. Click the "Next" button. If you chose not to receive security updates, click the "Yes" button on the warning dialog.


If you are ok with the summary information, click the "Install" button.



Wait for the installation to complete, then click the "Next" button.



On the installation complete screen, click the "Finish" button to launch the Configuration Wizard.




So this concludes the Weblogic Server installation process in OEL 6.





September 26, 2020

Extract Oracle DB information in one go


A single script to gather various information's of your database. Save the following code as .sql file and run it from sql prompt. This will generate a .lst file with the datetime.

This script has been tested on 11gR2, 12cR1, 12cR2, 19c 


column tm new_value file_time noprint

select to_char(sysdate,'DDMMYYYY')tm from dual;

spool &file_time.lst

set lines 152

set pages 1000

alter session set "_hash_join_enabled"=true

/

---------DATABASE NAME------

PROMPT Database Name and Status 

select name,open_mode,log_mode,database_role from v$database;




PROMPT TABLESPACE COUNT

SELECT COUNT(NAME) FROM V$TABLESPACE; 




PROMPT DATAFILES HEADER COUNT

SELECT COUNT(NAME) FROM V$DATAFILE_HEADER;




-----INSTANCE------

PROMPT INSTANCE STATUS

select status from v$instance;




----------------db size--------------

PROMPT DB SIZE(DATAFILE + REDOLOG+CONTROLFILE)

select a.data_size+b.temp_size+c.redo_size+d.controlfile_size "total_size in GB"

from ( select sum(bytes)/1024/1024/1024 data_size

from dba_data_files) a,

( select nvl(sum(bytes),0)/1024/1024/1024 temp_size

from dba_temp_files ) b,

( select sum(bytes)/1024/1024/1024 redo_size

from sys.v_$log ) c,

( select sum(BLOCK_SIZE*FILE_SIZE_BLKS)/1024/1024/1024 controlfile_size

from v$controlfile) d;







PROMPT TOTAL DATABASE USAGE




select (select sum(bytes/1048576) from dba_data_files) "Data Mb",

(select NVL(sum(bytes/1048576),0) from dba_temp_files) "Temp Mb",

(select sum(bytes/1048576)*max(members) from v$log) "Redo Mb",

(select sum(bytes/1048576) from dba_data_files) +

(select NVL(sum(bytes/1048576),0) from dba_temp_files) +

(select sum(bytes/1048576)*max(members) from v$log) "Total Mb"

from dual;







PROMPT

PROMPT

PROMPT DB PHYSICAL SIZE

PROMPT ==================

select sum(bytes/1024/1024/1024) "DB Physical Size(GB)" from dba_data_files;







PROMPT

PROMPT

PROMPT DB ACUTAL SIZE

PROMPT ================

select sum(bytes/1024/1024/1024) "DB Actual Size(GB)" from dba_segments;







----------TAblespace---------

PROMPT TABLESPACE INFORMATION

select TABLESPACE_NAME,STATUS,AUTOEXTENSIBLE, ONLINE_STATUS from dba_data_files;




PROMPT TABLESPACE SIZE AND FREE SPACE

set pagesize 100 

set lines 130

COLUMN free_space_mb format 99999990.00

COLUMN allocated_mb format 99999990.00

COLUMN used_mb format 99999990.00

COLUMN percent_used format 00.00

col tablespace_name format a25




SELECT SUBSTR(df.tablespace_name,1,30) tablespace_name,

(df.bytes) / 1024 / 1024 allocated_mb,

((df.bytes)-nvl(dfs.bytes,0))/1024/1024 used_mb,

NVL ((dfs.bytes) / 1024 / 1024, 0) free_space_mb,

round( ((df.bytes-nvl(dfs.bytes,0))/df.bytes * 100),2) percent_used

FROM ( select sum(bytes) bytes,tablespace_name from dba_data_files group by tablespace_name) df,

( select sum(bytes) bytes , tablespace_name from dba_free_space group by tablespace_name) dfs

WHERE df.tablespace_name = dfs.tablespace_name

ORDER BY percent_used ;




-------------tablespace>75----------------------------------------

PROMPT TABLESPACE USED MORE THAN 75% 

#alter session set "_hash_join_enabled"=true;

set pagesize 100

set lines 130

COLUMN free_space_mb format 99999990.00

COLUMN allocated_mb format 99999990.00

COLUMN used_mb format 99999990.00

COLUMN percent_used format 00.00

col tablespace_name format a25




SELECT SUBSTR(df.tablespace_name,1,30) tablespace_name,

(df.bytes) / 1024 / 1024 allocated_mb,

((df.bytes)-nvl(dfs.bytes,0))/1024/1024 used_mb,

NVL ((dfs.bytes) / 1024 / 1024, 0) free_space_mb,

round( ((df.bytes-nvl(dfs.bytes,0))/df.bytes * 100),2) percent_used

FROM ( select sum(bytes) bytes,tablespace_name from dba_data_files group by tablespace_name) df,

( select sum(bytes) bytes , tablespace_name from dba_free_space group by tablespace_name) dfs

WHERE df.tablespace_name = dfs.tablespace_name

and round( ((df.bytes-nvl(dfs.bytes,0))/df.bytes * 100),2) > 75

ORDER BY percent_used ;

------------Archivegap-------------------




#alter session set "_hash_join_enabled"=true;

PROMPT ARCIVELOG LAST SEQUENCE

select max(sequence#)"Last Sequence" from v$loghist;







PROMPT LAST APPLIED ARCHIVELOG SEQUENCE ON STANDBY DATABASE

select max(SEQUENCE#)"Applied Sequence" from v$archived_log where APPLIED='YES' and dest_id=2;







----------temp-----------------

PROMPT TEMP TABLESPACE INFO

SET LINESIZE 200

COL TABLESPACE_NAME FORMAT A20




SELECT TABLESPACE_NAME,SUM(BYTES_USED/1024/1024) "USED_MB",SUM(BYTES_FREE/1024/1024) "FREE_MB",

SUM(BLOCKS_FREE) "FREE_BLOCKS"

FROM V$TEMP_SPACE_HEADER

GROUP BY TABLESPACE_NAME;

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

PROMPT NUMBER OF ACTIVE SESSION

select count(*)"Active sessions" from v$session;




------------------Log sequence-----------------

PROMPT show parameter log_archive_dest_state_2

show parameter log_archive_dest_state_2




------------------Resource_Limit-----------------

PROMPT RESOURCE_LIMIT

SET LINES 200

SET PAGESIZE 200

COL RESOURCE_NAME FOR A30

COL INITIAL_ALLOCATION FOR A20

COL LIMIT_VALUE FOR A20

select * from v$resource_limit;










PROMPT COUNT OF INVALID OBJECTS

PROMPT ==========================

select count(*) from dba_objects where status='INVALID';




PROMPT DB HIT Ratio

PROMPT ==========================

select (1-(pr.value/

(dbg.value+cg.value)))*100

FROM v$sysstat pr,v$sysstat dbg,v$sysstat cg

WHERE Pr.name='physical reads'

AND dbg.name='db block gets'

AND cg.name='consistent gets';

PROMPT =============================LOAD========================================

select stat_name,value from v$OSSTAT where STAT_NAME='LOAD';




PROMPT =================================EVENT===================================

select event,count(event) from v$session group by event;




PROMPT =================================Session========================================

select username,status,count(*) from v$session group by username,status order by 1,3;




PROMPT =================================Number of Session========================================

SET LINESIZE 145

SET PAGESIZE 9999




COLUMN max_sess_allowed FORMAT 999,999 JUSTIFY r HEADING 'Max sessions allowed'

COLUMN num_sessions FORMAT 999,999,999 JUSTIFY r HEADING 'Number of sessions'

COLUMN pct_utl FORMAT a19 JUSTIFY r HEADING 'Percent Utilization'

COLUMN username FORMAT a15 JUSTIFY r HEADING 'Oracle User'

COLUMN num_user_sess FORMAT 999,999 JUSTIFY r HEADING 'Number of Logins'

COLUMN count_a FORMAT 999,999 JUSTIFY r HEADING 'Active Logins'

COLUMN count_i FORMAT 999,999 JUSTIFY r HEADING 'Inactive Logins'




PROMPT =================================Oracle Users Session========================================

SET verify off




SELECT

TO_NUMBER(a.value) max_sess_allowed

, TO_NUMBER(count(*)) num_sessions

, LPAD(ROUND((count(*)/a.value)*100,0) || '%', 19) pct_utl

FROM v$session b, v$parameter a

WHERE a.name = 'sessions'

GROUP BY a.value;




break on report

compute sum of num_user_sess count_a count_i on report




SELECT

lpad(nvl(sess.username, '[B.G. Process]'), 15) username

, count(*) num_user_sess

, nvl(act.count, 0) count_a

, nvl(inact.count, 0) count_i

FROM

v$session sess

, (SELECT count(*) count, nvl(username, '[B.G. Process]') username

FROM v$session

WHERE status = 'ACTIVE'

GROUP BY username) act

, (SELECT count(*) count, nvl(username, '[B.G. Process]') username

FROM v$session

WHERE status = 'INACTIVE'

GROUP BY username) inact

WHERE

nvl(sess.username, '[B.G. Process]') = act.username (+)

and nvl(sess.username, '[B.G. Process]') = inact.username (+)

GROUP BY

sess.username

, act.count

, inact.count;

=============================================== SQL row lock contention==========================================================




set linesize 1000

set pagesize 1000

col USERNAME format a10




select c.USERNAME, 

a.SID, 

c.SQL_ID, 

a.EVENT, 

a.STATE, 

c.STATUS, 

b.TIME_WAITED

from v$session_wait a,

v$session_wait_class b, 

v$session c

where a.SID=b.SID

and b.SID=c.SID

and c.SQL_ID is not null

and b.TIME_WAITED<>0 

and a.EVENT like '%row lock contention%'

order by 7;

=============================================== Table lock ==================================================================================================================

select s1.username || '@' || s1.machine|| ' ( SID=' || s1.sid || ' ) is blocking by '|| s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status

from v$lock l1, v$session s1, v$lock l2, v$session s2

where s1.sid=l1.sid and s2.sid=l2.sid

and l1.BLOCK=1 and l2.request > 0

and l1.id1 = l2.id1

and l2.id2 = l2.id2

and l1.type=l2.type;

Prompt==================================User Expiry Details===========================

select USERNAME,EXPIRY_DATE,PROFILE from dba_users where account_status='OPEN';







Prompt==================================TABLE MAX SIZE IN MB=================================

set linesize 1000

set pagesize 750

col Table_Name for a20

col owner for a15

col size for a10

select segment_name as "Table_Name",owner, round(bytes/1024/1024) || 'MB' as "Size"

from dba_segments where bytes>2073741824 and owner Not IN ('SYS','SYSTEM') 

order by bytes desc;




Prompt==================================TABLE MAX SIZE IN GB=================================

select segment_name as "Table_Name",owner, round(bytes/1024/1024/1024) || 'GB' as "Size"

from dba_segments where bytes>2073741824 and owner Not IN ('SYS','SYSTEM') 

order by bytes desc;




spool off

 

June 27, 2020

Creating Compute Instance in OCI

How to Create Compute Instance in Oracle Cloud Infrastructure(OCI)


First , lets login to oracle cloud

www.oracle.com/cloud

Provide cloud account name and user id & password to authenticate.

Step:-1 

To create a new compute instance,  click Compute, then select Instances.



Step 2.

Click on "Create Instance"




Step 3.

In Create Compute Instance page, provide instance name , select the image as per your requirement.



Step 4.

Select Availability Domain and Shape as per your requirement





Step 5.

By clicking on "change shape" we can choose the preferred instance type & shape details which is basically a template with different type of resources (Ocpu, Memory, Network Bandwidth etc) assigned as per  customer's different requirement.




Step 6.

In the networking section , Select the desired compartment where the instance would be created.
Choose a VCN . A VCN must be created before creating an instance.Also choose compartment for subnet.



Step 7.

Next select "Assign a PUBLIC IP Address" if you want OCI to assign a Public IP . For boot volume the default size is 46gb but this can be customized ranging from 50GB to 32TB



Step 8.

Add ssh keys if you already have one. Select a public key or you can create one using puttygen.



Step 9.

Choose a fault domain and create the compute instance.




Step 10.

On instance details screen, we can see different details about the instance such as Public IP ,Private IP, Fault Domain etc.




Step 11.

To login the Instance open putty and choose the ppk to login. 






Step 12. 

Login to the instance using user "opc"




That concludes our compute instance creation in OCI.


If you like this post, then please share it with others.
Please subscribe on email for every updates on mail.

Disclaimer:- The use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

June 25, 2020

How to upgrade Oracle Database 12c to 19c Manually

Oracle database can be upgraded directly to the new release from the following releases:

  • 11.2.0.4
  • 12.1.0.2
  • 12.2.0.1
  • 18

If your current Oracle Database is a release earlier than 11.2.0.4, then you cannot directly upgrade your Oracle Database to the latest release. In this case, you are required to upgrade to an intermediate release before upgrading to Oracle Database 19c.

There are many methods available for upgrading database to 19c . A few of them are mentioned below:-
  • Database Upgrade Assistant(DBUA)
  • Manual Upgrade
  • Full Transportable Export Import
  • Transportable Tablespace
  • Datapump Export Import

June 13, 2020

How to Create a Compartment in OCI


What is a Compartment:-

Compartment is a logical collection of related cloud resources. It is used to isolate resources.

Users who have privilege to use the compartment, can only access or manage it.

 

First , lets login to oracle cloud

Oracle Database 26ai Installation Using RPM on Oracle Linux 9 (OEL 9) – Step-by-Step Guide

  In this post I will describe the installation of Oracle Database 26ai 64-bit on Oracle Linux 9 (OL8) 64-bit. The installation requires a m...