Tuesday, July 2, 2013

Creating a Partition Size Larger Than 2TB in Linux


Frankly speaking, you cannot create a Linux partition larger than 2 TB using the fdisk command. The fdisk won't create partitions larger than 2 TB. This is fine for desktop and laptop users, but on server you need a large partition. For example, you cannot create 3TB or 4TB partition size (RAID based) using the fdisk command. It will not allow you to create a partition that is greater than 2TB. In this tutorial, you will learn more about creating Linux filesystems greater than 2 Terabytes to support enterprise grade operation under any Linux distribution.

To solve this problem use GNU parted command with GPT. It supports Intel EFI/GPT partition tables. Partition Table (GPT) is a standard for the layout of the partition table on a physical hard disk. It is a part of the Extensible Firmware Interface (EFI) standard proposed by Intel as a replacement for the outdated PC BIOS, one of the few remaining relics of the original IBM PC. EFI uses GPT where BIOS uses a Master Boot Record (MBR).
GUID Partition Table
(Fig.01: Diagram illustrating the layout of the GUID Partition Table scheme. Each logical block (LBA) is 512 bytes in size. LBA addresses that are negative indicate position from the end of the volume, with −1 being the last addressable block. Imaged Credit Wikipedia)

Linux GPT Kernel Support

EFI GUID Partition support works on both 32bit and 64bit platforms. You must include GPT support in kernel in order to use GPT. If you don't include GPT support in Linux kernelt, after rebooting the server, the file system will no longer be mountable or the GPT table will get corrupted. By default Redhat Enterprise Linux / CentOS comes with GPT kernel support. However, if you are using Debian or Ubuntu Linux, you need to recompile the kernel. Set CONFIG_EFI_PARTITION to y to compile this feature.
File Systems
   Partition Types
     [*] Advanced partition selection
     [*] EFI GUID Partition support (NEW)
....

Find Out Current Disk Size

Type the following command:
# fdisk -l /dev/sdb
Sample outputs:
Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table

Linux Create 3TB partition size

To create a partition start GNU parted as follows:
# parted /dev/sdb
Output:
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
Creates a new GPT disklabel i.e. partition table:
(parted) mklabel gpt
Sample outputs:
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted)
Next, set the default unit to TB, enter:
(parted) unit TB
To create a 3TB partition size, enter:
(parted) mkpart primary 0 0
OR
(parted) mkpart primary 0.00TB 3.00TB
To print the current partitions, enter:
(parted) print
Sample outputs:
Model: ATA ST33000651AS (scsi)
Disk /dev/sdb: 3.00TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start   End     Size    File system  Name     Flags
 1      0.00TB  3.00TB  3.00TB  ext4         primary
Quit and save the changes, enter:
(parted) quit
Sample outputs:
Information: You may need to update /etc/fstab.
Use the mkfs.ext3 or mkfs.ext4 command to format the file system, enter:
# mkfs.ext3 /dev/sdb1
OR
# mkfs.ext4 /dev/sdb1
Sample outputs:
mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
183148544 inodes, 732566272 blocks
36628313 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
22357 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
 102400000, 214990848, 512000000, 550731776, 644972544
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
Type the following commands to mount /dev/sdb1, enter:
# mkdir /data
# mount /dev/sdb1 /data
# df -H

Sample outputs:
Filesystem             Size   Used  Avail Use% Mounted on
/dev/sdc1               16G   819M    14G   6% /
tmpfs                  1.6G      0   1.6G   0% /lib/init/rw
udev                   1.6G   123k   1.6G   1% /dev
tmpfs                  1.6G      0   1.6G   0% /dev/shm
/dev/sdb1              3.0T   211M   2.9T   1% /data

Thursday, June 13, 2013

Mount Linux directory on Windows using Samba

I am writing this article for those who are interested in doing SAMBA share configuration between Linux and Windows machines. At the end of this article you will also find the steps to mount a Windows shared folder on Linux server using CIFS (common internet file system).

Samba Overview:
---------------
1. Uses Session Message Block (SMB) protocol. 
2. The most typical reason to use Samba is to allow windows machine and linux machine to interact.
3. Simple to Complex configurations.
4. Easy to manage as there is one main Samba Configuration file /etc/samba/smb.conf

We are going to setup a Oracle Linux box so that certain directories and files are shared and we can control how they are shared weather it should be read only or read write. Then from the windows machine we can access that linux share and vice versa. You can also interact between two linux machines using Samba protocol.

