Docstoc

Slide 1 - NASA - PowerPoint

Document Sample
Slide 1 - NASA - PowerPoint Powered By Docstoc
					     Oracle on Windows…
Things to Know plus a few Tricks
            Mark Sorger
         Abacus Technology
      Kennedy Space Center, FL
           Session # 347
       Speaker Qualifications
• Mark Sorger, Manager of Database
  Administration, Abacus Technology at
  Kennedy Space Center, FL.
• Team is responsible for All NASA Oracle and
  SQLServer DBs at Kennedy Space Center.
• Developer for 15yrs in Basic-Plus and Cobol.
• Server Admin on RSTS/E , VMS, and Windows
  for 20+ years.
       Speaker Qualifications - II
• Oracle DBA on OpenVMS, Windows, HP-UX,
  Red Hat Linux, and Solaris for 20 years.
• Microsoft Certified in NT, Brainbench Certified
  in Windows 2003 Server.
• Currently writing ‘Oracle on Windows’ for
  Rampant Press
        Why am I doing this??
• To save you some pain…

• I often get asked:
  ‘How do you do that in Windows???’
   If you don’t do anything else…
• Read the Oracle Database Platform Guide for
  Microsoft Windows for your release of Oracle!
  It will go over many of the topics we cover
  here in much more detail.
 Setting the stage…. The Hammer
              and Saw
• Sometimes people get O/S Bias, mostly due to
  familiarity….
• My philosophy is:
  When you need a hammer use a hammer.
  When you need a saw use a saw. (Sometimes
  UNIX/Linux fits, sometimes Windows does…)
• OR…Management makes the decision for you!
 Regardless of how it happened…
Congratulations…you now own a Windows box..
Suddenly, You’re a stranger in a
       strange land….
All of a sudden, grep, awk, crontab
         and vi are no help…
•   How do I see what’s going on?
•   How do I setup a batch run?
•   Are Oracle Installs different?
•   Can I script on this thing?
•   Hey – the slashes are backwards!
•   Its just an overgrown PC….
 First - A History Lesson. Windows
NT was derived from DEC VAX/VMS
• VMS in its day was used by Banks, Businesses,
  Hospitals, for CAD (Intergraph), etc.
• Dave Cutler, one of the authors of VMS, left
  DEC to go to Microsoft, and developed
  Windows NT there.
• Many items are similar, such as Access Control
  Lists, etc. You can even equate the Registry to
  a Sysgen Parameter file.
On with the Show…
Threads vs Processes – UNIX/Linux
• On UNIX and Linux, Oracle uses processes to
  run all the background tasks (PMON, SMON,
  LGWR, etc).
• Each database connection uses yet another
  UNIX process.
  On UNIX/Linux we have separate
      background processes:
>ps –ef | grep ora_

oracle 23549   1   0   Jan 12 ?   0:09 ora_qmnc_orcl
oracle 23514   1   0   Jan 12 ?   1:36 ora_pmon_orcl
oracle 23528   1   0   Jan 12 ?   0:00 ora_reco_orcl
oracle 23532   1   0   Jan 12 ?   0:38 ora_mmon_orcl
oracle 23524   1   0   Jan 12 ?   1:53 ora_ckpt_orcl
oracle 23522   1   0   Jan 12 ?   1:38 ora_lgwr_orcl
oracle 23534   1   0   Jan 12 ?   2:37 ora_mmnl_orcl
oracle 23547   1   0   Jan 12 ?   0:07 ora_arc1_orcl
oracle 23518   1   0   Jan 12 ?   0:07 ora_mman_orcl
oracle 23516   1   0   Jan 12 ?   0:09 ora_psp0_orcl
oracle 23545   1   0   Jan 12 ?   0:14 ora_arc0_orcl
oracle 23520   1   0   Jan 12 ?   0:38 ora_dbw0_orcl
oracle 23526   1   0   Jan 12 ?   1:30 ora_smon_orcl
Threads vs Processes – Windows is
            Different…
• On Windows, all of these processes are
  running as threads inside one single process
  called oracle.exe.
• The threads all run inside this one Windows
  process – the database support threads as
  well as the threads for all user connections.
Simply put, on Windows we have
  Oracle.exe doing everything…
