Wednesday, March 26, 2014

Soalris Trouble-shooting Journal


ps -e -opid,vsz,rss,osz,args

find and grep in one command line.
find . -print |xargs grep -i sh

Print the rest of the line
 awk '{print $1 "," $2 "," $3 "," $4 "," substr($0, index($0,$5))}' ps.txt > parsed.csv

Network Trouble-shooting

User complain application is to slow
Find which process is using certain port number
#  ps -ef| awk '{print $2}'| xargs -I '{}' sh -c 'echo examining process {}; pfiles {}| grep 7777'

# netstat -na |grep 7777
17.15.210.9.7777    137.15.191.92.33774  350720      0 49256      0 FIN_WAIT_2                                                                                                  
17.15.210.9.7777    137.15.191.92.33780  525568      0 49256      0 FIN_WAIT_2                                                                                                  
17.15.210.9.7777    137.15.191.92.33783  65024      0 49256      0 TIME_WAIT                                                                                                    
17.15.210.9.7777    137.15.191.92.33784  65024      0 49256      0 TIME_WAIT                                                                                                    
17.15.210.9.33507   137.15.210.9.7777    49152      0 49152      0 TIME_WAIT                                                                                                    
127.0.0.1.33511      127.0.0.1.7777       49243      0 49152      0 TIME_WAIT                                                                                                    
17.15.210.9.7777    137.15.191.92.32776  65024      0 49256      0 FIN_WAIT_2                                                                                                   
17.15.210.9.7777    137.15.191.92.32777  36736      0 49256      0 ESTABLISHED                                                                                                  
      *.7777               *.*                0      0 49152      0 LISTEN             

# ndd -get /dev/tcp tcp_time_wait_interval
# ndd -set /dev/tcp tcp_time_wait_interval 30000

Check Memory Allocated between Kernel and Users

# echo "::memstat" |mdb -k
Page Summary                Pages                MB  %Tot
------------     ----------------  ----------------  ----
Kernel                     751429              5870    9%
ZFS File Data              176922              1382    2%
Anon                      3034600             23707   36%
Exec and libs               40147               313    0%
Page cache                 645848              5045    8%
Free (cachelist)          3563927             27843   42%
Free (freelist)            175735              1372    2%
Total                     8388608             65536
 

ipcs - report inter-process communication facilities status

# ipcs -a

