How to change the Redo Log File size in Oracle Database

The Redo Logs must be dropped and recreated for changing the redo log size. It can be done online without shutting down the database. However, you need to make sure that the Redo Group being dropped should be INACTIVE when you do this.

To View the current satus:

select * from v$logfile;

select * from v$log;

 

We need to make active groups to Inactive before proceeding ahead:

alter system checkpoint;

It’s a basic requirement in Oracle Database that there should always be a minimum 2 Redo Log Groups available with the Database. Hence we can not drop any Redo Group if there are only 2 Groups. Drop inactive groups and recreate it:

alter database drop logfile group 1;

alter database add logfile group 1 ‘D:\APP\ADMINISTRATOR\ORADATA\ORCL11\RD01.LOG’ size 30M;

alter database drop logfile group 2;

alter database add logfile group 2 ‘D:\APP\ADMINISTRATOR\ORADATA\ORCL11\RD02.LOG’ size 30M;

Delete the dropped files  from File system also.

Now we have to drop the 3rd Redo Log Group. Before that, we need to change the status of this group:

alter system switch logfile;

Still the Grpoup is in Active status. Issue a checkpoint:

alter system checkpoint;

Drop inactive group and recreate it:

alter database drop logfile group 3;

alter database add logfile group 3 ‘D:\APP\ADMINISTRATOR\ORADATA\ORCL11\RD03.LOG’ size 30M;

Delete the dropped file  from File system also.

Then change the groups status to active:

alter system switch logfile;

Posted in DBA

ORA-02062: distributed recovery received

Oracle error something like

Errors in file /u01/app/oracle/diag/rdbms/dpdcapp/dpdcapp/trace/dpdcapp_reco_3513.trc:

ORA-02062: distributed recovery received DBID 10a13ece, expected 773f337a

Could be occurred if a transaction becomes in-doubt.

 

Oracle developed the two phase commit to allow the controlling SQL to ensure that all remote sites have committed their data before issuing a local commit. That is the two-phase commit mechanism ensures that all nodes either commit or perform a rollback together.

Distributed transactions can become in-doubt in the following ways:

  • A server machine running Oracle Database software crashes
  • A network connection between two or more Oracle Databases involved in distributed processing is disconnected
  • An unhandled software error occurs

 

Solution:

At first view all db links

select * from dba_db_links;

drop if any inconsistant dblink found

 

view anything is in-doubt:

SELECT COMMIT# ,LOCAL_TRAN_ID, STATE, MIXED, HOST, GLOBAL_TRAN_ID FROM DBA_2PC_PENDING;

The dba_2pc_neighbors view contains information about incoming and outgoing connections for pending transactions:

SELECT LOCAL_TRAN_ID, IN_OUT, DATABASE, INTERFACE FROM DBA_2PC_NEIGHBORS;

Then purge all LOCAL_TRAN_ID :

Execute DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY (‘ LOCAL_TRAN_ID ‘);

If error occurs then set internal Oracle parameter  _smu_debug_mode . Use it with the instruction of Oracle technical support:

alter system set  “_smu_debug_mode” = 4;

 

The background RECO process will try to resolve in-doubt transactions across Oracle distributed databases. Enable RECO:

ALTER SYSTEM DISABLE DISTRIBUTED RECOVERY;

ALTER SYSTEM ENABLE DISTRIBUTED RECOVERY;

Posted in DBA, ORA- Error

How to increase sessions, processes, transactions in Oracle 11g database

What are Sessions in Oracle database : Sessions specify the number of connections that can served by oracle database at a time. This is equivalent to the number of concurrent users of the application. If your application has a lot of concurrent users then you need to increase the sessions in the oracle database.
What are processes in Oracle database : Processes run in the background of Oracle database to maximize performance and accommodate many users.
What are transactions in Oracle database : A transaction is a logical, atomic unit of work that contains one or more SQL statements. A transaction groups SQL statements so that they are either all committed, which means they are applied to the database, or all rolled back, which means they are undone from the database
What is the relation between Sessions, transactions & processes : The Oracle Documentation states that TRANSACTIONS is derived from SESSIONS, which in turn is derived from PROCESSES, thus:

PROCESSES = Operating System Dependant

SESSIONS = (1.1 * PROCESSES) + 5

TRANSACTIONS = 1.1 * SESSIONS

 

For example, if processes are 100, then sessions will be 115 and transactions will be 127.

