Monday, April 20, 2009

check tcp traffic between servers

Here's the troubleshooting command for tcpdump:

tcpdump -A -s 0 -l 'dst host hostname'

Another example:
tcpdump -nnvvXSs 1024 src 10.94.242.73 and dst port 80 and greater 512


It'll capture 1024 bytes for the request with the size bigger than 512 bytes, and from a specific source server to the http port (80)

drop all tables in an Oracle schema

Here's the script to drop all tables in a schema:

SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 80
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET HEADING OFF
SET MARKUP HTML OFF
SET ESCAPE \
SPOOL DELETEME.SQL
select 'drop table ', table_name, 'cascade constraints \;' from user_tables;
SPOOL OFF
@DELETEME

Monday, March 16, 2009

Linux disk space usage by directory

du -sh * | sort -rn
Sorted by the directory size.

Friday, January 16, 2009

PL/SQL Tips - 1

1. Create procedure, function
procedure (...) is begin end;
function (...) return ... is ... begin end;
in, out, in out parameters.
2. Create package
package header (interface): create or replace package pkg as ... end;
package body (implementation): create or replace package body pkg as ... end;
3. Check objects created by user
select object_type, object_name, status from user_objects where object_type in ('FUNCTION','PROCEDURE','PACKAGE','PACKAGE BODY') order by object_type;
It's stored in the table called "user_objects".
4. Check implementations
select text from user_source where name= 'F_GETAREA_NR' order by line;
It's stored in the table called "user_source".

Wednesday, November 26, 2008

Dumping Oracle schema

Here's the link to dump an Oracle schema:
http://www.tek-tips.com/viewthread.cfm?qid=1301609&page=34

Command
(sample format)exp buffer= compress= grants= feedback= consistent= file= log= owner= userid=/@

(example invocation with sample values)exp buffer=15000000 compress=n grants=y feedback=1000 consistent=y file=DHUNT.TEST.dump log=TEST_Exp.log owner=TEST userid=TEST/TEST@dhunt

"buffer=" : give a large value, which speeds the export"compress=" : "Y" means 'allocate as an initial extent an extent size that accommodates the ENTIRE contents of the table'. "N" means 'use the standard "initial" and "next" parameters for the table. (I use "N" to avoid receiving the Oracle "Unable to allocate initial extent..." error.)"grants=" : "Y" means export the grant on this object; "N" means don't bother exporting grants. Use "N" if the other users that have grants to the source schema's objects in the source database do not exist in the target database."feedback=" : During the export, display to the screen, a dot (".") for every "n" records exported."consistent=" : "Y" means do not allow in-flight transactions to cause contents of tables to become inconsistent during the export."file=" : This is the name you give to the dump file. I usually use the format "..dump"."log=" : This is the name you give to the file that documents the progress (and errors, if applicable) that occur during the export. I usually use the format "_Exp.log"."owner=" : Name of source schema to export."userid=" : connect string for user officiating the export.

To import:
http://www.oracle.com/technology/products/text/x/Samples/Exp_Imp/index.html
Sample:
imp userid=samples/samples file=test.dmp show=n log=test.txt
imp sys/sys file=c:\dmp.dmp fromuser=user1 touser=userA

Sunday, April 27, 2008

starting Struts2

Compared with Struts1, Struts2 seems a little bit simplied regarding configuration files. However, there's something that needs our attention, which is the location of the struts.xml file.
This file should reside in the WEB-INF/classes directory instead of the WEB-INF directory.
It could also be put into a jar file in WEB-INF/lib directory.

Thursday, April 17, 2008

CheatSheet: Installing and Configuring Oracle 10g Database with WebSphere Message Broker (Windows Platform)

By default, webSphere Message Broker uses Derby or DB2 as the broker database; and how to configure Oracle database is not very clear in the documentation. In this cheatsheet, the step-by-step instruction will be given.

1. Create an Oracle table space (TS_WSBKR).
2. Create an Oracle user (WSBKR), and grant unlimited usage on TS_WSBKR to the user.
3. Grant database previlege to the broker database user:
GRANT CREATE SESSION TO WSBKR;
GRANT CREATE TABLE TO WSBKR;

4. Define a DSN for ODBC Connection
4.1 Go to "System DSN" definition tab though "ODBC data source administrator" in windows administrative tools or Oracle menu.
4.2 Create a new datasource using driver:
MQSeries DataDirect Technologies 5.00 32-BIT Sybase Wire Protocol
4.3 Enter the DSN name (DSN_WSBKR), description, and server name (in this case, use orcl, which is a sample Oracle instance), and use 10g client.
4.4 (Optional) In the Advanced tab, Select Enable SQLDescribeParam. Select Procedure Returns Results, which results in the Windows registry a string value called ProcedureRetResults with the value 1 being created.
4.5 Test the connection using WSBKR account and click "OK" button to create the DSN.
4.6 Start Windows regedit, and locate the following value:
HKEY_LOCAL_MACHINE
SOFTWARE
ODBC
ODBC.INI
DSN_WSBKR

Add a String value to the key DSN_WSBKR, which is called "WorkArounds" with the value 536870912.
5. Create an MQ queue manager for the broker (WSBKR_QM).
6. Create a broker to populate the database. When you create a broker, if the WebSphere MQ queue manager does not already exist, the queue manager is automatically created. The broker database must already exist but the tables in which the broker stores its internal data are created automatically when the first broker to use that database is created. Subsequent brokers that you create specifying the same database and database user ID share these tables. An example is like this: C:\Program Files\IBM\MQSI\6.1>mqsicreatebroker WSMSGBROKER -i yelei -a pppassword -q WSBKR_QM -n DSN_WSBKR -u WSBKR -p pppassword.

Note the default broker creation wizard provided by websphere message broker toolkit only creates broker database. In order to store business data, user database should also be created.

Wednesday, April 16, 2008

resolving problem when starting oracle control console

When installing oracle 10g, oracle console cannot be configured and started properly on a multi-network adapter machine. Even after disabling some network adapters, using static IP address, reconfiguring listener properties, it still doesn't work.
The error looks like this:
Refer to the log file at
D:\Programs\oracle\product\10.2.0\db\cfgtoollogs\emca\orcl\emca_2008-04-16_04-18-02-PM.log
for more details.Apr 16, 2008 4:18:28 PM oracle.sysman.emcp.EMConfig
performCONFIG: Stack Trace: oracle.sysman.emcp.exception.EMConfigException:
Error creating the repository at
oracle.sysman.emcp.EMReposConfig.invoke(EMReposConfig.java:194) at
oracle.sysman.emcp.EMReposConfig.invoke(EMReposConfig.java:124) at
oracle.sysman.emcp.EMConfig.perform(EMConfig.java:142) at
oracle.sysman.emcp.EMConfigAssistant.invokeEMCA(EMConfigAssistant.java:479) at
oracle.sysman.emcp.EMConfigAssistant.performConfiguration(EMConfigAssistant.java:1123) at
oracle.sysman.emcp.EMConfigAssistant.statusMain(EMConfigAssistant.java:463) at
oracle.sysman.emcp.EMConfigAssistant.main(EMConfigAssistant.java:412)

Then the following commands in %ORACLE_HOME%/bin might help resolve the problem:
Stop you dbconsole service.
emctl status dbconsole
emctl stop dbconsole

Now start the Oracle EM dbconsole Build Script
emca -repos (re)create
emca -config dbcontrol db