Saturday, October 23, 2010

ORA-38760: This database instance failed to turn on flashback database ORA-38701 ORA-27037

Problem Description


Whenever you try to startup your database then it fails with ORA-38760.

SQL> startup
ORACLE instance started.

Total System Global Area 1161966444 bytes
Fixed Size 1787966 bytes
Variable Size 1145750568 bytes
Database Buffers 225163524 bytes
Redo Buffers 1262132 bytes
Database mounted.
ORA-38760: This database instance failed to turn on flashback database.

In the Alert log there goes entry like this.

Errors in file /oracle/admin/agprod/udump/agprod_ora_409616.trc:
ORA-38701: Flashback database log 402 seq 402 thread 1: "/DBarchive/flash_recovery_area/AGPROD/flashback/o1_mf_47cqbhb5_.flb"
ORA-27037: unable to obtain file status
IBM AIX RISC System/6000 Error: 2: No such file or directory
Additional information: 3

The analogous of this error is during database running state whenever you delete the current flashbacklog, the database will crash with the following errors:

ORA-38701: Flashback database log 401 seq 401 thread 1:
"/DBarchive/flash_recovery_area/AGPROD/flashback/o1_mf_47cqbhb5_.flb"
ORA-27037: unable to obtain file status
IBM AIX RISC System/6000 Error: 2: No such file or directory
Additional information: 3
Sat Apr 11 00:03:12 2006
RVWR: terminating instance due to error 38701
Instance terminated by RVWR, pid = 5721

Cause of The Problem
The above errors occurred due to a well identified bug. If there is any I/O error that is preventing write to the flashback logs, the instance will crash. Losing the current flashback log will cause the instance to crash. Also during database startup if flashback logs are inaccessible then instance will crush.

Solution of The Problem
Solution A)-Upgarde Database Version:

This bug is affected from database version 10.1.0.1 to 10.1.0.4
It is fixed in database version 10gR2. So upgrade your database version.

Solution B)-Disable Flashback and restart the instance.
1)If you don't have the situation to upgrade the database then start the database in mount stage.
SQL> startup mount;

2)Turn off the Flashback
SQL> alter database flashback off;

3)Turn on the Flashback
SQL> alter database flashback on;

4)Startup the database
SQL>alter database open;

Or, SQL>shutdown
SQL>startup


Note:
After disabling flashback if you have guaranteed restore point then you still might get the error ORA-38760: This database instance failed to turn on flashback database while starting up the database. In this case you have to drop the guaranteed restore point.

You can see the available guaranteed restore point by,
select NAME,SCN,GUARANTEE_FLASHBACK_DATABASE,DATABASE_INCARNATION# from v$restore_point;
Then drop the guaranteed restore point by,
DROP RESTORE POINT NAME_OF_THE_GUARANTEED_RESTORE_POINT;
Now start your database.

What is View in Oracle

A view in oracle is nothing but a stored sql scripts. View itself contain no data. Whenever we query on a view underlying SQL scripts is executed. Suppose I have created a view as CREATE VIEW TEST_VIEW AS SELECT NAME FROM TEST; Now whenever I query on view TEST_VIEW underlying script SELECT NAME FROM TEST is executed.



A view can be queried, and the data it represents can be changed. Data in a view can be updated or deleted, and new data inserted. These operations directly alter the tables on which the view is based and are subject to the integrity constraints and triggers of the base tables.


Workaround Example:
Connect as a dba user and grant only insert privilege to table TEST on arju schema table to india.


SQL> CONN ARJU/A
Connected.


SQL> revoke SELECT ON TEST from india;
Revoke succeeded.


SQL> grant insert ON TEST TO INDIA;
Grant succeeded.


SQL> CONN INDIA/T
Connected.
SQL> CREATE VIEW ARJU_SCHMEA_VIEW AS SELECT * FROM ARJU.TEST;
View created.


Since india has only insert privilege on the base table so he can create view but can't select any row from the base table or view.


SQL> SELECT * FROM ARJU_SCHMEA_VIEW;
SELECT * FROM ARJU_SCHMEA_VIEW
*
ERROR at line 1:
ORA-01031: insufficient privileges
Now grant him select privilege on the base table.

SQL> CONN ARJU/A

