Thinking Out Loud

August 4, 2017

Windows Datapump Export

Filed under: 11g,oracle,Windows — mdinh @ 3:45 am
Tags:

The purpose of the script is to perform full database export keeping 3 export copies.
If export is successful, then fullexp*.dmp will be renamed with _1.dmp suffix added to filename.
If export is unsuccessful, then code will exit, skipping rename operations.

Note: there should never be .dmp file without # suffix unless export is unsuccessful.

In hindsight, directoryName should be using variable (ORACLE_SID) versus hardcode.

SET ORACLE_SID=DB01
SET directoryName=D:\DB01\export

expdp ‘/ as sysdba’ full=y directory=DATA_PUMP_DIR dumpfile=fullexp_%ORACLE_SID%_%COMPUTERNAME%.dmp logfile=fullexp_%ORACLE_SID%_%COMPUTERNAME%.log flashback_time=SYSTIMESTAMP REUSE_DUMPFILES=YES
IF %ERRORLEVEL% NEQ 0 GOTO ERROR

IF EXIST “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%_3.dmp” (DEL “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%_3.*”)

IF EXIST “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%_2.dmp” (RENAME “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%_2.dmp” “fullexp_%ORACLE_SID%_%COMPUTERNAME%_3.dmp”)
IF EXIST “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%_2.log” (RENAME “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%_2.log” “fullexp_%ORACLE_SID%_%COMPUTERNAME%_3.log”)

IF EXIST “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%_1.dmp” (RENAME “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%_1.dmp” “fullexp_%ORACLE_SID%_%COMPUTERNAME%_2.dmp”)
IF EXIST “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%_1.log” (RENAME “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%_1.log” “fullexp_%ORACLE_SID%_%COMPUTERNAME%_2.log”)

IF EXIST “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%.dmp” (RENAME “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%.dmp” “fullexp_%ORACLE_SID%_%COMPUTERNAME%_1.dmp”)
IF EXIST “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%.log” (RENAME “%directoryName%\fullexp_%ORACLE_SID%_%COMPUTERNAME%.log” “fullexp_%ORACLE_SID%_%COMPUTERNAME%_1.log”)

EXIT 0

:ERROR
EXIT 1

Results after 4 runs.

08/03/2017  07:53 PM     2,680,008,704 fullexp_DB01_CMWPHV1_1.dmp
08/03/2017  07:53 PM           161,707 fullexp_DB01_CMWPHV1_1.log
08/03/2017  07:46 PM     2,680,008,704 fullexp_DB01_CMWPHV1_2.dmp
08/03/2017  07:46 PM           161,707 fullexp_DB01_CMWPHV1_2.log
08/03/2017  07:37 PM     2,680,008,704 fullexp_DB01_CMWPHV1_3.dmp
08/03/2017  07:37 PM           161,707 fullexp_DB01_CMWPHV1_3.log

May 17, 2017

Windows Oracle Services Using PowerShell

Filed under: oracle,Windows — mdinh @ 10:39 pm

Lately, I have been getting feet wet with Windows.
I know GUI can be used but not very good to reproduce.

Here is now to find Stopped Oracle Windows Services and start them.

And if you want to use GUI, run Services.msc from command line.

Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.

PS C:\Users\oracle> hostname
minions

PS C:\Users\oracle> Get-Service -Name *oracle* | Where Status -eq "Stopped" | Format-List
Name                : Oracleagent12c1Agent
DisplayName         : Oracleagent12c1Agent
Status              : Stopped
DependentServices   : {}
ServicesDependedOn  : {}
CanPauseAndContinue : False
CanShutdown         : False
CanStop             : False
ServiceType         : Win32OwnProcess

Name                : OracleOraHome1ClrAgent
DisplayName         : OracleOraHome1ClrAgent
Status              : Stopped
DependentServices   : {}
ServicesDependedOn  : {}
CanPauseAndContinue : False
CanShutdown         : False
CanStop             : False
ServiceType         : Win32OwnProcess

Name                : OracleRemExecServiceV2
DisplayName         : OracleRemExecServiceV2
Status              : Stopped
DependentServices   : {}
ServicesDependedOn  : {}
CanPauseAndContinue : False
CanShutdown         : False
CanStop             : False
ServiceType         : Win32OwnProcess

