Thursday, July 4, 2013

Difference Between Unix and Linux

Unix
UNIX is copyrighted name only big companies are allowed to use the UNIX copyright and name, so IBM AIX and Sun Solaris and HP-UX all are UNIX operating systems.

Linux is Unix like OS
Linux is a clone of Unix. So, it can be considered as UNIX.

Linux Is Just a Kernel
Linux is just a kernel. All Linux distributions includes GUI system + GNU utilities. Linux distribution makes it complete usable operating systems by adding various applications.
However, most UNIX operating systems are considered as a complete operating system as everything come from a single source or vendor. Most UNIX operating systems comes with A-Z programs such as editor, compilers etc.

License and cost
Linux is Free. It is freely available in the market or can be downloaded from the Internet or redistribute it under GNU licenses. Most UNIX like operating systems are not free. They are vendor specific, costly and cann’t be redistributed.

Vendor Specific Unix OS
HP-UX
IBM AIX
Sun Solairs
Mac OS X
IRIX

Linux Distribution OS
Redhat Enterprise Linux
Fedora Linux
Debian Linux
Suse Enterprise Linux
Ubuntu Linux


Basics of Data Guard

Standby Database
A standby database is a transactionally consistent copy of an Oracle production database that is initially created from a backup copy of the primary database.

There are two types of Standby database
Physical Standby and
Logical Standby.

Physical Standby Database
A physical standby database is physically identical to the primary database, with on disk database structures that are identical to the primary database on a block-for-block basis. The database schema, including indexes, are identical. Data Guard maintains a physical standby database by performing Redo Apply.
Redo Apply-The physical standby database is maintained by applying redo data from the archived redo log files or directly from standby redo log files on the standby system using the Oracle recovery mechanism.
Open read-only
A physical standby database can be open in read-only mode so that you can execute queries on the database. While opened in read-only mode, the standby database can continue to receive redo data, but application of the redo data from the log files is deferred until the database resumes Redo Apply.
Open read/write
A physical standby database can also be opened for read/write access for purposes such as creating a clone database or for read/write reporting. While opened in read/write mode, the standby database does not receive redo data from the primary database and cannot provide disaster protection.

Benefits of Physical Standby Database
# Disaster recovery and high availability- A physical standby database enables a robust and efficient disaster recovery and high availability solution. Easy-to-manage switchover and failover capabilities.
# Data protection- Using a physical standby database, Data Guard can ensure no data loss, even in
the face of unforeseen disasters.
# Reduction in primary database workload-Oracle Recovery Manager (RMAN) can use physical standby databases to off-load backups from the primary database saving valuable CPU and I/O cycles.
# Performance- The Redo Apply technology used by the physical standby database applies changes using low-level recovery mechanisms, which bypass all SQL level code layers; therefore, it is the most efficient mechanism for applying high volumes of redo data.

Logical Standby Databases
A logical standby database is initially created as an identical copy of the primary database, but it later can be altered to have a different structure. The logical standby database is updated by executing SQL statements. This allows users to access the standby database for queries and reporting at any time.

Benefits of a Logical Standby Database
# Efficient use of standby hardware resources
# Reduction in primary database workload

Data Guard Operational Prerequisites
Hardware and Operating System Requirements
# All members of a Data Guard configuration must run an Oracle image that is built for the same platform.
#The hardware (for example, the number of CPUs, memory size, storage configuration) can be different between the primary and standby systems.
# The operating system running on the primary and standby locations must be the same, but the operating system release does not need to be the same. In addition, the standby database can use a different directory structure from the primary database.

Oracle Software Requirements
# Oracle Data Guard is available only as a feature of Oracle Database Enterprise Edition. It is not available with Oracle Database Standard Edition. This means the same release of Oracle Database Enterprise Edition must be installed on the primary database and all standby databases in a Data Guard configuration.
# The COMPATIBLE initialization parameter must be set to the same value on all
databases in a Data Guard configuration.
# The primary database must run in ARCHIVELOG mode
# The primary database can be a single instance database or a multi-instance Real Application Clusters database. The standby databases can be single instance databases or multi-instance Real Application Clusters (RAC) databases, and these standby databases can be a mix of both physical and logical types.
# Each primary database and standby database must have its own control file.
# If a standby database is located on the same system as the primary database, the archival directories for the standby database must use a different directory structure than the primary database.
# To protect against unlogged direct writes in the primary database that cannot be propagated to the standby database, turn on FORCE LOGGING at the primary database before performing datafile backups for standby creation. Keep the database in FORCE LOGGING mode as long as the standby database is required.
# The user accounts you use to manage the primary and standby database instances must have SYSDBA system privileges.
# Oracle recommends that when you set up Oracle Automatic Storage Management (ASM) and Oracle Managed Files (OMF) in a Data Guard configuration, set it up symmetrically on the primary and standby database.