Connected.
SQL> grant SELECT ON TEST TO INDIA;
Grant succeeded.

SQL> CONN INDIA/T

Connected.
SQL> SELECT * FROM ARJU_SCHMEA_VIEW;
no rows selected


Now insert row in to the view.
SQL> INSERT INTO ARJU_SCHMEA_VIEW VALUES(1);
1 row created.


SQL> COMMIT;
Commit complete.


SQL> SELECT * FROM ARJU_SCHMEA_VIEW;
A
----------
1


SQL> SELECT * FROM ARJU.TEST;
A
----------
1


So if underlying view is modified base table is affected.

Benefits of using views

•With views you can restrict database access in both column level and row level. Selective portion of tables can be hidden with view.



•Creating complex view and query on them allow you to make complex query easy. They allow you to make simple queries to retrieve the results from complicated queries.


•Views can be used to allow data independence for ad hoc users and application programs.


•You can present different views of the same data according to their particular criteria.


•For experiment you can just create view and query on them instead of creating temporary tables and dropping them while significantly reduce database fragmentation.

Database Administration Exercises

Dictionary Views to help you work

Using your text and any other sources you wish, make a list of the data dictionary views you feel would be the most helpful to a programmer who is writing applications that perform DML actions on rows from tables in the database. Give a brief explanation for your choice of each view.
Place and save your answers in a Word document named week3_exercise.doc.

Where are my Log Files and Groups?

You have inherited an existing database from a previous Administrator. There is little to no documentation provided for this database and, as you review the database setup, you find you need answers to the following questions:

  • What are the redo log group numbers, and how many members does each group have?
  • What directory or directories holds the redo log group members?
Write SQL commands or queries to discover all these answers. Place and save your answers in the Word document named week3_exercise.doc that you have started for this week's exercises.

Working with initialization parameters
Use your text and any online documentation you need, determine which of the initialization parameters (many are discussed in chapter 3) are static and which are dynamic. Also determine which can be changed using ALTER SESSION, and which can be changed using ALTER SYSTEM. Make a spread sheet type table with four columns for your lists (one for each category). Some parameters may appear on more than one list and that is acceptable. Use the parameters listed in the book to begin with, and then add some. You should try to have a listing of at least 20 different parameters. Place and save your answers in the Word document named week3_exercise.doc that you have started for this week's exercises.

Error Vmware Failed to lock the file

Problem Description:
If you use vmware then while opening it it failed with following messages,

Cannot open the disk '/home/oracle/win_vmware_image/Windows XP Professional 2.vmdk' or one of the snapshot disks it depends on.
Reason: Failed to lock the file.


The problem can happen with many reasons. Try to solve one by one.

Solution of the Problem:
1)Is you vmware is improperly shutdown? If so look at the directory where vmware resides. Search file there named extention .WRITELOCK. Delete the writelock file and try to start the vmware. If you succeed then no further steps necessary.

2)Do you point to your vmware to another location or add another disk which is not currently available. If so, under poweroff menu >select edit virtual mechine settings >You will see the list of hardware. If you suspect the hardware/disk is not currently available select it and then remove it. Now try to start your vmware.

3)Look for other vmware process or any software is running and whether it use your current existing disk. If so shutdown that process and try to start your vmware.

Different ways to open Office .docx documents

DOCX is the Word document which is the "Microsoft Office Open XML Format Document". This is the new upcoming format for Microsoft Office documents. This extension came with Microsoft Office 2007. It is a combination of XML architecture and ZIP compression for size reduction.

Microsoft introduced the .docx file format in its Office 2007 and wants it to replace the commonly used doc format. Any word document in Office 2007 can be saved as .docx file extension but as .docx extension is latest version, so older version like Office 2000, Office XP, Office 98 are not still aware of the .docx file extension. So these software can't open the .docx file. Though Microsoft promised that .docx file will be compatible to old Microsoft word but they are still their promises.

Now, as many users still using old Microsoft Office so many users can't open the .docx file document. So the main question for these users is of course how they would open a docx file to be able to read and work with it. The answer depends on the platform you are using. Below is some solutions based on platform you are using as well as solution of platform independent.