PS C:\Users\oracle> Start-Service -name Oracleagent12c1Agent
WARNING: Waiting for service 'Oracleagent12c1Agent (Oracleagent12c1Agent)' to start...
WARNING: Waiting for service 'Oracleagent12c1Agent (Oracleagent12c1Agent)' to start...
WARNING: Waiting for service 'Oracleagent12c1Agent (Oracleagent12c1Agent)' to start...
WARNING: Waiting for service 'Oracleagent12c1Agent (Oracleagent12c1Agent)' to start...

PS C:\Users\oracle> Get-Service -name Oracleagent12c1Agent
Status   Name               DisplayName
------   ----               -----------
Start... Oracleagent12c1... Oracleagent12c1Agent

PS C:\Users\oracle> Get-Service -name Oracleagent12c1Agent
Status   Name               DisplayName
------   ----               -----------
Running  Oracleagent12c1... Oracleagent12c1Agent

PS C:\Users\oracle> Get-Service -Name *oracle* | Where Status -eq "Stopped" | Format-List
Name                : OracleOraHome1ClrAgent
DisplayName         : OracleOraHome1ClrAgent
Status              : Stopped
DependentServices   : {}
ServicesDependedOn  : {}
CanPauseAndContinue : False
CanShutdown         : False
CanStop             : False
ServiceType         : Win32OwnProcess

Name                : OracleRemExecServiceV2
DisplayName         : OracleRemExecServiceV2
Status              : Stopped
DependentServices   : {}
ServicesDependedOn  : {}
CanPauseAndContinue : False
CanShutdown         : False
CanStop             : False
ServiceType         : Win32OwnProcess

PS C:\Users\oracle> C:\app\oracle\product\agent12c\core\12.1.0.3.0\bin\emctl status agent
Oracle Enterprise Manager Cloud Control 12c Release 3
Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.
---------------------------------------------------------------
Agent Version     : 12.1.0.3.0
OMS Version       : 12.1.0.3.0
Protocol Version  : 12.1.0.1.0
Agent Home        : C:/app/oracle/product/agent12c/agent/core/12.1.0.3.0
Agent Binaries    : c:\app\oracle\product\agent12c\core\12.1.0.3.0
Agent Process ID  : 538684
Parent Process ID : 536640
Agent URL         : https://minions.local:1830/emd/main/
Repository URL    : https://cloud.local:4903/empbs/upload
Started at        : 2017-05-17 13:30:23
Started by user   : minions$
Last Reload       : (none)
Last successful upload                       : 2017-05-17 13:31:00
Last attempted upload                        : 2017-05-17 13:31:00
Total Megabytes of XML files uploaded so far : 0.03
Number of XML files pending upload           : 1
Size of XML files pending upload(MB)         : 0
Available disk space on upload filesystem    : 68.70%
Collection Status                            : Collections enabled
Heartbeat Status                             : Ok
Last attempted heartbeat to OMS              : 2017-05-17 13:30:41
Last successful heartbeat to OMS             : 2017-05-17 13:30:41
Next scheduled heartbeat to OMS              : 2017-05-17 13:31:41

---------------------------------------------------------------
Agent is Running and Ready

PS C:\Users\oracle> Services.msc

December 18, 2016

Cloning 12c SE2 Oracle Home for Windows 2012 R2

Filed under: 12c,cloning,VirtualBox,Windows — mdinh @ 6:13 am

Process is pretty much similar to *nix environment with a few exceptions.

It was harder than it should be since I wanted to perform task using CLI vs GUI.

This does not cover zip and unzip of OH and I cannot believe how junky Winzip has become since I have typically been using 7-Zip.

Click link below for details.
Cloning 12c SE2 Oracle Home for Windows 2012 R2

 

 

November 19, 2015

Windows Task Scheduler CMD

Filed under: Windows — mdinh @ 12:56 am

Don’t get me wrong. GUI can be terrific but it does have its place.

When the connection between you and the the target host are multiple servers across the continent, the latency will drive me crazy mad.

Hence, my exploration to learn more command line.

Enough of my rant, let’s demo.

Tested on Windows 7

C:\Users\dinh>ver