Threads vs Processes Windows – II
• There will be one oracle.exe for each instance
  you have running on the server.
• Items such as the Listener, Oracle Agent, etc
  will still have separate processes.
            Windows Services
• There is a Service for each instance, typically
  called something like OracleServiceSID.
• Start/stop the OracleServiceSID to start or
  stop the instance.
• Once the service is running, you can use
  SQLPlus to startup/shutdown the DB at the
  command prompt if needed.
         Windows Services - II
• Just because the Service is running does NOT
  mean the database is up….
• Use Computer Management/Services GUI to
  see them, or C:\> net start
  at the command prompt.
• The Oracle Listener has a separate Windows
  Service
Windows Services Win 2003
Windows Services Win 2008
Windows Services Win 2008
   ‘net start’ to see the Services
C:\>net start
These Windows services are started:
Automatic Updates
OracleServiceORCL
OracleListener10g
Windows Management Instrumentation
The command completed successfully.
C:\>
      ‘net start’ to start the Oracle
                  Service
C:\>net start OracleServiceXE
The OracleServiceXE service is
  starting.
The OracleServiceXE service was
  started successfully.
C:>
       ‘net stop’ to stop the Oracle
                  Service
C:\>net stop OracleServiceXE
The OracleServiceXE service is
  stopping.
The OracleServiceXE service was
  stopped successfully.
C:\>
    ORADIM – on Windows Only
• In UNIX or Linux, when you create a database
  with a script, you use the ‘create
  database’ command - that’s all you need.
• In Windows, you first need to create the
  Windows Service. This is done with the
  ORADIM command.
• ORADIM can also be used to stop, start, and
  delete the Service.
          ORADIM - usage

Create the service:
ORADIM -NEW -SID ORCL -INTPWD
 password -MAXUSERS 4 -STARTMODE
 auto -PFILE
 C:\oracle\10g\database\init.ora
         ORADIM – usage II

Delete the service:

ORADIM –DELETE -SID ORCL
        ORADIM usage - III

Shutdown Service and Database

ORADIM -SHUTDOWN -SID ORCL -
 USRPWD / -SHUTTYPE INST, SRVC -
 SHUTMODE i
        ORADIM usage – IV

Startup the Service

ORADIM –STARTUP –SID ORCL
          Windows Event Logs
• Windows logs Events in several logs –
  System, Application and Security
• Oracle events are recorded in the Application
  event log, accessible via the Event Viewer.
• Setting AUDIT_TRAIL to ‘OS’ causes audit
  records to go to the Windows Event Log, not a
  file you can specify.
        Windows Event Logs - II
• AUDIT_FILE_DEST is not supported in
  Windows and should not be added to the
  init.ora file.
• Setting AUDIT_TRAIL to ‘DB’ causes audit
  records to be written to the database in
  SYS.AUD$, but some records are still written
  to the Event Log.
Event Viewer Win2003
Event Viewer Win2003
Event Viewer Win2008
     The ORA_DBA Local Group
• You will need to be a member of the
  ORA_DBA Local Server Group to do things like
  connect / as sysdba
• So, if you are running scheduled tasks/batch
  jobs (such as exports, backups, etc) the user
  you are running as also needs to be a member
  of the ORA_DBA local group on the server.
      ORA_DBA Local Group - II
• If you are using ‘at’ to schedule jobs, these
  jobs actually run as the SYSTEM account by
  default, not as who submitted them. Older
  versions of Windows wouldn’t allow you to
  put SYSTEM in the ORA_DBA group.
• If using the Task Scheduler GUI, you can
  designate a user for each scheduled task. This
  user must also be a member of ORA_DBA.
           How to set the SID
• In Windows, especially on servers with
  multiple databases, you must set the
  environment, as you do in UNIX.
• From a command prompt:
C:> Set oracle_sid=SID
  prior to running SQLPlus, doing an
  export/import, etc.
   How to set the ORACLE_HOME
• If you are running multiple releases of Oracle,
  or using Opatch, you will also need to set the
  ORACLE_HOME to use the command line.
• Example - from the command prompt:
C:>Set ORACLE_HOME=C:\Oracle\11g
• More later in the Installation section….
                     PATH