Basics of Data Guard

Data Guard
An application-transparent high performance low impact online Redo or SQL level background standby database transaction exchange utility capable of reporting, switchover and Failover. Data Guard is a disaster recovery solution for Oracle database. It protects Oracle database against primary site failures, disasters, errors and data corruption. Data Guard can switch any standby database to the production role, minimizing the downtime associated with the outage.

# It helps to take the data and automatically puts it somewhere.
# It makes available for Failover in case of failure.
# It also enable switchover for maintenance
# Helps in reporting
# Backups

Data Guard Configuration
A Data Guard configuration consists of one production database and one or more standby databases. The databases in a Data Guard configuration are connected by Oracle Net and may be dispersed geographically.

Primary Database- A Data Guard configuration contains one production database, also referred to as the primary database, that functions in the primary role. This is the database that is accessed by most of your applications. The primary database can be either a single-instance Oracle database or an Oracle Real Application Clusters database.

Standby Database- A standby database is a transactionally consistent copy of the primary database. Using a backup copy of the primary database, you can create up to nine standby databases and  incorporate them in a Data Guard configuration. Once created, Data Guard automatically maintains each standby database by transmitting redo data from the primary database and then applying the redo to the standby database.

Physical standby database- Provides a physically identical copy of the primary database, with on disk database structures that are identical to the primary database on a block-for-block basis. A physical standby database is kept synchronized with the primary database, though Redo Apply which recovers the redo data received from the primary database and applies the redo to the physical standby database

Logical standby database- Contains the same logical information as the production database, although the physical organization and structure of the data can be different. The logical standby database is kept synchronized with the primary database though SQL Apply, which transforms the data in the redo received from the primary database into SQL statements and then executing the SQL statements on the standby database.

Data Guard Services
There are three types of Data Guard Services as follows:

Redo Transport Services-Control the automated transfer of redo data from the production database to one or more archival destinations.

Log Apply Services-Apply redo data on the standby database to maintain transactional synchronization with the primary database. Redo data can be applied either from archived redo log files, or, if real-time apply is enabled, directly from the standby redo log files as they are being filled, without requiring the redo data to be archived first at the standby database.

Role Transitions- Change the role of a database from a standby database to a primary database, or
from a primary database to a standby database using either a switchover or a failover operation.
A switchover is a role reversal between the primary database and one of its standby databases. A switchover ensures no data loss.
A failover is when the primary database is unavailable. Failover is performed only in the event of a catastrophic failure of the primary database, and the failover results in a transition of a standby database to the primary role.

Data Guard Broker
The Data Guard broker is a distributed management framework that automates the creation, maintenance, and monitoring of Data Guard configurations.
Manager graphical user interface (GUI) or the Data Guard command-line interface (DGMGRL) are used for the configuration of Data Guard.

Data Guard Protection Modes
There are three types of Data Guard Protection Modes-
Maximum protection-This protection mode ensures that no data loss will occur if the primary database fails. To provide this level of protection, the redo data needed to recover each transaction must be written to both the local online redo log and to the standby redo log on at least one standby database before the transaction commits. To ensure data loss cannot occur, the primary database shuts down if a fault prevents it from writing its redo stream to the standby redo log of at least one transactionally consistent standby database.
Maximum availability-This protection mode provides the highest level of data protection that is possible without compromising the availability of the primary database. Like maximum protection mode, a transaction will not commit until the redo needed to recover that transaction is written to the local online redo log and to the standby redo log of at least one transactionally consistent standby database. Unlike maximum protection mode, the primary database does not shut down if a fault
prevents it from writing its redo stream to a remote standby redo log. Instead, the primary database operates in maximum performance mode until the fault is corrected, and all gaps in redo log files are resolved. When all gaps are resolved, the primary database automatically resumes operating in maximum availability mode.
Maximum performance- This protection mode (the default) provides the highest level of data protection that is possible without affecting the performance of the primary database. This is accomplished by allowing a transaction to commit as soon as the redo data needed to recover that transaction is written to the local online redo log. The primary database’s redo data stream is also written to at least one standby database, but that redo stream is written asynchronously with respect to the transactions that create the redo data.

