Saturday, October 23, 2010

Automatic startup issues of oracle database on windows

If you look for automatic startup on unix or linux server then have a look at, 

http://dbatutorials.blogspot.com/2010/10/automatic-startup-and-shutdown-oracle.html This post is related to automatic startup of windows machine only.

On windows to run oracle as background they run as windows services. If your oracle is started then you can see the background process oracle.exe after opening task manager (by pressing CTRL+ALT+DEL) and then browsing the processes tab. The background oracle.exe process is normally owned by system.

With the sc command (which is NT Service Controller and services) you can start and stop oracle service which is discussed on http://arjudba.blogspot.com/2008/10/how-to-start-services-from-command.html

Don't think that windows service is the database. Windows service can start/stop the database but it is also true that service has started but database does not yet started. You can start/stop oracle service from computer management.

To do so,
1)Right click on My Computer icon and click manage. You will see Computer Management window.
Alternatively you can open the window by,
- Go to control panel.
- Switch to classic view > Click Administrative Tools.
- Click Computer Management icon.

2)Go to the Services and Application menu > Select Services.

3)Navigate to Oracle Service. The name is in the form OracleService$ORACLE_SID where you may have orcl or other name instead of $ORACLE_SID.

4)Right click on that service. There you can see the "Startup type" drop down menu. If you select Automatic then database should starting up automatic while starting your windows. If it is manual then you need to manually start/stop the service.

Alternatively using oradim utility you can specify whether database would be started automatic or manual.

You can see list of oradim command by typing oradim on your command prompt as,
E:>oradim
ORADIM: [options]. Refer to manual.
Enter one of the following command:
Create an instance by specifying the following options:
-NEW -SID sid | -SRVC srvc | -ASMSID sid | -ASMSRVC srvc [-SYSPWD pass]
[-STARTMODE auto|manual] [-SRVCSTART system|demand] [-PFILE file | -SPFILE]
[-SHUTMODE normal|immediate|abort] [-TIMEOUT secs] [-RUNAS osusr/ospass]
Edit an instance by specifying the following options:
-EDIT -SID sid | -ASMSID sid [-SYSPWD pass]
[-STARTMODE auto|manual] [-SRVCSTART system|demand] [-PFILE file | -SPFILE]
[-SHUTMODE normal|immediate|abort] [-SHUTTYPE srvc|inst] [-RUNAS osusr/ospass]
Delete instances by specifying the following options:
-DELETE -SID sid | -ASMSID sid | -SRVC srvc | -ASMSRVC srvc
Startup services and instance by specifying the following options:
-STARTUP -SID sid | -ASMSID sid [-SYSPWD pass]
[-STARTTYPE srvc|inst|srvc,inst] [-PFILE filename | -SPFILE]
Shutdown service and instance by specifying the following options:
-SHUTDOWN -SID sid | -ASMSID sid [-SYSPWD pass]
[-SHUTTYPE srvc|inst|srvc,inst] [-SHUTMODE normal|immediate|abort]
Query for help by specifying the following parameters: -? | -h | -help

So to automatic startup of orcl database you may issue,
E:> oradim -edit -sid orcl -startmode auto

To make it manual you may issue,
E:> oradim -edit -sid orcl -startmode manual

After making it automatic, sometimes after starting windows you may wonder why my oracle service or sometimes oracle database is not yet started. This post will give you step by steps idea to resolve that problem.

1)Ensure that your oracle service is set to automatic. You can do it by oradim or with help you windows service which is discussed on the above of this post.

If you have already automatic but database service is not started then there is possibly improper settings in the registry or this is bad service.

2)After starting windows check if the oracle service is started. You can check it from task manager and looking for entry oracle.exe which is also discussed above of this post. If this is present then oracle service is started but oracle database is not. Investigate why oracle database is not started.

A proper way is to check alert log entry of the database. Alert log location is specified inside pfile/spfile of the database. If the problem is not with the database rather than oracle service then there will be no indication in the alert log that the database even tried to start.