• Which Oracle directory is first in the PATH can
  be set using Oracle Universal Installer,
  Computer /Advanced/Environment Variables,
  or on the command line
• The last product installed will be the first in
  the PATH - so beware!
• set PATH=C:\oracle\10g\bin;%PATH%
PATH – My Computer/Properties
PATH Variable
        The Windows Registry
• Windows uses the Registry to store various
  items needed by the O/S, such as parameters,
  file locations, values, etc.
• utility to maintain Registry is regedit.exe
• Export the Registry before making changes! A
  bad entry can make the server unusable.
• C:\Regsave
Windows Registry – regedit.exe
Windows Registry – regedit.exe
Windows Registry – regedit.exe
        Some Registry Entries
• HKEY_LOCAL_MACHINE\Software\Oracle
  is the root key.
• ORA_sid_PFILE – The path to your pfile
• ORA_sid_AUTOSTART – Tells Windows to start
  the database when the service starts. TRUE
• ORA_sid_SHUTDOWN – Tells Windows to
  shutdown the database when the service is
  stopped. This should always be TRUE!
         More Registry Entries
• ORA_sid_SHUTDOWN_TYPE – Oracle
  shutdown type when the service is stopped –
  immediate is best but can be abort or normal.
• ORACLE_HOME – path to Oracle Home
• NLS_LANG – server NLS language setting
• HKEY_LOCAL_MACHINE\System\CurrentContr
  olSet\Services - where services are located.
  Something you need to know
about 32-bit Windows and the SGA
Here’s what happens if you go over
          a 2GB SGA…
SQL> startup
ORA-27102: out of memory
OSD-00029: additional error
 information
O/S-Error: (OS 8) Not enough
 storage is available to process
 this command.
      Oracle on 32bit Windows
• 32bit Windows limits you to 2GB for the SGA
  and ALL the other Oracle support jobs AND all
  user jobs connected to the database.
• The max addressable memory per process is
  4GB – default is 2GB for OS and 2GB for you.
• The /3GB switch, you get 3GB by ‘borrowing’
  1GB from the OS. 1GB for OS, 3GB for you.
• 64bit Windows does not have this problem!
      The /3GB switch – Win 2003
• This is set in the boot.ini file on Win 2003:
1.   Make a copy of C:\boot.ini
2.   Edit C:\boot.ini
3.   Add /3GB /AWE to the end of the boot line
4.   Reboot the server
     The 3GB Switch – Win 2003 II
Example:

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server
   2003, Enterprise" /noexecute=optout /fastdetect /3GB /AWE
   The 3GB Switch – Win 2003 III
• You can tweak this a bit by including the
  /USERVA switch along with the /3GB switch.
• Allows you to modify how much of the OS
  memory you allocate for processes. For
  example, /USERVA=2800 will use 2.8GB for
  processes and 1.2GB for the OS – giving the
  OS a bit more for paged pool, etc.
            /3GB in Win 2008
• In Windows 2008, there is no longer a boot.ini
• The same result can be accomplished using
  bcdedit.exe.
• bcedit does many other things, but here we
  will just review setting /3GB. The command,
  from the command prompt, is:
  bcdedit /set increaseuserva 3072
         /3GB in Win 2008 - II
• 3072 is the user-mode memory allocation.
• To allow 3GB of memory we use 3*1024 MB =
  3072 MB.
• Same as using/3GB and /USERVA in the
  boot.ini for Windows 2003.
• Win 2008 equivalent of /3GB /USERVA=2800
  bcdedit /set increaseuserva 2800.
              /3GB - General
• If you set the /3GB switch and attempt to copy
  large files, you may get ‘not enough resources’
  errors.
• This is due to a lack of paged memory, since
  we stole half of it from the OS!
• Using /AWE (Win 2003) tends to make this
  better, since it also turns on Extended
  Memory Management
                    AWE
• Another solution to squeeze more memory for
  Oracle out of a 32bit system is to use Oracle
  AWE (Address Windowing Extensions).
• When you do this, you can not use Oracle
  automatic memory tuning (SGA_TARGET, etc).
  Information on this can be found in Metalink
  Note 225349.1.
    Directory Layouts - Windows
