About Me

My photo
Bangalore, India
I am an Oracle Certified Professional working in SAP Labs. Everything written on my blog has been tested on my local environment, Please test before implementing or running in production. You can contact me at amit.rath0708@gmail.com.

Monday, December 16, 2013

How to change ssh port to a non default port in Unix

Yesterday I have to change default ssh port from 22 to 1022. This change in port from default to non-default  enhances security of your server a little bit. Changing port from 22 to 1022 will stop automated attacks and it becomes difficult to guess from which port server is accessible.

Solution :-

1. As root user edit the sshd_config file in /etc/ssh location.

edit Port 22 to Port 1022

2. Before changing port to a non default value, check port is not being used by any other server.

3. Once Port has been changed in /etc/ssh/sshd_config file , restart SSH service :-

  #stopsrc -s sshd
  #startsrc -s sshd

  or by 

  #service sshd restart

4. Check that the changed port is working:-

ssh -p 1022 server1

I hope this article helped you.

Regards,
Amit Rath

Friday, December 13, 2013

Query Parameter in Datapump (EXPDP/IMPDP) utility

Sometimes we need to export or imprt only some data from a huge table. This can be done by using query parameter in Datapump utility. Query parameter can be used in both EXPDP as well as IMPDP utility.

1. EXPDP :-

Query parameter can be used in two ways  :-

a. Using parameter file :-

bash-3.2$
bash-3.2$ cat test.par
TABLES=AMIT
directory=datapump
DUMPFILE=expdp_test.dmp
logfile=expdp_test.log
query=amit:"where DATE > '01-DEC-2013'"
bash-3.2$

bash-3.2$ expdp user/user parfile=test.par

