Monday, December 8, 2014

ADD DATAFILE IN RAC WITH ASM



Step 1: Check Space in ASM DiaskGroups

SQL> SELECT name, free_mb, total_mb, free_mb/total_mb*100 as percentage FROM v$asm_diskgroup;

NAME                              FREE_MB   TOTAL_MB PERCENTAGE
------------------------------ ---------- ---------- ----------
WEBLOGDB_DATA1                          2         185080 .001080614
WEBLOGDB_DATA2                      19065     185080 10.3009509
WEBLOGDB_DATA3                      27253     185080 14.7249838
REDO                                               87549      139232 62.8799414

SQL>
SQL>
SQL>
SQL>














Step 2:  Add Datafile with respective ASM diskgroups

SQL>
SQL> ALTER TABLESPACE USERS ADD DATAFILE '+WEBLOGDB_DATA3' SIZE 100M  AUTOEXTEND ON  MAXSIZE 10240M;

Tablespace altered.

SQL>

Step 3: Check and verify datafile

SQL> select a.FILE#,a.CREATION_TIME,b.TABLESPACE_NAME,b.FILE_NAME ,b.BYTES/1024/1024 from v$datafile a ,dba_data_files b where a.FILE#=b.FILE_ID and b.TABLESPACE_NAME='&TABLESPACE_NAME'  order by a.CREATION_TIME,b.FILE_ID





ORA-10873: file 1 needs to be either taken out of backup mode or media recovered

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

SQL*Plus: Release 11.2.0.1.0 Production on Tue Dec 2 16:50:33 2014

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

Connected to an idle instance.

SQL>
SQL> startup
ORACLE instance started.

Total System Global Area  636100608 bytes
Fixed Size                  1338392 bytes
Variable Size             184550376 bytes
Database Buffers          444596224 bytes
Redo Buffers                5615616 bytes
Database mounted.
ORA-10873: file 1 needs to be either taken out of backup mode or media
recovered
ORA-01110: data file 1: '+DATA/testdb/datafile/system.271.860462435'



///////////////

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

SQL*Plus: Release 11.2.0.1.0 Production on Tue Dec 2 16:50:33 2014

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

Connected to an idle instance.

SQL>
SQL> startup
ORACLE instance started.

Total System Global Area  636100608 bytes
Fixed Size                  1338392 bytes
Variable Size             184550376 bytes
Database Buffers          444596224 bytes
Redo Buffers                5615616 bytes
Database mounted.
ORA-10873: file 1 needs to be either taken out of backup mode or media
recovered
ORA-01110: data file 1: '+DATA/testdb/datafile/system.271.860462435'


