Thursday, February 28, 2013

Oracle 11.2.0.3 upgrade precheck error: "PRVF-4190 : Verification of the hosts config file failed"

When I was upgrading Oracle 11.2.0.1 RAC database to 11.2.0.3 on Linux RHEL5 environment the prerequisite checks gaved following error:
"PRVF-4190 : Verification of the hosts config file failed"

This means that there is something wrong in the /etc/hosts file. Following MOS (My Oracle Support) ID gives more info about this:

[ID 1056025.1]

But in this time I was using same /etc/hosts file in several other RAC installations both 11.2.0.1 and 11.2.0.3 . And all of those were working nicely and none of those gaved this error when installing them. So it seems that upgrade is doing this check some other way than pure install of 11.2.0.3. (In my case this fail is probably because there is a lot of IPv6 addresses in hosts file. Thought that hosts file is still valid and working fine.)

I made SR about this and response was that I can ignore error because same file is working fine with other databases. So I ignored it and run upgrade. Upgrade went ok but after root scripts cluvfy (Oracle Cluster Verification Utility) was failing because the same error about hosts file. I checked the installAction log file and there was no other errors than hosts file error. So I hit the skip button and then finished installation and everything is working just fine.

So the point here is that if upgrade precheck is failing because of the hosts file (PRVF-4190) it can be ignored if it is not failing with clean installations and the hosts file is valid+working fine elsewhere.

Copy Archivelogs from ASM to disk via asmcmd


Copy current archivelogs from asmcmd (as oracle user):
export ORACLE_HOME=/u01/app/11.2.0/grid
export ORACLE_SID=+ASM1
asmcmd


ASMCMD> ls -la
ASMCMD> cd TEST_TESTDB_ARCH0/
ASMCMD> cd TESTDB/
ASMCMD> cd ARCHIVELOG/
ASMCMD> cd 2012_02_28/
# This gives you latest logs in the end of the listing:
ASMCMD> ls -lat --reverse

ASMCMD> cp '+TEST_TESTDB_ARCH0/TESTDB/ARCHIVELOG/2012_02_28/thread_2_seq_144810.3108.808567851' /backup/export/thread_2_seq_144810.3108.808567851


NOTE! You can use the cp command to:
----
-Copy files from a disk group to the operating system
-Copy files from a disk group to a disk group
-Copy files from the operating system to a disk group
----


Copy Archivelogs from ASM to disk via RMAN

Copy archivelogs from ASM to desired disk via RMAN (as oracle user):
#This makes backup of the file so it is not basic copy.

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=testdb1

rman

RMAN> connect target /

# This gives you latest logs in the end of the listing:
RMAN> LIST ARCHIVELOG ALL;

# And then copy desired:
RMAN> copy archivelog '+TEST_TESTDB_ARCH0/TESTDB/ARCHIVELOG/thread_2_seq_144809.675.808567493' to '/backup/export/thread_2_seq_144809.675.808567493';

Starting backup at 20120228-101014
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=2 sequence=144809 RECID=380790 STAMP=808567494
output file name=/backup/export/thread_2_seq_144809.675.808567493 RECID=380792 STAMP=808567817
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:03
Finished backup at 20120228-101018

Sunday, February 24, 2013

Oracle 11 and interval partitioning

If you have used Oracle range partitioning for example month based partitions before Oracle 11 then you needed to do each new month partitions yourself. Oracle 11 introduced interval partitions which can automatically create new partitions for desired intervals for example each months .

Here is simple example how to do range partiotion with interval (there is a lot of other paratmeter to use with partitions but this example just shows the interval):
SQL> CREATE TABLE test_data ( test_id number not null, test_name varchar2(32) not null, test_day date not null ) partition by range (test_day) interval (numtoyminterval(1, 'MONTH')) ( partition before_int_1_jan_2012 values less than (to_Date('01-01-2012', 'dd-mm-yyyy')));

Last partition before interval starts to create new partitions is called transition point. After that partition intervals are automatically created. For example if you insert data into test_data table and test_day value points into the next month thats month partition will be done and data is inserted into it.

It is also possible to alter older range partition tables to use interval with alter table clause:
SQL> ALTER TABLE test_data2 SET interval (numtoyminterval(1, 'MONTH'));

Remember that interval creates partitions with system generated names (you can rename these manually if you want). You can check intervals from user_tab_partitions view for example this way:
SQL> SELECT partition_name, high_value FROM USER_TAB_PARTITIONS WHERE table_name='TEST_DATA';

You can also check certain date partition with following clause:
SQL> SELECT * FROM test_data partition for (to_date('01-02-2012', 'dd-mm-yyyy'));


NOTE! Interval partition can be used only with date or number columns. And it can have only single partitioning key column. And it does not support subpartitions.

Saturday, February 23, 2013

Oracle 11 Encrypted tablespaces

Start of the Oracle 11 you can create encrypted tablespaces.
But you can't alter tablespaces to encrypted. So if you need to
encrypt tablespace you need always create new one with encryption on.

Encrypted tablespaces are created like this:
SQL> CREATE TABLESPACE test_enc_ts DATAFILE '/data/oradata/testdb/test_enc_ts_01.dbf'
size 512M encryption using '3DES168' default storage (encrypt);


If you don't use "using 'encryption_algorithm'" clause then
default algorithm (AES128) is used.

You can check if tablespace is encrypted from DBA_TABLESPACES view ENCRYPTED column.

Tablespace encryption will slow down DML and SQL operations but it
allows you to use indexes in all columns on it. If you encrypt only single column
in one table Oracle won't use index with that column. So in those cases
tablespace encryption is better than single column encryption.

Oracle 11 Password_life_time

It is good to remember that in Oracle 11 "Password_life_time" resource in default profile is 180 days. So if you create new user in Oracle 11 and do not set other profile to that user then this new user password will be expired in 180 days. Thought you can change this default profile setting like this:
SQL> ALTER PROFILE default LIMIT PASSWORD_LIFE_TIME UNLIMITED;
You can check all profile limits from here:
SQL> SELECT * FROM dba_profiles;

Remember also that when you create new database in Oracle 11 all it users get default profile by default. So they have Password_life_time 180 by default.

Oracle 11 passwords and upgrade

In Oracle 11 passwords are case sensitive by default. When you are upgrading older database to Oracle 11 password remains case-insensitive but if you change passwords they are starting to use case sensitivity.

You can check PASSWORD_VERSION column from DBA_USERS view. If users password version in there is lower than 11 then it is not case sensitive but if it is eleven or above then it is case sensitive by default. And if there is both 10g and 11g in column it points out that password assigned to user in 10g but then upgraded to 11g (case sensitive):
SQL> SELECT username, password_version FROM DBA_USERS;

If you want to take case sensitivity of you can do it with setting FALSE on "sec_case_sensitive_logon" parameter:
SQL> ALTER SYSTEM SET sec_case_sensitive_logon=false ;

Friday, February 15, 2013

ORA-12502 TNS:listener received no CONNECT_DATA from client on Oracle 11g RAC environment.

If you get "TNS-12502: TNS:listener received no CONNECT_DATA from client" errors in your listener.log or in your SCAN listener logs. Or some client connection gives "ORA - 12502 TNS:listener received no CONNECT_DATA from client" errors (check client sqlnet.log for these). Then you know there is some kind of connection problem going on.

There is troubleshooting guide for this kind of problems in MOS (My Oracle Support) (this advice to set sqlnet listener tracing on if errors are coming rarely.This way you can get more info about problematic connection (where it is coming etc.) But if these errors are coming frequently then it is not wise to set listener tracing on because you will get huge log file. If you get this error from multiple clients then your application probably provide invalid connection string.):
MOS document: [ID 453505.1]

If you have RAC environment you can also read following MOS (My Oracle Support) document (this help you to check that your remote and local listener settings are correct):
MOS document:[ID 453293.1]

If everything else looks to be ok then problem is probably in firewall/network settings. Check that you have opened both SCAN IPs and VIPs from client to server. If you open only SCAN IPs then you can get these errors because RAC uses internally also VIPs.



Oracle Critical Patch Updates (CPUs) are nowadays Security Patch Updates (SPUs).


Starting from October 2012 onwards Oracle's Critical Patch Updates (CPU) will be called Security Patch Updates (SPU). SPU patches are cumulative so the new SPU patch contains all previous patches. And you don't need to install previous CPU/SPU patches before installing new SPU. The patches will still be released as part of the overall Oracle Critical Patch Update (CPU) Program:
CPU/SPU patches in Oracle technet


NOTE! Window's Oracle installation have their own patches SPUs are not used in that environment.
More info about Oracle patch types:
My Oracle Support Document 1430923.1