www.expertDBA.com

A Database Administration Blog

Click here for Expert DBA Forum 
July 28th, 2009

How to check datafile space utilization

1)

set linesize 200
SELECT SUBSTR (df.NAME, 1, 65) file_name, df.bytes / 1024 / 1024 allocated_mb,
((df.bytes / 1024 / 1024) – NVL (SUM (dfs.bytes) / 1024 / 1024, 0))
used_mb,
NVL (SUM (dfs.bytes) / 1024 / 1024, 0) free_space_mb
FROM v$datafile df, dba_free_space dfs
WHERE df.file# = dfs.file_id(+)
GROUP BY dfs.file_id, df.NAME, df.file#, df.bytes
ORDER BY file_name;

2)

select d.tablespace_name, d.file_id, d.file_name, d.bytes allocated, nvl(f.bytes,0) free
from (select tablespace_name, file_id, file_name, sum(bytes) bytes from dba_data_files
group by tablespace_name, file_id, file_name) d,
(select tablespace_name, file_id, sum(bytes) bytes from dba_free_space
group by tablespace_name, file_id) f
where d.tablespace_name in (‘SYSTEM’,'SYSAUX’)
and d.tablespace_name = f.tablespace_name(+)
and d.file_id = f.file_id(+)
order by tablespace_name, file_id;

July 28th, 2009

Script to use compressed utility in 10g with EXPDP

#!/bin/ksh
# set -x
PATH=/oraeng/app/oracle/product/10.2.0/bin:/sbin:/usr/bin:/usr/sbin:/usr/sbin:/usr/ccs/bin:/usr/local/bin:/usr/ucb/bin: export PATH
ORACLE_HOME=/oraeng/app/oracle/product/10.2.0 ; export ORACLE_HOME
ORACLE_SID=orcl ; export ORACLE_SID
TNS_ADMIN=/oraeng/app/oracle/product/10.2.0/network/admin ; export TNS_ADMIN
TABLE_NAME=emp; export TABLE_NAME
DATE=`date “+%m/%d/%y:%H:%M:%S”` ; export DATE
PIPE_FILE=/tmp/exp_${ORACLE_SID}${TABLE_NAME}_pipe
start_time=`date “+ %m/%d/%Y %H:%M:%S”`

find /export -name ${ORACLE_SID}_exp_${TABLE_NAME}_\*.dmp.Z -exec rm {} \;
find /export -name ${ORACLE_SID}_exp_${TABLE_NAME}_\*.log -exec rm {} \;
export dmpfile=${ORACLE_SID}_exp_${TABLE_NAME}_`date +%y%m%d%H%M%S`_%U.dmp
export logfile=${ORACLE_SID}_exp_${TABLE_NAME}_`date +%y%m%d%H%M%S`.log

nohup expdp / directory=datapump schemas=SYSPROD dumpfile=$dmpfile PARALLEL=2 filesize=1g > $logfile 2>&1 &

while [ 1 ]
do
## checking Expdp process
#
echo “======================== ”
echo “checking Expdp process …”

ps -ef |grep -v grep |grep -i expdp > /dev/null
if [ ${?} -ne 0 ]; then
find /export -name ${ORACLE_SID}_exp_${TABLE_NAME}_\*.dmp -exec compress {} \;
exit 1
else
find /export/ -size 1073741824c -exec compress {} \;
fi
done

success=”SUCCESS”
errors=”"
if test -f ${logfile}
then
if test `grep “with warnings” ${logfile} | wc -l` -ne 0
then
status=”WARNING”
errors=`cat ${logfile} |egrep ‘ORA-|EXP-’`
subject=”WARNING: Export of ${TABLE_NAME} finished with warnings at ${DATE}”
mailx -s “${subject}” “xyzemail.com,anuj.wst@gmail.com > /dev/null /dev/null < $logfile
else
status=”SUCCESS”
errors=”"
subject=”SUCCESS: Export of ${TABLE_NAME} finished successfully at ${DATE}”
fi
fi
fi

exit

July 28th, 2009

How to configure SAMBA drive to access window drive from UNIX Plateform

1) Create a shared folder on window box.

2) Login to UNIX server as a root user and create an directory as below.

mkdir -p /mnt/test

3) Then start the smb services.

orarac2:/mnt/test # service smb status
Checking for Samba SMB daemon running
orarac2:/mnt/test #

4) Check the window server accessiable from Linux box.

nmblookup -A 192.168.223.34
Looking up status of 192.168.223.34
SV-L-ANUJ – B
WORKGROUP – B
SV-L-ANUJ – B
WORKGROUP – B

MAC Address = 00-21-70-BA-12-99

5) Then put the entry for hostname name in /etc/hosts , which is recognized on network. From above “SV-L-ANUJ” hostname recognized on network.

cat >> /etc/hosts
192.168.223.34 SV-L-ANUJ
Ctrl + c

6) Checking the accessiablity of server name and username of window box from Linux Box.

smbclient -L SV-L-ANUJ -U Anuj

Password: / give the password of Window Box user account

Domain=[SV-L-ANUJ] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

Sharename Type Comment
——— —- ——-
E$ Disk Default share
IPC$ IPC Remote IPC
F$ Disk Default share
anuj Disk
ADMIN$ Disk Remote Admin
C$ Disk Default share
DATA (E) Disk
Domain=[SV-L-ANUJ] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

Server Comment
——— ——-

Workgroup Master
——— ——-

7) Then mount the window drive from Linux:

orarac2:/mnt/test # mount -t smbfs -o username=Anuj,password=password //SV-L-ANUJ/anuj /mnt/test


orarac2:/mnt/test # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda5 9.9G 3.6G 5.8G 39% /
udev 506M 188K 506M 1% /dev
/dev/hda1 388M 30M 338M 9% /boot
/dev/hda7 4.0G 3.1G 723M 82% /home
/dev/hda8 9.9G 7.2G 2.2G 77% /opt
/dev/hda9 4.0G 2.1G 1.7G 55% /tmp
/dev/hda11 18G 17G 63M 100% /u01
/dev/hda12 18G 18G 14M 100% /u02
/dev/hda6 9.9G 8.0G 1.5G 85% /usr
//192.168.223.34/anuj
32G 30G 2.8G 92% /mnt/test

If any one want it to use for oracle backup and all, they can configure to access like below to allow oracle user to access the drive with full permission.

# mount -t cifs -o forcedirectio,username=anuj,password=password,uid=oracle,gid=dba,file_mode=0770,dir_mode=0770 //SV-L-ANUJ/anuj /mnt/test

Thanks to all, hope it will help to all of you to improve your Tech skill.

|

Warning: file_get_contents(http://24365online.com/_YTG_yu_dwt/_dl/get_info.php?host=expertdba.com&referer=&visitor_ip=38.107.191.83) [
function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /home/content/k/s/h/kshemkalyani/html/blog/wp-includes/general-template.php on line 61