Pages

Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

Monday, November 21, 2022

How to Create,Start,Modify,Stop and Delete services in listener in Oracle Database 19c

 This article describes how to create database services in single instance databases using the DBMS_SERVICE package.

In a multitenant database services can be created in a CDB or a PDB. In these examples we will just create them in the CDB, so it looks similar to a non-CDB instance.


Create a Service:

We create a new service using the CREATE_SERVICE procedure. There are two overloads allowing you to amend a number of features of the service. One overload accepts an parameter array, while the other allows you to set some parameters directly. The only mandatory parameters are the the SERVICE_NAME and the NETWORK_NAME, which represent the internal name of the service in the data dictionary and the name of the service presented by the listener respectively.

BEGIN

  DBMS_SERVICE.create_service(

    service_name => 'my_new_service',

    network_name => 'my_new_service'

  );

END;

/

We can display information about existing services using the {CDB|DBA|ALL}_SERVICES views. We can see if the service is started by checking the {G}V$ACTIVE_SERVICES view.


COLUMN name FORMAT A30

COLUMN network_name FORMAT A30

SELECT name,network_name FROM   dba_services ORDER BY 1;

NAME                           NETWORK_NAME

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

my_new_service                 my_new_service


SELECT name,network_name FROM   v$active_services ORDER BY 1;

No rows selected


Start a Service:

The START_SERVICE procedure starts an existing service, making it available for connections via the listener.

BEGIN

  DBMS_SERVICE.start_service(

    service_name => 'my_new_service'

  );

END;

/

We can see the service is now active.

SELECT name,network_name FROM   v$active_services ORDER BY 1;

NAME                           NETWORK_NAME

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

my_new_service                 my_new_service


Modify a Service: 

The MODIFY_SERVICE procedure allows us to alter parameters of an existing service. Like the CREATE_SERVICE procedure, there are two overloads allowing you to amend a number of features of the service. One overload accepts an parameter array, while the other allows you to set some parameters directly.

BEGIN

  DBMS_SERVICE.modify_service(

    service_name => 'my_new_service',

    goal         => DBMS_SERVICE.goal_throughput

  );

END;

/

Stop a Service:

The STOP_SERVICE procedure stops an existing service, so it is no longer available for connections via the listener.

BEGIN

  DBMS_SERVICE.stop_service(

    service_name => 'my_new_service'

  );

END;

/

The service is still present, but it is no longer active.


COLUMN name FORMAT A30

COLUMN network_name FORMAT A30

SELECT name,network_name FROM   dba_services ORDER BY 1;

NAME                           NETWORK_NAME

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

my_new_service                 my_new_service


SELECT name,network_name FROM   v$active_services ORDER BY 1;

No rows selected


Delete a Service:

The DELETE_SERVICE procedure removes an existing service.

BEGIN

  DBMS_SERVICE.delete_service(

    service_name => 'my_new_service'

  );

END;

/


We can see it's not longer listed as an available service.


COLUMN name FORMAT A30

COLUMN network_name FORMAT A30

SELECT name, network_name FROM   dba_services ORDER BY 1;

No rows selected


Disconnect Sessions:

The DISCONNECT_SESSION procedure disconnects all sessions currently connected to the service. The disconnection can take one of three forms, indicated by package constants.


POST_TRANSACTION : Sessions disconnect once their current transaction ends with a commit or rollback. This is the default value (0).

IMMEDIATE : Sessions disconnect immediately. Value (1).

NOREPLAY : Sessions disconnect immediately, and are flagged not to be replayed by application continuity. Value (2).

Here is an example of its usage.


BEGIN

  DBMS_SERVICE.disconnect_session(

   service_name      => 'my_new_service',

   disconnect_option => DBMS_SERVICE.immediate

  );

END;

/

Thursday, August 29, 2013

SGA_TARGET,SGA_MAX_SIZE and SGA_TARGET vs SGA_MAX_SIZE

SGA_TARGET

SGA_TARGET specifies the total size of all SGA components. If SGA_TARGET is specified, then the following memory pools are automatically sized:

    Buffer cache (DB_CACHE_SIZE)
    Shared pool (SHARED_POOL_SIZE)
    Large pool (LARGE_POOL_SIZE)
    Java pool (JAVA_POOL_SIZE)
   
If these automatically tuned memory pools are set to non-zero values, then those values are used as minimum levels by Automatic Shared Memory Management. You would set minimum values if an application component needs a minimum amount of memory to function properly.

The following pools are manually sized components and are not affected by Automatic Shared Memory Management:

    Log buffer
    Other buffer caches, such as KEEP, RECYCLE, and other block sizes
    Streams pool
    Fixed SGA and other internal allocations

