Tuesday, June 19, 2012

IPCS (Inter-process communication)

Inter-process communication (IPC) is a set of methods for the exchange of data among multiple threads in one or more processes. Processes may be running on one or more computers connected by a network. IPC methods are divided into methods for message passing, synchronization, shared memory, and remote procedure calls (RPC). The method of IPC used may vary based on the bandwidth and latency of communication between the threads, and the type of data being communicated.

This technique allows the processes to communicate with each another.
Since each process has its own address space and unique user space, how does the process communicate each other?
The answer is Kernel, the heart of the Linux operating system that has access to the whole memory. So we can request the kernel to allocate the space which can be used to communicate between processes.

The process can also communicate by having a file accessible to both the processes. Processes can open, and read/write the file, which requires lot of I/O operation that consumes time.

Different Types of IPCS

There are various IPC’s which allows a process to communicate with another processes, either in the same computer or different computer in the same network.
  • Pipes – Provides a way for processes to communicate with each another by exchanging messages. Named pipes provide a way for processes running on different computer systems to communicate over the network.
  • Shared Memory – Processes can exchange values in the shared memory. One process will create a portion of memory which other process can access.
  • Message Queue – It is a structured and ordered list of memory segments where processes store or retrieve data.
  • Semaphores – Provides a synchronizing mechanism for processes that are accessing the same resource. No data is passed with a semaphore; it simply coordinates access to shared resources.

10 IPCS Command Example

ipcs is a UNIX / Linux command, which is used to list the information about the inter-process communication ipcs command provides a report on System V IPCS (Message queue, Semaphore, and Shared memory).

IPCS Example 1: List all the IPC facility

ipcs command with -a option lists all the IPC facilities which has read access for the current process. It provides details about message queue, semaphore and shared memory.

# ipcs -a

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0xc616cc44 1056800768 oracle    660        4096       0
0x0103f577 323158020  root      664        966        1
0x0000270f 325713925  root      666        1          2

------ Semaphore Arrays --------
key        semid      owner      perms      nsems
0x0103eefd 0          root      664        1
0x0103eefe 32769      root      664        1
0x4b0d4514 1094844418 oracle    660        204

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
0x000005a4 32768      root       644        0            0
All the IPC facility has unique key and identifier, which is used to identify an IPC facility.

IPCS Example 2: List all the Message Queue

ipcs with option -q, lists only message queues for which the current process has read access.
$ ipcs -q

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
0x000005a4 32768      root       644        0            0

IPCS Example 3. List all the Semaphores

ipcs -s option is used to list the accessible semaphores.
# ipcs -s

------ Semaphore Arrays --------
key        semid      owner      perms      nsems
0x0103eefd 0          root      664        1
0x0103eefe 32769      root      664        1
0x4b0d4514 1094844418 oracle    660        204

IPCS Example 4. List all the Shared Memory

ipcs -m option with ipcs command lists the shared memories.
# ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0xc616cc44 1056800768 oracle    660        4096       0
0x0103f577 323158020  root      664        966        1
0x0000270f 325713925  root      666        1          2

IPCS Example 5. Detailed information about an IPC facility

ipcs -i option provides detailed information about an ipc facility.
# ipcs -q -i 32768

Message Queue msqid=32768
uid=0   gid=0   cuid=0  cgid=0  mode=0644
cbytes=0        qbytes=65536    qnum=0  lspid=0 lrpid=0
send_time=Not set
rcv_time=Not set
change_time=Thu Aug  5 13:30:22 2010
Option -i with -q provides information about a particular message queue. Option -i with -s provides semaphore details. Option -i with -m provides details about a shared memory.

IPCS Example 6. Lists the Limits for IPC facility

ipcs -l option gives the system limits for each ipc facility.
# ipcs -m -l

------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 67108864
max total shared memory (kbytes) = 17179869184
min seg size (bytes) = 1
The above command gives the limits for shared memory. -l can be combined with -q and -s to view the limits for message queue and semaphores respectively.
Single option -l gives the limits for all three IPC facilities.
# ipcs -l

IPCS Example 7. List Creator and Owner Details for IPC Facility

ipcs -c option lists creator userid and groupid and owner userid and group id. This option can be combined with -m, -s and -q to view the creator details for specific IPC facility.
# ipcs -m -c

------ Shared Memory Segment Creators/Owners --------
shmid      perms      cuid       cgid       uid        gid
1056800768 660        oracle     oinstall   oracle     oinstall
323158020  664        root       root       root       root
325713925  666        root       root       root       root

IPCS Example 8. Process ids that accessed IPC facility recently

ipcs -p option displays creator id, and process id which accessed the corresponding ipc facility very recently.
# ipcs -m -p

------ Shared Memory Creator/Last-op --------
shmid      owner      cpid       lpid
1056800768 oracle     16764      5389
323158020  root       2354       2354
325713925  root       20666      20668
-p also can be combined with -m,-s or -q.

IPCS Example 9. Last Accessed Time

ipcs -t option displays last operation time in each ipc facility. This option can also be combined with -m, -s or -q to print for specific type of ipc facility. For message queue, -t option displays last sent and receive time, for shared memory it displays last attached (portion of memory) and detached timestamp and for semaphore it displays last operation and changed time details.
# ipcs -s -t