Microsoft Windows [Version 6.1.7601]

C:\Users\dinh>

List by Folders:

C:\Users\dinh>schtasks /query /fo table /nh

Folder: \
DropboxUpdateTaskUserS-1-5-21-992222644- 18-Nov-2015 11:07:00 P Ready
DropboxUpdateTaskUserS-1-5-21-992222644- 18-Nov-2015 8:07:00 PM Ready
G2MUpdateTask-S-1-5-21-992222644-2553030 18-Nov-2015 7:45:00 PM Ready
G2MUploadTask-S-1-5-21-992222644-2553030 18-Nov-2015 9:31:00 PM Ready
GoogleUpdateTaskUserS-1-5-21-992222644-2 19-Nov-2015 6:55:00 PM Ready
GoogleUpdateTaskUserS-1-5-21-992222644-2 18-Nov-2015 7:55:00 PM Ready
hpUtility.exe_{3FB4CD0B-D6EE-4B93-BD0E-C N/A                    Ready
Microsoft_Hardware_Launch_ipoint_exe     N/A                    Ready
Microsoft_Hardware_Launch_itype_exe      N/A                    Ready
Microsoft_Hardware_Launch_mousekeyboardc N/A                    Ready

Folder: \Microsoft
INFO: There are no scheduled tasks presently available at your access level.

Folder: \Microsoft\Windows
INFO: There are no scheduled tasks presently available at your access level.

Folder: \Microsoft\Windows\Active Directory Rights Management Services Client
AD RMS Rights Policy Template Management Disabled
AD RMS Rights Policy Template Management N/A                    Ready

C:\Users\dinh>

List by TaskName:

C:\Users\dinh>schtasks /query /fo list

Folder: \
HostName:      CMWPHV1
TaskName:      \DropboxUpdateTaskUserS-1-5-21-992222644-2553030573-2413354843-1005Core
Next Run Time: 18-Nov-2015 11:07:00 PM
Status:        Ready
Logon Mode:    Interactive only

HostName:      CMWPHV1
TaskName:      \DropboxUpdateTaskUserS-1-5-21-992222644-2553030573-2413354843-1005UA
Next Run Time: 18-Nov-2015 8:07:00 PM
Status:        Ready
Logon Mode:    Interactive only

HostName:      CMWPHV1
TaskName:      \G2MUpdateTask-S-1-5-21-992222644-2553030573-2413354843-1005
Next Run Time: 18-Nov-2015 7:45:00 PM
Status:        Ready
Logon Mode:    Interactive only

HostName:      CMWPHV1
TaskName:      \G2MUploadTask-S-1-5-21-992222644-2553030573-2413354843-1005
Next Run Time: 18-Nov-2015 9:31:00 PM
Status:        Ready
Logon Mode:    Interactive only

HostName:      CMWPHV1
TaskName:      \GoogleUpdateTaskUserS-1-5-21-992222644-2553030573-2413354843-1005Core
Next Run Time: 19-Nov-2015 6:55:00 PM
Status:        Ready
Logon Mode:    Interactive only

HostName:      CMWPHV1
TaskName:      \GoogleUpdateTaskUserS-1-5-21-992222644-2553030573-2413354843-1005UA
Next Run Time: 18-Nov-2015 7:55:00 PM
Status:        Ready
Logon Mode:    Interactive only

HostName:      CMWPHV1
TaskName:      \hpUtility.exe_{3FB4CD0B-D6EE-4B93-BD0E-C69652A66A6C}
Next Run Time: N/A
Status:        Ready
Logon Mode:    Interactive only

HostName:      CMWPHV1
TaskName:      \Microsoft_Hardware_Launch_ipoint_exe
Next Run Time: N/A
Status:        Ready
Logon Mode:    Interactive/Background

HostName:      CMWPHV1
TaskName:      \Microsoft_Hardware_Launch_itype_exe
Next Run Time: N/A
Status:        Ready
Logon Mode:    Interactive/Background

HostName:      CMWPHV1
TaskName:      \Microsoft_Hardware_Launch_mousekeyboardcenter_exe
Next Run Time: N/A
Status:        Ready
Logon Mode:    Interactive/Background

Folder: \Microsoft
INFO: There are no scheduled tasks presently available at your access level.

Folder: \Microsoft\Windows
INFO: There are no scheduled tasks presently available at your access level.

Folder: \Microsoft\Windows\Active Directory Rights Management Services Client
HostName:      CMWPHV1
TaskName:      \Microsoft\Windows\Active Directory Rights Management Services Client\AD RMS Rights Policy Template Management (Autom
ated)
Next Run Time: Disabled
Status:
Logon Mode:    Interactive/Background

HostName:      CMWPHV1
TaskName:      \Microsoft\Windows\Active Directory Rights Management Services Client\AD RMS Rights Policy Template Management (Autom
ated)
Next Run Time: Disabled
Status:
Logon Mode:    Interactive/Background

HostName:      CMWPHV1
TaskName:      \Microsoft\Windows\Active Directory Rights Management Services Client\AD RMS Rights Policy Template Management (Manua
l)
Next Run Time: N/A
Status:        Ready
Logon Mode:    Interactive/Background

C:\Users\dinh>

Search for TaskName:

C:\Users\dinh>schtasks /query /fo LIST |findstr /I dropbox

TaskName:      \DropboxUpdateTaskUserS-1-5-21-992222644-2553030573-2413354843-1005Core
TaskName:      \DropboxUpdateTaskUserS-1-5-21-992222644-2553030573-2413354843-1005UA

List TaskName Summary:

C:\Users\dinh>schtasks /query /fo LIST /tn “\DropboxUpdateTaskUserS-1-5-21-992222644-2553030573-2413354843-1005UA”

Folder: \
HostName:      CMWPHV1
TaskName:      \DropboxUpdateTaskUserS-1-5-21-992222644-2553030573-2413354843-1005UA
Next Run Time: 18-Nov-2015 8:07:00 PM
Status:        Ready
Logon Mode:    Interactive only

List TaskName Detail:

C:\Users\dinh>schtasks /query /fo LIST /v /tn “\DropboxUpdateTaskUserS-1-5-21-992222644-2553030573-2413354843-1005UA”

Folder: \
HostName:                             CMWPHV1
TaskName:                             \DropboxUpdateTaskUserS-1-5-21-992222644-2553030573-2413354843-1005UA
Next Run Time:                        18-Nov-2015 8:07:00 PM
Status:                               Ready
Logon Mode:                           Interactive only
Last Run Time:                        18-Nov-2015 7:07:00 PM
Last Result:                          0
Author:                               dinh
Task To Run:                          C:\Users\dinh\AppData\Local\Dropbox\Update\DropboxUpdate.exe /ua /installsource scheduler
Start In:                             N/A
Comment:                              Keeps your Dropbox software up to date. If this task is disabled or stopped, your Dropbox soft
ware will not be kept up to date, meaning security vulnerabilities that may arise cannot be fixed and features may not work. This ta
sk uninstalls itself when t
Scheduled Task State:                 Enabled
Idle Time:                            Disabled
Power Management:
Run As User:                          dinh
Delete Task If Not Rescheduled:       Enabled
Stop Task If Runs X Hours and X Mins: Disabled
Schedule:                             Scheduling data is not available in this format.
Schedule Type:                        Daily
Start Time:                           11:07:00 PM
Start Date:                           17-Jul-2015
End Date:                             N/A
Days:                                 Every 1 day(s)
Months:                               N/A
Repeat: Every:                        1 Hour(s), 0 Minute(s)
Repeat: Until: Time:                  None
Repeat: Until: Duration:              24 Hour(s), 0 Minute(s)
Repeat: Stop If Still Running:        Disabled

C:\Users\dinh>

If you really want to use GUI:

Launch GUI Task Scheduler:

C:\Users\dinh>control schedtasks

Reference: Schtasks

January 27, 2013

FREE stuff for new Windows system

Filed under: Windows — mdinh @ 3:39 pm

I have a new W7 laptop and going through installing FREE and essential software.

I will add more accordingly.

Click link to open in new window.
7-Zip
CCleaner (Check out others nice software from the same provider)
Notepad++
Print to PDF
ULTRADEFRAG
VirtualBox
WinMD5
WinMerge
WinSCP
Xming X Server

What software do you like and are currently using?

Blog at WordPress.com.