In Oracle file structure, there is one type of file called redo log file, which record down all the transactions done to the database. There will be a finite number of redo log files, which will keep on reusing the files in a Mary Go Round way. As the database is enabled with archived log, the redo log file will be duplicated into a copy of archived log before it is being reused.
Aside from recovering purpose, archived log can also be served as a transaction tracking material. However the log itself is in binary form, which we need a utility called LogMiner to decode the log file.
- Before you can use LogMiner you need to install the package by executing the following SQL file as SYS user:
- Then grant necessary privilege to user who can execute LogMiner package (Let’s say user James):
grant execute_catalog_role to james;
- Then create synonym for the LogMiner package:
create public synonym dbms_logmnr for sys.dbms_logmnr;
- You can query the list of archived log:
SELECT distinct member LOGFILENAME FROM V$LOGFILE;
There is 2 ways to read the archived log, one is to read the archived log at the database with the archived log, or move the archived log to another database and read it there. To read the log at the same database:
- Check where is your archived log placed (you may check it from the parameter file
log_archive_dest). Assume that it is
/u01/db/archive and the log you want to encode is
- Run statement below to add the archived log to the dictionary:
- Then run statement below to start the LogMiner:
exec DBMS_LOGMNR.START_LOGMNR(options => dbms_logmnr.dict_from_online_catalog);
To read the log at a different database:
- Move the archived logs to another database server (let’s say you placed in at
- Run statement below to build a data dictionary for the archived log (you can change the file and directory):
- The run statement below to add the log file into the dictionary:
- Start the LogMiner:
exec DBMS_LOGMNR.START_LOGMNR(dictfilename => '/u01/temp/logmnr.dat');
Either way, you can query the log content through this view
v$logmnr_contents. However the data in the view will be wiped off after you close the session, which mean you need to add the log file and start the LogMiner again in order to get back the data. Some useful columns include:
- username: database user used
- timestamp: when it is happened
- sql_redo: SQL statement of what actually been done
- sql_undo: SQL statement to undo the transaction
- scn: system change number, the unique id of this transaction
- seg_type_name: object type
- table_space: from which tablespace
- seg_owner: object owner
- table_name: table name
- operation: update, insert, delete, commit or rollback
- session_info: include info such as from which machine
After we setup the Backup Strategy, we need to prepare for recovering. Basically it involves 2 major steps: restore and recover.
Restore database simply means uncompress (such as UNTAR) the full backup from the backup tape:
- Uncompressed the full backup from tape (assume the tape is known as
tar xvf /dev/st0
- Don’t try to start the database first before you finish the next step, recovering database.
Different between restore and recover is that: restore is directly extracted from a backup, while recover is rebuilding data of an outdated database (such as from a full backup) to a status of particular moment.
- Remove all the archived log in the archived log directory (assume it is
rm -fv /u01/oracle/archive/*
- Uncompressed the daily backup (which is the archived log) .
tar xvf /dev/st0
- Start SQLPLUS as SYSDBA.
sqlplus / as sysdba
- Start database in mount mode
- In case you have problem in startup the database because of the parameter file is not set, issue the command below and try again:
create spfile from pfile = 'dest_of_your_parameter_file';
- Then issue command below to start recover from archived log:
recover database using backup controlfile until cancel
- It will keep asking for your comfirmation on the name of the archived log to be recovered. Either press Enter, the location of the archived log, or key in cancel to stop the recover.
- After recover open the database by issuing command below, aware that you won’t able the continue recover the archived log after issue this command, or else you need to start all over again from restoring database:
alter database open resetlogs;
- In case you face problem in open the database, add
_allow_resetlogs_corruption=true to the parameter file, issue command below and try again.
create sp file from pfile = '
Below is a backup strategy of Oracle Database with the conditions:
- The database is Archived Log Enabled.
- The database can be shutdown during weekend.
Archived log records down all the transactions that be performed in the database, which can serve as backup or trace log. It can even be backup when the database is up (hot backup). This strategy is using Linux environment, but you may apply the method to other OS. It involves 2 parts: daily backup (the hot backup) and weekend backup (or full backup, cold backup):
Daily Backup: AKA hot backup, which the backup is performed when database is up.
- This will be performed every night of weekday.
- Identify where is your archived log placed (refer to
log_archive_dest parameter in the parameter file).
- Set CRON job to TAR all the archived log into Tape (assume
/dev/st0 is your tape drive and
/u01/oracle/archive is your archive log directory):
tar cvf /dev/st0 /u01/oracle/archive
- You may check the status of the Tape using command below:
Try to install
mt-st package in case the command is not installed.
- To verify the content of the tape and save it as a log by using command below:
tar tvf /dev/st0 > dailybackup.log
Weekend Backup: AKA cold backup because it is performed when the database is shutdown.
- This will be performed during weekend.
- Shutdown the database (command might be different depend on your Oracle Environment Setting).
service dbora stop
- TAR the whole database directory (assume
/u01/oracle is where your database placed).
tar cvf /dev/st0 /u01/oracle
- Verify the tape and save it as log.
tar tvf /dev/st0 > fullbackup.log
- Remove the archived log (or the archived log will getting more and more until take out all your spaces).
rm -fv /u01/oracle/archive/*
- Start the database.
service dbora start
Continue to Recover Strategy.
URL Query String is the string append to the web page URL. For example http://www.google.com/search?q=url+query+string, the string after the question mark (?) is the query string.
Most of the surfers will not care about the URL, which they consider them as alien language. However it would be nice if the URL can be translated into something more friendly to surfers, and most important to the search engine.
If your web server is Apache, you might follow the steps below to rewrite the URL (assume the folder of your website is webdir inside your document root):
- Enable the rewrite module in Apache. To do this, you need to edit the configuration file conf\httpd.conf.
- Find the following line and uncomment it.
LoadModule rewrite_module modules/mod_rewrite.so
- In some scenario, you need to set the AllowOverride parameter to All as well.
<Directory "document roots">
- Then restart the server.
- Create a file called .htaccess at webdir.
- Add the following coding or sample to .htaccess.
RewriteRule index.html$ index.php [NC]
RewriteRule index/([^/]+)$ index.php?a=$1 [NC]
RewriteRule index/([^/]+)/([^/]+)$ index.php?a=$1&b=$2 [NC]
Now when you type:
- index.html, it will translate to index.php
- index/category, it will translate to index.php?a=category
- index/cateogory/linux, it will translate to index.php?a=category&b=linux
Steps to setup VNC Server at Linux:
- Install VNC Server (the name of the program might be different):
- Fedora (RPM):
yum install vnc-server
- Ubuntu (DEB):
sudo apt-get install vnc4server
- After install, start VNC Server(it will ask you to enter a password):
- Then stop VNC Server:
vncserver -kill :1
~/.vnc/xstartup (it will not appear if you didn’t start VNC Server once). Uncomment the following 2 lines to enable the Windows X in VNC Server (the lines might be different):
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
- Start again VNC Server:
- In another machine, use your favorite VNC Client Program to access VNC Server:
Display is the number after the colon you set at VNC Server. For example: