Skip to main content

Posts

PowerShell script to manage Maximo

#run powershell script remotely Invoke-Command -ComputerName COMPUTER -ScriptBlock { COMMAND } Invoke-Command -ComputerName COMPUTER -ScriptBlock { COMMAND } -credential a.jsun #find computer last reboot time systeminfo -S servername   |findstr /I "boot time" PS > Invoke-Command -ComputerName servername  -ScriptBlock { Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime } #find computer last 10 reboot time invoke-command -computername $servername -scriptblock {get-eventlog system | where-object {$_.eventid -eq 6006 -or $_.eventid -eq 6005 }  | select -first 10} #query status of windows service sc \\servername  query "OracleWeblogic ship76domain_Vessel_ManSrv" PS > Invoke-Command -ComputerName servername  -ScriptBlock { Get-Service -Name "OracleWeblogic ship76domain_Vessel_ManSrv" } #query history of a service start/stop in eventlog PS > (Get-EventLog -LogName "System" -Source "Service Contro...

Case study of SQL AlwaysOn transaction log file shrink

Case study of SQL AlwaysOn transaction log file shrink. Usually backup transaction log will move the LVF head lower, make it possible to shrink transaction log, but with sqlalwaysOn configuration, I found that it not work as always, I need to specifically fill up the highest LVF so that transaction log head can move to lower side. This is the case study of that. The following blog explained lazy truncation of sql AlwaysOn: https://blogs.msdn.microsoft.com/sql_pfe_blog/2013/06/27/lazy-log-truncation-clearing-of-sql-transaction-log-vlf-status-deferred/ To find out the file size: SELECT DB_NAME ( database_id ) AS DatabaseName , Name AS Logical_Name , Physical_Name , ( size * 8 )/ 1024 SizeMB FROM sys . master_files --WHERE DB_NAME(database_id) = 'AdventureWorks' order by 4 desc GO We use Sp_CentralAdmin database as example to shrink logfile: Use Sp_CentralAdmin go Dbcc loginfo go Noticed that all the LVF has status=2. ...

powershell script to loop database query etc on multiple servers.

1. To test connection time: 1.1 $PASSWD="whatever" $PASSED get-content bosslist.txt|foreach-object {measure-command {(echo "select 1 from dual")|sqlplus jsun/$PASSWD@"(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(Host = $_)(Port = 1521))) (CONNECT_DATA = (SID =SIDNAME)))"}}|findstr TotalSeconds output looks like this: TotalSeconds      : 1.6875126 TotalSeconds      : 1.6090257 TotalSeconds      : 1.61322 ... 1.2: This command will combine the server name to the totalseconds output. get-content bosslist.txt|foreach-object { $server=$_ measure-command {(echo "select 1 from dual")|sqlplus jsun/$PASSWD@"(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(Host = $_)(Port = 1521))) (CONNECT_DATA = (SID =PCP1)))"} }|select-object  {"Server "+$server+" : "+$_.TotalSeconds} output look like this: "Server "+$server+" : "+$_.TotalSeconds ------------------------...

10 Useful Sar (Sysstat) Examples for UNIX / Linux Performance Monitoring

found this very helpful: https://www.thegeekstuff.com/2011/03/sar-examples/?utm_source=feedburner 1. CPU Usage of ALL CPUs (sar -u) This gives the cumulative real-time CPU usage of all CPUs. “1 3” reports for every 1 seconds a total of 3 times. Most likely you’ll focus on the last field “%idle” to see the cpu load. $ sar -u 1 3 Linux 2.6.18-194.el5PAE (dev-db) 03/26/2011 _i686_ (8 CPU) 01:27:32 PM CPU %user %nice %system %iowait %steal %idle 01:27:33 PM all 0.00 0.00 0.00 0.00 0.00 100.00 01:27:34 PM all 0.25 0.00 0.25 0.00 0.00 99.50 01:27:35 PM all 0.75 0.00 0.25 0.00 0.00 99.00 Average: all 0.33 0.00 0.17 0.00 0.00 99.50 Following are few variations: sar -u  Displays CPU usage for the current day that was collected until that point. sar -u 1 3  Displays real time CPU usage every 1 se...

Use command line emcli to delete Grid control targets

Our Oracle database oracle_home and instance_name have massive change and the targets need to be removed, I can remove the host but the EM admin said he has group rule setup and do not want to delete host, so I have to delete the target one-by-one, clicking in EM console is no fun, I logon to the EM repository database and run this query to generate the script to run on EM weblogic server. select 'emcli delete_target -name='||TARGET_NAME||' -type="'||TARGET_TYPE||'"' from sysman.mgmt_targets where upper(host_name) like 'HOSTNAME%' and target_type like 'rac_database'; It generate command like below: $emcli delete_target -name=blablabla -type="rac_database" I need to run the emcli login first before run delete target... emcli login -username=sysman -password=thepassword

Convert RAC database to RACOneNode

It's three nodes RAC, db name is TEST, instance name is TEST1|2|3, the goal is to convert from RAC to RACOneNode and make it run on node2. srvctl stop instance -d TEST -i TEST1 srvctl stop instance -d TEST -i TEST3 srvctl remove instance -d TEST -i TEST1 srvctl remove instance -d TEST -i TEST3 srvctl add service -s TEST_svc -d TEST -r TEST2 srvctl convert database -d TEST -dbtype RACONENODE -i TEST srvctl modify database -d TEST -e node2 srvctl stop database -d TEST srvctl start database -d TEST srvctl status database -d TEST srvctl config database -d TEST

some shell scripting on RAC

###To get all the database instance name on a consolidated Unix/Linux server: #because some of the RAC-ONE-NODE db instance has ckpt process name like this ora_ckpt_dbname_1, we have to deal with the third "_" and forth field: ps -ef|grep ckpt|awk '{print $8}'|awk ' FS="_" { print $3"_"$4}'|sed 's/_$//g'|egrep -ve "^$|+ASM|-MGMT" ###To find any running db instance missing in /etc/oratab: for db in `ps -ef|grep ckpt|grep -v -i asm|grep -v -i "MGMTDB"|awk '{print $8}'|awk ' FS="_" {print $3"_"$4}'|sed 's/_$//g'|sort`  do export ORACLE_SID=$db if ! grep -w $ORACLE_SID /etc/oratab 1>/dev/null ; then echo $ORACLE_SID else : fi done ###To loop through the databases on the consolidated server: for example, to find RAC db export ORAENV_ASK=NO for db in `ps -ef|grep ckpt|awk '{print $8}'|sort|awk ' FS="_" { print $3"_"$4;}...