IPC status from <running system> as of Thursday, March 27, 2014 08:26:37 AM EDT
T         ID      KEY        MODE        OWNER    GROUP  CREATOR   CGROUP CBYTES  QNUM QBYTES LSPID LRPID   STIME    RTIME    CTIME
Message Queues:
T         ID      KEY        MODE        OWNER    GROUP  CREATOR   CGROUP NATTCH      SEGSZ   CPID  LPID   ATIME    DTIME    CTIME
Shared Memory:
m 2046820368   0xe40fca34 --rw-r-----   oracle      dba   oracle      dba     30       8192 12929  9289  8:25:38  8:25:38 15:04:47
m 2046820367   0x0        --rw-r-----   oracle      dba   oracle      dba     30 1593835520 12929  9289  8:25:38  8:25:38 15:04:47
m 2046820366   0x0        --rw-r-----   oracle      dba   oracle      dba     30   16777216 12929  9289  8:25:38  8:25:38 15:04:47
m  637534211   0x431e738c --rw-r-----   oracle      dba   oracle      dba     30       8192 16241  9172  8:22:03  8:22:03  9:35:20
m  620757119   0x0        --rw-r-----   oracle      dba   oracle      dba     30 1593835520 16241  9172  8:22:03  8:22:03  9:35:00
m  620757118   0x0        --rw-r-----   oracle      dba   oracle      dba     30   16777216 16241  9172  8:22:03  8:22:03  9:35:00
m         21   0xbeb8757c --rw-r-----   oracle      dba   oracle      dba     22       8192  5053  8414  8:00:03  8:00:03  9:51:04
m         20   0x0        --rw-r-----   oracle      dba   oracle      dba     22  637534208  5053  8414  8:00:03  8:00:03  9:51:04
m         19   0x0        --rw-r-----   oracle      dba   oracle      dba     22  637534208  5053  8414  8:00:03  8:00:03  9:51:04
m         18   0x0        --rw-r-----   oracle      dba   oracle      dba     22  352321536  5053  8414  8:00:03  8:00:03  9:51:04
m          6   0x16494d40 --rw-r-----   oracle      dba   oracle      dba     47       8192  4456  9268  8:25:01  8:25:01  9:48:18
m          5   0x0        --rw-r-----   oracle      dba   oracle      dba     47 1593835520  4456  9268  8:25:01  8:25:01  9:48:17
m          4   0x0        --rw-r-----   oracle      dba   oracle      dba     47   16777216  4456  9268  8:25:01  8:25:01  9:48:17
m          2   0x1afdc6c0 --rw-r-----   oracle      dba   oracle      dba     31       8192  4363  9308  8:26:29  8:26:29  9:47:01
m          1   0x0        --rw-r-----   oracle      dba   oracle      dba     31 1593835520  4363  9308  8:26:29  8:26:29  9:47:00
m          0   0x0        --rw-r-----   oracle      dba   oracle      dba     31   16777216  4363  9308  8:26:29  8:26:29  9:47:00
T         ID      KEY        MODE        OWNER    GROUP  CREATOR   CGROUP NSEMS   OTIME    CTIME
Semaphores:
s         84   0xd6077268 --ra-r-----   oracle      dba   oracle      dba   154  8:26:32 15:04:47
s         46   0x97c29ec  --ra-r-----   oracle      dba   oracle      dba   154  8:26:34  9:35:20
s         12   0x913ec9ac --ra-r-----   oracle      dba   oracle      dba   154  8:26:36  9:51:04
s          8   0x408bd0e4 --ra-r-----   oracle      dba   oracle      dba   154  8:26:36  9:48:18
s          4   0x31ebae14 --ra-r-----   oracle      dba   oracle      dba   154  8:26:29  9:47:01
s          0   0x7c4d     --ra-ra-ra-     root     root     root     root     1  3:08:20 15:00:37





User Memory Usage