For Older Version of Microsoft Office:
If you are on windows machine and you have older version of Microsoft Office like Office XP, Office 2000, Office 98 then the best way is to install Microsoft compatibility pack for previous Office versions that adds .docx support in Microsoft Word. You can download the compatibility pack from http://office.microsoft.com/en-us/word/HA100444731033.aspx.

If you use Open office Software:
If you use open office software then you can use the Open XML Translator for Open Office to be able to read and edit docx files.

Online Solution:
There are many websites over Internet that do the conversion job and most of them do offer the job for free. You can upload your .docx file in that site and then you will get back .doc document. There are many docx converter sites for it.

A hack way:
This procedure worked perfectly for Microsoft Office 2007 beta version. But if it is not beta then it will not work. Still you can get an idea about the contents inside your .docx file. The idea is as .docx file is the combination of XML architecture and ZIP compression. So first save the .docx file as .zip and then extract it using any extract utility like unzip. If you used beta version then word folder you will get your expected word file. If you don't you can still have an idea to rename big sized .XML to .HTML and open that file in your browser.

How to know process ID or PID on windows

Process Identifier or Process ID or PID is the unique ID of a process running on the system. With PID we can uniquely identify a process and can know about their characteristics.


On unix based system like linux, solaris, HP-UX with "ps" command we can easily identify each type of process and their PID. We can also grep the output for filtering. But for Windows operating system such as Windows 95, Windows 98, Windows 2000, Windows XP, Windows Vista, Windows Server 2003, Windows Server 2008 and Windows 7 there is no such utility or command.


In windows through GUI we can still see the process ID or PID of a process. This is sometime very essential to track a culprit process. It can be seen from Task Manager. To get Task Manager right click on empty area in the task bar and then you can select Task Manger. You can also get Task Manager window by clicking CTRL+ALT+DEL.


After opening task manager you will see there is no process ID or PID there by default. But you can see Processes tab there. Whenever you click on processes tab, process information is shown. By default option is Image Name(Process Name), User Name(the user under whom process is running), CPU(percentage of CPU usage) and Mem Usage(Total how many KB is allocated to the process).


To get Process ID,
- Click Processes tab.
- Click on View menu, then click on Select Columns.
- In the "Select Columns" or "Select Process Page Columns" dialog, check the checkbox for PID (Process Identifier), and click OK.



You will see PID is shown and you can easily track each process identifier.

How to check or identify which process is listening to port 80 in windows

From yesterday, on my computer I could not start my apache service. From the XAMPP Control Panel Application whenever I start Apache it fails to start. I reinstalled apache several time but it could not help . In fact after installing Apache HTTPD web server or Microsoft IIS Internet Information Services web server, or any other application software or service and daemon that requires to open and listen to port 80 (HTTP) or port 443 (HTTPS SSL) it fails. So I consider myself to investigate about the program that is using port 80 or 443.

I am sure that a program is using port 80 or port 443 and restrict apache to use these port as I get following after installing Apache web server using XAMPP.

(OS 10052) Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down


So, I need to identify the program which is listening to port 80 and kill that process or at least restrict that process to listen to port 80.

To following steps will help you to find the culprit one.

1)Open command prompt. You can do it by clicking your start menu, then select Run, type cmd in the Run box and hit enter.

2)I expect you will see command prompt here unless you have viruses in your computer that restrict to show. In the command prompt type,

>netstat -o -n -a | findstr 0.0:80
in order to determine the process ID which is using port 80.

or type,
>netstat -o -n -a | findstr 0.0:443
in order to determine the process ID which is listening to port 443.

or type,
>netstat -aon
in order to list all connection that is listening, established, starting, closing and all other states. As netstat -aon will list all connections so from that you need to manually search for line 0.0.0.0:80 or 0.0.0.0:443 to determine the process ID.

3)Determine the process ID which is listening to port 80 or 443.
A typical output from the above commands are,
E:\Documents and Settings\Arju>netstat -o -n -a | findstr 0.0:80
TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       4712

E:\Documents and Settings\Arju>netstat -o -n -a | findstr 0.0:443
TCP    0.0.0.0:443            0.0.0.0:0              LISTENING       4712
UDP    0.0.0.0:443            *:*                                    316

E:\Documents and Settings\Arju>netstat -aon