• ORACLE_HOME
C:\oracle\product\10.2.0 (10g)
C:\oracle\product\11.2.0 (11g R2)
Data Files – RAID 10 or 5
D:\oracle\oradata\SID\dbf
  Sample Directories – Windows II
• Redo Logs – Sequential so RAID 1
E:\oracle\oradata\SID\redo0
F:\oracle\oradata\SID\redo1
• Archivelogs – Sequential so RAID 1
G:\oracle\oradata\SID\archives
• Exports
H:\oracle\oradata\SID\exports
    Commonly Used Commands
• To get help on any command, type the
 command, followed by /? or use
 HELP <command>..
• The HELP command by itself will list all the
 available O/S commands.
• Windows is not case sensitive so you can use
 upper, lower, or mixed case.
            HELP examples
• help – lists all Windows commands with
  short descriptions of each.

• help dir – lists help about the dir
  command

• dir /? – lists help about the dir command
                        cd
cd - This is the same as the Unix/Linux ‘cd’. It
  changes your current working directory to
  whatever path you enter.
  Example of the syntax is:

cd    C:\oracle\10g\network\admin
               cd - continued
• If the destination directory is on a different
  drive, you need to specify that drive first, then
  type the cd command,
• Otherwise Windows will not be able to find
  the directory.
• Providing a full path including the drive letter
  still won’t work unless you do that first…
             cd – continued II
Example:

C:\> D:
D:\> cd d:\newdir
D:\newdir>

• Trick: cd c:\Ora* will take you to first match
    More Windows Commands - l
• dir – gives a listing of the current directory
  tip: dir | find “<DIR>”
• mkdir - Used to create a directory
• rmdir – deletes a directory
• type - This is similar to Unix/Linux command
  ‘cat’. It does what the name implies, typing
  out the contents of a file.
   More Windows Commands - lI
• more - This command is similar to type,
  except that it stops at each screenful instead
  of continuously scrolling past.
• del – deletes a file or files. The /Q (meaning
  quiet) switch disables the prompts asking if it
  is OK to delete.
   More Windows Commands - III
• copy – copies a file or files to a new
  destination. /Y switch suppresses all
  prompts, such as ‘ok to overwrite’
• xcopy – same as copy except it moves entire
  directory trees, while copy moves individual
  files. This allows you to keep directory
  structures intact ; useful for things such as
  copying Oracle Database Files for cold saves.
                      FTP
• The FTP client on Windows (outbound) from
  your server works from the command prompt.
• If you want to FTP to your Server, you will
  need to install Microsoft IIS (Internet
  Information Services), specify the FTP Service.
• The FTP Service does not get installed by
  default in the Windows Server 2003 IIS
  Installation.
   ODBC and 32bit Apps on 64bit
            Windows
• If you run 64bit ODBC Administrator and add a
  datasource, 32bit apps (Access) will not see it.
• You need to run the 32bit ODBC
  Administrator, located in the SYSWOW64
  folder in your Windows software directory.
  For example:
• C:\Windows\SYSWOW64\odbcad32.exe
 Connecting to a Drive on Another
              Server
• This works IF you have permissions on the
  other box AND if admin shares are enabled.
• To connect to a drive on another server:
Start\run: \\server_name\driveletter$
Start\run: \\myserver\c$
• A Windows Explorer window will pop up
  connected to the device.
             Batch Jobs
- Use the ‘at’ command:
at hh:mm /every:d
  path_to_batch_file

at 20:00 /every:M,T,W,Th,F
 c:\scripts\exports\export.bat
             Batch Jobs
- If you want a logfile:
at 20:00 /every:M,T cmd.exe /c
  "c:\scripts\exports\export.bat
  > c:\scripts\logs\export.log"
- Or – use the Windows Task Scheduler
        Batch Jobs - TaskScheduler

- If you want a logfile, enter this where the
  scriptname would go:
c:\scripts\exports\export.bat >
  c:\scripts\logs\export.log 2>&1

• 1 is standard output (stdout). 2 is standard error (stderr).
• So 2>&1 says to send standard error to where ever standard
  output is being redirected. Sends errors to the output file.
Batch Jobs - TaskScheduler
           Windows 2008 UAC
