Unix commands part-2


little detailed in commands.. for shel script use
-----There are many commands will add few and update it day by day----
--date command in different way use in shel
$ date
Fri Oct 27 09:27:04 EAT 2017
$ date '+%a'
Fri
$ date '+%d-%b-%y'
27-Oct-17
$ date '+%d-%b-%y %a'
27-Oct-17 Fri
----------same in capital letter 
$ date '+%d-%b-%y %a' | tr '[a-z]' '[A-Z]'
27-OCT-17 FRI
=================================================================
chmod
=================================================================
Change file permissions
there are 3type of permisons read, write, ande xecute

EXAMPLE: chmod u=rwx,g=rx,o=r filename
The letters u, g, and o stand for "user", "group", and "other".
("=") means "set the permissions exactly like this
letters "r", "w", and "x" stand for "read", "write", and "execute"

we can use same command with numbers also 
example :- chmod 644 file name
Out of 3 numbers in exaple  "user(6= read+write)", "group(4= read)", and "other(4= read)".
=======================
4 stands for "read",
2 stands for "write",
1 stands for "execute", and

0 stands for "no permission."
So 7 is the combination of permissions 4+2+1 (read, write, and execute), like this you can choose number depends on required permission.
-------------simple way i explained to minimize text size------------

=================================================================
chown
=================================================================
The chown command is used to change the owner and group of files, directories and links

chown user file
chown user:group file

chown user:group directory

have many sub commands to explain all it need seperate article as dba this system admin job(not dba) so am not explain much here 

====================================================================
 Cleanup any unwanted trace files more than seven days old
====================================================================
find . *.trc -mtime +7 -exec rm {} \;
=========================

tar and un tar

To create a tar from a directory and its subdirectories:
tar -cvf packed_files.tar dir_to_pack
To unpack tar files, use the following commands:
For an uncompressed tar file:
tar -xvf file_to_unpack.tar
=================================================
mailq  ==> to check mails in mail queue





ORA-03137: TTC protocol internal error : [12333] [255] [255] [255] [] [] [] []

ORA-03137: TTC protocol internal error : [12333] [255] [255] [255] [] [] [] []


even though i post same error before but with diffrent argument 
these internal errors have any arguments and many soluotions .


 [12333] [255] [255] [255] [] [] [] []

solution 

Add this parameter to the sqlnet.ora file at BOTH the origin (or client) and at the server , instance: 

SQLNET.SEND_TIMEOUT=n 

Where n is a value in seconds. The setting itself, and not the value, should resolve this issue so a relatively high setting eliminate this problem. 

E.g. 

SQLNET.SEND_TIMEOUT=60000 



Thanks for the visit !
 Any doubts or correction/suggestions, please comment below it helps me to improve in further posts.


--------above sol not resolved after apply so for this 3137 traditional parameter we applied for fix



Hello Dipak -

Please verify/perform the following and let us know the status.

1. Check the client software version. An incompatible client software is a common cause of this error. Upgrade the client software to current version (i.e. match the server version).

The following note explains the supported combinations of clients for a particular RDBMS Server release.
Note 207303.1 Client / Server / Interoperability Support Between Different Oracle Versions

Similar issues are reported when the client installation is faulty.

2. An incompatible NLS Client setting can also trigger such internal errors. Check the NLS settings as explained in the following note.
Note 77442.1 ORA_NLS (ORA_NLS32, ORA_NLS33, ORA_NLS10) Environment Variables explained

3. There are a number of bugs associated with the use of bind peeking. Turn off bind peeking as follows:
alter system set "_optim_peek_user_binds"=false;    ==> apply and fix
please note in some rare cases this parameter causes performance degradation, 
as this hidden parameters harmful do not apply simply with out oracle or expert suggestion 

ORA-1092 : opitsk aborting process

sharing
This error shown when load high from database and unix server(as we have unix type veritas cluster

) detect hang and db failover to another node.


even in alertlog show only one errror and no other info(no trace file generation) trace cause so 
in this case below is help to trace(generate trace file immediate when impact time by using below mentod) and raise case to vedor and upload trace file(even if you can able to trace cause from file as you can)

Hanganalyze need to be collected when the situation occurs, below are the steps to perform such task. 
Hanganalyze 
sqlplus '/ as sysdba' 
oradebug setmypid 
oradebug unlimit 
oradebug hanganalyze 3 
-- Wait one minute before getting the second hanganalyze 
oradebug hanganalyze 3 
oradebug tracefile_name 
exit 