Active Connections

Proto  Local Address          Foreign Address        State           PID
TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       4712
TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       1324
TCP    0.0.0.0:443            0.0.0.0:0              LISTENING       4712
TCP    0.0.0.0:3306           0.0.0.0:0              LISTENING       1920
TCP    0.0.0.0:5101           0.0.0.0:0              LISTENING       7636
TCP    0.0.0.0:17536          0.0.0.0:0              LISTENING       316
TCP    10.65.49.113:1175      118.160.238.122:80     ESTABLISHED     316
TCP    10.65.49.113:1451      209.85.137.125:5222    ESTABLISHED     1588
TCP    10.65.49.113:1561      66.102.9.83:80         CLOSE_WAIT      3436
TCP    10.65.49.113:1623      96.17.159.66:80        CLOSE_WAIT      1964
TCP    10.65.49.113:2659      216.10.192.112:80      CLOSE_WAIT      5164
TCP    10.65.49.113:2782      216.10.192.112:80      CLOSE_WAIT      3692
TCP    10.65.49.113:3084      74.125.87.83:80        ESTABLISHED     2736
TCP    10.65.49.113:3179      74.125.87.191:80       ESTABLISHED     2736
TCP    10.65.49.113:3180      74.125.87.83:80        ESTABLISHED     2736
TCP    10.65.49.113:3185      74.125.87.101:443      ESTABLISHED     5164
TCP    10.65.49.113:3187      74.125.87.147:80       ESTABLISHED     5164
TCP    10.65.49.113:3850      68.180.217.28:5050     ESTABLISHED     7636
TCP    10.65.49.113:3881      68.142.233.181:80      ESTABLISHED     7636
TCP    10.65.49.113:4837      207.46.125.86:1863     ESTABLISHED     320
TCP    127.0.0.1:1247         0.0.0.0:0              LISTENING       3692
TCP    127.0.0.1:1557         0.0.0.0:0              LISTENING       6172
TCP    127.0.0.1:1557         127.0.0.1:1558         ESTABLISHED     6172
TCP    127.0.0.1:1558         127.0.0.1:1557         ESTABLISHED     7928
TCP    127.0.0.1:1672         0.0.0.0:0              LISTENING       1532
TCP    127.0.0.1:1727         127.0.0.1:1728         ESTABLISHED     7636
TCP    127.0.0.1:1728         127.0.0.1:1727         ESTABLISHED     7636
TCP    127.0.0.1:1990         127.0.0.1:1991         ESTABLISHED     5164
TCP    127.0.0.1:1991         127.0.0.1:1990         ESTABLISHED     5164
TCP    127.0.0.1:1993         127.0.0.1:1994         ESTABLISHED     5164
TCP    127.0.0.1:1994         127.0.0.1:1993         ESTABLISHED     5164
UDP    0.0.0.0:443            *:*                                    316
UDP    0.0.0.0:17536          *:*                                    316
UDP    10.65.49.113:123       *:*                                    1364
UDP    10.65.49.113:1900      *:*                                    1500
UDP    127.0.0.1:123          *:*                                    1364
UDP    127.0.0.1:1025         *:*                                    1924
UDP    127.0.0.1:1171         *:*                                    316
UDP    127.0.0.1:1716         *:*                                    320
UDP    127.0.0.1:1730         *:*                                    7636
UDP    127.0.0.1:1900         *:*                                    1500
UDP    127.0.0.1:2993         *:*                                    1588
UDP    127.0.0.1:9877         *:*                                    1924
UDP    127.0.0.1:9977         *:*                                    1924
UDP    127.0.0.1:62976        *:*                                    1924

From the above output we see process ID 4712 is the culprit one which is listening to port 80 and 443 and thus restrict web server to use them.

4)In this step find the process which has the Process ID 4712. You can simply follow  http://dbatutorials.blogspot.com/2010/10/how-to-know-process-id-or-pid-on.html and bring task manager to display that process ID. From task manager Image Name determine the process name.

So now you can kill that process or still if you want to run that process first run you web server/apache and then run that program. In this way apache first will listen to port 80 and that program will not be able to use as it starts after web server.

Disable Skype from Using, Opening or Listening on Port 80 and 443