• Windows 2008 has a feature called UAC (User
  Account Control)
• In a nutshell, what it does is break your
  session token into a privileged and non-
  privileged token.
• By default, everything you do is done non-
  privileged unless you tell Windows differently.
        Windows 2008 UAC - II
• You must use ‘run as administrator’ for
  anything you wish to do that requires elevated
  access, even command prompt or explorer.
• You must check ‘run with highest privileges’
  on batch jobs if they require privileges.
• UAC can be disabled if your IT Security allows
  it. Usually you need to live with it.
        Windows 2008 UAC - III
• Microsoft Technet has a good writeup:

http://technet.microsoft.com/en-
  us/library/cc709691%28WS.10%29.aspx
     Installs/Upgrades/Patches I
• Stop all Oracle Services First
  -The OracleServiceSID, Oracle Listener, and
  other Oracle services need to be stopped.
  -If not, there will be open DLLs that cannot be
  replaced by the Installer.
    Installs/Upgrades/Patches II
• Stop the Windows ‘Distributed Transaction
  Coordinator Service’
  -This Windows service coordinates
  transactions that span multiple resource
  managers, such as databases, message
  queues, and file systems.
  -It may have Oracle files/dlls open.
    Installs/Upgrades/Patches III
• Stop any Antivirus Software or backup
  Agents.
  -To improve performance of the
  install/upgrade
  -To keep the Antivirus or Backup Software
  from locking up any files/dlls.
    Installs/Upgrades/Patches IV
• If you get errors specifying open DLLs, you
  can find them…
  -If the Oracle installer reports a specific DLL
  being open, you can find out what has that
  DLL open using the TASKLIST utility.
  tasklist /m filename.dll
  returns all processes that have the DLL open. -
  -You can then kill using the taskkill utility
     Installs/Upgrades/Patches V
• Open DLLs – when all else fails….
  -If you cannot locate what is locking a dll, then
  set all the Oracle Services to ‘manual’ and
  reboot the server.
    Installs/Upgrades/Patches VI
• The ORACLE_HOME environment variable
 -ORACLE_HOME environment variable will not get
 reset by an upgrade. More likely, it will be blank,
 since the Oracle Installer clears it out by default.
 -Can cause TNS Protocol Adapter errors when trying
 to start the Listener, ODBC datasources to fail, etc.
 -It is a good practice to check this following any
 upgrades. Oracle recommends you not set
 ORACLE_HOME at all….
    Installs/Upgrades/Patches VII
• The PATH environment variable
  -The last Oracle Product installed will be the
  first thing in the PATH. This can get you in
  trouble!!
  -You can change this with the Environment
  Tab in Oracle Universal Installer, or in the
  Advanced tab of Computer Properties.
    Installs/Upgrades/Patches VIII
• Use LSNRCTL to create the Listener Service
  -When you first install or upgrade to a new
  release, you will notice there is no
  ‘OracleListener’ Windows Service.
  -The first time you run LSNRCTL from the
  command prompt, provided you have a good
  listener.ora file, lsnrctl will create it for you.
     Installs/Upgrades/Patches VIII
• LSNRCTL fails at first
Welcome to LSNRCTL, type "help" for information.

   LSNRCTL> stat
   Connecting to
   (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle_server)(PORT=1
   521)))
   TNS-12541: TNS:no listener
   TNS-12560: TNS:protocol adapter error
   TNS-00511: No listener
   Windows Error: 61: Unknown error
     Installs/Upgrades/Patches VIII
• LSNRCTL – The First Start creates the Service
  LSNRCTL> start
  Starting tnslsnr: please wait...

  Failed to open service <OracleTNSListener>, error 1060.

  TNSLSNR for Windows: Version 10.2.0.1 - Production
  System parameter file is c:\oracle\10g\network\admin\listener.ora
  Log messages written to c:\oracle\10g\network\listener.log
  Listening on:
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XLE)(PORT=1521)))
  Connecting to
  (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=XLE)(PORT=1521)))
Handy Utilities
  The mail must go through…!




Somehow we need to email the DBA when an export
completes/fails, if we get ORA- errors, etc
             Email Utilities
• On UNIX we have - mailx

