Monday, July 28, 2014

RAC 11.2 enable archivelog

[oracle@rac1 ~]$ sqlplus / as sysdba
SQL> show parameter recovery;

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest             string
db_recovery_file_dest_size         big integer 0
recovery_parallelism             integer     0

SQL> alter system set db_recovery_file_dest_size=20G scope=both sid='*';
SQL> alter system set db_recovery_file_dest='+FRA' scope=both sid='*';
SQL> archive log list;
Database log mode           No Archive Mode
Automatic archival           Disabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     4
Current log sequence           5
SQL> alter system set cluster_database=false scope=spfile sid='racdb1';
SQL> exit
[oracle@rac1 ~]$ srvctl stop database -d racdb
[oracle@rac1 ~]$ sqlplus / as sysdba

SQL> startup mount
SQL> alter database archivelog;
SQL> alter system set cluster_database=true scope=spfile sid='racdb1';
SQL> shutdown immediate
SQL> exit
[oracle@rac1 ~]$ srvctl start database -d racdb
[oracle@rac1 ~]$ sqlplus / as sysdba
SQL> archive log list;
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     4
Next log sequence to archive   5
Current log sequence           5

Saturday, July 26, 2014

RAC 11.2 Multiplex Oracle Database control files on ASM

Multiplex oracle rac control files on ASM

[oracle@rac1 ~]$ sqlplus / as sysdba
SQL> show parameter control_file

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time         integer     7
control_files                 string     +DATA/racdb/controlfile/curren
                         t.260.853897145

SQL> alter system set control_files='+DATA/racdb/controlfile/current.260.853897145','+FRA' scope=spfile;

System altered.

SQL> exit

[oracle@rac1 ~]$ srvctl stop database -d racdb
[oracle@rac1 ~]$ srvctl start database -d racdb -o nomount

[oracle@rac1 ~]$ sqlplus / as sysdba
SQL> show parameter control_files;

control_files                 string     +DATA/racdb/controlfile/curren
                         t.260.853897145, +FRA
SQL> exit

[oracle@rac1 ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Sat Jul 26 21:21:19 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: RACDB (not mounted)

RMAN> restore controlfile from '+DATA/racdb/controlfile/current.260.853897145';

Starting restore at 26-JUL-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 instance=racdb1 device type=DISK

channel ORA_DISK_1: copied control file copy
output file name=+DATA/racdb/controlfile/current.260.853897145
output file name=+FRA/racdb/controlfile/current.256.853968129
Finished restore at 26-JUL-14

RMAN> exit

[oracle@rac1 ~]$ sqlplus / as sysdba
SQL> alter system set control_files='+DATA/racdb/controlfile/current.260.853897145','+FRA/racdb/controlfile/current.256.853968129' scope=spfile;

System altered.

SQL> exit

[oracle@rac1 ~]$ srvctl stop database -d racdb
[oracle@rac1 ~]$ srvctl start database -d racdb

[oracle@rac1 ~]$ sqlplus / as sysdba
SQL> show parameter control_files;

control_files                 string     +DATA/racdb/controlfile/curren
                         t.260.853897145, +FRA/racdb/co
                         ntrolfile/current.256.85396812
                         9
SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
+DATA/racdb/controlfile/current.260.853897145
+FRA/racdb/controlfile/current.256.853968129

SQL> exit
[oracle@rac1 ~]$

Friday, July 25, 2014

Increase SHM memory to acomodate MEMORY_TARGET

When setting memory_target for oracle you can get errors

-bash-4.1# umount tmpfs
umount: /dev/shm: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))

-bash-4.1# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/vda1              28G   19G  7.5G  72% /
tmpfs                 939M  200M  740M  22% /dev/shm

-bash-4.1# umount tmpfs
umount: /dev/shm: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))

-bash-4.1# umount -l tmpfs
-bash-4.1# mount -t tmpfs shmfs -o size=2048m /dev/shm
-bash-4.1# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/vda1              28G   19G  7.5G  72% /
shmfs                 2.0G     0  2.0G   0% /dev/shm
-bash-4.1# vi /etc/fstab
tmpfs                   /dev/shm                tmpfs   size=2048m        0 0

Configure user equivalence for user oracle RAC

[grid@rac1 ~]$ su - oracle
Password:
[oracle@rac1 ~]$ mkdir .ssh
[oracle@rac1 ~]$ ssh-keygen -t rsa
[oracle@rac1 ~]$ cd .ssh
[oracle@rac1 .ssh]$ ls
id_rsa  id_rsa.pub
[oracle@rac1 .ssh]$ cat id_rsa.pub >> authorized_keys
[oracle@rac1 .ssh]$ scp authorized_keys oracle@rac2:/home/oracle/.ssh
oracle@rac2's password:
authorized_keys                               100%  405     0.4KB/s   00:00   



On second node run the same commands to generate the keys, update authorized_keys file and send it to the other server. Then test the connection between nodes.

[oracle@rac1 .ssh]$ ssh rac1 date
[oracle@rac1 .ssh]$ ssh rac2 date