3)If there is no error in the alert log then connect to sql*plus as sysdba and try to start your database.

sqlplus / as sysdba
startup


4)If step 3 is successful then be sure the problem is related to windows service. May be there is improper settings in the registry or it is bad service.

5)Check setting on registry. From Start menu> Click Run and then type regedit.
Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\ORACLE_HOME_NAME

-First take a backup of the registry entry by right clicking on the ORACLE folder on the left and then export.

-In the ORACLE_HOME_NAME you will see a key name ORA_$ORACLE_SID_AUTOSTART. If your database name is orcl then you will see a key named ORA_orcl_AUTOSTART.
The value of this key must be TRUE in order to automatic startup of the database. Edit the key and make it TRUE.

-After change ORA_$ORACLE_SID_AUTOSTART to TRUE test the service by stopping and then restarting the service to see it the database automatically starts. If it does, then that fixed your problem. You can also reboot the server to verify that the database will start automatically. However in some cases your database does not start after rebooting. Then there is problem with the service itself. Follow step 6 then.

6)Delete the service.
E:>oradim -delete -sid $ORACLE_SID


If your $ORACLE_SID is orcl then the command will be,
E:>oradim -delete -sid orcl

Then create the service by,
oradim -new -sid $ORACLE_SID -startmode AUTO

If your $ORACLE_SID is orcl then the command will be,
oradim -new -sid orcl -startmode AUTO

If you use password file and initialization file other than default location then start it by,
E:>oradim -new -sid orcl -intpwd a -startmode AUTO -pfile D:\initorcl.ora

Where database name is orcl, SYS password is a and pfile resides on D:\initorcl.ora

How to get GUI from windows to linux/Unix computer

You can connect to linux computer from windows computer using telnet, ssh shell or putty software. After connecting to linux computer you only get text based user interface. You can't get graphical user interface through these software. But sometimes you want to get GUI on your linux machine remotely connecting from windows machine and vice-versa. For example, you want to run Oracle Universal Installer GUI window or you want to run dbca GUI interface. With vncviewer and vncserver software you can achieve your goal.


Download both vncserver and vncviewer from the link http://www.realvnc.com/cgi-bin/download.cgi. For unix computer(where you like to display GUI window) download the VNC Enterprise Edition which includes vnc viewer, XFree86 module, stand-alone server and x0vncserver.

For windows computer (from where you connect to unix machine) download Stand-alone Viewer.

Similarly if you want to get GUI connecting from unix to windows computer download vnc server for windows and vnc viewer from unix machine.

I downloaded vnc Enterprise Edition (server one) for Linux machine and vnc Enterprise Edition Viewer for windows machine. I downloaded the GZipped Tarfile for unix and Executable file for windows machine.

On unix, first gunzip then untar and run vncserver.
[root@localhost tmp]# ls
vnc-4_1_3-x86_linux.tar.gz
[root@localhost tmp]# gunzip vnc-4_1_3-x86_linux.tar.gz
[root@localhost tmp]# ls

vnc-4_1_3-x86_linux.tar
[root@localhost tmp]# tar -xvf vnc-4_1_3-x86_linux.tar
[root@localhost tmp]# cd vnc-4_1_3-x86_linux

[root@localhost vnc-4_1_3-x86_linux]# ls
java vncconfig.man vncserver vncviewer.man Xvnc.man
LICENCE.txt vncinstall vncserver.man x0vncserver
README vncpasswd vnc.so x0vncserver.man
vncconfig vncpasswd.man vncviewer Xvnc
[root@localhost vnc-4_1_3-x86_linux]# vncserver

You will require a password to access your desktops.

Password:
Verify:

New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log

While prompt password give at least 6 digits password. Check vncserver script and by default port is 5901 for localhost.localdomain:1 and 5902 is for localhost.localdomain:2.

Now from windows computer, run Vncviewer Listener and then give password for vncserver and port. Then you will be able to run GUI inside your vnc viewer.