• On Windows we have…nothing
       Enter…. The BLAT Utility
• Blat.exe – public domain program to send
  emails.
• Download the utility, place blat.exe someplace
  in the PATH (eg. in c:\windows\system), and
  point it to your email server.
• Then you can use the blat to send emails from
  scripts. The website is www.blat.net.
                 BLAT Setup
• Syntax of initial setup (only done once):
  blat –install email_spooler
  Userid_on_email_server
• Example:
Blat –install smtp.edu OracleDBA
           BLAT Sending Email
• Using blat to send an email:
blat <filename> -t <dest
  emailaddress> -s <subject>

blat D:\exp\exp.log -t
 admin@email.com -s “Prod exp"
• * -tf <filename> sends to list of addresses
How do you rerun something every
   few minutes??? Two ways…
The Task Manager does this but it’s
    a bit hidden in Win 2003…
• Use the GUI to create a task, and set the
  interval. I use ‘daily’ at 12:00AM
• Check ‘show advanced properties’ at the end.
• Click the schedule tab, then the advanced
  button.
• Check ‘recurring’, choose how often, and the
  interval. If continuous, choose 24 hours.
With The Task Manager - Win 2008
            The SOON Utility
• Soon.exe – Windows 2000 Resource Kit,
  allows you to run batch job in next xx seconds.
• If you use this, it will not be a saved job and
  will need to be resubmitted on reboots.
• Available at Microsoft Download Center site:
 www.microsoft.com/downloads/en/default.aspx
          SOON.exe example
• Example of running a script in 2 minutes (120
  seconds) using soon.exe:

c:\soon\soon.exe 0120
  c:\uptime\check_DBSvc.cmd
    How to do some useful stuff

Such as….
Search alert log – using findstr and
  goto with tags, soon, and blat
:: checkdb.bat
::   checks for ORA errors in alert log and emails them off
:: rerun in 60 minutes/3600 seconds
c:\adminscripts\soon\soon.exe 3600 c:\adminscripts\checkdb\checkdb.bat
:: look for ORA- in alertlog
@findstr "ORA-" c:\oracle\admin\orcl\bdump\alert_orcl.log && call
   :send_mail
goto :eof
:: Subroutine to send mail
:send_mail
del /Q c:\adminscripts\checkdb\error.txt
findstr "ORA-" c:\oracle\admin\orcl\bdump\alert_orcl.log >
   c:\adminscripts\checkdb\error.txt
Blat c:\adminscripts\checkdb\error.txt -t userid@email.xxx -s “ORCL ORA
   error"
:eof
exit
    Quick note: FINDSTR vs FIND
• FIND searches for a single string
• FINDSTR searches for a single string, multiple
  strings, or an exact phrase
  - FINDSTR “abc” finds ‘abc’
  - FINDSTR “abc 123” finds ‘abc’ OR ‘123’
  - FINDSTR /C:”abc 123” finds ‘abc 123’
  Use forfiles to clear archivelogs
:: Get rid of files using forfiles utility

forfiles –p d:\oracle\oradata\orcl\archives
  –m *.* -d -7 –c "cmd /c dir @FILE"

forfiles –p d:\oracle\oradata\orcl\archives
  –m *.* -d -7 –c "cmd /c del/q @FILE"

exit
Check to see if a Service is Running
:: check_DBSvc.cmd - checks to be sure DB Service is running
c:\admin\soon\soon.exe 0120 c:\admin\uptime\check_DBSvc.cmd
:: Look for DB service from NET START command
del /Q c:\admin\uptime\svc.txt
net start > c:\admin\uptime\svc.txt
findstr /C:"OracleServiceORCL" c:\admin\uptime\svc.txt && goto
   :eof
:: didn't find service, so drop thru to here and send mail
:send_mail
Blat c:\admins\uptime\svc.txt -t userid@email.xxx -s “ORCL DB
   Service not running “
:: The End
:eof
exit
Check to see if a Service is Running
    – checking the time first