------ Semaphore Operation/Change Times --------
semid    owner      last-op                    last-changed
0        root        Thu Aug  5 12:46:52 2010   Tue Jul 13 10:39:41 2010
32769    root        Thu Aug  5 11:59:10 2010   Tue Jul 13 10:39:41 2010
1094844418 oracle      Thu Aug  5 13:52:59 2010   Thu Aug  5 13:52:59 2010

IPCS Example 10. Status of current usage

ipcs with -u command displays current usage for all the IPC facility. This option can be combined with a specific option to display the status for a particular IPC facility.
# ipcs -u

------ Shared Memory Status --------
segments allocated 30
pages allocated 102
pages resident  77
pages swapped   0
Swap performance: 0 attempts     0 successes

------ Semaphore Status --------
used arrays = 49
allocated semaphores = 252

------ Messages: Status --------
allocated queues = 1
used headers = 0
used space = 0 bytes

Tuesday, June 12, 2012

Usage of WFLOAD command for UPLOAD,DOWNLOAD

We use the Workflow Definitions Loader to save or load process definitions from a database or flat file. We can also define as it is a utility that moves workflow data between a file and a database and it is also used to upgrade, upload and download the workflow data.
Following is the syntax and the parameter details of WFLOAD

WFLOAD <apps/pwd> 0 Y {UPLOAD | DOWNLOAD | UPGRADE | FORCE} [@<appl-shortname>:]<filepath> [<item type>]
WFLOAD <apps/pwd>@<connect_string> 0 Y {UPLOAD | UPGRADE | FORCE} <filepath>[<file_name.wft>]
Example:-
 WFLOAD apps/pwd@<connect_string> 0 Y UPLOAD POREQAPPRV.wft

Different “Upload Modes” applicable to WFLOADUPGRADE – Honors both protection and customization levels of dataUPLOAD  - Honors only protection level of data [No respect of Customization Level]FORCE   - Force upload regardless of protection or customization level

Use the following command to download workflow definition
WFLOAD <apps/pwd> 0 Y {UPLOAD | DOWNLOAD | UPGRADE | FORCE} [@<appl-shortname>:]<filepath> [<item type>]
WFLOAD <apps_user_name>/<password>@db 0 Y DOWNLOAD file_name.wft <Item_Type>
Example:-

WFLOAD <apps_user_name>/<password>@db 0 Y DOWNLOAD header.wft OEOH

DOWNLOAD -  Parameter to WFLOAD to download workflow definition

As a standard practice, Oracle’s upgrade patches mostly run in UPGRADE mode, hence your customizations can protected if best practices for development are followed.

One can find the seeded workflow definition files under
$<PRODUCT_TOP>/patch/115/import/<LANG> directory.
For example, .wft files related to order management can be located in the following directory:-

 $ONT_TOP/patch/115/import/US
Example:
-------
[usxxxxx:oracle:]$ WFLOAD apps/simple4u 0 Y FORCE $LDMF_TOP/install/sql/LOGI_STANDARD_PRICING_WF.wft
Log filename    : L7883028.log


Report filename : O7883028.out
Oracle Workflow Definition Loader 2.6.4.0.
Access level: 100, Mode: FORCE
Uploaded 2 ITEM_TYPE record(s) to database.
Uploaded 53 LOOKUP_TYPE record(s) to database.
Uploaded 23 MESSAGE record(s) to database.
Uploaded 101 ACTIVITY record(s) to database.
Uploaded 0 ROLE record(s) to database.

Wednesday, June 6, 2012

Oracle 11g New Features

How to check alert.log in Oracle 11g
#############################

Oracle 11g introduce new tool/utility called ADRCI known as ADR command line tool.
This tool allow user to interact with ADR ,check alert log, check health monitor(HM) status ,

Package incident and problem information into a zip file for send to Oracle Support. Etc.


No username/password need to log in to ADRCI, ADRCI interact with file system and ADR data is secured only by operating system permissions on the ADR directories.

$adrci
adrci> set editor vi
adrci> show alert ( it will open alert in vi editor )
adrci> show alert -tail ( Similar to Unix tail command )
adrci> show alert -tail 200 ( Similar to Unix Command tail -200 )
adrci> show alert -tail -f ( Similar to Unix command tail -f )

adrci> show alert -tail 100 -f ( Similar to tail -100f )


Too list all the "ORA-" error run following command

$adrci
adrci> show alert -P "MESSAGE_TEXT LIKE '%ORA-%'"
>


In 11g alert file is saved in 2 location, one is in alert directory ( in XML format log.xml ) and
old style alert file in trace directory. Both these directory reside inside ADR HOME. ADR (Automatic Diagnostic Repository ) is a file system based directory structure outside of the database, So you can have access of diagnostic data even database is down.

New initialization parameter DIAGNOSTIC_DEST decide where to store ADR data ( i.e diagnostic data). In oracle 11g parameter background_dump_dest, core_dump_dest, user_dump_dest is replaced by DIAGNOSTIC_DEST. Even you set background_dump_dest, core_dump_dest, user_dump_dest it not going to used i.e. 11g ignore these parameters.


SQL> show parameter diagnostic_dest
NAME TYPE VALUE
--------------- --------------------------- -------------------------
diagnostic_dest string /u01/app/oracle