# prstat -s size
# prstat -s rss
   PID USERNAME  SIZE   RSS STATE   PRI NICE      TIME  CPU PROCESS/NLWP
 12953 oracle   1785M 1762M sleep    59    0   0:02:16 0.0% oracle/258
  4384 oracle   1789M 1761M sleep    59    0   0:20:29 0.0% oracle/258
 12955 oracle   1784M 1759M sleep    59    0   0:02:15 0.0% oracle/258
  4477 oracle   1786M 1758M sleep    59    0   0:20:58 0.0% oracle/258
  4386 oracle   1789M 1757M sleep    59    0   0:19:50 0.0% oracle/258
  4479 oracle   1787M 1756M sleep    59    0   0:20:40 0.0% oracle/258
 13030 oracle   1779M 1752M sleep    59    0   0:00:06 0.0% oracle/1
  4553 oracle   1778M 1752M sleep    59    0   0:00:57 0.0% oracle/1
 12967 oracle   1774M 1751M sleep    59    0   0:08:56 0.0% oracle/1
 12963 oracle   1774M 1751M sleep    59    0   0:00:06 0.0% oracle/1
 12969 oracle   1774M 1751M sleep    59    0   0:00:07 0.0% oracle/1
 12943 oracle   1774M 1751M sleep    59    0   0:00:20 0.0% oracle/1
 12994 oracle   1774M 1751M sleep    59    0   0:00:09 0.0% oracle/1
 12937 oracle   1774M 1751M sleep    59    0   0:01:19 0.0% oracle/1
 12971 oracle   1774M 1751M sleep    59    0   0:00:07 0.0% oracle/1
 16288 oracle   1784M 1751M sleep    59    0   0:09:49 0.0% oracle/258
 16286 oracle   1784M 1750M sleep    59    0   0:09:59 0.0% oracle/258
 13032 oracle   1774M 1750M sleep    59    0   0:00:10 0.0% oracle/1
 12949 oracle   1774M 1750M sleep    59    0   0:08:57 0.0% oracle/1
 21326 oracle   1784M 1750M sleep    60    0   0:11:04 0.0% oracle/13
 13189 oracle   1774M 1750M sleep    59    0   0:00:26 0.0% oracle/1
  4450 oracle   1779M 1749M sleep    59    0   0:00:50 0.0% oracle/1
 12945 oracle   1774M 1749M sleep    59    0   0:00:28 0.0% oracle/1
  4448 oracle   1775M 1749M sleep    59    0   0:01:26 0.0% oracle/1
  4398 oracle   1774M 1749M sleep    59    0   1:13:48 0.0% oracle/1
  4551 oracle   1775M 1749M sleep    59    0   0:01:24 0.0% oracle/1
  8814 oracle   1775M 1748M sleep    59    0   0:00:01 0.0% oracle/1
  8240 oracle   1775M 1748M sleep    59    0   0:00:02 0.0% oracle/1
  4491 oracle   1774M 1748M sleep    59    0   1:12:41 0.0% oracle/1
 21365 oracle   1784M 1748M sleep    60    0   0:02:58 0.0% oracle/7
  4473 oracle   1774M 1748M sleep    59    0   1:16:30 0.0% oracle/1
  4380 oracle   1774M 1748M sleep    59    0   1:13:20 0.0% oracle/1
  4394 oracle   1774M 1747M sleep    59    0   0:00:51 0.0% oracle/1
  4461 oracle   1774M 1747M sleep    59    0   0:10:09 0.0% oracle/1
  4487 oracle   1774M 1747M sleep    59    0   0:00:51 0.0% oracle/1
  4368 oracle   1774M 1747M sleep    59    0   0:10:20 0.0% oracle/1
  8945 oracle   1774M 1747M sleep    59    0   0:00:00 0.0% oracle/1
  4469 oracle   1774M 1747M sleep    59    0   0:03:48 0.0% oracle/1
  4493 oracle   1774M 1747M sleep    59    0   0:01:07 0.0% oracle/1
  4374 oracle   1774M 1747M sleep    59    0   0:02:44 0.0% oracle/1
  4513 oracle   1774M 1747M sleep    59    0   0:01:10 0.0% oracle/1
  4400 oracle   1774M 1747M sleep    59    0   0:01:07 0.0% oracle/1
  4410 oracle   1774M 1747M sleep    59    0   0:01:12 0.0% oracle/1
  4495 oracle   1774M 1747M sleep    59    0   0:01:05 0.0% oracle/1
  4402 oracle   1774M 1747M sleep    59    0   0:01:04 0.0% oracle/1
  4467 oracle   1774M 1747M sleep    59    0   0:02:38 0.0% oracle/1
Total: 271 processes, 6303 lwps, load averages: 0.19, 0.21, 0.21


Display information about the address space of a process

# pmap -x /proc/* > /var/tmp/pmap.txt
# egrep "[0-9]:|^total" /var/tmp/pmap.txt
9663:   /opt/IBM/WebSphere/AppServer/java/bin/sparcv9/java -XX:+UnlockDiagnost
9711:   /opt/IBM/WebSphere/AppServer/java/bin/sparcv9/java -XX:+UnlockDiagnost
989:    /usr/sbin/auditd
total Kb    9560    6456     184       -
9897:   /opt/IBM/WebSphere/AppServer/java/bin/sparcv9/java -XX:+UnlockDiagnost
991:    /usr/bin/login
total Kb    4080    3328      80       -
9944:   /opt/IBM/WebSphere/AppServer/java/bin/sparcv9/java -XX:+UnlockDiagnost
9974:   oracleV11STA (LOCAL=NO)
9994:   /opt/IBM/WebSphere/AppServer/java/bin/sparcv9/java -XX:+UnlockDiagnost