Smb.conf layout:
----------------
There are 4 special sections in Samba configuration files as given below,

[global] Global Configuration Settings
[homes] Shares users home directories -> Any setting in home section will override the global settings.
[printers] Define shared printer access
[userdefined] This will be a user defined section

step1:
cd /u01
mkdir expdump
chmod 777 expdump/
chown -R oracle:oinstall /u01/expdump


step2Example of a user defined section is as given below,
[expdump]
comment = Export Datapump dump location
path = /u01/expdump
available = yes
valid users = oracle

readonly = no
browsable = yes 

public = yes
writable = yes


There are zillion (exaggerating) more parameters used for different settings like require passwords, limit by host, limit by time of day etc.

step3:
service smb restart --> Restart the samba service.
smbpasswd -a oracle ---> this will add new user for samba which is different from OS user oracle.

step4Now you can go to windows server and map network drive for \\linuxservername\expdumpshare folder. This way the linux shared folder is accessible from windows machine and vice versa.

Installing Samba
Login in as root and query if the following rpm's are installed or not if the following packages are not available then firstly install them using rpm command,

#rpm -ivh 

[root@egdodb samba]# rpm -qa | grep xinetd
xinetd-2.3.14-10.el5

[root@egdodb samba]# rpm -qa | grep samba
samba-common-3.0.33-3.7.el5
samba-3.0.33-3.7.el5
samba-common-3.0.33-3.7.el5
samba-client-3.0.33-3.7.el5
system-config-samba-1.2.41-3.el5

Configuring Samba:
------------------
You can configure samba by various ways, like manually updating the smb.conf file, using yast utility on suse linux, using SWAT Samba Web Admin Tool and using 'webmin' web based tool. The following is the manual way of updating the smb.conf file,

Update the smb.conf file manually and then run the 'testparm' command to validate the smb.conf file entries,

[root@egdodb samba]# testparm smb.conf

Load smb config files from smb.conf
Processing section "[homes]"
Processing section "[printers]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
workgroup = MYGROUP
server string = Samba Server Version %v
passdb backend = tdbsam
cups options = raw

[homes]
comment = Home Directories
read only = No
browseable = No


Mounting Windows share on Linux server using CIFS

The following are the steps to mount a windows shared folder (\\filesrv\LOGDIR) on linux machine.

[root@egpodb01 tmp]# cd /tmp
[root@egpodb01 tmp]# mkdir logdump
[root@egpodb01 tmp]# chmod 777 logdump
[root@egpodb01 tmp]# mount -t cifs //filesrv/LOGDIR -o username=samimalik,password=***** /tmp/logdump
[root@egpodb01 tmp]# df -h /tmp/logdump/
Filesystem                Size    Used   Avail   Used%     Mounted on
//filesrv/LOGDIR     100G  50G    50G     50%        /tmp/expdump

Tuesday, May 28, 2013

Find consuming sql from process id




Find consuming sql from process id


Get cpu consuming PID from top command and then execute below script to find relevant SQL statements along with SQL ID & Username

prompt "Please Enter The UNIX Process ID"
set lines 200
set long 20000
set pages 0
select
s.username su, sa.SQL_ID, sa.sql_fulltext
from v$process p,
v$session s,
v$sqlarea sa
where p.addr=s.paddr
and s.username is not null
and s.sql_address=sa.address(+)
and s.sql_hash_value=sa.hash_value(+)
and spid=&SPID;


for eg,

[oracle@igrexandc003d02 ~]$ top
top - 09:14:40 up 86 days, 10 min,  3 users,  load average: 13.56, 13.70, 14.04
Tasks: 818 total,  14 running, 804 sleeping,   0 stopped,   0 zombie
Cpu(s): 56.4%us,  0.9%sy,  0.0%ni, 42.5%id,  0.0%wa,  0.0%hi,  0.2%si,  0.0%st
Mem:  148704036k total, 113554696k used, 35149340k free,  1573068k buffers
Swap: 25165816k total,     3712k used, 25162104k free, 53273236k cached

   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 21899 oracle    20   0 32.4g  64m  32m R 99.7  0.0   1873:07 oracle
 21903 oracle    20   0 32.4g  63m  32m R 99.7  0.0   1826:24 oracle
 21905 oracle    20   0 32.3g  64m  32m R 99.7  0.0   1654:55 oracle
 21915 oracle    20   0 32.3g  63m  31m R 99.7  0.0   1826:48 oracle