:: check_DBSvc.cmd - checks to be sure DB Service is running
:: Check the time and exit if 11pm,
del /Q c:\adminscripts\uptime\time.txt
@echo %time:~0,2% > c:\adminscripts\uptime\time.txt
findstr "23" c:\adminscripts\uptime\time.txt && goto :eof
:: Look for DB service. If we find it, just exit, else send mail
del /Q c:\adminscripts\uptime\services.txt
net start > c:\adminscripts\uptime\services.txt
findstr /C:"OracleServiceORCL" c:\adminscripts\uptime\services.txt && goto
   :eof
:: didn't find service, so drop thru to here and send mail
:send_mail
Blat c:\adminscripts\uptime\services.txt -t userid@email.xxx -s “ORCL DB
   Service not running “
:: The End
:eof
exit
  To show running processes and
       which has a dll open:
• tasklist - shows all processes
• tasklist /m - shows all processes and
  open DLLs
• tasklist /m filename.dll - shows
  what process has a particular DLL open
   How to rename/datestamp files
             You can either rotate like this:

del d:\oracle\oradata\orcl\exp\orcl_export5.*

ren d:\oracle\oradata\orcl\exp\orcl_export4.*
   orcl_export5.*
ren d:\oracle\oradata\orcl\exp\orcl_export3.*
   orcl_export4.*
ren d:\oracle\oradata\orcl\exp\orcl_export2.*
   orcl_export3.*
ren d:\oracle\oradata\orcl\exp\orcl_export1.*
   orcl_export2.*
ren d:\oracle\oradata\orcl\exp\orcl_export.*
   orcl_export1.*
         OR Use a datestamp:

set DATESTAMP=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%

ren c:\adminscripts\logs\exp.log exp.%DATESTAMP%
                 Kill a Process
• Use the Task Manager

• Use the ‘taskkill’ utility
    Killing Jobs with Task Manager
• Sometimes killing a job with the Task Manager
  works, sometimes it doesn’t.
• If it won’t kill a task, usually because the task is
  running as ‘SYSTEM’, you can:
C:\> at hh::mm /interactive
  taskmgr.exe (hh:mm 2 min from now)
  This runs taskmgr as SYSTEM and it will have the
  permissions needed.
          Killing jobs with TASKKILL

C:\>tasklist | findstr cmd.exe
cmd.exe                    3880 Console
  0        2,592 K
cmd.exe                     2492 Console
  0        2,340 K
C:\>taskkill /pid 2492
The process for pid 2492 is killed.
C:\>
       How to Kill a stuck Windows
        Service without Rebooting
1.) find the pid of the underlying process:
C:\>     sc queryex OracleServiceORCL
SERVICE_NAME: OracleServiceORCL
        TYPE        : 10 WIN32_OWN_PROCESS
        STATE        : 4 RUNNING
                  (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
        SERVICE_EXIT_CODE : 0 (0x0)
        CHECKPOINT        : 0x0
        WAIT_HINT        : 0x0
        PID        : 357
     How to Kill a stuck Windows
    Service without Rebooting– II

2.) This gives you the PID, so you can kill the process


C:>     taskkill /PID 357 /F

* the /F flag means 'force‘. Like a UNIX kill -9
Lastly… and I hope I didn’t put you
          all to sleep….
 How to ‘sleep’. Maybe your script
 needs a pause for some reason..
Sleep.exe in the Windows 2000 Resource Kit allows a
   batch file to sleep for n seconds.

OR….. Use the ping command
ping -n seconds+1 127.0.0.1>nul

So……To sleep for 20 seconds:
ping -n 20 127.0.0.1>nul
           Parting Thoughts
Whether you think you can, or you think you
 can’t, you are usually right…

-- Henry Ford
           Parting Thought II
Your only job security is between your
 ears…

-- Thomas J. Sorger
                   Lastly
If nothing changes, nothing changes….
-- Anonymous
It’s already done, it just hasn’t happened yet!
-- Mark Sorger
                 Slides
• Contact me
• Posted on KSCOUG Website
  www.kscoug.ksc.nasa.gov
         Questions? Thank You!
• Please complete the evaluation form!
• Speaker: Mark Sorger
• Session: 347
• * Contact info: sorgerm@hotmail.com
* please put IOUG in the subject so I don’t think it’s
  SPAM !
• www.kscoug.ksc.nasa.gov

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:26
posted:7/16/2011
language:English
pages:120