Data Guard Benefits-
Disaster recovery, data protection, and high availability
Data Guard provides an efficient and comprehensive disaster recovery and high availability solution. Easy-to-manage switchover and failover capabilities allow role reversals between primary and standby databases, minimizing the downtime of the primary database for planned and unplanned outages.

Complete data protection
Data Guard can ensure no data loss, even in the face of unforeseen disasters. A standby database provides a safeguard against data corruption and user errors. Storage level physical corruptions on the primary database do not propagate to the standby database. Similarly, logical corruptions or user errors that cause the primary database to be permanently damaged can be resolved. Finally, the redo
data is validated when it is applied to the standby database.

Efficient use of system resources
The standby database tables that are updated with redo data received from the primary database can be used for other tasks such as backups, reporting, summations, and queries, thereby reducing the primary database workload necessary to perform these tasks, saving valuable CPU and I/O cycles.
A logical standby database can remain open while the tables are updated from the primary database,
and the tables are simultaneously available for read-only access.

Automatic gap detection and resolution
If connectivity is lost between the primary and one or more standby databases (for example, due to network problems), redo data being generated on the primary database cannot be sent to those standby databases. Once a connection is reestablished, the missing archived redo log files (referred to as a gap) are automatically detected by Data Guard, which then automatically transmits the missing archived redo log files to the standby databases. The standby databases are synchronized with the primary database, without manual intervention by the DBA.

Automatic role transitions
When fast-start failover is enabled, the Data Guard broker automatically fails over to a synchronized standby site in the event of a disaster at the primary site, requiring no intervention by the DBA. In addition, applications are automatically notified of the role transition.



Frequently Use Unix Commands

List Command: ls
The ls command shows a list of files in the present directory.
For example:
[oracle@localhost ~]$  ls
Desktop  oraInventory  Screenshot.png

If the ls commands is use with  -l option it would help to get more information about the listed files.
For example:
[oracle@localhost ~]$  ls -l
total 148
drwxr-xr-x    2  oracle  oinstall   4096     Jun 30 09:35  Desktop
drwxrwx---   6  oracle  oinstall   4096     Jun 30 09:45   oraInventory
-rw-r--r--      1  oracle  oinstall 128924   Jul  1 00:18    Screenshot.png

First Column: represents file type and permission given on the file. Below is the description of all type of files.
Second Column: represents the number of memory blocks taken by the file or directory.
Third Column: represents owner of the file. This is the Unix user who created this file.
Fourth Column: represents group of the owner. Every Unix user would have an associated group.
Fifth Column: represents file size in bytes.
Sixth Column: represents date and time when this file was created or modified last time.
Seventh Column: represents file or directory name.

Unix Meta Characters
Meta characters have special meaning in Unix. For example * and ? are meta characters. We use
* to match 0 or more characters, a question mark ? matches with single character.
For example:
[oracle@localhost dbs]$  ls *.ora
initdw.ora  init.ora  spfileorcl.ora

Unix Hidden Files
An invisible file is one whose first character is the dot or period character (.). UNIX programs
(including the shell) use most of these files to store configuration information.

Creating and Editing Files
Vi editor:
It is use to create or edit ordinary files on any Unix system.
[oracle@localhost ~]$ vi filename

After this press i for editing the file. For saving the file press Esc then Shift+: and wq!. Exit saving the file.

Display Content of a File
Cat Command:
It is use to see the content of a file.
[oracle@localhost ~]$ cat filename

The above command will display the contents of the filename file.

Copying Files
Cp Command: It is use to make a copy of a file. The basic syntax of the command is:
[oracle@localhost ~]$  cp source_file destination_file