Display kernel statistics

# kstat -p
# kstat -p -c kmem_cache
# kstat -p -m vmem
# kstat -p -c vmem

Kernel Memory Usage

# echo ::kmastat |mdb -k >/var/tmp/kmastat.txt
cache                        buf    buf    buf    memory     alloc alloc
name                        size in use  total    in use   succeed  fail
------------------------- ------ ------ ------ --------- --------- -----
kmem_magazine_1               16   3578  70104   1130496  66395659     0
kmem_magazine_3               32  26504  33274   1073152   1663838     0
kmem_magazine_7               64   8285  37973   2449408  13721403     0
kmem_magazine_15             128  15055 140868  18317312   9814269     0
kmem_magazine_31             256   1772   3379    892928   2679104     0
kmem_magazine_47             384    937  16968   6619136   1816530     0
kmem_magazine_63             512    446  29310  16007168    710969     0
kmem_magazine_95             768    539   1960   1605632   1472138     0
kmem_magazine_143           1152   1883  22316  26116096    774079     0
kmem_slab_cache               56 585196 629010  35536896  79538488     0
kmem_bufctl_cache             24 1620169 1708221  41279488  81971159     0
kmem_bufctl_audit_cache      128      0      0         0         0     0
kmem_va_8192                8192 530991 644096 981467136   3068930     0
kmem_va_16384              16384 373715 404832 2337800192  24111784     0
kmem_va_24576              24576    157    770  20185088     76948     0
kmem_va_32768              32768    392    752  24641536     50345     0
kmem_va_40960              40960    154    486  21233664     77627     0
kmem_va_49152              49152    164    165   8650752     44645     0


Reference: http://docs.oracle.com/cd/E19253-01/816-5041/casestudy-27/index.html
 

Friday, March 21, 2014

WebSphere JEE Packaging recommendations


Consider the following basic rules when packaging an enterprise application:
Package EJB JAR modules and web WAR modules that make up an application together
in the same EAR module and execute them within the same application server JVM
process. This configuration avoids remote EJB calls (RMI/IIOP) across application server
JVM processes, which is costly from a performance perspective.
Place utility classes that are used by a single web module only within the web module’s
WEB-INF/lib folder.
Place utility classes that are used by multiple modules within an enterprise application at
the root of the EAR file as Utility Projects so that they are accessible by both servlets and
EJB.
Place utility classes that are used by multiple enterprise applications outside the
applications on a directory that is referenced through a shared library definition.
Keep the class path clean and reference only required libraries for your application.

Thursday, March 20, 2014

Oracle: Create New Database

Login as oracle
$ export ORACLE_SID=BMP

$ cat initBMP.ora

db_name='BMP'
memory_target=1G
processes = 150
audit_file_dest='/usr2/app/oracle/admin/BMP/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/usr2/app/oracle/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/usr2/app/oracle'
dispatchers='(PROTOCOL=TCP) (SERVICE=BMPXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
control_files = (/dbfs/BMP/ora_control1, /dbfs/BMP/ora_control2)
compatible ='11.1.0'