To alter the sessions,transactions, processes follow this procedure –
1. At command line, type sqlplus
2. For username give / as sysdba
3. Give the following commands –
alter system set sessions=400 scope=spfile;
alter system set processes=350 scope=spfile;
alter system set transactions=440 scope=spfile;

Give the values according to the requirement
4. After running these commands, you need to restart the Oracel instance, follow these commands
shutdown immediate;
startup;

5. After startup is complete run the following commands to see the updated values

select name, value
from v$spparameter
where name in (‘sessions’,’processes’,’transactions’);

 

 

Posted in Uncategorized

Oracle 11g : Login problem(ORA-01017 Invalid Username/Password) from older client

Oracle 11g is case sensitive. For that reason older version of oracle client failed to login and cause  ORA-01017 Invalid Username/Password error.

Solution 1: Use newer version of oracle client

Solution 2: Stop case sensitive option by

alter system set sec_case_sensitive_logon=FALSE scope=both;

Posted in DBA, ORA- Error

How to take Data Pump Backup from a remote database

Oracle Data Pump is a new and unique feature of Oracle Database 11g Release 2. A new public interface package, DBMS_DATAPUMP, provides a server-side infrastructure for fast data and metadata movement between Oracle databases. It is ideal for large databases and data warehousing environments, where high-performance data movement offers significant time savings to database administrators.

Data Pump automatically manages multiple, parallel streams of unload and load for maximum throughput. The degree of parallelism can be adjusted on-the-fly. There are new and easy-to-use Export and Import utilities (expdp and impdp), as well as a web-based Enterprise Manager export/import interface.

Data Pump Export and Import both support a network mode in which the job’s source is a remote Oracle instance. When you perform an import over the network, there are no dump files involved because the source is another database, not a dump file set.

When you perform an export over the network, the source can be a read-only database on another system. Dump files are written out on the local system just as they are with a local (non-networked) export.

 

In the following example, I am showing you step by step procedure to export(expdp) from a remote database:

 

Here in this example, source database is  Oracle 11g and  running on linux and there is another computer running on windows where you need to take backup of source database. At first install oracle 11g on windows machine. After installation of oracle, add source database’s network information to tnsnames.ora file as follows:

SOURCE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.20)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL)
)
)

Then create a folder where backup will be taken. For example D:\BACKUP

 

2. You have to create a user on source database(running on linux) to take export backup. You also have to grant appropriate permission to new user for taking backup as follows:

[oracle@testserver ~]$ sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Mon Aug 22 10:12:51 2016

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

Enter user-name: sys as sysdba
Enter password:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create user dpback identified by dpback;

SQL> grant connect, resource to dpback;

SQL> grant EXP_FULL_DATABASE to dpback;

SQL> GRANT CREATE ANY DIRECTORY TO dpback;

 

3. Login to your database(running on windows) as follows:                                                                                                                                                C:\Users\SUMAN>sqlplus

Enter user-name: sys as sysdba
Enter password:

Create a dblink to source database as follows:

SQL> CREATE PUBLIC DATABASE LINK SOURCE
CONNECT TO dpback
IDENTIFIED BY dpback
USING ‘SOURCE’;

You need to create a user to take expdp backup just like you did at your source database

SQL> create user dpback identified by dpback;

SQL> grant connect, resource to dpback;

SQL> grant EXP_FULL_DATABASE to dpback;

SQL> GRANT CREATE ANY DIRECTORY TO dpback;

 

4. Connect as dpback user

SQL> conn dpback
Enter password:
Connected.
SQL> create directory dp_dir as ‘D:\BACKUP’;

Directory created.

5. Now you can take expdp backup by running following command

C:\Users\SUMAN>expdp dpback/dpback directory=dp_dir full=Y dumpfile=full.dmp logfile=full.log network_link=SOURCE

Here network_link=SOURCE is important. SOURCE is the dblink name that I create at first.

You can add compression, parallel etc parameter for better performance. You can also create a batch file to automate backup as follows:

expdp dpback/dpback directory=dp_dir full=Y dumpfile=full_epayment%date:~-4%_%date:~4,2%_%date:~7,2%_%time:~0,2%_%time:~3,2%.dmp logfile=full_epayment%date:~-4%_%date:~4,2%_%date:~7,2%_%time:~0,2%_%time:~3,2%.log compression=all network_link=SOURCE

 

To import you can use following command:

impdp system/**** directory=dp_dir full=Y dumpfile=FULL_EPAYMENT.DMP logfile=imp_full_epayment.log EXCLUDE=SCHEMA:\”LIKE \’SYS%\’\”

Before executing impdp command, make sure that

1) IMP_FULL_DATABASE is granted to the import user

2) All the tablespaces of source database has been created.

 

 

 

Posted in Backup and Restore, DBA

How do you pass username/password to start Oracle WebLogic server in Unix

To start WebLogic just run start script as follows:

$ DOMAIN_HOME/startWebLogic.sh

But you need to enter username and password and if you close this terminal the service stops. Here I have discussed how to pass username and password to  startWebLogic.sh and how to run it at background process.

At first go to the directory “security” inside your <DOMAIN_ROOT>\servers\<SERVER_NAME>. If the directory security does not appear the create a directory named security under  <DOMAIN_ROOT>\servers\<SERVER_NAME>. For example

/u02/bip/user_projects/domains/bifoundation_domain/servers/AdminServer/security

then enter the directory

$ cd /u02/bip/user_projects/domains/bifoundation_domain/servers/AdminServer/security

create a file with exactly same name as “boot.properties”

$ vi  boot.properties

enter the following two lines inside the file

username=Administrator_username
password=Administrator_password

Assign this file executable permission

$ chmod 640 boot.properties

Now if you run startWebLogic.sh, you need not enter username and password.

Most of the time you login into remote server via ssh. If you start a shell script  and you exit (abort remote connection), the process  will get killed. It is better to leave job running in background. But, if you log out of the system, the job will be stopped and terminated by your shell. To solve this issue, use nohup command line-utility which allows to run  shell script that can continue running in the background after you log out from a shell as follows:

$ cd /u02/bip/user_projects/domains/bifoundation_domain

$ nohup ./startWebLogic.sh 1>logs/nohup.out 2>logs/error &

There is another way that you may add this script at crontab and it will start automatically at the server end as follows:

$ crontab -e

@reboot /bin/sleep 300 ; /u02/bip/user_projects/domains/bifoundation_domain/startWebLogic.sh

In this example web logic service starts just 5 minutes after reboot.

 

 

 

 

Posted in WebLogic Server

How to use Oracle Wallet

Oracle wallet is a secured external password store where the Oracle login credentials are stored in client-side. This allows scripts to contain connections using the “/@db_alias” syntax. It is often necessary to make connections to the database from shell scripts held on the filesystem. This can be a major security issue if these scripts contain the database connection details and oracle wallet is a good solution in that situation.  A configured Wallet consists of two files, cwallet.sso and ewallet.p12 stored in a secure Wallet directory. First, decide on the location of the Oracle wallet. In this example I will use the “/u01/app/oracle/product/wallet” directory.

At first create a directory by the following command

$ mkdir -p /u01/app/oracle/product/wallet

Then you need to create oracle wallet by the following command

$ mkstore -wrl /u01/app/oracle/product/wallet/ -create

You need to enter password that will be used for the management of oracle wallet.

 Add the following entries into the “sqlnet.ora” file

WALLET_LOCATION=

(SOURCE=

(METHOD=FILE)

(METHOD_DATA =

(DIRECTORY =/u01/app/oracle/product/wallet)

)

)
SQLNET.WALLET_OVERRIDE = TRUE

 

Then add the following lines to tnsnames.ora file

db_alias1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =hostname)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = servicename)
)
)

Add the password credentials  for system to the wallet by the following command

$ mkstore -wrl /u01/app/oracle/product/wallet/ -createCredential  db_alias1  system  system_password

Now connect database by the following command

$sqlplus /@db_alias1

SQL> show user
USER is "SYSTEM"

You can modify credentials by the following command 

$ mkstore -wrl /u01/app/oracle/product/wallet -modifyCredential db_alias1 user1 user1_password

You can view the credentials by the followint command

$ mkstore -wrl /u01/app/oracle/product/wallet -listCredential

That’s fine if you only ever connect as a single user to each database, but what if you connect as multiple users? Simply add a new entry into the wallet using a different db_alias and make sure the alias is present in the “tnsnames.ora” file. So if we have a user called “user2” on the “ORCL” database, we create a new entry in the wallet.

In tnsnames.ora

db_alias2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =hostname)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)

$ mkstore -wrl /u01/app/oracle/product/wallet/ -createCredential  db_alias2  user2  user2_password

You can also delete credentials by as follows

$ mkstore -wrl <wallet_location> -deleteCredential db_alias2

 

 

 

 

Posted in Security

A basic RMAN Backup

Hi

I am discussing here basic RMAN backup and the example shows the easiest way to complete RMAN backup.

Go to command prompt and type

rman target /

Now you are in RMAN prompt.

Execute show all to view the current configuration. At first the default configuration will be shown
RMAN> SHOW ALL;

Now you have to change the RMAN configuration according to your requirements.

Change the backup destination as follows:

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/backup/full_%u_%s_%p';

Change the retention policy and fix how many days you want to keep old backup for example 7 days.

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

Now execute show all to view the changes.

To take a full backup database and archive logs execute the following:
RMAN> BACKUP AS BACKUPSET DATABASE PLUS ARCHIVELOG;

Now your backup is done.



 

 

 

Tagged with:
Posted in Backup and Restore

how to make database archiving log mode

At first set the archiving log destination as follows:

> alter system set log_archive_dest=’E:\archive’ scope=spfile;

Then restart the database to make it effective and see spfile about the changes.

To make the database in archiving mode follow the steps below

step1.  SQL> shutdown immediate

step2. SQL> startup mount

step3. SQL> alter database archivelog;

step4. SQL>alter database open;

 

Now your database is in archiving mode. There are some views to query about archiving.

V$DATABASE
Identifies whether the database is in ARCHIVELOG or NOARCHIVELOG mode and whether MANUAL (archiving mode) has been specified.
V$ARCHIVED_LOG
Displays historical archived log information from the control file. If you use a recovery catalog, the RC_ARCHIVED_LOG view contains similar information.
V$ARCHIVE_DEST
Describes the current instance, all archive destinations, and the current value, mode, and status of these destinations.
V$ARCHIVE_PROCESSES
Displays information about the state of the various archive processes for an instance.
V$BACKUP_REDOLOG
Contains information about any backups of archived logs. If you use a recovery catalog, the RC_BACKUP_REDOLOG contains similar information.
V$LOG
Displays all redo log groups for the database and indicates which need to be archived.
V$LOG_HISTORY
Contains log history information such as which logs have been archived and the SCN range for each archived log.

 

 

Posted in Backup and Restore

Dynamic Action in APEX Tabular form

Dynamic action allow to make things happen in the user’s browser without sending messages back and forth to the server. Here is an example how you can use it in tabular form. At first take a look at the example

http://apex.oracle.com/pls/apex/f?p=1968:9

login as  suman/suman1

Here is three fields  Select,Data and Description. When you select No then data field will be disabled. I am going to show you how to do that with dynamic action. In most cases, you need to save data through custom process. So I saved this tabular data through custom process.

Lets start, first create a tabular form and run it. Then you have to find out html element name. In firefox I use firebug to do so.firebug

Here the name of select field is f03 and Data is f04. I have to disable the appropriate id of f04 according to the value of f03.Now create a dynamic action, set Event Change selection type jQuery Selector. jQuery Selector should be like select[name=’f03′]. In action field set Execute JavaScript Code and code should should be like below

var el = this.triggeringElement.id;
var row = el.split(“_”)[1];
if ($v(el) == “N”) {
// disable the field
$x_disableItem(“f04_” + row, true);
}
else {
// enable the field
$x_disableItem(“f04_” + row, false);
}

Make sure Selection type is Triggering Element. Dynamic action is created, run the page and check. Hope this works. It looks complete but still a little work to do. Because when you save data, disabled items value will not be saved. So you have to enable all the possible disable fields enable. You can do that through another dynamic action. So create new dynamic action like below code

apex.jQuery(‘[name=”f04″]’).each(
function(){
$x_disableItem(this.id, false);
}
);

Set Event Before Page Submit. Now data will be saved according to our target. If you think to save data through custom process then create a process On Submit and write code as below

begin
FOR i IN 1 .. APEX_APPLICATION.g_f03.COUNT
LOOP

insert into TEST_TABULAR
(
ID,
SLCT,
DATA,
DESCRIP
)
values(
TEST_TABULAR_SEQ.NEXTVAL,
APEX_APPLICATION.g_f03(i),
APEX_APPLICATION.g_f04(i),
APEX_APPLICATION.g_f05(i)
);
END LOOP;

commit;
end;

Now our target page is completed. Thank you for reading.

Posted in APEX
Create your own website, free on WordPress.com.Create your own website.
Start free