[oracle@igrexandc003d02 ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.3.0 Production on Tue May 28 09:14:43 2013

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


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

SQL> prompt "Please Enter The UNIX Process ID"
"Please Enter The UNIX Process ID"
SQL> set lines 200
set long 20000
SQL> SQL> set pages 0
SQL> select
  2  s.username su, sa.SQL_ID, sa.sql_fulltext
  3  from v$process p,
  4  v$session s,
  5  v$sqlarea sa
  6  where p.addr=s.paddr
and s.username is not null
  7    8  and s.sql_address=sa.address(+)
  9  and s.sql_hash_value=sa.hash_value(+)
 10  and spid=&SPID;
Enter value for spid: 21899
old  10: and spid=&SPID
new  10: and spid=21899
OBI_RO                         byk85pccx0ydb
                                             select T454950.MASTER_VALUE_CHAR as c1,
                                                  count(distinct T436164.CHANGE_ISSUE_NUM) as c2
                                             from
                                                  WC_PRODUCTIVITY_PROJ_D T436164 /* Dim_WC_PRODUCTIVITY_PROJ_D */ ,
                                                  WC_PRODUCTIVITY_PROJ_SNAP_D T454994 /* Dim_WC_PRODUCTIVITY_PROJ_SNAP_D */ ,

                                                  WC_PRODUCTIVITY_PROJ_CODE_D T455950 /* Dim_WC_PRODUCTIVITY_PROJ_CODE_D_Fina
                                             ncial_Unit */ ,
                                                  WC_PRODUCTIVITY_PROJ_NOTE_F T454975 /* Fact_WC_PRODUCTIVITY_PROJ_NOTE_F */
                                             ,
                                                  WC_PRODUCTIVITY_PROJ_CODE_D T454950 /* Dim_WC_PRODUCTIVITY_PROJ_CODE_D_Note
                                              */ ,
                                                  W_PROD_CAT_DH T441548 /* Dim_W_PROD_CAT_DH_Prod_Proj */
                                             where  ( T436164.CHANGE_ISSUE_NUM = T454975.CHANGE_ISSUE_NUM and T436164.PROD_CA
                                             T_WID = T441548.ROW_WID and T436164.SNAPSHOT_DT_WID = T454994.SNAPSHOT_DT_WID an
                                             d T436164.FINANCIAL_UNIT_WID = T455950.ROW_WID and T436164.SAVINGS_TYPE = 'Hard
                                             Savings P&L' and T436164.VARIANCE_TYPE = 'Productivity' and T441548.L6ANC_PRODCA
                                             T_NAME = 'Valves & Tube Fabrication' and T441548.L7ANC_PRODCAT_NAME = 'Valves &
                                             Tube Fabrication' and T441548.HIERARCHY_CODE = 'AUTO_CUSTOM_CATEGORY1' and T4549
                                             50.ROW_WID = T454975.NOTE_TYPE_WID and T454994.SNAPSHOT_NAME = '2013-05-27 (Dail
                                             y Refresh)' and T455950.GROUP_NAME = 'Asia-Pac' and T455950.MASTER_CODE <> 'ZZ -
                                              Hussmann' and (T436164.PROJECT_TYPE in ('Material Other / In bound Logistics',
                                             'Material Price', 'Material VAVE - external (Supplier driven)', 'Material VAVE -
                                              internal (IR driven)')) and T454975.CREATED_ON_DT >= TO_DATE('2012-05-07 00:00:
                                             00' , 'YYYY-MM-DD HH24:MI:SS') )
                                             group by T454950.MASTER_VALUE_CHAR
                                             order by c1


SQL>

Tuesday, May 21, 2013

block_detail.sql


To find out blocker & waiter in RAC Instance (specially useful  in EBS)

set lines 200
col WMOD for a20
col WCID for a20
col BCID for a20
col BMOD for a20
col BLOCKER for a12
col WAITER for a10
select vsb.sid bsid, vsb.inst_id binst, vsb.username blocker, vsb.client_identifier bcid, vsb.module bmod,
       vsw.sid wsid, vsw.inst_id winst, vsw.username waiter, vsw.client_identifier wcid, vsw.module wmod,
       trunc(vlw.ctime/60) minutes
  from (select inst_id,sid, id1, id2, ctime from gv$lock where request > 0) vlw,
       (select inst_id,sid, id1, id2, ctime from gv$lock where block > 0) vlb,
       gv$session vsb,
       gv$session vsw
  where vsw.sid=vlw.sid
    and vsb.sid=vlb.sid
    and vsb.inst_id=vlb.inst_id
    and vsw.inst_id=vlw.inst_id
    and vlb.id1=vlw.id1
    and vlb.id2=vlw.id2
order by blocker, minutes desc
/


      BSID      BINST BLOCKER      BCID                 BMOD                       WSID      WINST WAITER     WCID                 WMOD                    MINUTES
---------- ---------- ------------ -------------------- -------------------- ---------- ---------- ---------- -------------------- -------------------- ----------
      3204          2 APPS         JSTANIK              e:INV:frm:WIPTXCFM        13861          1 APPS       MMRNKA               e:INV:frm:WSHFRREL           23
      3204          2 APPS         JSTANIK              e:INV:frm:WIPTXCFM         5696          1 APPS       M-JTKADLEC           e:INV:frm:INVTOTRX           23
      3204          2 APPS         JSTANIK              e:INV:frm:WIPTXCFM         6908          1 APPS       MMRNKA               e:INV:frm:WSHFRREL           20
      3204          2 APPS         JSTANIK              e:INV:frm:WIPTXCFM         8866          1 APPS       MMRNKA               e:INV:frm:WSHFRREL           16
      3204          2 APPS         JSTANIK              e:INV:frm:WIPTXCFM        11372          1 APPS       SMPATEKA             e:WIP:frm:WIPTXMAT           16
      3204          2 APPS         JSTANIK              e:INV:frm:WIPTXCFM         3773          1 APPS       AJPATEL              e:INV:frm:WSHFRREL           16
      3204          2 APPS         JSTANIK              e:INV:frm:WIPTXCFM           39          1 APPS       CHAUHANK             e:INV:frm:WSHFRREL           14
      3204          2 APPS         JSTANIK              e:INV:frm:WIPTXCFM           77          1 APPS       NSHARMA              e:INV:frm:WSHFRREL            8
      3204          2 APPS         JSTANIK              e:INV:frm:WIPTXCFM         9423          1 APPS       IRBJEV               e:INV:frm:INVTOTRX            6
      3204          2 APPS         JSTANIK              e:INV:frm:WIPTXCFM         1917          2 APPS       PVOJACEK             e:INV:bes:xxont.orac          1
                                                                                                                                   le.apps.ont.OrderLin


Sunday, May 5, 2013

-manifest option in admrgpch

While applying more than 100 patches, you cannot unzip all the patches and put it in source directory instead you can do use of -manifest option of admrgpch command to merge those patches with downloaded zip files from metalink.

The sequence of these parameters are important !!!

[ebspat@igrexanwh002cn04 nonad]$ admrgpch -s src -manifest /u08/patches/r12/oks_csp_modules/nonad/src/patchlist.txt -d dest -merge_name oks_csp_merge

Put all zipped patches in src directory and keep list of those patches in patchlist.txt


unzipping /u08/patches/r12/oks_csp_modules/nonad/src/p10097694_R12.OKS.B_R12_GENERIC.zip..
unzipping /u08/patches/r12/oks_csp_modules/nonad/src/p11806604_R12.OKS.B_R12_cs.zip..
unzipping /u08/patches/r12/oks_csp_modules/nonad/src/p11806604_R12.OKS.B_R12_d.zip..
unzipping /u08/patches/r12/oks_csp_modules/nonad/src/p11806604_R12.OKS.B_R12_esa.zip..
unzipping /u08/patches/r12/oks_csp_modules/nonad/src/p11806604_R12.OKS.B_R12_e.zip..
unzipping /u08/patches/r12/oks_csp_modules/nonad/src/p11806604_R12.OKS.B_R12_f.zip..
...
...
...
...
...
...

 -- Processing patch: src/12411685_ZHS
 -- Processing file: src/12411685_ZHS/u12411685.drv
 -- Done processing file: src/12411685_ZHS/u12411685.drv
 -- Done processing patch: src/12411685_ZHS



Copying files...

5% complete. Copied 161 files of 3202...
10% complete. Copied 321 files of 3202...
15% complete. Copied 481 files of 3202...
20% complete. Copied 641 files of 3202...
25% complete. Copied 801 files of 3202...
30% complete. Copied 961 files of 3202...
35% complete. Copied 1121 files of 3202...
40% complete. Copied 1281 files of 3202...
45% complete. Copied 1441 files of 3202...
50% complete. Copied 1601 files of 3202...
55% complete. Copied 1762 files of 3202...
60% complete. Copied 1922 files of 3202...
65% complete. Copied 2082 files of 3202...
70% complete. Copied 2242 files of 3202...
75% complete. Copied 2402 files of 3202...
80% complete. Copied 2562 files of 3202...
85% complete. Copied 2722 files of 3202...
90% complete. Copied 2882 files of 3202...
95% complete. Copied 3042 files of 3202...
100% complete. Copied 3202 files of 3202...

Character-set converting files...

  200 unified drivers merged.

Patch merge completed successfully

Please check the log file at ./admrgpch.log.
[ebspat@igrexanwh002cn04 nonad]$

Output Post Processor Log File Contains java.io.FileNotFoundException (No such file or directory)


[ebsi1a@igrexanwh002cn05 log]$ ls -rtl *FNDOPP*
-rw-r--r-- 1 ebsi1a dba  1186 Apr 17 09:30 FNDOPP44572.txt
-rw-r--r-- 1 ebsi1a dba  1186 Apr 17 09:30 FNDOPP44571.txt
-rw-r--r-- 1 ebsi1a dba  1186 Apr 17 09:30 FNDOPP44570.txt
-rw-r--r-- 1 ebsi1a dba  1186 Apr 17 09:32 FNDOPP44573.txt
-rw-r--r-- 1 ebsi1a dba  5581 Apr 18 11:09 FNDOPP44730.txt
-rw-r--r-- 1 ebsi1a dba 13341 Apr 18 11:29 FNDOPP44731.txt
-rw-r--r-- 1 ebsi1a dba  3998 Apr 18 11:29 FNDOPP44732.txt
-rw-r--r-- 1 ebsi1a dba 15165 Apr 18 11:32 FNDOPP44729.txt
[ebsi1a@igrexanwh002cn05 log]$ vi FNDOPP44731.txt


[041813_094235103][][EXCEPTION] [DEBUG]  [sun.cpu.isalist]:[]
[4/18/13 9:42:38 AM] [44731:RT2214394] Output file was found but is zero sized - Deleted
[4/18/13 9:42:38 AM] [UNEXPECTED] [44731:RT2214394] java.io.FileNotFoundException:  /ebsi1a/app/applmgr/IREBSI1A/comn/temp/xdoHXsE2Rzqiu041813_0942381350.fo (No such file or directory)

Issue was with XML Publisher temporary directory path.

Solution: Output Post Processor Log File Contains java.io.FileNotFoundException (No such file or directory) Error [ID 463388.1]

Rsync command usage for Application files while Cloning


Run rsync commands from target application node

/usr/bin/rsync --delete -av --exclude-from=/asccnv/rsync_appl_top_exclude -e ssh ascuat@igrexandc002cn05:/ascuat/app/applmgr/ascuat/appl/ /asccnv/app/applmgr/IRasccnv/appl/ --rsync-path=/usr/bin/rsync

/usr/bin/rsync --delete -av --exclude-from=/asccnv/rsync_comn_top_exclude -e ssh ascuat@igrexandc002cn05:/ascuat/app/applmgr/ascuat/comn/ /asccnv/app/applmgr/IRasccnv/comn/ --rsync-path=/usr/bin/rsync

/usr/bin/rsync --delete -av --exclude-from=/asccnv/rsync_techst_exclude -e ssh ascuat@igrexandc002cn05:/ascuat/app/applmgr/ascuat/techst/ /asccnv/app/applmgr/IRasccnv/techst/ --rsync-path=/usr/bin/rsync



[asccnv@igrexanwh002cn06 ~]$ cat /asccnv/rsync_appl_top_exclude
- admin/log/**
- admin/out/**
- *.log
- *.out
- *.req
- *.tmp
- *.rti
- *.PDF
- *.tar.gz
- *.EXCEL

[asccnv@igrexanwh002cn06 ~]$ cat /asccnv/rsync_comn_top_exclude
- admin/log/**
- admin/out/**
- temp/**
- ptemp/**
- _pages/**
- *.log
- *.out
- *.req
- *.mgr
- *.tmp
- FNDCP*.txt
- WFM*.txt
- *.rti
- *.PDF
- *.tar.gz
- *.EXCEL

[asccnv@igrexanwh002cn06 ~]$ cat /asccnv/rsync_techst_exclude
- *.log
- *.out
- *.tmp
- *.tar.gz