If you have running skype in your system and you now try to install web server or a program that need to use HTTP port 80 or HTTPS port 443, then there possibly an error message saying that the port 80 or 443 has been in used or occupied by another application. Though you don't have currently installed any web server like Apache or IIS (Microsoft Internet Information Service).



So you need to investigate which program is using/opening/listening on port 80 or 443. In the post, http://dbatutorials.blogspot.com/2010/10/how-to-check-or-identify-which-process.html  it is clearly discussed who you can know which process listening on which port. So you can know the process name from that post.


Now our concern is about skype. Skype allows users to use port 80 and 443 as an alternatives for incoming connections. Skype uses port 80 and 443 to allow Skype behind firewall to connect to peer or accept incoming connection from peers.


Only one program can open/use/listen one port at a time. So if skype uses port 80 other program will not be able to use it. Skype uses port 80 and port 443 (for SSL HTTP connection) and thus prevent other applications which require such port from working properly. So to make important program to work like web server we need to disable skype to use port 80 and port 443. Also, leaving the port 80 and 443 opens and listening also has security risk where the port can be scanned by malicious virus or hacker to launch attack or infection.


If you want to use skype and also web sever then you must turn off and disable Skype usage of and listening on port 80 and port 443. following is the steps to do this.


1) Open the Skype window.
2) Click on Tools menu.
3) Select Options.
4) Click on Advanced tab.
5) Go to Connection sub-tab.
6) Untick or uncheck the check box for "Use port 80 and 443 as an alternatives for incoming connections option."
7) Click on Save button and then restart Skype to make the change effective.

Helpctr.exe application error

About Helpctr.exe Process

helpctr.exe (helpctr stands for Microsoft Help and Support Center) is a Windows NT/2000/XP generic process which is loaded in the background when you run Windows Help. When help is requested in Windows 2000 or later version of Windows this process will be initiated. This is a non-essential process which means disabling or enabling it is upon to user preference.

Note that The process helpctr.exe is not a virus or a worm or a Trojan horse or spyware, or adware.

Problem Symptoms:
- I am using Windows XP with service pack 2. when I start my computer the hard drive keep running and it take a lot of time to start windows.

- When I open the task manager by right clicking on the task bar or open the task manager using ctrl+alt+del it shows the helpctr.exe appear in many, many times. In fact all my task manager entry if filled with helpctr.exe process.

- The boxes Helpctr.exe keep coming on the screen. And the following box appeared
helpctr.exe application error-
the application failed to initialize properly(0x000012d) or ((oxc000017, or 0xc000012d142)) Click on OK to terminate the application.
Click on CANCEL to debug the program.

- After another box reads: Microsoft Visual C++ runtime library
runtime error!
Program :C:\Windows\PC HEALTH\ HELPCTR\Binaries\helpctr.exe
This application has requested the Runtime to terminate it in an unusual way. Please contact the applications support team for more information.

- If I want to remove those so many pop up message after clicking either close or ok or cross button one there is another box under it and in fact so many boxes there. If I move that box, there is another box under it. When I click all boxes ok button all pop ups are gone and the screen seems to be normal as well as all of the helpctr.exe entries in Task Manager are gone.

- After I clicked all the pop ups HelpCtr.exe the computer continues to work as usual but suddenly it started same problem frequently pop up window appears one after another. In fact it depends on the application. For example if I open google chrome browser I see lots of google help page appeared there. If I open firefox browser lots of tab containing firefox help page appeared. If I dont open any application frequently windows help and messaging centre window appears. If I push the X in the upper right corner of the help menu the help window closes but then reopens again by itself. if it doesn't reopen by itself it reopens when I click anywhere on the application.

Problem Investigation:
I used windows Search button and searched for helpctr.* and found helpctr.exe exists in about 5 locations. I changed the name to another name of each folder and rebooted. But the problem remained same.

I reinstall windows computer but still no help.

Installed anti virus but no help. Problem remained. I removed helpctr.exe but still same problem

I even deleted my help folder in windows. But still did not solve my problem. It rather looking for the help boxes to pop up (which dont exist anymore). So it will give me an error box about my helpctr.exe application not functioning, but the box will never close. It just keeps popping up over and over again.

