lunes, 8 de septiembre de 2014

Enable Oracle ARCHIVELOG mode


What is Oracle's ArchiveLog mode






Oracle writes to online rebuild log files (redo log online) in a cyclic manner, Oracle saves all the transactions that are being performed in these redo log files online. It starts writing to the first redo log file online, when it fills it passes to the second, and so on until the last redo log file online, when it fills the last one it initiates a process in the background called LGWR (Log Writer) to overwrite The contents of the first redo log file online and start over. When Oracle runs in ARCHIVELOG mode the background process called ARCH makes a copy of each redo log file online once the LGWR process finishes writing to it, it saves that copy to the offline rebuild files (redo log Offline) to disk:



Before proceeding, we can see whether or not the Archive mode is active with the command SQL> ARCHIVE LOG LIST from SqlPlus.


Define the path where the copy of the Redo Logs will be created

We have to define the path in the parameter log_archive_dest_1 as follows from SqlPlus with the user sys:

SQL> ALTER SYSTEM SET log_archive_dest_1='LOCATION=/U/oradata/PRUEBA/archive' SCOPE=SPFILE;



Format the name of the files to back up

For this we use the parameter log_archive_format as shown below from SqlPlus with the user sys:

SQL> ALTER SYSTEM SET log_archive_format='PRUEBA_%s.arc' SCOPE=SPFILE

Where TEST is the name of the database,% s is the log sequence number and arc is the extension that indicates that it is an archive (archived)

To enable ArchiveLog mode (as a DBA user)

  1. You need to shut down the SQL database> SHUTDOWN IMMEDIATE ;
  2. After that it is mounted under SQL> STARTUP MOUNT ;
  3. We execute the following SQL command> ALTER DATABASE ARCHIVELOG ;
  4. Finally we open the SQL database> ALTER DATABASE OPEN ;
Note: If we want to deactivate the ArchiveLog mode we do the same steps as above but only change step 3 by the  SQL> ALTER DATABASE NOARCHIVELOG;

sábado, 31 de mayo de 2014

Environment Variables Needed to StartOracle (Linux)

To be able to start the listener, upload the database and Enterprise manage, also known as EM; We have to set the following variables in our console every time we log in, we can also configure them in the ~ / .bash_profile file of the Oracle user (see how to do this).

The first variable is ORACLE_HOME this will have the path that they defined in the installation of the database, for example the home of my database is '/oracle/app/oracle/product/11.2.0/db_1' then in my case The commands that I have to execute as an Oracle user will be:

set ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db_1
export ORACLE_HOME

The second variable is ORACLE_SID this will have the sid of the database which is also specified when we installed it, it is usually the same name of the database.
If you do not know the SID execute this command as root: 'ps -ef | Grep -i pmon 'and you'll see something like this' oracle 27161 1 0 Mar07? 00:03:53 ora_pmon_ora11g 'where ora11g is the SID.
In my case the SID is 'ora11g' then the commands that I have to execute as an Oracle user to define the variable would be:

set ORACLE_SID=ora11g
export ORACLE_SID

Only one time set up the ORACLE_HOME, ORACLE_SID, and ORACLE_BASE variables (Linux)

To configure our environment variables only once, we have to edit a file called bash_profile, with the Oracle user.
In the file we have to add three ORACLE_BASE variables which is the path where our oracle is, ORACLE_HOME which is the home path of the database and lastly ORACLE_SID which is the sid ne our database.
In my case the ORACLE_BASE is '/ oracle / app / oracle', the ORACLE_HOME is '/oracle/app/oracle/product/11.2.0/db_1' and the ORACLE_SID is 'ora11g'.
To edit the file we run:
Vi ~ / .bash_profile
To add the variables we go to the end of the file and press the insert key, next we add the variables that in my case would be:
 
ORACLE_BASE=/oracle/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=ora11g; export ORACLE_SID

And finally to save the file we press the escape key and type ': wq' we press enter and then we proceed to restart the machine.