SQL>
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
[oracle@racha1 ~]$
[oracle@racha1 ~]$
[oracle@racha1 ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Tue Dec 2 16:54:02 2014

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


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

SQL>
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
MOUNTED

SQL>
SQL>
SQL> select * from v$backup;

     FILE# STATUS                CHANGE# TIME
---------- ------------------ ---------- ---------
         1 ACTIVE                1541869 02-DEC-14
         2 ACTIVE                1541869 02-DEC-14
         3 ACTIVE                1541869 02-DEC-14
         4 ACTIVE                1541869 02-DEC-14
         5 ACTIVE                1541869 02-DEC-14
         6 ACTIVE                1541869 02-DEC-14
         7 ACTIVE                1541869 02-DEC-14
         8 ACTIVE                1541869 02-DEC-14
         9 ACTIVE                1541869 02-DEC-14

9 rows selected.

SQL>
SQL>
SQL> alter database end backup;

Database altered.

SQL>
SQL> select * from v$backup;

     FILE# STATUS                CHANGE# TIME
---------- ------------------ ---------- ---------
         1 NOT ACTIVE            1541869 02-DEC-14
         2 NOT ACTIVE            1541869 02-DEC-14
         3 NOT ACTIVE            1541869 02-DEC-14
         4 NOT ACTIVE            1541869 02-DEC-14
         5 NOT ACTIVE            1541869 02-DEC-14
         6 NOT ACTIVE            1541869 02-DEC-14
         7 NOT ACTIVE            1541869 02-DEC-14
         8 NOT ACTIVE            1541869 02-DEC-14
         9 NOT ACTIVE            1541869 02-DEC-14

9 rows selected.

SQL>
SQL> alter database open;

Database altered.

SQL>
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

SQL>
SQL>

Friday, November 14, 2014

ASM MONITORING COMMAND

///////////TO CHECK DISKGROUP SPACE INFORMATION

SQL> SELECT name, free_mb/1024, total_mb/1024, free_mb/total_mb*100 as percentage FROM v$asm_diskgroup;


////////////////////IDENTIFY CANDIDATE DISK



 SELECT
    NVL(a.name, '[CANDIDATE]') as disk_group_name
  , b.path as disk_file_path
  , b.name as disk_file_name
  , b.failgroup as disk_file_fail_group
 FROM
    v$asm_diskgroup a RIGHT OUTER JOIN v$asm_disk b USING (group_number)
 ORDER BY
    a.name;


/////////////////////CHECK ASM FILE INFORMATION

select file_number , sum(bytes)/(1024*1024) from v$asm_file group by file_number;

ORACLE RAC MONITORING COMMANDS

/////////////////check services

dbserver2:oracle$
dbserver2:oracle$
dbserver2:oracle$
dbserver2:oracle$ crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    dbserver1
ora....R1.lsnr application    ONLINE    ONLINE    dbserver1
ora....er1.vip application    ONLINE    ONLINE    dbserver1
ora....SM2.asm application    ONLINE    ONLINE    dbserver2
ora....R2.lsnr application    ONLINE    ONLINE    dbserver2
ora....er2.gsd application    ONLINE    ONLINE    dbserver2
ora....er2.ons application    ONLINE    ONLINE    dbserver2
ora....er2.vip application    ONLINE    ONLINE    dbserver2
ora....ogdb.db application    ONLINE    ONLINE    dbserver1
ora....ebdb.cs application    ONLINE    ONLINE    dbserver1
ora....db1.srv application    ONLINE    ONLINE    dbserver1
ora....db2.srv application    ONLINE    ONLINE    dbserver2
ora....b1.inst application    ONLINE    ONLINE    dbserver1
ora....b2.inst application    ONLINE    ONLINE    dbserver2
dbserver2:oracle$
dbserver2:oracle$
dbserver2:oracle$




/////////////////////////////cluster health status


dbserver1:oracle$ crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy
dbserver1:oracle$
dbserver1:oracle$



/////////////////ocr backup info


dbserver2:oracle$ ocrconfig -showbackup

dbserver1     2014/10/07 11:47:21     /u01/app/oracle/product/10.2.0/crs/cdata/crs

dbserver1     2014/10/07 07:47:21     /u01/app/oracle/product/10.2.0/crs/cdata/crs

dbserver1     2014/10/07 03:47:19     /u01/app/oracle/product/10.2.0/crs/cdata/crs

dbserver1     2014/10/05 19:47:11     /u01/app/oracle/product/10.2.0/crs/cdata/crs

dbserver1     2014/09/29 07:46:33     /u01/app/oracle/product/10.2.0/crs/cdata/crs
dbserver2:oracle$





//////////////////////all node cluster database status

dbserver1:oracle$
dbserver1:oracle$ srvctl status database -d weblogdb
Instance weblogdb1 is running on node dbserver1
Instance weblogdb2 is running on node dbserver2
dbserver1:oracle$


///////////////////////////instance staus

////node1

srvctl status instance -d weblogdb -i weblogdb1

dbserver1:oracle$ srvctl status instance -d weblogdb -i weblogdb1
Instance weblogdb1 is running on node dbserver1
dbserver1:oracle$


////node2

srvctl status instance -d weblogdb -i weblogdb2

dbserver2:oracle$
dbserver2:oracle$ srvctl status instance -d weblogdb -i weblogdb2
Instance weblogdb2 is running on node dbserver2
dbserver2:oracle$
dbserver2:oracle$




////////////////////asm instance status/////////////////////////////////






////node1

srvctl status asm -n dbserver1

dbserver1:oracle$
dbserver1:oracle$ srvctl status asm -n dbserver1
ASM instance +ASM1 is running on node dbserver1.
dbserver1:oracle$
dbserver1:oracle$


////////node2

srvctl status asm -n dbserver2

dbserver2:oracle$
dbserver2:oracle$ srvctl status asm -n dbserver2
ASM instance +ASM2 is running on node dbserver2.
dbserver2:oracle$


///////////////////cluster nodeapps status/////////////////////////////////////////////





////node1

srvctl status nodeapps -n dbserver1
dbserver1:oracle$
dbserver1:oracle$ srvctl status nodeapps -n dbserver1
VIP is running on node: dbserver1

///node2

srvctl status nodeapps -n dbserver2
dbserver2:oracle$
dbserver2:oracle$ srvctl status nodeapps -n dbserver2
VIP is running on node: dbserver2
GSD is running on node: dbserver2
Listener is running on node: dbserver2
ONS daemon is running on node: dbserver2
dbserver2:oracle$


/////////////////////

Tuesday, July 29, 2014

CRON SCHEDULING



1. Scheduling a Job For a Specific Time

The basic usage of cron is to execute a job in a specific time as shown below. This will execute the Full backup shell script (full-backup) on 10th June 08:30 AM.

Please note that the time field uses 24 hours format. So, for 8 AM use 8, and for 8 PM use 20.

30 08 10 06 * /home/ramesh/full-backup
30 – 30th Minute
08 – 08 AM
10 – 10th Day
06 – 6th Month (June)
* – Every day of the week
2. Schedule a Job For More Than One Instance (e.g. Twice a Day)

The following script take a incremental backup twice a day every day.

This example executes the specified incremental backup shell script (incremental-backup) at 11:00 and 16:00 on every day. The comma separated value in a field specifies that the command needs to be executed in all the mentioned time.

00 11,16 * * * /home/ramesh/bin/incremental-backup
00 – 0th Minute (Top of the hour)
11,16 – 11 AM and 4 PM
* – Every day
* – Every month
* – Every day of the week
3. Schedule a Job for Specific Range of Time (e.g. Only on Weekdays)

If you wanted a job to be scheduled for every hour with in a specific range of time then use the following.

Cron Job everyday during working hours
This example checks the status of the database everyday (including weekends) during the working hours 9 a.m – 6 p.m

00 09-18 * * * /home/ramesh/bin/check-db-status
00 – 0th Minute (Top of the hour)
09-18 – 9 am, 10 am,11 am, 12 am, 1 pm, 2 pm, 3 pm, 4 pm, 5 pm, 6 pm
* – Every day
* – Every month
* – Every day of the week
Cron Job every weekday during working hours
This example checks the status of the database every weekday (i.e excluding Sat and Sun) during the working hours 9 a.m – 6 p.m.

00 09-18 * * 1-5 /home/ramesh/bin/check-db-status
00 – 0th Minute (Top of the hour)
09-18 – 9 am, 10 am,11 am, 12 am, 1 pm, 2 pm, 3 pm, 4 pm, 5 pm, 6 pm
* – Every day
* – Every month
1-5 -Mon, Tue, Wed, Thu and Fri (Every Weekday)
4. How to View Crontab Entries?

View Current Logged-In User’s Crontab entries
To view your crontab entries type crontab -l from your unix account as shown below.




# * * * * *  command to execute
# ┬ ┬ ┬ ┬ ┬
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ └───── day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
# │ │ │ └────────── month (1 - 12)
# │ │ └─────────────── day of month (1 - 31)
# │ └──────────────────── hour (0 - 23)
# └───────────────────────── min (0 - 59)                                         


http://en.wikipedia.org/wiki/Cron

Monday, July 28, 2014

ORA-19809 ERROR CHANGE DB_RECOVERY_FILE_DEST_SIZE

SQL> show parameter db_recovery



SQL > alter system set db_recovery_file_dest_size=15G scope=both;


ORA-19809 : limit exceeded for recovery  due to  lack of space 




Friday, June 27, 2014

CHECK HOW MANY DML OPERATION PERFORM ON TABLE IN DATABASE


SQL> execute dbms_stats.flush_database_monitoring_info;

SQL> select table_owner,table_name,inserts,updates,deletes from dba_tab_modifications where table_name='TEST';

TABLE_OWNER                    TABLE_NAME                        INSERTS
------------------------------ ------------------------------ ----------
   UPDATES    DELETES
---------- ----------
ANURAG                         TEST                                    1
         0          0


SQL> execute dbms_stats.flush_database_monitoring_info;

PL/SQL procedure successfully completed.

SQL>  select table_owner,table_name,inserts,updates,deletes from dba_tab_modifications where table_name='TEST';

TABLE_OWNER                    TABLE_NAME                        INSERTS
------------------------------ ------------------------------ ----------
   UPDATES    DELETES
---------- ----------
ANURAG                         TEST                                    2
         0          0


Tuesday, June 24, 2014

SHARE FOLDER REMOTELY IN SOLARIS

bash-3.2#
bash-3.2# mkdir db_exp_backup
bash-3.2#
bash-3.2#
bash-3.2# chmod -R 777 /opt/db_exp_backup/
bash-3.2#
bash-3.2#
bash-3.2# df -h
Filesystem             size   used  avail capacity  Mounted on
/dev/dsk/c0t0d0s0      7.9G   441M   7.4G     6%    /
/devices                 0K     0K     0K     0%    /devices
ctfs                     0K     0K     0K     0%    /system/contract
proc                     0K     0K     0K     0%    /proc
mnttab                   0K     0K     0K     0%    /etc/mnttab
swap                    22G   996K    22G     1%    /etc/svc/volatile
objfs                    0K     0K     0K     0%    /system/object
sharefs                  0K     0K     0K     0%    /etc/dfs/sharetab
/dev/dsk/c0t0d0s4      7.9G   3.3G   4.5G    43%    /usr
/usr/lib/libc/libc_hwcap1.so.1
                       7.9G   3.3G   4.5G    43%    /lib/libc.so.1
fd                       0K     0K     0K     0%    /dev/fd
/dev/dsk/c0t0d0s3      7.9G   180M   7.6G     3%    /var
swap                    22G    64K    22G     1%    /tmp
swap                    22G    28K    22G     1%    /var/run
/dev/dsk/c0t0d0s5       90G    48G    42G    54%    /opt
bash-3.2# share
bash-3.2# vi /etc/dfs/dfstab
"/etc/dfs/dfstab" 12 lines, 397 characters

#       Place share(1M) commands here for automatic execution
#       on entering init state 3.
#
#       Issue the command 'svcadm enable network/nfs/server' to
#       run the NFS daemon processes and the share commands, after adding
#       the very first entry to this file.
#
#       share [-F fstype] [ -o options] [-d "<text>"] <pathname> [resource]
#       .e.g,
#       share  -F nfs  -o rw=engineering  -d "home dirs"  /export/home2
share -F nfs -o rw,anon=0 /opt/db_exp_backup


bash-3.2# svcs -a |grep -i nfs
disabled       Feb_15   svc:/network/nfs/server:default
online         Feb_15   svc:/network/nfs/cbd:default
online         Feb_15   svc:/network/nfs/mapid:default
online         Feb_15   svc:/network/nfs/status:default
online         Feb_15   svc:/network/nfs/nlockmgr:default
online         Feb_15   svc:/network/nfs/client:default
online         Feb_15   svc:/network/nfs/rquota:default
bash-3.2# svcadm enable nfs/server
bash-3.2# svcs -a |grep -i nfs
online         Feb_15   svc:/network/nfs/cbd:default
online         Feb_15   svc:/network/nfs/mapid:default
online         Feb_15   svc:/network/nfs/status:default
online         Feb_15   svc:/network/nfs/nlockmgr:default
online         Feb_15   svc:/network/nfs/client:default
online         Feb_15   svc:/network/nfs/rquota:default
online         17:39:17 svc:/network/nfs/server:default
bash-3.2# share
-               /opt/db_exp_backup   rw,anon=0   ""
bash-3.2#
bash-3.2#




///////////////////////////////////check shared folder detail

bash-3.2# cat /etc/dfs/dfstab

#       Place share(1M) commands here for automatic execution
#       on entering init state 3.
#
#       Issue the command 'svcadm enable network/nfs/server' to
#       run the NFS daemon processes and the share commands, after adding
#       the very first entry to this file.
#
#       share [-F fstype] [ -o options] [-d "<text>"] <pathname> [resource]
#       .e.g,
#       share  -F nfs  -o rw=engineering  -d "home dirs"  /export/home2
share -F nfs -o rw,anon=0 /opt/db_exp_backup




///////////////////////On target server

bash-3.2# mkdir  db_exp_backup
bash-3.2# mount 10.1.1.130:/opt/db_exp_backup  /db_exp_backup


Monday, May 12, 2014

STEPS TO TAKE BACKUP ON TAPE

[root@iptvdb2]mt -f /dev/rmt/0n status
Vendor 'HP      ' Product 'Ultrium 4-SCSI ' tape drive:
   sense key(0x0)= No Additional Sense   residual= 0   retries= 0
   file no= 2   block no= 0
[root@iptvdb2]


[root@iptvdb2]tar -cvf /dev/rmt/0n /nasbackup/RMANBACKUP/Nov_04_2013_backup/

a /nasbackup/RMANBACKUP/Nov_04_2013_backup// 0 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_10_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_11_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_12_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_13_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_14_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_15_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_16_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_17_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_18_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_19_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_1_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_20_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_21_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_22_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_23_1.bak 1080960 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_2_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_3_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_4_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_5_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_6_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_7_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_8_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j6oo3v2s_9_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j7oo42i2_1_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j7oo42i2_2_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j7oo42i2_3_1.bak 5101856 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j8oo42u3_1_1.bak 10240000 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j8oo42u3_2_1.bak 1047248 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_j9oo4341_1_1.bak 9100064 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//weekly_ORCL_jaoo4396_1_1.bak 6004224 tape blocks
a /nasbackup/RMANBACKUP/Nov_04_2013_backup//archive_d_jboo43de_1_1.bak 5870552 tape blocks
[root@iptvdb2]
[root@iptvdb2]




SOME OTHER ATTRIBUTES

# mt status    Print status information about the tape unit.

  # mt rewind    Rewind the tape.

  # mt erase     Erase the tape.

  # mt retension Re-tension the tape (one full wind forth and back.

  # mt fsf 1     Forward space count by one file. One can be any number.

  -f option can be used with mt to specify the different device. For
  solaris /dev/rmt/0 is the default device.

  # mt -f /dev/rmt/1n fsf 3

ERROR NO SPACE LEFT ON DEVICE

ORA-27154: post/wait create failed
ORA-27300: OS system dependent operation:semget failed withstatus: 28
ORA-27301: OS failure message: No space left on device
ORA-27302: failure occurred at: sskgpsemsper

Although theerror says “No space left on device”, but it is not true. The problem is duekernel semaphore configuration. After setting a proper value(echo"250 1500 100 128" > /proc/sys/kernel/sem), the problemwill be solved:

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on MonJun 21 08:20:51 2010

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

Connected to an idle instance.

SQL> startup
ORA-27154: post/wait create failed
ORA-27300: OS system dependentoperation:semget failed with status: 28
ORA-27301: OS failure message: No spaceleft on device
ORA-27302: failure occurred at:sskgpsemsper
SQL> exit
Disconnected
[oracle@localhost ~]$ df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
304G 173G 115G 61% /
/dev/hda1 99M 12M 82M 13% /boot
tmpfs 1.3G 0 1.3G 0% /dev/shm
[root@localhost kernel]# cat /proc/sys/kernel/sem
250 100 32 128
[root@localhost kernel]# echo "250 1500 100 128" > /proc/sys/kernel/sem
[root@localhost kernel]# cat /proc/sys/kernel/sem
250 500 100 128
[root@localhost kernel]#

SCRIPT FOR CHECKING ARCHIVE LOG GENERATION ON ORACLE DATABASE

/////////////////////////On daily basis:

set pagesize 100
ALTER SESSION SET nls_date_format = 'YYYY-MM-DD';
-- As Table
SELECT TRUNC(completion_time) AS time, ROUND(SUM(blocks * block_size)/1024/1024,2) AS size_mb, ROUND(SUM(blocks * block_size)/1024/1024/1024,2) AS size_gb
FROM v$archived_log GROUP BY TRUNC(completion_time) ORDER BY 1 DESC;
-- As csv-File
SELECT TRUNC(completion_time) || ';' || ROUND(SUM(blocks * block_size)/1024/1024,2) || ';' || ROUND(SUM(blocks * block_size)/1024/1024/1024,2)
FROM v$archived_log GROUP BY TRUNC(completion_time) ORDER BY 1 DESC;



//////////////////////////On hourly basis:



set pagesize 100
ALTER SESSION SET nls_date_format = 'YYYY-MM-DD HH24';
-- As Table
SELECT TRUNC(completion_time,'HH24') AS time, ROUND(SUM(blocks * block_size)/1024/1024,2) AS size_mb, ROUND(SUM(blocks * block_size)/1024/1024/1024,2) AS size_gb
FROM v$archived_log GROUP BY TRUNC(completion_time,'HH24') ORDER BY 1 DESC;
-- As csv-File
SELECT TRUNC(completion_time,'HH24') || ';' || ROUND(SUM(blocks * block_size)/1024/1024,2) || ';' || ROUND(SUM(blocks * block_size)/1024/1024/1024,2)
FROM v$archived_log GROUP BY TRUNC(completion_time,'HH24') ORDER BY 1 DESC;

SCRIPT TO CALCULATE UNDO SIZE AND RETENTION TIME IN ORACLE DATABASE FOR EXP-00008: ORACLE error 1555 encountered ORA-01555: snapshot too old: rollback segment number 10 with name "_SYSSMU10$" too small error

//////////////////////maximum time take to execute query in sec


SQL>select max(maxquerylen) from v$undostat;


//////////////////////////Needed UNDO Size in MB


SQL>SELECT
ROUND(d.undo_size/(1024*1024),2) "ACTUAL UNDO SIZE [MByte]",
SUBSTR(e.value,1,25) "UNDO RETENTION [Sec]",
ROUND((TO_NUMBER(e.value)*TO_NUMBER(f.value)*g.undo_block_per_sec)/(1024*1024),2) "NEEDED UNDO SIZE [MByte]"
FROM
(
SELECT
SUM(a.bytes) undo_size
FROM
v$datafile a,
v$tablespace b,
dba_tablespaces c
WHERE
c.contents = 'UNDO'
AND c.status = 'ONLINE'
AND b.name = c.tablespace_name
AND a.TS# = b.TS#
) d,
v$parameter e,
v$parameter f,
(
SELECT
MAX(undoblks/((end_time-begin_time)*3600*24))
undo_block_per_sec
FROM
v$undostat
) g
WHERE
e.name = 'undo_retention'
AND f.name = 'db_block_size';


///////////////////////Optimal UNDO Retention in seconds





SQL>SELECT
ROUND(d.undo_size/(1024*1024),2) "ACTUAL UNDO SIZE [MByte]",
SUBSTR(e.value,1,25) "UNDO RETENTION [Sec]",
ROUND((d.undo_size/(TO_NUMBER(f.value)*g.undo_block_per_sec))) "OPTIMAL UNDO RETENTION [Sec]"
FROM
(
SELECT
SUM(a.bytes) undo_size
FROM
v$datafile a,
v$tablespace b,
dba_tablespaces c
WHERE
c.contents = 'UNDO'
AND c.status = 'ONLINE'
AND b.name = c.tablespace_name
AND a.TS# = b.TS#
) d,
v$parameter e,
v$parameter f,
(
SELECT
MAX(undoblks/((end_time-begin_time)*3600*24))
undo_block_per_sec
FROM
v$undostat
) g
WHERE
e.name = 'undo_retention'
AND f.name = 'db_block_size';


/////////////////////for change undo retention time



SQL>ALTER SYSTEM SET UNDO_RETENTION = [values based on your calculation];


/////////////////////////////number of error ora-01555



SQL>select 'Number of "ORA-01555 (Snapshot too old)" encountered since
the last startup of the instance : ' || sum(ssolderrcnt)
from v$undostat;




/////////////////////Actual undo tablespace size


SQL>SELECT SUM(a.bytes/1024/1024) undo_size
  FROM v$datafile a,
       v$tablespace b,
       dba_tablespaces c
WHERE c.contents = 'UNDO'
   AND c.status = 'ONLINE'
   AND b.name = c.tablespace_name
   AND a.ts# = b.ts#;


Sunday, April 27, 2014

SCRIPT TO DATAPUMP/NORMAL EXPORT/IMPORT STATUS MONITORING

/////////////import job  status


SELECT
SUBSTR(sql_text, INSTR(sql_text,'INTO "'),50) table_name
, rows_processed
, ROUND( (sysdate-TO_DATE(first_load_time,'yyyy-mm-dd hh24:mi:ss'))*24*60,1) minutes
, TRUNC(rows_processed/((sysdate-to_date(first_load_time,'yyyy-mm-dd hh24:mi:ss'))*24*60)) rows_per_minute
FROM sys.v_$sqlarea
WHERE
sql_text like 'INSERT %INTO "%'
AND command_type = 2
AND open_versions > 0;




///////////export job status

select
   round(sofar/totalwork*100,2)  percent_completed, 
   v$session_longops.* 
from 
   v$session_longops 
where
   sofar <> totalwork 
order by
   target, sid; 

Saturday, April 12, 2014

How to Configure Solaris 10 Project Resource Controls for Oracle

How to Configure Solaris 10 Project Resource Controls for Oracle
This is not an all-inclusive installation guide – Oracle already has written that
Oracle® Database Installation Guide 10g Release 2 (10.2) for Solaris Operating System (SPARC 64-Bit) HTML
Oracle® Database Installation Guide 10g Release 2 (10.2) for Solaris Operating System (x86) HTML
Oracle® Database Installation Guide 10g Release 2 (10.2) for Solaris Operating System (x86-64) HTML
Rather this is to supplement Chapter 2, Preinstallation Tasks. Sections 2.54 – 2.6 inclusive. Oracle forgot to add, and continues to forget, the details on creating a project for Oracle and configuring resource controls for that project.
So, picking up from where you create the Oracle Inventory group, oinstall, and the database administrator group, dba. ( # groupadd oinstall # groupadd dba):
1.   Configure Kernel Parameters and Resource Controls
From the Oracle installation guide it is not clear which kernel parameters are supposed to use the new Solaris 10 resource control facility, and those which are to use the the /etc/system file.
The following table is ripped from the 10.2 installation guide and as it says in the doco, the kernel parameter and shell limit values shown in the following section are recommended values only.
For production database systems, Oracle recommends that you tune these values to optimize the performance of the system.
Refer to your operating system documentation for more information about tuning kernel parameters blah blah blah.
The table contains the four resource controls that replace the old entries in the /etc/system file for a specific kernel parameter. Note that the /etc/system file is still used for the parameters listed with an ‘NA’ in the Resource Control Column.
Kernel Parameter
Resource Control
Recommended Value
shmsys:shminfo_shmmax
project.max-shm-memory
4294967295
shmsys:shminfo_shmmni
project.max-shm-ids
100
semsys:seminfo_semmsl
project.max-sem-nsems
256
semsys:seminfo_semmni
project.max-sem-ids
100
noexec_user_stack
NA
1
semsys:seminfo_semmns
NA
1024
semsys:seminfo_semvmx
NA
32767
shmsys:shminfo_shmmin
NA
1
shmsys:shminfo_shmseg
NA
10
I’ll ignore the kernel parameters in /etc/system – that’s documented already. Let’s take a look at the resource control settings instead. Much more interesting.
Before we start setting resource values, we first need to create a project for the Oracle installation:
1.1.   Create the group.dba project for Oracle
# projadd group.dba<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 
You should now see the project listed by the projects command and in /etc/project

bash-3.00# projects -l group.dba
group.dba

        projid : 100

        comment: ""

               users  : (none)

        groups : (none)

        attribs:



bash-3.00# cat /etc/project

system:0::::

user.root:1::::

noproject:2::::

default:3::::

group.staff:10::::

group.dba:100::::

Assuming all looks good, then proceed…

1.2.   Configure group.dba project Resource Controls

projmod -sK "project.max-shm-memory=(privileged,2G,deny)" group.dba

projmod -sK "project.max-sem-ids=(privileged,100,deny)" group.dba

projmod -sK "project.max-shm-ids=(privileged,100,deny)" group.dba

projmod -sK "project.max-sem-nsems=(privileged,256,deny)" group.dba

Just to check (for fun):
bash-3.00# projects -l group.dba
group.dba



      projid : 100

       comment: ""

        users  : (none)

        groups : (none)



        attribs: project.max-sem-ids=(privileged,100,deny)



                 project.max-sem-nsems=(privileged,256,deny)



                 project.max-shm-ids=(privileged,100,deny)



                 project.max-shm-memory=(privileged,2147483648,deny)






BTW, don’t use the prctl command to change the values (as shown in part of the installation guide) as the changed parameters do not persist after a system restart (as it says later in the installation guide after you have already followed their example and used prctl). Use projmod



1.3.   Create, or update oracle user with default project group.dba



1.3.1.          Create the Oracle user account, oracle, group.dba as default project



# useradd -g oinstall -G dba -m -d /export/home0/oracle -s /bin/bash -K project=group.dba oracle



Set the password of the oracle user:



# passwd -r files oracle





What’s with this –K value? From the sun man page doco:



-K key=value



Replace existing or add to a user's key=value pair attributes. Multiple -K options can be used to replace or add multiple key=value pairs. The generic -K option with the appropriate key can be used instead of the specific implied key options (-A, -P, -R, -p). See user_attr(4) for a list of valid key=value pairs. Values for these keys are usually found in man pages or other sources related to those keys. For example, see project(4) for guidance on values for the project key. Use the commandppriv(1) with the -v and -l options for a list of values for the keys defaultpriv and limitpriv.



Keys must not be repeated. Specifying a key= without a value removes an existing key=value pair.



The type key must be specified only without a value or with the role value. Specifying the type key without a value leaves the account as a normal user, with the role value changing from a normal user to a role user. As arole account, no roles (-R or roles=value) can be present.






See user_attr(4) for a list of valid key=value pairs









1.3.2.          Update an existing oracle user default project to group.dba



There is an algorithm Solaris uses to determine the default project:




Determining a User's Default Project

To log in to the system, a user must be assigned a default project. A user is automatically a member of that default project, even if the user is not in the user or group list specified in that project.

Because each process on the system possesses project membership, an algorithm to assign a default project to the login or other initial process is necessary.

The algorithm is documented in the man page getprojent(3C).

The system follows ordered steps to determine the default project. If no default project is found, the user's login, or request to start a process, is denied.

The system sequentially follows these steps to determine a user's default project:

1. If the user has an entry with a project attribute defined in the /etc/user_attr extended user attributes database, then the value of the project attribute is the default project. See the user_attr(4) man page.

2. If a project with the name user.user-id is present in theproject database, then that project is the default project. See the project(4) man page for more information.

3. If a project with the name group.group-name is present in the project database, where group-name is the name of the default group for the user, as specified in the passwd file, then that project is the default project. For information on the passwd file, see the passwd(4) man page.

4. If the special project default is present in the projectdatabase, then that project is the default project.



If you have already created the Oracle user you may find that while oracle is a member of the project, it’s default project is not group.dba.

You can use the usermod command to assign Oracle to the project.


# usermod -K project=group.dba oracle

You should now see in the /etc/user_attr file an entry for Oracle.

bash-3.00# cat /etc/user_attr

# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.



# Use is subject to license terms.

# /etc/user_attr



# execution attributes for profiles. see user_attr(4)



#



#ident  "@(#)user_attr  1.1     07/01/31 SMI"


adm::::profiles=Log Management



lp::::profiles=Printer Management



postgres::::type=role;profiles=Postgres Administration,All



root::::auths=solaris.*,solaris.grant;profiles=Web Console Management,All;lock_after_retries=no



oracle::::type=normal;project=group.dba<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />







Oracle’s default project according to the default project algorithm should now be group.dba



bash-3.00# su - oracle



Sun Microsystems Inc.   SunOS 5.10      Generic January 2005



<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 



-bash-3.00$ id -p



uid=101(oracle) gid=102(oinstall) projid=100(group.dba)


-bash-3.00$



Solaris Containers-Resource Management and Solaris Zones: "Setting Resource Controls"

1.4.   Commands Used With Projects and Tasks

The commands that are shown in the following table provide the primary administrative interface to the project and task facilities.



Man Page Reference 


Description 




Displays project memberships for users. Lists projects fromproject database. Prints information on given projects. If no project names are supplied, information is displayed for all projects. Use theprojects command with the -l option to print verbose output.




Executes the user's default shell or specified command, placing the execution command in a new task that is owned by the specified project.newtask can also be used to change the task and the project binding for a running process. Use with the -F option to create a finalized task.




Updates information in the password files. Use with the -K key=value option to add to user attributes or replace user attributes in local files.




Adds a new project entry to the /etc/project file. The projadd command creates a project entry only on the local system.projadd cannot change information that is supplied by the network naming service. Can be used to edit project files other than the default file,/etc/project. Provides syntax checking forproject file. Validates and edits project attributes. Supports scaled values.




Modifies information for a project on the local system. projmod cannot change information that is supplied by the network naming service. However, the command does verify the uniqueness of the project name and project ID against the external naming service. Can be used to edit project files other than the default file,/etc/project. Provides syntax checking forproject file. Validates and edits project attributes. Can be used to add a new attribute, add values to an attribute, or remove an attribute. Supports scaled values.




Deletes a project from the local system. projdelcannot change information that is supplied by the network naming service.




Adds default project definitions to the local files. Use with the -Kkey=value option to add or replace user attributes.




Deletes a user's account from the local file.




Modifies a user's login information on the system. Use with the -K key=valueoption to add or replace user attributes.