I have even tried following steps based on some posts suggestion after searching google but still that did not solve the problem. What I did is to delete the help cache files in your user profile directory.

1. Start Windows Explorer

2. The files are in a hidden directory, so you will need to enable to view the hidden files. In the Windows Explorer do following to enable viewing on hidden files.
Tools -> Folder Options -> View ->
From Advanced settings Hidden files and folders:
Select Show hidden files and folders
Click ok.

3. Then you will have to go into your user profile's help cache location. This is normally at the following location:
<Windows Installation Directory>\Documents and Settings\<USERNAME>\Application Data\Microsoft\HTML Help\

Where <Windows Installation Directory> is like C: or D:
and <USERNAME> is your windows login name.


4. Delete all the files you find in the above folder. You may wish to make a backup first. Simply copy the folder to another location.

You will see your problem may disappeared temporary but it is not permanent solution.

Solution of the Problem
After pop up keep opening I pressed many keys at a time and I see problem stops. And I tried to understand for which keystroke the problem stops. I also see all the time help related page and error appeared. So I guess the F1 key might be the culrpit. From my keyboard I removed F1 key and it worked really. So you have two solutions of the above problem. As this problem is hardware problem and specifically your keyboard's F1 is the culprit so either replace your keyboard with a new one and repair your keyboard so that F1 key does not keep pressed. In fact the problem arises since F1 key pressed continuously.

How to delete duplicate rows from a excel file

The method demonstrated here is applicable for 

- Microsoft Office Excel 2003 and
- Microsoft Excel 2002.
A duplicate row or a duplicate record means all values in the row are an exact match of all the values in another row.

In this post I will filter excel list for unique rows, delete the original list, and then replace it with the filtered list. So before proceeding I recommend you backup the original excel file because existing excel file will be overwritten.

Step by step solution is provided.

Step 01: Open the excel document. Select all the rows, including the column headers in the list.
Step 02: On the Data menu, point to Filter, and then click Advanced Filter.
Step 03: In the Advanced Filter dialog box, click Filter the list, in place.
Step 04: Select the Unique records only check box, and then click OK.

The filtered list is displayed and the duplicate rows are hidden.

Step 05: On the Edit menu, click Office Clipboard.
The Clipboard task pane is displayed.

Step 06: Copy the filtered list. You filtered list should be still selected and you just need to press CTRL+C or just click Copy button.

In this stage the filtered list is highlighted with bounding outlines and the selection appears as an item at the top of the Clipboard.

Step 07: In this step just delete the original list because we want to overwrite it. To delete the original list on the Data menu, point to Filter, click Show All, original list will be displayed and then press DELETE key.

Step 08: In the Clipboard, click on the filtered list item. The filtered list appears in the same location as the original list.

How to open an odt file

ODT indicates Open Document Format. It is an open standard text document created with Writer, the OpenOffice.org and StarOffice word processor; formatted using the OASIS OpenDocument XML-based standard. From OpenOffice.org, file extensions of text comes with .odt format, spreadsheet comes with .ods format and presentation comes with .odp format.

Microsoft Word by default can't open odt files. Open Document text files can be opened and edited with any OpenOffice-compatible program which are specified below.

1) OpenOffice.org Writer: You can download OpenOffice Write from the link OpenOffice.
2) Sun Microsystems Writer (included with StarOffice).
3) AbiSource AbiWord.
4) IBM Lotus Notes 8 or later.
5) On MAC OS with Apple TextEdit as well as with NeoOffice Writer.
6) On Unix OS with KOffice KWord.
7) Microsoft Word with OpenXML/ODF Translator Add-in.

Though Microsoft Word can't open odt file directly but with plugins you can open it.
If you want to open through Microsoft Word, download the ODF plugin from Sun ODF Plugin. Now you will be able to open odf files whether you use Microsoft Office 2003 or Office 2007.

8) If you don't have time to install any software or don't have administrative privilege and you have Internet connection then you can try any online converter tool such as Zamzar or Media Convert to open an odt file.

9) You can also upload odt file to Google Docs and from google docs you will be able to read the file.

10) Zoho Writer is another option to open odt file.

Automatic startup and shutdown oracle on linux

Oracle database server provides two scripts to configure automatic database startup and shutdown process.



