yum install nc on server1 and server2 ----> install netcat on server1 nc -ul 38893 >> test ----> listen for udp on port 38893, append to file "test" on server2 echo "hello test2" > /tmp/testfile cat testfile2 | nc -u server1 38893 ----> send contents of testfile2 over udp to port 38893 on server1 ctrl-c on server1 ctrl-c cat test "hello test2" is appended to file "test"
Uncategorized
Oracle – Query locking
Display locks in Oracle database
select * from gv$lock where block = 1 select * from gv$session where sid in (1998) select sid, serial#, lockwait, blocking_instance, blocking_session, final_blocking_instance, final_blocking_session from gv$session where program not like 'oracle%' and blocking_session is not null --ALTER SYSTEM KILL SESSION 'sid,serial#,inst_id'; select * from gv$session where status = 'KILLED' -- non-RAC environment SELECT Decode(request, 0, 'Holder: ', 'Waiter: ') ||vl.sid sess, status,id1,id2,lmode,request,vl.TYPE FROM v$lock vl,v$session vs WHERE ( id1, id2, vl.TYPE ) IN (SELECT id1, id2, TYPE FROM v$lock WHERE request > 0) AND vl.sid = vs.sid ORDER BY id1, request
[Look for UBABLK in gv$transaction – if value remains static for a while, the transaction is potentially blocked
select * from gv$transaction
SQL Server – DBCC
DBCC TRACEON(2520)
DBCC HELP (‘?’)
GO
DBCC HELP(<command>)
GO
Following is the list of all the DBCC commands and their syntax. List contains all documented and undocumented DBCC commands.
DBCC activecursors [(spid)]
DBCC addextendedproc (function_name, dll_name)
DBCC addinstance (objectname, instancename)
DBCC adduserobject (name)
DBCC auditevent (eventclass, eventsubclass, success, loginname
, rolename, dbusername, loginid)
DBCC autopilot (typeid, dbid, tabid, indid, pages [,flag])
DBCC balancefactor (variance_percent)
DBCC bufcount [(number_of_buffers)]
DBCC buffer ( {‘dbname’ | dbid} [, objid [, number [, printopt={0|1|2} ] [, dirty | io | kept | rlock | ioerr | hashed ]]])
DBCC bytes ( startaddress, length )
DBCC cachestats
DBCC callfulltext
DBCC checkalloc [(‘database_name'[, NOINDEX | REPAIR])] [WITH NO_INFOMSGS[, ALL_ERRORMSGS][, ESTIMATEONLY]]
DBCC checkcatalog [(‘database_name’)] [WITH NO_INFOMSGS]
DBCC checkconstraints [( ‘tab_name’ | tab_id | ‘constraint_name’ | constraint_id )] [WITH ALL_CONSTRAINTS | ALL_ERRORMSGS]
DBCC checkdb [(‘database_name'[, NOINDEX | REPAIR])] [WITH NO_INFOMSGS[, ALL_ERRORMSGS] [, PHYSICAL_ONLY][, ESTIMATEONLY][,DBCC TABLOCK]
DBCC checkdbts (dbid, newTimestamp)]
DBCC checkfilegroup [( [ {‘filegroup_name’ | filegroup_id} ] [, NOINDEX] )] [WITH NO_INFOMSGS
[, ALL_ERRORMSGS][, PHYSICAL_ONLY][, ESTIMATEONLY][, TABLOCK]]
DBCC checkident (‘table_name'[, { NORESEED | {RESEED [, new_reseed_value] } } ] )
DBCC checkprimaryfile ( {‘FileName’} [, opt={0|1|2|3} ])
DBCC checktable (‘table_name'[, {NOINDEX | index_id | REPAIR}])
[WITH NO_INFOMSGS[, ALL_ERRORMSGS] [, PHYSICAL_ONLY][, ESTIMATEONLY][, TABLOCK]]
DBCC cleantable (‘database_name’|database_id, ‘table_name’|table_id,[batch_size])
DBCC cacheprofile [( {actionid} [, bucketid])
DBCC clearspacecaches (‘database_name’|database_id,
‘table_name’|table_id, ‘index_name’|index_id)
DBCC collectstats (on | off)
DBCC concurrencyviolation (reset | display | startlog | stoplog)
DBCC config
DBCC cursorstats ([spid [,’clear’]])
DBCC dbinfo [(‘dbname’)]
DBCC dbrecover (dbname [, IgnoreErrors])
DBCC dbreindex (‘table_name’ [, index_name [, fillfactor ]]) [WITH NO_INFOMSGS]
DBCC dbreindexall (db_name/db_id, type_bitmap)
DBCC dbrepair (‘dbname’, DROPDB [, NOINIT])
DBCC dbtable [({‘dbname’ | dbid})]
DBCC debugbreak
DBCC deleteinstance (objectname, instancename)
DBCC des [( {‘dbname’ | dbid} [, {‘objname’ | objid} ])]
DBCC detachdb [( ‘dbname’ )]
DBCC dropcleanbuffers
DBCC dropextendedproc (function_name)
DBCC dropuserobject (‘object_name’)
DBCC dumptrigger ({‘BREAK’, {0 | 1}} | ‘DISPLAY’ | {‘SET’, exception_number}
| {‘CLEAR’, exception_number})
DBCC errorlog
DBCC extentinfo [({‘database_name’| dbid | 0}
[,{‘table_name’ | table_id} [, {‘index_name’ | index_id | -1}]])]
DBCC fileheader [( {‘dbname’ | dbid} [, fileid])
DBCC fixallocation [({‘ADD’ | ‘REMOVE’},
{‘PAGE’ | ‘SINGLEPAGE’ | ‘EXTENT’ | ‘MIXEDEXTENT’}
, filenum, pagenum [, objectid, indid])
DBCC flush (‘data’ | ‘log’, dbid)
DBCC flushprocindb (database)
DBCC free dll_name (FREE)
DBCC freeproccache
dbcc freeze_io (db)
dbcc getvalue (name)
dbcc icecapquery (‘dbname’, stored_proc_name
[, #_times_to_icecap (-1 infinite, 0 turns off)])
Use ‘dbcc icecapquery (printlist)’ to see list of SP’s to profile.
Use ‘dbcc icecapquery (icecapall)’ to profile all SP’s.
dbcc incrementinstance (objectname, countername, instancename, value)
dbcc ind ( { ‘dbname’ | dbid }, { ‘objname’ | objid }, { indid | 0 | -1 | -2 } )
DBCC indexdefrag ({dbid | dbname | 0}, {tableid | tablename}, {indid |indname})
DBCC inputbuffer (spid)
DBCC invalidate_textptr (textptr)
DBCC invalidate_textptr_objid (objid)
DBCC iotrace ( { ‘dbname’ | dbid | 0 | -1 }
, { fileid | 0 }, bufsize, [ { numIOs | -1 }
[, { timeout (sec) | -1 } [, printopt={ 0 | 1 }]]] )
DBCC latch ( address [, ‘owners’] [, ‘stackdumps’])
DBCC lock ([{‘DUMPTABLE’ | ‘DUMPSTATS’ | ‘RESETSTATS’ | ‘HASH’}] |
[{‘STALLREPORTTHESHOLD’, stallthreshold}])
DBCC lockobjectschema (‘object_name’)
DBCC log ([dbid[,{0|1|2|3|4}[,[‘lsn’,'[0x]x:y:z’]|[‘numrecs’,num]|[‘xdesid’,’x:y’] |[‘extent’,’x:y’]|[‘pageid’,’x:y’]|[‘objid’,{x,’y’}]|[‘logrecs’,
{‘lop’|op}…]|[‘output’,x,[‘filename’,’x’]]…]]])
DBCC loginfo [({‘database_name’ | dbid})]
DBCC matview ({‘PERSIST’ | ‘ENDPERSIST’ | ‘FREE’ | ‘USE’ | ‘ENDUSE’})
DBCC memobjlist [(memory object)]
DBCC memorymap
DBCC memorystatus
DBCC memospy
DBCC memusage ([IDS | NAMES], [Number of rows to output])
DBCC monitorevents (‘sink’ [, ‘filter-expression’])
DBCC newalloc – please use checkalloc instead
DBCC no_textptr (table_id , max_inline)
DBCC opentran [({‘dbname’| dbid})] [WITH TABLERESULTS[,NO_INFOMSGS]]
DBCC outputbuffer (spid)
DBCC page ( {‘dbname’ | dbid}, filenum, pagenum
[, printopt={0|1|2|3} ][, cache={0|1} ])
DBCC perflog
DBCC perfmon
DBCC pglinkage (dbid, startfile, startpg, number, printopt={0|1|2}
, targetfile, targetpg, order={1|0})
DBCC pintable (database_id, table_id)
DBCC procbuf [({‘dbname’ | dbid}[, {‘objname’ | objid}
[, nbufs[, printopt = { 0 | 1 } ]]] )]
DBCC proccache
DBCC prtipage (dbid, objid, indexid [, [{{level, 0}
| {filenum, pagenum}}] [,printopt]])
DBCC pss [(uid[, spid[, printopt = { 1 | 0 }]] )]
DBCC readpage ({ dbid, ‘dbname’ }, fileid, pageid
, formatstr [, printopt = { 0 | 1} ])
DBCC rebuild_log (dbname [, filename])
DBCC renamecolumn (object_name, old_name, new_name)
DBCC resource
DBCC row_lock (dbid, tableid, set) – Not Needed
DBCC ruleoff ({ rulenum | rulestring } [, { rulenum | rulestring } ]+)
DBCC ruleon ( rulenum | rulestring } [, { rulenum | rulestring } ]+)
DBCC setcpuweight (weight)
DBCC setinstance (objectname, countername, instancename, value)
DBCC setioweight (weight)
DBCC show_statistics (‘table_name’, ‘target_name’)
DBCC showcontig (table_id | table_name [, index_id | index_name] [WITH FAST, ALL_INDEXES, TABLERESULTS [,ALL_LEVELS]])
DBCC showdbaffinity
DBCC showfilestats [(file_num)]
DBCC showoffrules
DBCC showonrules
DBCC showtableaffinity (table)
DBCC showtext (‘dbname’, {textpointer | {fileid, pageid, slotid[,option]}})
DBCC showweights
DBCC shrinkdatabase ({dbid | ‘dbname’}, [freespace_percentage
[, {NOTRUNCATE | TRUNCATEONLY}]])
DBCC shrinkfile ({fileid | ‘filename’}, [compress_size
[, {NOTRUNCATE | TRUNCATEONLY | EMPTYFILE}]])
DBCC sqlmgrstats
DBCC sqlperf (LOGSPACE)({IOSTATS | LRUSTATS | NETSTATS | RASTATS [, CLEAR]}
| {THREADS} | {LOGSPACE})
DBCC stackdump [( {uid[, spid[, ecid]} | {threadId, ‘THREADID’}] )]
DBCC tab ( dbid, objid )
DBCC tape_control {‘query’ | ‘release’}[,(‘.tape’)]
DBCC tec [( uid[, spid[, ecid]] )]
DBCC textall [({‘database_name’|database_id}[, ‘FULL’ | FAST] )]
DBCC textalloc ({‘table_name’|table_id}[, ‘FULL’ | FAST])
DBCC thaw_io (db)
DBCC traceoff [( tracenum [, tracenum … ] )]
DBCC traceon [( tracenum [, tracenum … ] )]
DBCC tracestatus (trace# [, …trace#])
DBCC unpintable (dbid, table_id)
DBCC updateusage ({‘database_name’| 0} [, ‘table_name’ [, index_id]])
[WITH [NO_INFOMSGS] [,] COUNT_ROWS]
DBCC upgradedb (db) DBCC usagegovernor (command, value)
DBCC useplan [(number_of_plan)]
DBCC useroptions DBCC wakeup (spid)
DBCC writepage ({ dbid, ‘dbname’ }, fileid, pageid, offset, length, data)
Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL, Extreme Expert
SQL Server – Generate SQL for Database Snapshot
with
preamble(c) as (select 'create database ' + db_name() + '_Snapshot on'),
files(c) as (select '(name=' + name + ', filename=''' + physical_name + '.ss'')' + char(10) from sys.database_files where type = 0),
filescoalesce (c) as (select c + ',' from files for xml path('')),
lastline(c) as (select 'as snapshot of ' + db_name() + char(10) + char(10) + 'GO' + char(10))
select c [--] from preamble
union all
select left(c, len(c) -2) from filescoalesce
union all
select c from lastline
Oracle Linux – Install vnc server
[root@oralintest ~]# yum install tigervnc-server Loaded plugins: langpacks, ulninfo Resolving Dependencies --> Running transaction check ---> Package tigervnc-server.x86_64 0:1.8.0-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================================================== Installing: tigervnc-server x86_64 1.8.0-1.el7 ol7_latest 213 k Transaction Summary =============================================================================================================================================================================== Install 1 Package Total download size: 213 k Installed size: 504 k Is this ok [y/d/N]: y Downloading packages: warning: /var/cache/yum/x86_64/7Server/ol7_latest/packages/tigervnc-server-1.8.0-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY Public key for tigervnc-server-1.8.0-1.el7.x86_64.rpm is not installed tigervnc-server-1.8.0-1.el7.x86_64.rpm | 213 kB 00:00:00 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle Importing GPG key 0xEC551F03: Userid : "Oracle OSS group (Open Source Software group)" Fingerprint: 4214 4123 fecf c55b 9086 313d 72f9 7b74 ec55 1f03 Package : 7:oraclelinux-release-7.4-1.0.4.el7.x86_64 (@anaconda/7.4) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : tigervnc-server-1.8.0-1.el7.x86_64 1/1 Verifying : tigervnc-server-1.8.0-1.el7.x86_64 1/1 Installed: tigervnc-server.x86_64 0:1.8.0-1.el7 Complete! [root@oralintest ~]#
Linux – Java High cpu utilization by threads
[oracle@ovmm-t01 ~]$ /u01/app/oracle/java/bin/jps -v
32606 Jps -Dapplication.home=/u01/app/oracle/java -Xms8m
3083 CLIMain -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/u01/app/oracle/ovm-manager-3/domains/ovm_domain/servers/AdminServer/logs -Ddomain-dir=/u01/app/oracle/ovm-manager-3/domains/ovm_domain -Dlog4j.configuration=file:./log4j.properties
13774 Server -Xms512m -Xmx4096m -XX:MaxPermSize=512m -Dweblogic.Name=AdminServer -Djava.security.policy=/u01/app/oracle/Middleware/wlserver/server/lib/weblogic.policy -Dweblogic.ProductionModeEnabled=true -DUseSunHttpHandler=true -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/u01/app/oracle/ovm-manager-3/domains/ovm_domain/servers/AdminServer/logs -Dorg.quartz.properties=/u01/app/oracle/ovm-manager-3/domains/ovm_domain/config/appfw/quartz.properties -Dweblogic.security.SSL.protocolVersion=TLS1 -Dweblogic.security.disableNullCipher=true -Djava.awt.headless=true -Xdebug -Xrunjdwp:transport=dt_socket,address=127.0.0.1:8453,server=y,suspend=n -da:org.apache.myfaces.trinidad -Djava.endorsed.dirs=/u01/app/oracle/java/jre/lib/endorsed:/u01/app/oracle/Middleware/wlserver/../oracle_common/modules/endorsed -Djava.protocol.handler.pkgs=oracle.mds.net.protocol -Dopss.version=12.1.3 -Digf.arisidbeans.carmlloc=/u01/app/oracle/ovm-manager-3/domains/ovm_domain/config/fmwconfig/carml -Digf.arisidstack.home=/u01/app/oracle/ovm-manager-3
Identify thread taking cpu using top command
Get the dump trace
/u01/app/oracle/java/bin/jstack 3083 > jstack_3083.out
Convert 12332 into hex = 302c
Search for 302c in jstack_3083.out
vim jstack_3083.out
Shows that EchoShell is the thread that is taking >80% cpu
Linux – colors
T='rayfox'
echo -e "\n 40m 41m 42m 43m\
44m 45m 46m 47m";
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
' 36m' '1;36m' ' 37m' '1;37m';
do FG=${FGs// /}
echo -en " $FGs \033[$FG $T "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
done
echo;
done
echo
SQL Server – Display Availability Group Failovers
AlwaysOn
Get-winEvent -ComputerName <Listener> -filterHashTable @{logname ='Microsoft-Windows-FailoverClustering/Operational'; id=1641}|
ft -AutoSize -Wrap
Oracle – Install sqlci on RHEL Linux
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz" cp xzf jdk-8u141-linux-x64.tar.gz /usr/lib/jvm/ cd /usr/lib/jvm/ tar xzf jdk-8u141-linux-x64.tar.gz cd jdk1.8.0_141 alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_141/bin/java 2 alternatives --config java (choose the right one) copy sqlcl-17.2.0.184.1230-no-jre.zip to linux server unzip into a directory cp <path>/bin/sql into /usr/lib/jvm/jdk1.8.0_141/bin/ cp <path>/lib/* into /usr/lib/jvm/jdk1.8.0_141/lib/ change permissions of the new files (e.g. uucp:143) export PATH=$PATH:/usr/lib/jvm/jdk1.8.0_141/bin if TNS_ADMIN is set you can use tnsnames syntax :sql system/oracle_4U@ORCL othewise use ezconnect syntax : sql system/oracle_4U@rh6-121-rac2:1521/fox2
Oracle – ASM – asmcmd
Get a list of diskroups – bash shell
diskgroups=$(sqlplus -s -L / as sysdba << EOF
set pages 0 feedback off
select listagg (name, ' ') within group (order by name) from v\$asm_diskgroup;
EOF
)
asmcmd web page – Sachin’s DBA Blog