The above command copy the contents of source_file to the destination_file

Renaming or Moving File
mv command: To change the name of a file use the mv command. Its basic syntax is:
[oracle@localhost ~]$  mv old_file new_file

Following is the example which would rename existing file filename to newfile:
[oracle@localhost ~]$  mv filename newfile

Deleting Files:
Rm command: To delete an existing file use the rm command. Its basic syntax is:
[oracle@localhost ~]$ rm filename

You can remove multiple files at a tile as follows:
[oracle@localhost ~]$ rm  filename1  filename2  filename3


Basics of Unix/Linux



What is Unix ?
The UNIX operating system is a set of programs that act as a link between the computer and the user.

The computer programs that allocate the system resources and coordinate all the details of the computer's internals is called the operating system or kernel.

Users communicate with the kernel through a program known as the shell. The shell is a
command line interpreter; it translates commands entered by the user and converts them into a
language that is understood by the kernel.

# Unix was originally developed  in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas McIlroy, and Joe Ossanna.

# There are various Unix variants available in the market. Solaris Unix, IBM-AIX, HP-UX unix.

# UNIX is called multitasking a user can run multiple programs at the same time.

# UNIX is called a multiuser system because several users can access at the same time.

What is Linux ?
Linux is an operating system that was first created at the University of Helsinki in Finland by a
young student named Linus Torvalds. At this time the student was working on a UNIX system that
was running on an expensive platform. Because of his low budget, and his need to work at home,
he decided to create a copy of the UNIX system in order to run it on a less expensive platform,
such as an IBM PC.

The Linux operating system is developed under the GNU General Public License (also known as
GNU GPL) and its source code is freely available to everyone who downloads it via the Internet.
The CD-ROM version of Linux is also available in many stores, and companies that provide it will
charge you for the cost of the media and support. Linux may be used for a wide variety of
purposes including networking, software development, and as an end-user platform. Linux is
often considered an excellent, low-cost alternative to other more expensive operating systems
because you can install it on multiple computers without paying more.

Advantages of Linux
# There are no royalty or licensing fees for using Linux, and the source code can be modified to fit
your needs. The results can be sold for profit, but original authors retain copyright and you must
provide the source to your modifications.

# Because it comes with source code to the kernel, it is quite portable. Linux runs on more CPUs
and platforms than any other computer operating system.

#The recent direction of the software and hardware industry is to push consumers to purchase
faster computers with more system memory and hard drive storage. Linux systems are not
affected by those industries’ orientation because of it capacity to run on any kind of computers,
even aging x486-based computers with limited amounts of RAM.

# Linux is a true multi-tasking operating system similar to his brother UNIX. That means that if a
program crashes you can kill it and continue working with confidence.

#Another benefit is that Linux is practically immunized against all kinds of viruses that we find in
other operating systems. To date we have found only two viruses that were effective on Linux
systems.

Unix Components
Kernel
The computer programs that allocate the system resources and coordinate all the details of the computer's internals is called the operating system or kernel.

Cell
Users communicate with the kernel through a program known as the shell. The shell is a command line interpreter; it translates commands entered by the user and converts them into a language that is understood by the kernel. C Shell, Bourne Shell and Korn Shell are most famous shells which are available with most of the Unix variants.

Commands and Utilities
There are various command and utilities which you would use in your day to day activities.  cp, mv, cat  and  grep  etc. are few examples of commands and utilities. There are over 250 standard commands plus numerous others provided through 3rd party software. All the commands come along with various optional options.

Files and Directories
All data in UNIX is organized into files. All files are organized into directories. These directories are organized into a tree-like structure called the file system.

File Management in Unix
All data in UNIX is organized into files. All files are organized into directories. These directories
are organized into a tree-like structure called the file system.
Thare are three basic types of files in unix
Ordinary  Files
An ordinary file is a file on the system that contains data, text, or program instructions. In this tutorial, you look at working with ordinary files.
Directories
Directories store both special and ordinary files. For users familiar with Windows or Mac OS, UNIX directories are equivalent to folders.
Special Files
Some special files provide access to hardware such as hard drives, CD-ROM drives, modems, and Ethernet adapters. Other special files are similar to aliases or shortcuts and enable you to access a single file using different names.