Friday, October 19, 2012

change of IP-address in linux box running Oracle server


Most people  face problem while working on the database whenever they changed  the ip-address and/or hostname  of the machine.  Enterprise manager may not working properly.
I am mentioning this issue in this post with the problem that I face.  My machine is configured  with DHCP.  Oracle recommends to use static IP address. So I also want to change this.  To configure static address in rhel5, you need to follow these two steps:
1.  Assigning static IP address
 log in as root
issue neat command
It will open network configuration  GUI window.
Select eth0 here,  go to edit. Select statically set IP address.  Enter ip address and mention subnet mask.  Click on OK button.  After, click on File >> save to save your changes.  After ,you will get the dialogue saying
Changes are saved. You may want to restart the network and network services or restart the computer.
click on OK. Exit the network configuration window. Then,  logged in as root user, issue
service network restart.
Now, to change the host name(if you want), make modification in /etc/sysconfig/network. My /etc/sysconfig/network looks like:
----------------------------------------------------------------------------------------------------------------------
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=host2.oracle.com
--------------------------------------------------------------------------------------------------------------------
2. Now, as a second step, make appropriate entry in /etc/hosts. My /etc/hosts after modification looks like:
-----------------------------------------------------------------------------------------------------------------------------------
# Do not remove the following line, or various programs  that require network functionality will fail.
127.0.0.1              localhost.localdomain localhost
#::1                        localhost6.localdomain6 localhost6
192.168.2.102     host2.oracle.com             host2
------------------------------------------------------------------------------------------------------------------------------------
Now, reboot the system.

Now, after changing ip address and /or hostname ,you may face certain problems while working on the database. Your listener and/or em console may not working properly.

Use netmgr to configure your listener again.

And to enable  proper functioning of em console,  start your listener after proper configuration, then start database.  .
Firstly, I issued
emca  -config  dbcontrol db
Command ran successfully. But after getting enterprise manager console , homepage shows
Error : java.lang.Exception: UnknownHostException sending request :: host1.oracle.com.
The solution is to issue below command , not above.