$cat newBMP.sql
CREATE DATABASE BMP
   USER SYS IDENTIFIED BY think4me
   USER SYSTEM IDENTIFIED BY think4me
   LOGFILE GROUP 1 ('/dbfs/BMP/redo01.log') SIZE 100M,
           GROUP 2 ('/dbfs/BMP/redo02.log') SIZE 100M,
           GROUP 3 ('/dbfs/BMP/redo03.log') SIZE 100M
   MAXLOGFILES 5
   MAXLOGMEMBERS 5
   MAXLOGHISTORY 1
   MAXDATAFILES 100
   CHARACTER SET US7ASCII
   NATIONAL CHARACTER SET AL16UTF16
   EXTENT MANAGEMENT LOCAL
   DATAFILE '/dbfs/BMP/system01.dbf' SIZE 325M REUSE
   SYSAUX DATAFILE '/dbfs/BMP/sysaux01.dbf' SIZE 325M REUSE
   DEFAULT TABLESPACE users
      DATAFILE '/dbfs/BMP/users01.dbf'
      SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
   DEFAULT TEMPORARY TABLESPACE tempts1
      TEMPFILE '/dbfs/BMP/temp01.dbf'
      SIZE 20M REUSE
   UNDO TABLESPACE undotbs1
      DATAFILE '/dbfs/BMP/undotbs01.dbf'
      SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

$ mkdir /dbfs/BMP
$ export ORACLE_SID=BMP
$ sqlplus / as sysdba

SQL> create SPFILE FROM PFILE;
SQL> startup nomount
SQL> @/var/tmp/oracle/newBMP.sql
SQL> shutdown immediate
SQL> startup
ORACLE instance started.

Total System Global Area 1068937216 bytes
Fixed Size                  2235208 bytes
Variable Size             616563896 bytes
Database Buffers          444596224 bytes
Redo Buffers                5541888 bytes
Database mounted.
Database opened.

Create password file in $ORACLE_HOME/dbs
$ orapwd file=orapwBMP entries=10

Run Scripts to Build Data Dictionary Views

SQL> CONNECT / AS SYSDBA
SQL> spool /var/tmp/bmp.log
SQL> @/u01/oracle/rdbms/admin/catalog.sql
SQL> @/u01/oracle/rdbms/admin/catproc.sql
SQL> spool off
SQL> EXIT
 
 
Reference: http://docs.oracle.com/cd/B19306_01/server.102/b14231/create.htm 

Monday, March 17, 2014

Cacti and Windows 2k8

snmpwalk -v2c -cgroupv3 37.15.10.89

As far as I know, SNMPv3 is not supported on either Windows Server 2008 or Windows Server 2008 R2.

Supported Versions

http://msdn.microsoft.com/en-us/library/aa379141(VS.85).aspx

For Windows Server 2012, there is no official document announcement that the SNMPv3 is supported. Given this situation, you may try some third-party tools to simulate the environment to run SNMPv3.


Oracle: Database Migration with Datafile location changed

1. Copy all the data files, control files to new server.
2. Modify init ora file accordingly
3. Start up the instance, and you will get some errors because data file location changed.
4. Run below command to extract all data files list.
$ SQLPLUS/NOLOG 
SQL> CONNECT / AS SYSDBA 
SQL> spool dfiles.lst
SQL> SELECT * from V$DBFILE; 
SQL> spool off 
SQL> SELECT * from V$LOGFILE; 
SQL> SHUTDOWN 
SQL> EXIT 
 
5.  create config.sql as below

STARTUP NOMOUNT
CREATE CONTROLFILE SET DATABASE "<ORACLE_SID>" RESETLOGS
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 200
    MAXINSTANCES 8
    MAXLOGHISTORY 1168
LOGFILE
  GROUP 1 '/data1/<ORACLE_SID>/redo01.log'  SIZE 100M,
  GROUP 2 '/data2/<ORACLE_SID>/redo02.log'  SIZE 100M,
  GROUP 3 '/data3/<ORACLE_SID>/redo03.log'  SIZE 100M