Copy files between Unix and Windows with rcp

There are many third party tools by which you can copy files between windows and unix machine. Some common tools are winscp, SSHSecureShellClient etc. Instead of using any third party tool, you can use original unix and windows built-in tool to do the task.


The RCP (Remote CoPy) is a standard UNIX tool and a Microsoft Windows 2000 tool that copies files/folder to and from computer running the RCP service.

Before you can use the RCP tool from a Windows-based computer you must do something in your UNIX computer.

you must turn on the RCP service and update the security files to allow the Windows-based computer to connect to your unix machine over this service.

The following steps will help you.

Step 01: Turn on RCP service on UNIX Host

Turn on the RCP service on unix machine by using inetd:

1. Log on as root.
2. Edit the file /etc/Inetd.conf.
3. Uncomment the lines that start with shell and that start with exec.
4. Save the file.
5. Use ps -ef |grep inetd and determine inetd service pid. Send the Host User Profile (HUP) signal to inetd by using kill or by using pkill.
6. Run inetd again.

To turn on the RCP service by using xinetd:

1. Log on as root.
2. Edit the file /etc/Xinetd.d/rsh. You may get another file based on your linux distrinution.
3. Change the line disable to no.
4. Save the file.
5. Use ps -ef |grep inetd and determine inetd service pid. Send the HUP signal to xinetd by using kill or by using pkill.
6. Run xinetd again.

Step 02: Set the security permissions
After turning on RCP services you must set the security permissions to allow the Windows host to connect to your computer.

1. Edit the file /etc/hosts.equiv. Based on your linux distribution this file may vary. You can get like /etc/hosts.allow.
2. In the file add a line that contains the name of your Windows host.
3. Add a second line that contains the name of your Windows host and the name of a user who can access the directory that you want to transfer. Separate the two elements with a tab character.
4. Save the file.

Step 03: Transfer the files or directory

From windows computer you can transfer files or folders using rcp using following syntax.
RCP [-a | -b] [-h] [-r] [host][.user:]source [host][.user:] path\destination

For example, to copy the file index.html from the path /home/oracle on the computer unixhost as the user oracle you must use from windows computer,
rcp unixhost.oracle:/home/oracle/index.html index.html

In order to copy whole directory you need to use -r(for recursive) with rcp command.
To copy test directory under /home/oracle on unix, from windows computer issue,
rcp -r unixhost.oracle:/home/oracle/test test

Resolve of You may be a victim of software counterfeiting Windows is not genuine

Microsoft has released WGA(Windows Genuine Advantage) Notifications application which generate the warning message "This copy of Windows is not genuine". This Windows Genuine Advantage Notifications application check your Microsoft Windows XP validity and then if it found that the copy of Windows XP is not validated, not genuine, counterfeit, unlicensed, pirated, illegal, unauthorized or simply failed the Windows Genuine Advantage validation process, then the notification messages will appear at various places and time.


While logn to your machine it comes a pop up window indicating you to 'Resolve now' or 'Get Genuine' and wait for 5 seconds.

After logon to your system you get "You may be a victim of software counterfeiting' message on the bottom right corner of log-in screen.

Along with randomly appeared as balloon notification message with an icon in the notification area (system tray) you got other changes like you background became black.

In this post I will provide several solutions so that we may get rid of WGA notifications.

Method 01:
1.Open task manager window, You can do it by pressing Ctrl+Alt+Del or right click on taskbar and then select Task Manager.

2.On the Task Manager pop up window under processes tab find wgatray.exe process and then right click and select End process tree option and then select yes.

3.Restart Windows XP in Safe Mode.

4.Delete WgaTray.exe file from c:\Windows\System32.

5.Delete WgaTray.exe file from c:\Windows\System32\dllcache.

6.Click on Start menu and write regedit.

7.Browse to the location,
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\
Windows NT\CurrentVersion\Winlogon\Notify
and then delete the folder 'WgaLogon' and all its contents

8.Restart Windows XP.

Method 02:

This one is very easy method and works perfectly.
1.Rename the file 'WgaLogon.dll' and 'WgaTray.exe' in C:\WINDOWS\system32 folder.

2.Open Task Manager and then kill WgaTray.exe process.

3.Reboot your computer.

Method 03:
If you have turned on system restore feature then do a system Restore to restore the PC to a previous restore point or to a previous time where the WGA Notifications hasn’t kicked in. To use System Restore, go to Start -> All Programs -> Accessories -> System Tools -> System Restore.

Who is connected to your windows machine using which port

To access any application of another system either through WWW service, FTP service, POP3/SMTP services, or even just NetBIOS over TCP/IP you have to go through a port. In other sense if someone from outside access something on your system he enter through a port. And you sometimes might be curious to know who is accessing your system and which ports they are using.

With netstat tool you can easily identify it.
On windows system in order to know details of it just type netstat /? in command prompt.
Here is the output,

C:\Documents and Settings\Queen>netstat /?

Displays protocol statistics and current TCP/IP network connections.

NETSTAT [-a] [-b] [-e] [-n] [-o] [-p proto] [-r] [-s] [-v] [interval]

-a Displays all connections and listening ports.
-b Displays the executable involved in creating each connection or
listening port. In some cases well-known executables host
multiple independent components, and in these cases the
sequence of components involved in creating the connection
or listening port is displayed. In this case the executable
name is in [] at the bottom, on top is the component it called,
and so forth until TCP/IP was reached. Note that this option
can be time-consuming and will fail unless you have sufficient
permissions.
-e Displays Ethernet statistics. This may be combined with the -s
option.
-n Displays addresses and port numbers in numerical form.
-o Displays the owning process ID associated with each connection.
-p proto Shows connections for the protocol specified by proto; proto
may be any of: TCP, UDP, TCPv6, or UDPv6. If used with the -s
option to display per-protocol statistics, proto may be any of:
IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6.
-r Displays the routing table.
-s Displays per-protocol statistics. By default, statistics are
shown for IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6;
the -p option may be used to specify a subset of the default.
-v When used in conjunction with -b, will display sequence of
components involved in creating the connection or listening
port for all executables.
interval Redisplays selected statistics, pausing interval seconds
between each display. Press CTRL+C to stop redisplaying
statistics. If omitted, netstat will print the current
configuration information once.

In order to know all connection along with port now connection to your system just press netstat.
C:\Documents and Settings\Queen>netstat
The listing will appear with several fields.
-The protocol type.
-Hostname:port
-Foreign Address that is who is connected to your system.
-State of the connection.

Open an application using keyboard shortcuts on windows


Mouse is a convenient way to do tasks since its inventory. But sometimes use of keyboard gives more quickly and flexible access than mouse. This is more true if you are a good typist. Suppose to open an application. In order to access Internet explorer with mouse we would do,
-Take mouse pointer to start menu and click the menu.
-Go to all programs.
-And move pointer to internet explorer and click on it. IE launches.

If you use keyboard shortcut then with three key combination you can open any application. To do this.
1.Write click on the application to which you want to create shortcut.
Select create shortcut. If your application resides on start menu>all programs then
you don't need this steps.

2.Right click on the shortcut and select properties.

3.A new windows appears. Click on shortcut tab.

4.In the shortcut key field press any key related to program for example in order to create shortcut for internet explorer in the shortcut key field press I.

5.Click ok and you are done.

6.Now press Ctrl+Alt+key_that_you_entered_in_the_shortcut_key_field for example in case of internet exploere press Ctrl+Alt+I and you will see Internet explorer will launch.

Next time you don't need to use mouse to access any application if you create shortcut key on that application.

How to start services from command prompt on windows


On windows to start oracle service we would go to computer management>Then select services>Scroll down to oracle services and then start the service if it set to manual.
We can do the same task from command prompt itself.

In fact to start listener, emctl, isqlplus someone can follow the same procedure- starting a service using GUI.