[Below command won't work if you do not start the database]
[oracle@host2 ~]$  emca  -config dbcontrol db -repos recreate
And, answer the questions that it asks. Here is the output:
-------------------------------------------------------------------------------------------------------------
STARTED EMCA at Oct 19, 2012 11:27:22 AM
EM Configuration Assistant, Version 10.2.0.1.0 Production
Copyright (c) 2003, 2005, Oracle.  All rights reserved.
Enter the following information:
Database SID: orcl
Database Control is already configured for the database orcl
You have chosen to configure Database Control for managing the database orcl
This will remove the existing configuration and the default settings and perform a fresh configuration
Do you wish to continue? [yes(Y)/no(N)]: y
Listener port number: 1521
Password for SYS user: 
Password for DBSNMP user: 
Password for SYSMAN user: 
Email address for notifications (optional): sys
Invalid email.
Email address for notifications (optional):
Outgoing Mail (SMTP) server for notifications (optional):
-----------------------------------------------------------------

You have specified the following settings

Database ORACLE_HOME ................ /u01/app/oracle/product/10.2.0/db_1

Database hostname ................ host2.oracle.com
Listener port number ................ 1521
Database SID ................ orcl
Email address for notifications ...............
Outgoing Mail (SMTP) server for notifications ...............

-----------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: y
Oct 19, 2012 11:27:45 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/emca/orcl/emca_2012-10-19_11-27-22-AM.log.
Oct 19, 2012 11:27:46 AM oracle.sysman.emcp.util.DBControlUtil stopOMS
INFO: Stopping Database Control (this may take a while) ...
Oct 19, 2012 11:27:48 AM oracle.sysman.emcp.EMReposConfig dropRepository
INFO: Dropping the EM repository (this may take a while) ...
Oct 19, 2012 11:28:56 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Oct 19, 2012 11:28:56 AM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Oct 19, 2012 11:32:41 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully created
Oct 19, 2012 11:32:44 AM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Oct 19, 2012 11:34:22 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Oct 19, 2012 11:34:22 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>>>>>>> The Database Control URL is http://host2.oracle.com:5501/em <<<<<<<<<<<
Enterprise Manager configuration completed successfully
FINISHED EMCA at Oct 19, 2012 11:34:31 AM

[oracle@host2 ~]$ emctl start dbconsole
TZ set to Asia/Calcutta
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0 
Copyright (c) 1996, 2005 Oracle Corporation.  All rights reserved.
http://host2.oracle.com:5501/em/console/aboutApplication
 - An instance of Oracle Enterprise Manager 10g Database Control is already running.
And Enjoy..............



Thursday, October 11, 2012

Resolving Autotrace error


I was working in 10.2.0 version. When I tried to set autotrace to on. I got SP2-0618 error. And here is a small illustration and solution.


SQL> conn hr/hr
Connected.

SQL> set autotrace on;
SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report

SQL> conn / as sysdba
Connected.

SQL> set autotrace on;

SQL>select * from hr.demo1;

        ID                                                                    
----------                                                                    
         1                                                                    
         2                                                                    
         3                                                                    
         4                                                                    
         5                                                                    
         6                                                                    
         7                                                                    
         8                                                                    
         9                                                                    
        10                                                                    
        11                                                                    

        ID                                                                    
----------                                                                    
        12                                                                    
        13                  
----------output truncated----------------------------

Execution Plan
----------------------------------------------------------                    
Plan hash value: 970289426                                                    
                                                                             
---------------------------------------------------------------------------  
| Id  | Operation         | Name  | Rows  | Bytes | Cost (%CPU)| Time     |  
---------------------------------------------------------------------------  
|   0 | SELECT STATEMENT  |       | 50000 |   195K|    21   (5)| 00:00:01 |  
|   1 |  TABLE ACCESS FULL| DEMO1 | 50000 |   195K|    21   (5)| 00:00:01 |  
---------------------------------------------------------------------------  


Statistics not shown.


SQL> conn / as sysdba
Connected.
SQL> alter user scott identified by tiger account unlock;

User altered.

SQL> conn scott/tiger;
Connected.

SQL> set autotrace on;
SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report

SQL> conn / as sysdba
Connected.

SQL> grant plustrace to public;
grant plustrace to public
      *
ERROR at line 1:
ORA-01919: role 'PLUSTRACE' does not exist

Execute plustrce.sql from $ORACLE_HOME/sqlplus/admin folder.

SQL> @?/sqlplus/admin/plustrce.sql
SQL>
SQL> drop role plustrace;
drop role plustrace
          *
ERROR at line 1:
ORA-01919: role 'PLUSTRACE' does not exist


SQL> create role plustrace;

Role created.

SQL>
SQL> grant select on v_$sesstat to plustrace;

Grant succeeded.

SQL> grant select on v_$statname to plustrace;

Grant succeeded.

SQL> grant select on v_$mystat to plustrace;

Grant succeeded.

SQL> grant plustrace to dba with admin option;

Grant succeeded.

After the execution of the script,

SQL> grant plustrace to public;

Grant succeeded.

SQL> conn hr/hr
Connected.

SQL> set autotrace on;

No error shown.
From hereon, autotrace facility will output properly.


SQL>conn / as sysdba
Connected.
SQL> set autotrace on;

select * from hr.demo1;

        ID                                                                    
----------                                                                    
         1                                                                    
         2                                                                    
         3                                                                    
         4                                                                    
         5                                                                    
         6                                                                    
         7                                                                    
         8                                                                    
         9                                                                    
        10                                                                    
        11                                                                    

        ID                                                                    
----------                                                                    
        12                                                                    
        13                  
----------output truncated----------------------------

Execution Plan
----------------------------------------------------------
Plan hash value: 970289426

---------------------------------------------------------------------------
| Id  | Operation         | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |       | 50000 |   195K|    21   (5)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| DEMO1 | 50000 |   195K|    21   (5)| 00:00:01 |
---------------------------------------------------------------------------


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
       3415  consistent gets
          0  physical reads
          0  redo size
     923122  bytes sent via SQL*Net to client
      37048  bytes received via SQL*Net from client
       3335  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      50000  rows processed


Statistics also shown.
I also tested the same thing in 11g release 2 and found that that is also true for 11g.

Thats all.