The scripts are,
$ORACLE_HOME/bin/dbstart
$ORACLE_HOME/bin/dbshut



Now let's look at unix level script. When a unix machine boots it runs scripts beginning with Snnname in /etc/rc3.d.


-Here the number nn indicates the order in which these scripts will be run. The name just indicates the function of the script.
In the same way shutdown scripts are named as Knnname which are run from /etc/rc0.d.
If we want that Oracle is the last program that is automatically started, and it is the first to be shutdown then we will name the startup and shutdown scripts on OS like /etc/rc3.d/S99oracle and /etc/rc0.d/K01oracle respectively.
The database script dbstart and dbora will be called from OS script /etc/rc3.d/S99oracle and /etc/rc0.d/K01oracle respectively.


Note that dbstart and dbshut take each SID, in turn, from the /etc/oratab file and
startup or shutdown the database.


Automate Startup/Shutdown of Oracle Database on Linux


Step 01: Be sure that oratab file is correct and complete.
Check for oratab file either in /etc/oratab or in /var/opt/oracle/oratab.
Database entries in the oratab file have the following format:
$ORACLE_SID:$ORACLE_HOME:[Y|N]
Here Y indicates that the database can be started up and shutdown using dbstart/dbshut script.


If in my database there is two database named arju and arjudup then my oratab file will contain the entry like,


dbhost:/var/opt/oracle/product/10.2.0/db_1:Y
dbhost:/var/opt/oracle/product/10.2.0/db_1:Y



where /var/opt/oracle/product/10.2.0/db_1 is the $ORACLE_HOME of my database.


Step 02: Create a script to call dbstart and dbshut.
In this example I will create one script that will do both startup and shutdown operation. I will name this script as dbora and will be placed in '/etc/init.d'.


a) Login as root.
b) Change directories to /etc/init.d
c) Create a file called dbora and chmod it to 750.


# touch dbora
# chmod 750 dbora
d)Edit the dbora file and make the contents of it like below.

#!/bin/bash
#
# chkconfig: 35 99 10   
# description: Starts and stops Oracle processes
#
ORA_HOME=/var/opt/oracle/product/10.2.0/db_1
ORA_OWNER=oracle

case "$1" in
'start')

# Start the TNS Listener
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
# Start the Oracle databases:
su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
# Start the Intelligent Agent
if [ -f $ORA_HOME/bin/emctl ];
then
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start agent"
elif [ -f $ORA_HOME/bin/agentctl ]; then

su - $ORA_OWNER -c "$ORA_HOME/bin/agentctl start"
else
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl dbsnmp_start"
fi
# Start Management Server
if [ -f $ORA_HOME/bin/emctl ]; then
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"
elif [ -f $ORA_HOME/bin/oemctl ]; then
su - $ORA_OWNER -c "$ORA_HOME/bin/oemctl start oms"
fi
# Start HTTP Server
if [ -f $ORA_HOME/Apache/Apache/bin/apachectl]; then
su - $ORA_OWNER -c "$ORA_HOME/Apache/Apache/bin/apachectl start"
fi
touch /var/lock/subsys/dbora
;;
'stop')
# Stop HTTP Server
if [ -f $ORA_HOME/Apache/Apache/bin/apachectl ]; then

su - $ORA_OWNER -c "$ORA_HOME/Apache/Apache/bin/apachectl stop"
fi
# Stop the TNS Listener

su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
# Stop the Oracle databases:
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
rm -f /var/lock/subsys/dbora
;;
esac
# End of script dbora


3.As root perform the following to create symbolic links:

# ln -s /etc/init.d/dbora /etc/rc3.d/S99oracle
# ln -s /etc/init.d/dbora /etc/rc0.d/K01oracle

Alternatively you can register the Service using
/sbin/chkconfig --add dbora

This action registers the service to the Linux service mechanism.

4. Test the script to see if it works.
The real test is to reboot unix box and then see whether oracle is started up automatically or not.
However to test the script created in step 2, without rebooting, do the following:

Login as root and then,
# /etc/init.d/dbora start (for startup)
# /etc/init.d/dbora stop (for shutdown)

If you restart start and stop oracle database is successful then you are almost done.

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