Export: Release 11.2.0.1.0 - Production on Fri Dec 13 12:20:47 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "USER"."SYS_EXPORT_TABLE_01":   user/****** parfile=test.par
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 384 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "USER"."AMIT"             30.67 KB      75 rows
Master table "USER"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for USER.SYS_EXPORT_TABLE_01 is:
  /disk1/datapump/expdp_etst.dmp
Job "USER"."SYS_EXPORT_TABLE_01" successfully completed at 12:20:53

b. In Command Line :-

expdp user/user directory=datapump dumpfile=expdp_taa_01.dmp logfile=expdp_taa_01.log query=amit:\"where DATE \> \'01-DEC-2013\'\" tables=AMIT

Export: Release 11.2.0.1.0 - Production on Fri Dec 13 12:24:50 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "USER"."SYS_EXPORT_TABLE_01":  user/******** directory=datapump dumpfile=expdp_taa_01.dmp logfile=expdp_taa_01.log query=amit:"where DATE > '01-DEC-2013'" tables=AMIT
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 384 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "USER"."AMIT"             30.67 KB      75 rows
Master table "USER"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for USER.SYS_EXPORT_TABLE_01 is:
  /disk1/datapump/expdp_taa_01.dmp
Job "USER"."SYS_EXPORT_TABLE_01" successfully completed at 12:24:56

2. IMPDP :-

a. Using par file :-

bash-3.2$ cat test.par

schemas=DATA
include=TABLE:"IN('TEST')"
directory=datapump
DUMPFILE=expdp_fullDB_12_Dec_13.dmp
logfile=expdp_etst.log
query=test:"where DATE > '01-DEC-2013'"
remap_schema=DATA:AMIT

bash-3.2$ impdp amit/amit parfile=test.par

Import: Release 11.2.0.1.0 - Production on Fri Dec 13 12:44:22 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "AMIT"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting "AMIT"."SYS_IMPORT_SCHEMA_01":  amit/******** parfile=test.par
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
. . imported "AMIT"."TEST"                    51.17 KB      75 out of 1614 rows
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Job "AMIT"."SYS_IMPORT_SCHEMA_01" successfully completed at 12:44:44

b. In Command line :-

bash-3.2$ impdp amit/amit directory=datapump dumpfile=expdp_fullDB_12_Dec_13.dmp logfile=test.log query=TEST:\"where DATE \> \'01-DEC-2013\'\" schemas= DATA  include=TABLE:\"IN\(\'TEST\'\)\" remap_schema=DATA:AMIT

Import: Release 11.2.0.1.0 - Production on Fri Dec 13 12:38:29 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "AMIT"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting "AMIT"."SYS_IMPORT_SCHEMA_01":  amit/******** directory=datapump dumpfile=expdp_fullDB_12_Dec_13.dmp logfile=test.log query=test:"where DATE > '01-DEC-2013'" schemas=DATA include=TABLE:"IN('TEST')" remap_schema=DATA:AMIT
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
. . imported "AMIT"."TEST"                    51.17 KB      75 out of 1614 rows
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Job "AMIT"."SYS_IMPORT_SCHEMA_01" successfully completed at 12:38:55

I hope this article helped you.

Regards,
Amit Rath

Tuesday, December 10, 2013

ORA-14460: only one COMPRESS or NOCOMPRESS clause may be specified

Yesterday I was importing a dumpfile using Datapump utility and I faced below mentioned error :-

Import: Release 11.2.0.1.0 - Production on Tue Dec 09 09:14:11 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table  "AMIT" ."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting  "AMIT" ."SYS_IMPORT_FULL_01":  amit/******** directory=datapump dumpfile=expdp_amit_04.dmp logfile=impdp_amit_01.log remap_schema=amit21:amit TRANSFORM=STORAGE:n
Processing object type TABLE_EXPORT/TABLE/TABLE
ORA-39083: Object type TABLE:"AMIT"."TEST" failed to create with error:
ORA-14460: only one COMPRESS or NOCOMPRESS clause may be specified
Failing sql is:
CREATE TABLE "AMIT"."TEST" ("ID" NUMBER(12) , "NAME" VARCHAR2(20 BYTE)
ORA-39083: Object type TABLE:"AMIT"."TEST" failed to create with error:
ORA-14460: only one COMPRESS or NOCOMPRESS clause may be specified

Solution :-

Use TRANSFORM=segment_attributes:n in IMPDP

impdp amit/amit directory=datapump dumpfile=expdp_amit_04.dmp logfile=impdp_amit_01.log remap_schema=amit21:amit TRANSFORM=STORAGE:n,segment_attributes:n &
Import: Release 11.2.0.1.0 - Production on Tue Dec 09 09:15:49 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table  "AMIT" ."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting  "AMIT" ."SYS_IMPORT_FULL_01":  amit/******** directory=datapump dumpfile=expdp_amit_04.dmp logfile=impdp_amit_01.log remap_schema=amit21:amit TRANSFORM=STORAGE:n,SEGMENT_ATTRIBUTES:n &
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "INCMS2_MG"."SYS_IMPORT_FULL_01" completed at 09:16:34

I hope this article helped you.

Regards,
Amit Rath

Thursday, December 5, 2013

How to determine schemas or contents inside an expdp dumpfile

Sometimes we need to list out the contents of an expdp dumpfile before importing it. There is a parameter in Datapump IMPDP utility in which we can list out ddl's present inside a dump file. PFB steps :-

bash-3.2$ impdp system/system dumpfile=expdp_fullDB_12_Nov_13.dmp logfile=amit.log sqlfile=dump.txt directory=datapump &

Import: Release 11.2.0.1.0 - Production on Thu Dec 5 10:13:53 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYSTEM"."SYS_SQL_FILE_FULL_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_SQL_FILE_FULL_01":  system/******** dumpfile=expdp_fullDB_12_Nov_13.dmp logfile=amit.log sqlfile=dump.txt directory=datapump
Processing object type DATABASE_EXPORT/TABLESPACE
Processing object type DATABASE_EXPORT/SYS_USER/USER
Processing object type DATABASE_EXPORT/SCHEMA/USER
Processing object type DATABASE_EXPORT/ROLE
Processing object type DATABASE_EXPORT/GRANT/SYSTEM_GRANT/PROC_SYSTEM_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/GRANT/SYSTEM_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/ROLE_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/DEFAULT_ROLE
Processing object type DATABASE_EXPORT/RESOURCE_COST
Processing object type DATABASE_EXPORT/SCHEMA/DB_LINK
Processing object type DATABASE_EXPORT/TRUSTED_DB_LINK
Processing object type DATABASE_EXPORT/SCHEMA/SEQUENCE/SEQUENCE
Processing object type DATABASE_EXPORT/DIRECTORY/DIRECTORY
Processing object type DATABASE_EXPORT/DIRECTORY/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/CONTEXT
Processing object type DATABASE_EXPORT/SCHEMA/PUBLIC_SYNONYM/SYNONYM
Processing object type DATABASE_EXPORT/SCHEMA/SYNONYM
Processing object type DATABASE_EXPORT/SCHEMA/TYPE/TYPE_SPEC
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/PRE_SYSTEM_ACTIONS/PROCACT_SYSTEM
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/POST_SYSTEM_ACTIONS/PROCACT_SYSTEM
Processing object type DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/PRE_TABLE_ACTION
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/GRANT/OWNER_GRANT/OBJECT_GRA
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/GRANT/CROSS_SCHEMA/OBJECT_GR
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/CONSTRAINT/CONSTRAINT
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/STATISTICS/INDEX_STATI
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/COMMENT
Processing object type DATABASE_EXPORT/SCHEMA/PACKAGE/PACKAGE_SPEC
Processing object type DATABASE_EXPORT/SCHEMA/FUNCTION/FUNCTION
Processing object type DATABASE_EXPORT/SCHEMA/PROCEDURE/PROCEDURE
Processing object type DATABASE_EXPORT/SCHEMA/PROCEDURE/GRANT/OWNER_GRANT/OBJECT
Processing object type DATABASE_EXPORT/SCHEMA/PACKAGE/COMPILE_PACKAGE/PACKAGE_SP
Processing object type DATABASE_EXPORT/SCHEMA/FUNCTION/ALTER_FUNCTION
Processing object type DATABASE_EXPORT/SCHEMA/PROCEDURE/ALTER_PROCEDURE
Processing object type DATABASE_EXPORT/SCHEMA/VIEW/VIEW
Processing object type DATABASE_EXPORT/SCHEMA/VIEW/GRANT/OWNER_GRANT/OBJECT_GRAN
Processing object type DATABASE_EXPORT/SCHEMA/VIEW/GRANT/CROSS_SCHEMA/OBJECT_GRA
Processing object type DATABASE_EXPORT/SCHEMA/VIEW/COMMENT
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type DATABASE_EXPORT/SCHEMA/PACKAGE_BODIES/PACKAGE/PACKAGE_BOD
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/FUNCTIONAL_AND_BITMAP/
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/STATISTICS/FUNCTIONAL_
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/POST_TABLE_ACTION
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TRIGGER
Processing object type DATABASE_EXPORT/SCHEMA/POST_SCHEMA/PROCACT_SCHEMA
Job "SYSTEM"."SYS_SQL_FILE_FULL_01" successfully completed at 10:14:38

bash-3.2$ ls -ltr|tail 

total 26568216

-rw-r--r--    1 oracle   oinstall   28361199 Dec 05 10:14 dump.txt
-rw-r--r--    1 oracle   oinstall       3937 Dec 05 10:14 amit.log

Above dump.txt includes ddl's of all schemas, tablespaces present inside the dumpfile.

I hope this article helped you.

Regards,
Amit Rath

Monday, December 2, 2013

Difference between Static listener and Dynamic listener registrations

Database can be registered in two ways with a listener :-

1. Static Registration :- A static registration of database to a listener is used when we want to remotely start our database. Static registration is like hardcoding a instance details in listener.ora file. In a static registration an instance is registered with the listener whether its up or not. When a client request comes listener opens a dedicated connection , and server later find out that instance is not up then it gives error message as "Oracle not available". 

2. Dynamic Registration :- In Dynamic registration , registration is performed by PMON process. Once a Database instance starts, its PMON process registers instance details with associated listener. Dynamic registration does not require any manual configuration in the listener.ora file where as Static configuration does.From Oracle 8i dynamic configuration introduced. 

PFB listener.ora file having static configuration :-

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = AMIT)
      (ORACLE_HOME = /oracle_home/oracle/ora11g/product)
    )
    (SID_DESC =
      (SID_NAME = TEST)
      (ORACLE_HOME = /oracle_home/oracle/ora11g/product)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.11.1.10)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /oracle_home/oracle

PFB listener.ora file having dynamic configuration :-

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.11.1.10)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /oracle_home/oracle
As we can see dynamic configuration is much easier as compared to static configuration.

PFB listener status details when using Dynamic regitration :-

bash-3.2$ lsnrctl status

LSNRCTL for IBM/AIX RISC System/6000: Version 11.2.0.1.0 - Production on 02-DEC-2013 10:51:59

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=amit)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for IBM/AIX RISC System/6000: Version 11.2.0.1.0 - Production
Start Date                01-DEC-2013 16:19:04
Uptime                    10 days 18 hr. 32 min. 56 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /oracle_home/oracle/ora11g/product/network/admin/listener.ora
Listener Log File         /oracle_home/oracle/diag/tnslsnr/new/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=amit)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "amit" has 1 instance(s).
  Instance "amit", status READY, has 1 handler(s) for this service...
Service "amitXDB" has 1 instance(s).
  Instance "amit", status READY, has 1 handler(s) for this service...
The command completed successfully

Above status as "READY" resembles that listener has checked instance details and found its status as up or running to handle client request.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=amit)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for IBM/AIX RISC System/6000: Version 11.2.0.1.0 - Production
Start Date                01-DEC-2013 16:42:04
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /oracle_home/oracle/ora11g/product/network/admin/listener.ora
Listener Log File         /oracle_home/oracle/diag/tnslsnr/new/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=amit)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

Above status resembles that either Instance is not up, or its not been registered with listener.

PFB commands to register database instance with listerner if its not automatically registering with listener :-

bash-3.2$ sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Mon Dec 2 11:43:39 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Enter user-name: /as sysdba

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter system register;

System altered.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
bash-3.2$ lsnrctl status

LSNRCTL for IBM/AIX RISC System/6000: Version 11.2.0.1.0 - Production on 02-DEC-2013 11:43:51

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=amit)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for IBM/AIX RISC System/6000: Version 11.2.0.1.0 - Production
Start Date                01-DEC-2013 16:44:04
Uptime                    0 days 0 hr. 1 min. 47 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /oracle_home/oracle/ora11g/product/network/admin/listener.ora
Listener Log File         /oracle_home/oracle/diag/tnslsnr/new/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=amit)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "amit" has 1 instance(s).
  Instance "amit", status READY, has 1 handler(s) for this service...
Service "amitXDB" has 1 instance(s).
  Instance "amit", status READY, has 1 handler(s) for this service...
The command completed successfully

PFB listener status details when using static regitration also :-

bash-3.2$ lsnrctl status

LSNRCTL for IBM/AIX RISC System/6000: Version 11.2.0.1.0 - Production on 02-DEC-2013 11:50:28

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST= amit)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for IBM/AIX RISC System/6000: Version 11.2.0.1.0 - Production
Start Date                01-DEC-2013 18:10:27
Uptime                    0 days 02 hr. 40 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /oracle/oracle/ora11g/product/network/admin/listener.ora
Listener Log File         /oracle/oracle/diag/tnslsnr/pacs3/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=amit)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "amit" has 2 instance(s).
  Instance "amit", status UNKNOWN, has 1 handler(s) for this service...
  Instance "amit", status READY, has 1 handler(s) for this service...
Service "amitXDB" has 1 instance(s).
  Instance "amit", status READY, has 1 handler(s) for this service...
The command completed successfully

Above status as "UNKNOWN" resembles that listener has not checked instance status details that whether its up or not, it has just registered the details of instance. So listener is not sure that whether instance can handle client request or not.

I hope this article helped you.

Regards,
Amit Rath

H2 Database ( In Memory Database)

H2 database is a RDBMS , IN Memory database. Its a java SQL database. Main Features of H2 database are :-

1. Very fast ,open source , JDBC Api
2. Can have both embedded and server modes
3. Browser based console application.
4. Small footprint of 1MB size jar file.
5. Commercial support is available.

Maximum Size of H2 Database :-

1. Database File Size Limit :- 4 TB or higher ( using default page size 2KB).
2. Maximum rows per table :- 2^64
3. Memory Requirements for IN memory database :- Larger Database needs more memory. As 1.1 version storage mechanism, minimum memory required for 12 GB database is 240 MB.

There are two modes of H2 database :-

1. Embedded Mode :- In this mode, application and database are in same Virtual Machine( VM )  . Application open database within same VM. It is the fastest and easiest connection mode. But in this mode database will be open in one VM only. Both persistent as well as IN memory database can be opened. NO Limit is there on number of database open currently and number of open connections.

H2 database in Embedded , persistent mode :-

bash-3.2$ pwd
/home/oracle/h2/bin
bash-3.2$ java -cp h2-1.3.170.jar org.h2.tools.Shell

Welcome to H2 Shell 1.3.170 (2012-11-30)
Exit with Ctrl+C
[Enter]   jdbc:h2:~/test
URL       jdbc:h2:~/amit
[Enter]   org.h2.Driver
Driver
[Enter]   sa
User      amit
[Enter]   Hide
Password  amit
Connected
Commands are case insensitive; SQL statements end with ';'
help or ?      Display this help
list           Toggle result list / stack trace mode
maxwidth       Set maximum column width (default is 100)
autocommit     Enable or disable autocommit
history        Show the last 20 statements
quit or exit   Close the connection and exit

sql> show tables;
TABLE_NAME | TABLE_SCHEMA
AA         | PUBLIC
AMIT       | PUBLIC
(2 rows, 23 ms)

H2 database in Embedded , Memory mode :-

bash-3.2$ java -cp h2-1.3.170.jar org.h2.tools.Shell

Welcome to H2 Shell 1.3.170 (2012-11-30)
Exit with Ctrl+C
[Enter]   jdbc:h2:~/test
URL       jdbc:h2:mem:
[Enter]   org.h2.Driver
Driver
[Enter]   sa
User      amit_mem
[Enter]   Hide
Password  amit_mem
Connected
Commands are case insensitive; SQL statements end with ';'
help or ?      Display this help
list           Toggle result list / stack trace mode
maxwidth       Set maximum column width (default is 100)
autocommit     Enable or disable autocommit
history        Show the last 20 statements
quit or exit   Close the connection and exit

sql> show tables;
TABLE_NAME | TABLE_SCHEMA
(0 rows, 221 ms)
sql>

2. Server Mode :-  In this mode an application open a database residing on another server. A server can be started on same or another virtual machine. Many applications can connect to same database at same time . Internally server process open database in Embedded mode. Server process is slower than embedded mode as data is transferred over TCP/IP.

H2 database in Server mode (persistent mode) :-

1. First start the server 

bash-3.2$ pwd
/home/oracle/h2/bin
bash-3.2$ java -cp h2-1.3.170.jar org.h2.tools.Server
Web Console server running at http://10.10.7.11:8082 (only local connections)
Failed to start a browser to open the URL http://10.10.7.11:8082: Browser detection failed and system property h2.browser not set
TCP server running at tcp://10.10.7.11:9092 (only local connections)
PG server running at pg:// 10.10.7.11:5435 (only local connections)

2. open local connections to this server from another session :-

bash-3.2$ java -cp h2-1.3.170.jar org.h2.tools.Shell

Welcome to H2 Shell 1.3.170 (2012-11-30)
Exit with Ctrl+C
[Enter]   jdbc:h2:~/test
URL       jdbc:h2:tcp://10.10.7.11:9092/~/amit
[Enter]   org.h2.Driver
Driver
[Enter]   sa
User      incms
[Enter]   Hide
Password  incms
Connected
Commands are case insensitive; SQL statements end with ';'
help or ?      Display this help
list           Toggle result list / stack trace mode
maxwidth       Set maximum column width (default is 100)
autocommit     Enable or disable autocommit
history        Show the last 20 statements
quit or exit   Close the connection and exit


sql> 
show tables;
TABLE_NAME | TABLE_SCHEMA
AA         | PUBLIC
AMIT       | PUBLIC
(2 rows, 64 ms)

H2 database in Server mode (Memory mode) :- We can open a IN memory H2 database in Server mode also. Its called a Named Memory H2 database. We can open Named memory H2 database from multiple sessions :-

bash-3.2$ java -cp h2-1.3.170.jar org.h2.tools.Shell

Welcome to H2 Shell 1.3.170 (2012-11-30)
Exit with Ctrl+C
[Enter]   jdbc:h2:~/test
URL       jdbc:h2:tcp://10.10.7.11:9092/mem:memory
[Enter]   org.h2.Driver
Driver
[Enter]   sa
User      incms
[Enter]   Hide
Password  incms121
Connected
Commands are case insensitive; SQL statements end with ';'
help or ?      Display this help
list           Toggle result list / stack trace mode
maxwidth       Set maximum column width (default is 100)
autocommit     Enable or disable autocommit
history        Show the last 20 statements
quit or exit   Close the connection and exit

sql>  create table aaa
...> ( id number, name varchar2(12));
(Update count: 0, 0 ms)
sql>
sql> insert into aaa values ('1' ,'amit');
(Update count: 1, 60 ms)
sql> insert into aaa values ('21' ,'sunil');
(Update count: 1, 0 ms)
sql> commit;
(Update count: 0, 0 ms)
sql> select * from aaa;
ID | NAME
1  | amit
21 | sunil
(2 rows, 150 ms)
sql>

Open this memory database from another session :-

bash-3.2$ java -cp h2-1.3.170.jar org.h2.tools.Shell

Welcome to H2 Shell 1.3.170 (2012-11-30)
Exit with Ctrl+C
[Enter]   jdbc:h2:~/test
URL       jdbc:h2:tcp://10.10.7.11:9092/mem:memory
[Enter]   org.h2.Driver
Driver
[Enter]   sa
User      incms
[Enter]   Hide
Password  incms121
Connected
Commands are case insensitive; SQL statements end with ';'
help or ?      Display this help
list           Toggle result list / stack trace mode
maxwidth       Set maximum column width (default is 100)
autocommit     Enable or disable autocommit
history        Show the last 20 statements
quit or exit   Close the connection and exit

sql> select * from aaa;
.ID | NAME
1  | amit
21 | sunil
(2 rows, 139 ms)

For more clarifications related to H2 database visit http://www.h2database.com//html/main.html 

I hope this article helped you.

Regards,
Amit Rath