-- STANDBY LOGFILE
DATAFILE
'/data2/<ORACLE_SID>/system01.dbf',
'/data4/<ORACLE_SID>/undotbs01.dbf',
'/data1/<ORACLE_SID>/sysaux01.dbf',
'/data5/<ORACLE_SID>/users01.dbf',
'/data1/<ORACLE_SID>/csisdata01.dbf',
'/data2/<ORACLE_SID>/csisdata02.dbf',
'/data3/<ORACLE_SID>/csisdata03.dbf',
'/data4/<ORACLE_SID>/csisdata04.dbf',
'/data5/<ORACLE_SID>/csisdata05.dbf',
'/data6/<ORACLE_SID>/csisdata06.dbf',
'/data7/<ORACLE_SID>/csisdata07.dbf',
'/data8/<ORACLE_SID>/csisdata08.dbf',
'/data1/<ORACLE_SID>/csisindex01.dbf',
'/data2/<ORACLE_SID>/csisindex02.dbf',
'/data3/<ORACLE_SID>/csisindex03.dbf',
'/data4/<ORACLE_SID>/csisindex04.dbf',
'/data5/<ORACLE_SID>/csisindex05.dbf',
'/data8/<ORACLE_SID>/tfdindex08.dbf',
'/data6/<ORACLE_SID>/user02.dbf'
CHARACTER SET WE8ISO8859P1
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/DBF/QA/ORA_LOGS/1_1_705162525.dbf';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
-- All logs need archiving and a log switch is needed.
-- --ALTER SYSTEM ARCHIVE LOG ALL;
-- Database can now be opened normally.
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
-- --ALTER TABLESPACE TEMP ADD TEMPFILE '/data3/<ORACLE_SID>/temp01.dbf'
    -- -- SIZE 3000M REUSE AUTOEXTEND OFF;
ALTER DATABASE OPEN RESETLOGS;
ALTER TABLESPACE TEMP ADD TEMPFILE '/data3/<ORACLE_SID>/temp01.dbf' SIZE 500M REUSE AUTOEXTEND OFF;
COMMIT;

6. Move all old control files out of its location.
7. Run below command to create new control files
$ SQLPLUS/NOLOG
SQL> CONNECT / AS SYSDBA 
SQL> spool newControls.log
SQL> @config.sql
SQL> spool off
SQL> shutdown immediate
SQL> startup
 
8. Verify the migration. 

Wednesday, March 12, 2014

Remove Comments and empty lines from SQL file

sed '/\/\*.*\*\// d; /\/\*/,/\*\// d; s/--.*$//; /^$/ d; $!N; s/\n/ /' sample.sql > /tmp/parsed.sql

Thursday, March 6, 2014

Compile rdp desktop on SUSE 11.2

Resource:
http://lists.opensuse.org/opensuse-security-announce/2010-04/msg00000.html

 Get RDP Desktop source code from http://www.rdesktop.org/
i.e.
# mkdir /var/tmp/rdp
# cd /var/tmp/rdp
# wget http://prdownloads.sourceforge.net/rdesktop/rdesktop-1.8.1.tar.gz?download
# tar -zxf  rdesktop-1.8.1.tar.gz
# cd  rdesktop-1.8.1
# ./configure --prefix=/opt/rdp-1.8.1 --disable-credssp --disable-smartcard
# make
# make install

“ERROR: Could not find X Window System headers/libraries
To specify paths manually, use the options –x-includes and –x-libraries”
FIX: add the X-windows development tools though YaST to compile successfully – x-org-x11-devel
ERROR: Could not find OpenSSL headers/libraries.
To specify a path manually, use the –with-openssl option
FIX: add the OpenSSL development tools through YaST to compile successfully – openssl-devel
# cd /opt/rdp-1.8.1/bin
# ./rdesktop -x l -g 90% rdpserver

on Windows 2k8 server

from a Run box, type "mmc" to open the Microsoft Management Console. Click File -> Add/Remove Snap-in. Click the "Add..." button, choose "Group Policy Object Editor" from the list and click "Add" (you may have to push "Finish") then "Close" then "OK".

Now browse to Local Computer Policy -> Computer Configuration -> Administrative Templates -> Windows Components -> Terminal Services. From the list, modify "Always show desktop on connection" to "Enabled" and "Enforce Removal of Remote Desktop Wallpaper" to "Disabled". Now close the MMC clicking "No" about saving the settings.