Thanks for the visit !
 Any doubts or correction/suggestions, please comment below it helps me to improve in further posts.

How to Resolve ORA-03297 When Resizing a Datafile by Finding the Table Highwatermark

 Doc ID 130866.1

REM Script is meant for Oracle version 9 and higher
REM -----------------------------------------------

set serveroutput on
exec dbms_output.enable(1000000);

declare

cursor c_dbfile is
select f.tablespace_name,f.file_name,f.file_id,f.blocks,t.block_size
,decode(t.allocation_type,'UNIFORM',t.initial_extent/t.block_size,0) uni_extent
,decode(t.allocation_type,'UNIFORM',(128+(t.initial_extent/t.block_size)),128) file_min_size
from dba_data_files f,
dba_tablespaces t
where f.tablespace_name = t.tablespace_name
and t.status = 'ONLINE'
order by f.tablespace_name,f.file_id;

cursor c_freespace(v_file_id in number) is
select block_id, block_id+blocks max_block
from dba_free_space
where file_id = v_file_id
order by block_id desc;

/* variables to check settings/values */
dummy number;
checkval varchar2(10);
block_correction1 number;
block_correction2 number;

/* running variable to show (possible) end-of-file */
file_min_block number;

/* variables to check if recycle_bin is on and if extent as checked is in ... */
recycle_bin boolean:=false;
extent_in_recycle_bin boolean;

/* exception handler needed for non-existing tables note:344940.1 */
sqlstr varchar2(100);
table_does_not_exist exception;
pragma exception_init(table_does_not_exist,-942);

/* variable to spot space wastage in datafile of uniform tablespace */
space_wastage number;

begin

/* recyclebin is present in Oracle 10.2 and higher and might contain extent as checked */
begin
select value into checkval from v$parameter where name = 'recyclebin';
if checkval = 'on'
then
recycle_bin := true;
end if;
exception
when no_data_found
then
recycle_bin := false;
end;

/* main loop */
for c_file in c_dbfile
loop
/* initialization of loop variables */
dummy :=0;
extent_in_recycle_bin := false;
file_min_block := c_file.blocks;

begin

space_wastage:=0; /* reset for every file check */

<<check_free>>

for c_free in c_freespace(c_file.file_id)
loop
/* if blocks is an uneven value there is a need to correct
with -1 to compare with end-of-file which is even */
block_correction1 := (0-mod(c_free.max_block,2));
block_correction2 := (0-mod(c_file.blocks,2));
if file_min_block+block_correction2 = c_free.max_block+block_correction1
then

/* free extent is at end so file can be resized */
file_min_block := c_free.block_id;

/* Uniform sized tablespace check if space at end of file
is less then uniform extent size */
elsif (c_file.uni_extent !=0) and ((c_file.blocks - c_free.max_block) < c_file.uni_extent)
then

/* uniform tablespace which has a wastage of space in datafile
due to fact that space at end of file is smaller than uniform extent size */

space_wastage:=c_file.blocks - c_free.max_block;
file_min_block := c_free.block_id;

else
/* no more free extent at end of file, file cannot be further resized */
exit check_free;
end if;
end loop;
end;

/* check if file can be resized, minimal size of file 128 {+ initial_extent} blocks */
if (file_min_block = c_file.blocks) or (c_file.blocks <= c_file.file_min_size)
then

dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
dbms_output.put_line('cannot be resized no free extents found');
dbms_output.put_line('Note: for some cases, dba_free_spaces data is not accurate, and this script does not work for such cases. You may want to manually check if the datafile is feasible to be resized');
dbms_output.put_line('.');

else

/* file needs minimal no of blocks which does vary over versions,
using safe value of 128 {+ initial_extent} */
if file_min_block < c_file.file_min_size
then
file_min_block := c_file.file_min_size;
end if;


dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
dbms_output.put_line('current size: '||(c_file.blocks*c_file.block_size)/1024||'K'||' can be resized to: '||round((file_min_block*c_file.block_size)/1024)||'K (reduction of: '||round(((c_file.blocks-file_min_block)/c_file.blocks)*100,2)||' %)');


/* below is only true if recyclebin is on */
if recycle_bin
then
begin
sqlstr:='select distinct 1 from recyclebin$ where file#='||c_file.file_id;
execute immediate sqlstr into dummy;