From command prompt same task can be achieved by using SC command line program which is used for communicating with the NT Service Controller and services.

With the sc command you can Queries the status for a service, or enumerates the status for types of services, start, stop, config, delete a service and many more.

Suppose in order to see the status of my oracle service OracleServiceARJU (ARJU is my SID name replace ARJU with your SID) issue,
C:\Documents and Settings\Queen>sc query OracleServiceARJU

SERVICE_NAME: OracleServiceARJU
TYPE : 10 WIN32_OWN_PROCESS
STATE : 1 STOPPED
(NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 1077 (0x435)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0

Here we see state is STOPPED.
So we started it by,
C:\Documents and Settings\Queen>sc start OracleServiceARJU


SERVICE_NAME: OracleServiceARJU
TYPE : 10 WIN32_OWN_PROCESS
STATE : 2 START_PENDING
(NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x7d0
PID : 3556
FLAGS :

Now check the status by,
C:\Documents and Settings\Queen>sc query OracleServiceARJU

SERVICE_NAME: OracleServiceARJU
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE,PAUSABLE,ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0

In order to see help just issue sc on command prompt.
C:\Documents and Settings\Queen>sc
DESCRIPTION:
SC is a command line program used for communicating with the
NT Service Controller and services.
USAGE:
sc server [command] [service name] option1 option2...

The option server has the form "\\ServerName"
Further help on commands can be obtained by typing: "sc [command]"
Commands:
query-----------Queries the status for a service, or
enumerates the status for types of services.
queryex---------Queries the extended status for a service, or
enumerates the status for types of services.
start-----------Starts a service.
pause-----------Sends a PAUSE control request to a service.
interrogate-----Sends an INTERROGATE control request to a service.
continue--------Sends a CONTINUE control request to a service.
stop------------Sends a STOP request to a service.
config----------Changes the configuration of a service (persistant).
description-----Changes the description of a service.
failure---------Changes the actions taken by a service upon failure.
qc--------------Queries the configuration information for a service.
qdescription----Queries the description for a service.
qfailure--------Queries the actions taken by a service upon failure.
delete----------Deletes a service (from the registry).
create----------Creates a service. (adds it to the registry).
control---------Sends a control to a service.
sdshow----------Displays a service's security descriptor.
sdset-----------Sets a service's security descriptor.
GetDisplayName--Gets the DisplayName for a service.
GetKeyName------Gets the ServiceKeyName for a service.
EnumDepend------Enumerates Service Dependencies.

The following commands don't require a service name:
sc server command option
boot------------(ok | bad) Indicates whether the last boot should
be saved as the last-known-good boot configuration
Lock------------Locks the Service Database
QueryLock-------Queries the LockStatus for the SCManager Database
EXAMPLE:
sc start MyService

Would you like to see help for the QUERY and QUERYEX commands? [ y | n ]: y
QUERY and QUERYEX OPTIONS :
If the query command is followed by a service name, the status
for that service is returned. Further options do not apply in
this case. If the query command is followed by nothing or one of
the options listed below, the services are enumerated.
type= Type of services to enumerate (driver, service, all)
(default = service)
state= State of services to enumerate (inactive, all)
(default = active)
bufsize= The size (in bytes) of the enumeration buffer
(default = 4096)
ri= The resume index number at which to begin the enumeration
(default = 0)
group= Service group to enumerate
(default = all groups)
SYNTAX EXAMPLES
sc query - Enumerates status for active services & drivers
sc query messenger - Displays status for the messenger service
sc queryex messenger - Displays extended status for the messenger service
sc query type= driver - Enumerates only active drivers
sc query type= service - Enumerates only Win32 services
sc query state= all - Enumerates all services & drivers
sc query bufsize= 50 - Enumerates with a 50 byte buffer.
sc query ri= 14 - Enumerates with resume index = 14
sc queryex group= "" - Enumerates active services not in a group
sc query type= service type= interact - Enumerates all interactive services
sc query type= driver group= NDIS - Enumerates all NDIS drivers