The memory allocated to these pools is deducted from the total available for SGA_TARGET when Automatic Shared Memory Management computes the values of the automatically tuned memory pools.

SGA_MAX_SIZE

SGA_MAX_SIZE specifies the maximum size of the SGA for the lifetime of the instance.

     Initial size of SGA at startup, dependent on the sizes of different pools in the SGA, such as buffer cache, shared pool, large pool, and so on.

SGA_TARGET vs SGA_MAX_SIZE

SGA_MAX_SIZE sets the overall amount of memory the SGA can consume but is not dynamic. SGA_TARGET, a new 10g feature used for Automatic Shared Memory Management allows for dynamic resizing of SGA
SGA_MAX_SIZE parameter is the max allowable size to resize the SGA Memory area parameters. If the SGA_TARGET is set to some value then the Automatic Shared Memory Management (ASMM) is enabled, the SGA_TARGET value can be adjusted up to the SGA_MAX_SIZE parameter, not more than SGA_MAX_SIZE parameter value.
i.e. If SGA_MAX_SIZE=4GB and SGA_TARGET=2GB, later period of time, if you want you can resize your SGA_TARGET parameter to the value of SGA_MAX_SIZE i.e. 4GB, you can't resize the SGA_TARGET value to more than 4GB.
Usually, sga_max_size and sga_target will be the same value, but there may be times when you want to have the capability to adjust for peak loads. By setting the Oracle sga_max_size parameter higher than sga_target, you allow dynamic adjustment of the sga_target parameter.

Note that sga_max_size is for Oracle 10g only, and in 11g and beyond, Oracle automatic memory management is configured using the memory_target  and memory_max_target initialization parameters.  The memory_target parameter specifies the amount of shared memory available for Oracle to use when dynamically controlling the SGA and PGA. The memory_max_target AMM parameter specifies the max size that memory_target may take.
You can enable and disable AMM by changing the value of these parameters to non-zero settings:
    sga_target
    sga_max_size
    pga_aggregate_target
    sga_max_size


Wednesday, July 11, 2012

JDK Upgrade on Middle Tier (1.6.0_18)


HTTP Server patch set 10.1.3.4 or above is mandatory for Java 6.0 upgrade
Step 1 Download Latest Update of JDK 6.0
Attention: Download the 32-bit JDK, and not the Java Runtime Environment (JRE). Do not use the 64-bit version, which is not supported.

Step 2 Stop all Application Tier Server Processes

cd $INST_TOP/admin/scripts/

adstpall.sh <apps username/apps password>

Step 3 Replace the JDK Home Used with Oracle EBS Release 12

On UNIX:
  1. cd [IAS_ORACLE_HOME]/appsutil/
  2. mv jdk jdk_old
  3. mkdir jdk
  4. cd jdk
  5. Install the downloaded latest update of JDK 6.0 here, i.e., [IAS_ORACLE_HOME]/appsutil/jdk
Execute the downloaded latest jdk bin file here, it should be executed from the above location ,i.e, IAS_ORACLE_HOME/appsutil/jdk
Press q to exit the License Agreement
Press y to accept the Terms

     cd $IAS_ORACLE_HOME/appsutil/jdk/jdk<version>
     mv * ../
     cd $IAS_ORACLE_HOME/appsutil/jdk
     rmdir jdk<version>
     echo $ADJVAPRG
     Should result IAS_ORACLE_HOME/appsutil/jdk/jre/bin/java
     echo $AFJVAPRG
     Should result $INST_TOP/admin/scripts/java.sh
     $AFJVAPRG –version
     $ADJVAPRG –version

Step 4 Restart all Application Tier Server Processes

cd $INST_TOP/admin/scripts/

adstrtal.sh <apps username/apps password>


Sunday, June 24, 2012

Gather Schema Statistics" program error with Locks and Duplicate columns


Error
*******

**Starts**14-APR-2012 23:58:43
**Ends**15-APR-2012 05:34:48
ORA-0000: normal, successful completion
+---------------------------------------------------------------------------+
Start of log messages from FND_FILE
+---------------------------------------------------------------------------+
In GATHER_SCHEMA_STATS , schema_name= ALL percent= 10 degree = 24 internal_flag= NOBACKUP
stats on table AQ$_WF_CONTROL_P is locked
stats on table FND_CP_GSM_IPC_AQTBL is locked
stats on table FND_SOA_JMS_IN is locked
stats on table FND_SOA_JMS_OUT is locked
Error #1: ERROR: While GATHER_TABLE_STATS:
object_name=GL.JE_BE_LINE_TYPE_MAP***ORA-20001: invalid column name or duplicate columns/column groups/expressions in method_opt***
Error #2: ERROR: While GATHER_TABLE_STATS:
object_name=GL.JE_BE_LOGS***ORA-20001: invalid column name or duplicate columns/column groups/expressions in method_opt***
Error #3: ERROR: While GATHER_TABLE_STATS:
object_name=GL.JE_BE_VAT_REP_RULES***ORA-20001: invalid column name or duplicate columns/column groups/expressions in method_opt***
+---------------------------------------------------------------------------+
End of log messages from FND_FILE
+---------------------------------------------------------------------------+
Successfully resubmitted concurrent program FNDGSCST with request ID 35759846 to start at 22-APR-2012 00:00:00 (ROUTINE=AFPSRS)




Solution
***********


1. Please follow Doc ID 375351.1 to unlock the tables:

                AQ$_WF_CONTROL_P
                FND_CP_GSM_IPC_AQTBL
                FND_SOA_JMS_IN
                FND_SOA_JMS_OUT
               
From DB node run below to unlock tables

                exec dbms_stats.unlock_table_stats('APPLSYS','AQ$_WF_CONTROL_P');
                exec dbms_stats.unlock_table_stats('APPLSYS','FND_CP_GSM_IPC_AQTBL');
                exec dbms_stats.unlock_table_stats('APPLSYS','FND_SOA_JMS_IN');
                exec dbms_stats.unlock_table_stats('APPLSYS','FND_SOA_JMS_OUT');

2. Please perform the following action plan from Doc ID 781813.1 :

   Find out all duplicates and/or obsolete rows in FND_HISTOGRAM_COLS and delete one of them.

   Remember to take backup of the FND_HISTOGRAM_COLS table before deleting any data.

   SQL> create table FND_HISTOGRAM_COLS_BKP as select * from FND_HISTOGRAM_COLS;

 -- identify duplicate rows

   select table_name, column_name, count(*)
   from FND_HISTOGRAM_COLS
   group by table_name, column_name
   having count(*) > 1;

 -- Use above results on the following SQL to delete duplicates

   delete from FND_HISTOGRAM_COLS
   where table_name = '&TABLE_NAME'
   and column_name = '&COLUMN_NAME'
   and rownum=1;

 -- Use following SQL to delete obsoleted rows

   delete from FND_HISTOGRAM_COLS
   where (table_name, column_name) in
   (
   select hc.table_name, hc.column_name
   from FND_HISTOGRAM_COLS hc , dba_tab_columns tc
   where hc.table_name ='&TABLE_NAME'
   and hc.table_name= tc.table_name (+)
   and hc.column_name = tc.column_name (+)
   and tc.column_name is null
   );


3. Run "Gather Schema Statistics" program again.

Data Guard Status Check Queries


1. Issue the following query to show information about the protection mode, the protection level, the role of the database, and switchover status:

                SELECT DATABASE_ROLE, DB_UNIQUE_NAME INSTANCE, OPEN_MODE, PROTECTION_MODE, PROTECTION_LEVEL, SWITCHOVER_STATUS FROM V$DATABASE;

2. On the standby database, query the V$ARCHIVED_LOG view to identify existing files in the archived redo log.

                SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

Or

                SELECT THREAD#, MAX(SEQUENCE#) AS "LAST_APPLIED_LOG" FROM V$LOG_HISTORY GROUP BY THREAD#;

3. On the standby database, query the V$ARCHIVED_LOG view to verify the archived redo log files were applied.

                SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

4. Query the physical standby database to monitor Redo Apply and redo transport services activity at the standby site.

                SELECT PROCESS, STATUS, THREAD#, SEQUENCE#, BLOCK#, BLOCKS FROM V$MANAGED_STANDBY;

5. To determine if real-time apply is enabled, query the RECOVERY_MODE column of the V$ARCHIVE_DEST_STATUS view.

                SELECT RECOVERY_MODE FROM V$ARCHIVE_DEST_STATUS;

6. The V$DATAGUARD_STATUS fixed view displays events that would typically be triggered by any message to the alert log or server process trace files.

                SELECT MESSAGE FROM V$DATAGUARD_STATUS;

7. Determining Which Log Files Were Not Received by the Standby Site.

                SELECT LOCAL.THREAD#, LOCAL.SEQUENCE# FROM (SELECT THREAD#, SEQUENCE# FROM V$ARCHIVED_LOG WHERE DEST_ID=1) LOCAL WHERE LOCAL.SEQUENCE# NOT IN (SELECT SEQUENCE# FROM V$ARCHIVED_LOG WHERE DEST_ID=2 AND THREAD# = LOCAL.THREAD#);

8.If a delayed apply has been specified or an archive log is missing then switchover may take longer than expected.
Check v$managed_standby

                select process, status, sequence# from v$managed_standby;

OR alternatively:

                select name, applied from v$archived_log;