CRS-2800: Cannot start resource 'ora.asm' as it is already in the INTERMEDIATE state on server

In my test environment with 2 VM I had a situation when the Oracle cluster was unable to start:

-bash-4.1# ./crsctl stop cluster
CRS-2796: The command may not proceed when Cluster Ready Services is not running
CRS-4000: Command Stop failed, or completed with errors.
-bash-4.1# ./crsctl start cluster
CRS-2800: Cannot start resource 'ora.asm' as it is already in the INTERMEDIATE state on server 'rac1'
CRS-4000: Command Start failed, or completed with errors.
-bash-4.1# ./crsctl stat res -t
CRS-4535: Cannot communicate with Cluster Ready Services
CRS-4000: Command Status failed, or completed with errors.


Looking in ASM at the state of diskgroup (only the one with OCR and voting disks), it was dismounted and the cluster needed it in order to start.

[grid@rac1 ~]$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.3.0 Production on Fri Jul 25 22:42:22 2014

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL> select NAME , STATE FROM V$ASM_DISKGROUP;

NAME                   STATE
------------------------------ -----------
VOTE                   DISMOUNTED

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
[grid@rac1 ~]$ asmcmd mount VOTE
[grid@rac1 ~]$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.3.0 Production on Fri Jul 25 22:43:46 2014

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL>                
SQL> select NAME , STATE FROM V$ASM_DISKGROUP;

NAME                   STATE
------------------------------ -----------
VOTE                   MOUNTED

SQL> exit


Then as root, try to start the cluster and check its status.

-bash-4.1# ./crsctl start cluster
CRS-4691: Oracle Clusterware is already running
CRS-4000: Command Start failed, or completed with errors.
-bash-4.1# ./crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS      
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
               ONLINE  ONLINE       rac1                                        
               ONLINE  ONLINE       rac2                                        
ora.VOTE.dg
               ONLINE  ONLINE       rac1                                        
               ONLINE  ONLINE       rac2                                        
ora.asm
               ONLINE  ONLINE       rac1                     Started            
               ONLINE  ONLINE       rac2                     Started            
ora.gsd
               OFFLINE OFFLINE      rac1                                        
               OFFLINE OFFLINE      rac2                                        
ora.net1.network
               ONLINE  ONLINE       rac1                                        
               ONLINE  ONLINE       rac2                                        
ora.ons
               ONLINE  ONLINE       rac1                                        
               ONLINE  ONLINE       rac2                                        
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       rac1                                        
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       rac2                                        
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       rac2                                        
ora.cvu
      1        ONLINE  ONLINE       rac2                                        
ora.oc4j
      1        ONLINE  ONLINE       rac2                                        
ora.rac1.vip
      1        ONLINE  ONLINE       rac1                                        
ora.rac2.vip
      1        ONLINE  ONLINE       rac2                                        
ora.scan1.vip
      1        ONLINE  ONLINE       rac1                                        
ora.scan2.vip
      1        ONLINE  ONLINE       rac2                                        
ora.scan3.vip
      1        ONLINE  ONLINE       rac2                                        


Wednesday, July 23, 2014

compat-libstdc++ not installed when installing Oracle 11.2.0.3 on RHEL6

When installing 11.2.0.3 on RHEL6, to ease the installation, you can install

-bash-4.1# yum install oracle-rdbms-server-11gR2-preinstall

This RPM still don't install 2 required packages: compat-libstdc++ and sysstat

The interesting part is that the package name of compat-libstdc++ is compat-libstdc++-33.

-bash-4.1# yum install compat-libstdc++
Setting up Install Process
No package compat-libstdc++ available.
Error: Nothing to do


-bash-4.1# yum install compat-libstdc++-33
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package compat-libstdc++-33.x86_64 0:3.2.3-69.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================================================================
 Package                                                         Arch                                               Version                                                    Repository                                               Size
=============================================================================================================================================================================================================================================
Installing:
 compat-libstdc++-33                                             x86_64                                             3.2.3-69.el6                                               ol6_ga_base                                             183 k

Transaction Summary
=============================================================================================================================================================================================================================================
Install       1 Package(s)

Total download size: 183 k
Installed size: 806 k
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 183 k
compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm                                                                                                                                                                           | 183 kB     00:01    
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : compat-libstdc++-33-3.2.3-69.el6.x86_64                                                                                                                                                                                   1/1
  Verifying  : compat-libstdc++-33-3.2.3-69.el6.x86_64                                                                                                                                                                                   1/1

Installed:
  compat-libstdc++-33.x86_64 0:3.2.3-69.el6                                                                                                                                                                                                 

Complete!

Change Oracle DB Console logout timeout

For DB Control, you should set it in:

$ORACLE_HOME/oc4j/j2ee/oc4j_applications/applications/em/em/WEB-INF/web.xml
and set the following parameter to -1 (no limit):   <session-config>       <session-timeout>-1</session-timeout>  </session-config> 

or if you like, you can specify a positive number to indicate the number of minutes before timeout.