if dummy > 0
then

dbms_output.put_line('Extents found in recyclebin for above file/tablespace');
dbms_output.put_line('Implying that purge of recyclebin might be needed in order to resize');
dbms_output.put_line('SQL> purge tablespace '||c_file.tablespace_name||';');
end if;
exception
when no_data_found
then null;
when table_does_not_exist
then null;
end;
end if;
dbms_output.put_line('SQL> alter database datafile '''||c_file.file_name||''' resize '||round((file_min_block*c_file.block_size)/1024)||'K;');

if space_wastage!=0
then
dbms_output.put_line('Datafile belongs to uniform sized tablespace and is not optimally sized.');
dbms_output.put_line('Size of datafile is not a multiple of NN*uniform_extent_size + overhead');
dbms_output.put_line('Space that cannot be used (space wastage): '||round((space_wastage*c_file.block_size)/1024)||'K');
dbms_output.put_line('For optimal usage of space in file either resize OR increase to: '||round(((c_file.blocks+(c_file.uni_extent-space_wastage))*c_file.block_size)/1024)||'K');
end if;

dbms_output.put_line('.');

end if;

end loop;

end;
/



=============if lower version not posted any one need lower version like 8 please ref document from oracle as i posted number 



Thanks for the visit !
 Any doubts or correction/suggestions, please comment below it helps me to improve in further posts.

Active Session History (ASH) performed an emergency flush

===================================
Active Session History (ASH) performed an emergency flush. This may mean that ASH is undersized. If emergency flushes are a recurring issue, you may consider increasing ASH size by setting the value of _ASH_SIZE to a sufficiently large value. Currently, ASH size is 83886080 bytes. Both ASH size and the total number of emergency flushes since instance startup can be monitored by running the following query: 
select total_size,awr_flush_emergency_count from v$ash_info; 
====================================================


The ASH buffers may need to be increased if the message is logged frequently.

Please review:

Active Session History (ASH) Performed An Emergency Flush Messages In The Alert Log ( Doc ID 1385872.1 )




Thanks for the visit !
 Any doubts or correction/suggestions, please comment below it helps me to improve in further posts.

11.2.0.4 version, RDBMS :The value (80) of MAXTRANS parameter ignored. (alert log messege)



===================REFRENCE ==============
This is an informational error that you are getting this error because somebody is running a DDL (create table/index) that is specifying the maxtrans parameter. 

Please refer the below note for more details: 
DataPump Export/Import Generate Messages "The Value (30) Of Maxtrans Parameter Ignored" in Alert Log ( Doc ID 455021.1 ) 

======================================

ORA-03137: TTC protocol internal error : [12333] [6] [3] [8] [] [] [] []

Cause:
======
This error is only affecting the session seeing the error. This error does not relate to any potential data corruption or any data loss.
This error is only telling us that the client and server process communication was terminated due to some event.
Most of the customers tried workaround of setting "_optim_peek_user_binds"=false to avoid this problem
OR
In Some cases
Bug 18841764 Network related error like ORA-12592 or ORA-3137 or ORA-3106 may be signaled
Network/TTC related error ORA-12592, ORA-3137, ORA-3106 may be signaled on SQL*Net TCP/IP transport.
Usually this problem is seen with following circumstances.
- Sending large size data to database server, for example, using sqlldr, expdp
Solution:
=========
workaround 1
============
one time occurrences can be safely ignored as there wasn't any impact.
OR
If error is consistent,

SQL> alter system set "_optim_peek_user_binds"=false;
Restart the db instance and listener.

Impact:It disables bind peeking and therefore affects execution plans that depend on this feature this is slight query performance impact but
nothing on network.
and
For Bug 18841764 the solution is as follows
============
Workaround 2
============
set sqlnet.send_timeout to any value except 0 on the server and client. In a previous incident setting it to 600 resolved the issue.
Example
sqlnet.send_timeout=600
OR
Apply one off patch 18841764 which is available on base version.
patch not available for 11203 on HP-UX Itanium
NOTE==>11203 is out of premier support and needs exception license to get any new patches or file new bug. As per our records CSI 13872399 do
not have exception license.

Common Oracle Clusterware crsctl commands

  Oracle Clusterware crsctl commands: # Check cluster status crsctl check crs crsctl check cluster # Cluster resources crsctl status reso...