Synchronization of primary and standby database due to log transfer gap. [ID 150214.1] Modified 06-MAY-2009 Type BULLETIN Status PUBLISHED
PURPOSE -------
The purpose of this document is; a) How to verify whether there is a gap in the log transfer from the primary to the standby database. b) How to solve this problem.
The problem is that the primary and standby database are not able to operate in managed recovery mode while the setup followed the Oracle reference manuals.
The cause is a gap in archives produced by primary database, the standby database is waiting for these archive logs. It may be necessary to synchronize the primary and standby database.
SCOPE & APPLICATION ------------------- 1. Detection of the log gap primary and standby database.
a) Use a sql statement. b) Check the alert files. c) Check for fal server process. d) Checking archive destinations.
2. Synchronize the primary and standby database.
a) Make the missing archives available for the standby database. b) Recover the standby database automatic.
3. Check the log gap primary and standby database is solved.
a) Use a sql statement. b) Check the alert files.
After correcting the log gap problem place the standby database in sustained managed recovery mode as in Note:120855.1.
1. Detection of the log gap primary and standby database.
a) Using a sql statement. -----------------------
To find out which logs have not been received by this standby destination, issue the following query at the primary database:
SQL> SELECT local.thread#, local.sequence# from (select thread#, sequence# from v$archived_log where dest_id=1) local where local.sequence# not in (select sequence# from v$archived_log where dest_id=2 and thread# = local.thread#);
THREAD# SEQUENCE# ---------- ---------- 1 521 1 522 1 523 1 524 1 525 Another possible statement to check this is (at the standby database): SELECT thread#, low_sequence#, high_sequence# from V$archive_gap;
Note: the sql statements give additional information (confirmation) of information of alert files. If these sql statements return rows it doesn't necessarily mean ther's an actual gap! Always check the alert files as in 1b.
b) Check the alert files. -------------------------
Alert file primary database:
Thu Jun 21 13:23:13 2001 ARC0: Beginning to archive log 1 thread 1 sequence 525 ARC0: Warning; LGWR is actively archiving destination LOG_ARCHIVE_DEST_2 ARC0: Transmitting activation ID 680595809 (28911161) ARC0: Error 12541 connecting to standby host 'ssym_nlsu22.world' ARC0: Error 12541 Creating archive log file to 'ssym_nlsu22.world' ARC0: Completed archiving log 1 thread 1 sequence 525 Thu Jun 21 13:40:21 2001 Thread 1 advanced to log sequence 527 Current log# 1 seq# 527 mem# 0: /ots0/app/oracle/product/9.0.1/dbs/sroo/LOG1Oa Current log# 1 seq# 527 mem# 1: /ots0/app/oracle/product/9.0.1/dbs/sroo/LOG2Oa Thu Jun 21 13:40:21 2001 ARC0: Beginning to archive log 2 thread 1 sequence 526 ARC0: Warning; LGWR is actively archiving destination LOG_ARCHIVE_DEST_2 ARC0: Transmitting activation ID 680595809 (28911161) ARC0: Completed archiving log 2 thread 1 sequence 526
Alert file standby:
$ tail -50 alert_ssy*|more
Thu Jun 21 13:34:53 2001 Media Recovery Start: Managed Standby Recovery Successfully started datafile 1 media recovery Datafile #1: '/ots0/app/oracle/product/9.0.1/dbs/sroo/backup/system09.dbf' Media Recovery Log Media Recovery Waiting for thread 1 seq# 522 Thu Jun 21 13:40:23 2001 Fetching gap sequence for thread 1, gap sequence 522-525 Trying FAL server: Error fetching gap sequence, no FAL server specified Thu Jun 21 13:40:38 2001 Failed to request gap sequence. Thread #: 1, gap sequence: 522-525 All FAL server has been attempted.
c) Fal server process. -------------------
A Fal server process is an Oracle server process running on the primary database servicing fal request from a fal client. An example of a request of a client are queueing requests to send archived redologfiles from a primary database to one or more standby databases.
Checking the archive destination of the primary database:
/home/server/sroo/test $ ls arch_1_521.arc arch_1_523.arc arch_1_525.arc arch_1_522.arc arch_1_524.arc arch_1_526.arc testsroo/
Checking the archive destination of the standby database:
/home/server/sroo/test/testsroo $ ls arch_1_526.arc
2 Synchronize the primary and standby database. ---------------------------------------------
a) Make the missing archives available for the standby database. -------------------------------------------------------------
=>Copy and register (if necessary) the missing archives from the gap to a location that can be reached by the standby database that is the standby_archive_dest.
SQL> alter database register logfile '/home/server/sroo/test/testsroo/arch_1_521.arc';
b) Recover the standby database automatic. ---------------------------------------
Cancel the managed recovery (check Note:120855.1):
after cancel the standby recovery session shows: SQL> recover managed standby database; ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below ORA-01152: file 1 was not restored from a sufficiently old backup ORA-01110: data file 1: '/ots0/app/oracle/product/9.0.0/dbs/sroo/backup/system09.dbf' ORA-16037: user requested cancel of managed recovery operation
Then recover the standby database:
SQL> recover automatic standby database; ORA-00279: change 61729 generated at 06/21/2001 13:40:21 needed for thread 1 ORA-00289: suggestion : /home/server/sroo/test/testsroo/arch_1_527.arc ORA-00280: change 61729 for thread 1 is in sequence #527 ORA-00278: log file '/home/server/sroo/test/testsroo/arch_1_527.arc' no longer needed for this recovery ORA-00308: cannot open archived log '/home/server/sroo/test/testsroo/arch_1_527.arc' ORA-27037: unable to obtain file status SVR4 Error: 2: No such file or directory Additional information: 3
Specify log: {=suggested | filename | AUTO | CANCEL} => cancel Media recovery cancelled.
Set the standby database back to work:
SQL> recover managed standby database;
3 Check the log gap primary and standby database is solved.
a) Using an sql statement. -----------------------
To find out which logs have not been received by this standby destination, issue the following query at the primary database:
SQL> SELECT local.thread#, local.sequence# from (select thread#, sequence# from v$archived_log where dest_id=1) local where local.sequence# not in (select sequence# from v$archived_log where dest_id=2 and thread# = local.thread#);
=> no rows selected => OK!
Note: Even if this sql statement returns rows synchronisation may be succesfull - always check alert files (next item).
b) Checking the alert files. -------------------------
Check alert files if archives are now picked up by standby database:
Checking alert file primary:
$ tail -50 alert_sy*
Thu Jun 21 13:23:13 2001 ARC0: Beginning to archive log 1 thread 1 sequence 525 ARC0: Warning; LGWR is actively archiving destination LOG_ARCHIVE_DEST_2 ARC0: Transmitting activation ID 680595809 (28911161) ARC0: Error 12541 connecting to standby host 'ssym_nlsu22.world' ARC0: Error 12541 Creating archive log file to 'ssym_nlsu22.world' ARC0: Completed archiving log 1 thread 1 sequence 525 Thu Jun 21 13:40:21 2001 Thread 1 advanced to log sequence 527 Current log# 1 seq# 527 mem# 0: /ots0/app/oracle/product/9.0.1/dbs/sroo/LOG1Oa Current log# 1 seq# 527 mem# 1: /ots0/app/oracle/product/9.0.1/dbs/sroo/LOG2Oa Thu Jun 21 13:40:21 2001 ARC0: Beginning to archive log 2 thread 1 sequence 526 ARC0: Warning; LGWR is actively archiving destination LOG_ARCHIVE_DEST_2 ARC0: Transmitting activation ID 680595809 (28911161) ARC0: Completed archiving log 2 thread 1 sequence 526 Thu Jun 21 13:56:37 2001 LGWR: Transmitting activation ID 680595809 (28911161) LGWR: Beginning to archive log 2 thread 1 sequence 528 Thread 1 advanced to log sequence 528 Current log# 2 seq# 528 mem# 0: /ots0/app/oracle/product/9.0.1/dbs/sroo/LOG3Oa Current log# 2 seq# 528 mem# 1: /ots0/app/oracle/product/9.0.1/dbs/sroo/LOG4Oa Thu Jun 21 13:56:38 2001 ARC0: Beginning to archive log 1 thread 1 sequence 527 ARC0: Warning; LGWR is actively archiving destination LOG_ARCHIVE_DEST_2 ARC0: Completed archiving log 1 thread 1 sequence 527
Checking alert file standby:
$ tail -50 alert_ssy*
Thu Jun 21 13:54:45 2001 ALTER DATABASE RECOVER automatic standby database Thu Jun 21 13:54:45 2001 Media Recovery Start Successfully started datafile 1 media recovery Datafile #1: '/ots0/app/oracle/product/9.0.1/dbs/sroo/backup/system09.dbf' Media Recovery Log Media Recovery Log /home/server/sroo/test/testsroo/arch_1_522.arc Media Recovery Log /home/server/sroo/test/testsroo/arch_1_523.arc Media Recovery Log /home/server/sroo/test/testsroo/arch_1_524.arc Media Recovery Log /home/server/sroo/test/testsroo/arch_1_525.arc Media Recovery Log /home/server/sroo/test/testsroo/arch_1_526.arc Media Recovery Log /home/server/sroo/test/testsroo/arch_1_527.arc ORA-279 signalled during: ALTER DATABASE RECOVER automatic standby database... Thu Jun 21 13:55:01 2001 ALTER DATABASE RECOVER CANCEL Media Recovery Cancelled Completed: ALTER DATABASE RECOVER CANCEL Thu Jun 21 13:56:00 2001 ALTER DATABASE RECOVER managed standby database Thu Jun 21 13:56:00 2001 Media Recovery Start: Managed Standby Recovery Successfully started datafile 1 media recovery Datafile #1: '/ots0/app/oracle/product/9.0.1/dbs/sroo/backup/system09.dbf' Media Recovery Log Media Recovery Waiting for thread 1 seq# 527 Thu Jun 21 13:56:45 2001 Media Recovery Log /home/server/sroo/test/testsroo/arch_1_527.arc Media Recovery Waiting for thread 1 seq# 528
Rate this document Article Rating Rate this document Excellent Good Poor Did this document help you? Yes No Just browsing How easy was it to find this document? Very easy Somewhat easy Not easy
Learn the basics of installing Oracle Database 11g Release 1 on Oracle Enterprise Linux 5 (or RHEL5) from the bare metal up (for evaluation purposes only).
The guide provides a walkthrough of installing an Oracle Database 11g Release 1 database on commodity hardware for the purpose of evaluation. If you are new to Linux and/or Oracle, this guide is for you. It starts with the basics and walks you through an installation of Oracle Database 11g Release 1 from the bare metal up. Both 32-bit and 64-bit architectures are covered. Unless otherwise indicated, the installation steps are the same for either.
This guide will take the approach of offering the easiest paths, with the fewest number of steps for accomplishing a task. This approach often means making configuration choices that would be inappropriate for anything other than an evaluation. For that reason, this guide is not appropriate for building production-quality environments, nor does it reflect best practices.
This guide is divided into four parts: Part I covers the installation of the Linux operating system, Part II covers configuring Linux for Oracle, Part III discusses the essentials of installing the Oracle Database, and Part IV covers creating additional filesystems and Automatic Storage Management (ASM). The Appendix provides information to help you get started using your new database including how to access the database interactively and how to stop and start the database and related services.
Part I: Installing Enterprise Linux 5
This section describes how to install Oracle Enterprise Linux 5 (OEL5) on your hardware (but the same steps will apply for RHEL5). Please take a moment to make sure that your hardware meets or exceeds the minimum hardware requirements for Oracle Database 11g Release 1.
Minimum hardware requirements:
32-bit (x86)
x86 compatible CPU
1 GB RAM
10 GB available disk space (3.5 GB for the Oracle software + 1.5 GB for the database + 3 GB for OEL5 + 2 GB swap)
64-bit (x86_64)
x86_64 compatible CPU
1 GB RAM
10.5 GB available disk space (4 GB for the Oracle software + 1.5 GB for the database + 3 GB for OEL5 + 2 GB swap)
Note: Both Linux and Oracle must be installed for the same architecture. 32-bit Oracle will only run on 32-bit Linux and 64-bit Oracle will only run on 64-bit Linux.
Now, let's walk through the process of installing the Linux operating system on a server. The instructions assume a fresh install of Linux (as opposed to an upgrade), that the server will be dedicated to Oracle, and that no other operating systems or data are on the server.
Oracle Database 11g Release 1 is certified to run the base release of OEL5 without updates. Free copies of OEL5 are available for download.
Boot the server using the first CD or DVD
You may need to change your BIOS settings to allow booting from the CD/DVD.
The boot screen appears with the boot: prompt at the bottom of the screen.
Select Enter to continue with a graphical install on the console.
The installer scans your hardware
Oracle Enterprise Linux splash screen
Click on Next
Language Selection
Accept the default.
Keyboard Configuration
Accept the default.
Install or Upgrade
Select Install and click on Next
Disk Partitioning Setup
A thorough treatment of disk partitioning is beyond the scope of this guide, which assumes that you are familiar with disk partitioning methods.
WARNING: Improperly partitioning a disk is one of the surest and fastest ways to wipe out everything on your hard disk. If you are unsure how to proceed, stop and get help, or you will risk losing data!)
Accept the default partition layout. Note that the default layout is sufficient for an evaluation, but would not be appropriate for other purposes. The default layout may create a swap partition that is smaller than the Oracle guidelines recommend. This is also sufficient for an evaluation.
Network Configuration
It is usually best to configure database servers with a static IP address. To do so, click on Edit .
A pop-up window appears. Uncheck the Configure using DHCP box, and enter the IP Address and Netmask for the server. Be sure that Activate on boot is checked, and click on OK .
In the Hostname box, select manually and enter the hostname.
In the Miscellaneous Settings box, enter the remaining network settings.
Time Zone Selection
Choose the time settings that are appropriate for your area. Setting the system clock to UTC is usually a good practice for servers. To do so, select on System clock uses UTC.
Set Root Password
Enter a password for root, and enter it again to confirm.
Package Installation
This guide will follow the Oracle recommended practice of using a "default RPMs" installation. Accept the default software selection and click on Next.
Additional RPMs are required to run Oracle Database 11g Release 1. These will be installed later.
Installing Packages
Software will be copied to the hard disk and installed. Change disks as prompted.
After software installation is complete
Remove any boot CD/DVD media.
Click on Next.
Welcome
Click on Forward
License Agreement
Read the license agreement. If you agree to the terms, select Yes, I agree to the License Agreement and click on Forward.
Firewall Configuration
For the purposes of this walk-through, no firewall is configured. Select Disabled and click on Forward.
Click on Yes when the "Warning - No Firewall" window appears.
SELinux
Select Disabled from the drop down bar and click on Forward.
Kdump
Do not enable Kdump. Accept the default and click on Forward.
Date and Time
Set the Date and Time.
If you want to use an NTP server (recommended), select Enable Network Time Protocol and enter the name of the NTP server.
System User
Create an account for yourself.
Do not create an account for oracle at this time. Creating the oracle account is covered later in this section.
Sound Card
Configure the sound card, if any, and click on Forward.
Additional CDs
Click on Finish.
The system will reboot
A graphical login screen appears.
Congratulations! Your OEL5 software is now installed.
Installing Required Packages
Additional Linux software packages must be installed before installing the Oracle software. The package requirements differ for 32-bit and 64-bit architectures, so this section contains separate instructions for each architecture.
32-bit (x86) Installations
Required kernel version: 2.6.18 This kernel, or any of the kernels supplied in updates, works with Oracle Database 11g Release 1 .
Check your kernel version by running the following command:
uname -r
Ex:
# uname -r
2.6.18-8.el5
Required package versions (or later):
compat-libstdc++-33-3.2.3-61
elfutils-libelf-0.125-3.el5
elfutils-libelf-devel-0.125-3.el5
glibc-2.5-12
glibc-devel-2.5-12
glibc-common-2.5-12
gcc-4.1.1-52.el5
gcc-c++-4.1.1-52.el5
kernel-headers
libgcc-4.1.1-52.el5
libaio-0.3.106-3.2
libaio-devel-0.3.106-3.2
libstdc++-4.1.1-52.el5
libstdc++-devel-4.1.1-52.el5
unixODBC-2.2.11-7.1
unixODBC-devel-2.2.11-7.1
sysstat-7.0.0-3.el5
binutils-2.17.50.0.6-2.el5
make-3.81-1.1
If you've performed a "default RPMs" install as suggested by Oracle, there are still some required packages that must be installed:
compat-libstdc++-33
elfutils-libelf-devel
glibc-devel-2.5
gcc
gcc-c++
libaio-devel
libstdc++-devel
unixODBC
unixODBC-devel
sysstat
To install the remaining packages, mount the Oracle Enterprise Linux media and move to the directory containing the RPMs.
Some required packages are dependent upon other packages, so the dependant packages must be installed as well. Login as root and run the following commands to install the remaining required packages and their dependent packages. (Warning: packages often move from disk to disk across different releases.)
Required kernel version: 2.6.18 This kernel, or any of the kernels supplied in updates, works with Oracle Database 11g Release 1 .
Check your kernel version by running the following command:
uname -rm
Ex:
# uname -rm
2.6.18-8.el5 x86_64
Required package versions (or later):
binutils-2.17.50.0.6
compat-libstdc++-33-3.2.3
compat-libstdc++-33-3.2.3 (32 bit)
elfutils-libelf-0.125
elfutils-libelf-devel-0.125
gcc-4.1.1
gcc-c++-4.1.1
glibc-2.5-12
glibc-2.5-12 (32 bit)
glibc-common-2.5
glibc-devel-2.5
glibc-devel-2.5-12 (32 bit)
libaio-0.3.106
libaio-0.3.106 (32 bit)
libaio-devel-0.3.106
libgcc-4.1.1
libgcc-4.1.1 (32 bit)
libstdc++-4.1.1
libstdc++-4.1.1 (32 bit)
libstdc++-devel 4.1.1
make-3.81
sysstat-7.0.0
Note that there are a number of packages where both the 64-bit and 32-bit RPMs must be installed. Fortunately, both are provided on the 64-bit Linux installation media.
If you've performed a "default RPMs" install as suggested by Oracle, there are still some required packages that must be installed:
compat-libstdc++-33-3.2.3
compat-libstdc++-33-3.2.3 (32 bit)
elfutils-libelf-devel-0.125
gcc-4.1.1
gcc-c++-4.1.1
glibc-devel-2.5
glibc-devel-2.5-12 (32 bit)
libaio-devel-0.3.106
libstdc++-devel 4.1.1
sysstat-7.0.0
To install the remaining packages, mount the Oracle Enterprise Linux media and move to the directory containing the RPMs.
Some required packages are dependent upon other packages, so the dependant packages must be installed as well. Login as root and run the following commands to install the remaining required packages and their dependent packages:
Mount CD 2
mount -t iso9660 -r /dev/cdrom /media
cd /media/Server
Now that the Linux software is installed, you need to configure it for Oracle. This section walks through the steps required to configure Linux for Oracle Database 11g Release 1.
Create the Oracle Groups and User Account
Next, create the Linux groups and user account that will be used to install and maintain the Oracle Database 11g Release 1 software. The user account will be called oracle, and the groups will be oinstall and dba. Execute the following commands as root:
Ex:
# passwd oracle
Changing password for user oracle.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Create Directories
Now create directories to store the Oracle Database 11g Release 1 software and the database files. This guide adheres to the Optimal Flexible Architecture (OFA) for the naming conventions used in creating the directory structure. For more information on OFA standards, see Appendix D of the Oracle Database Installation Guide 11g Release 1 (11.1) for Linux.
The following assumes that the directories are being created in the root filesystem. This is done for the sake of simplicity and is not recommended as a general practice. These directories would normally be created as separate filesystems.
Oracle Database 11g Release 1 requires the kernel parameter settings shown below. The values given are minimums, so if your system uses a larger value, don't change it. Linux allows modification of most kernel parameters while the system is up and running, so there's no need to reboot the system after making kernel parameter changes.
Note that OEL 5 already has values defined for kernel.shmall and kernel.shmmax. Use the default values if they are the same or larger than the required values.
If you're following along and have just installed Linux, the kernel parameters will all be at their default values and you can just cut and paste the following commands while logged in as root.
Run the following commands as root to verify your settings:
/sbin/sysctl -a | grep shm
/sbin/sysctl -a | grep sem
/sbin/sysctl -a | grep file-max
/sbin/sysctl -a | grep ip_local_port_range
/sbin/sysctl -a | grep rmem_default /sbin/sysctl -a | grep rmem_max /sbin/sysctl -a | grep wmem_default /sbin/sysctl -a | grep wmem_max
Ex:
# /sbin/sysctl -a | grep shm
kernel.shmmni = 4096
kernel.shmall = 268435456
kernel.shmmax = 4294967295
kernel.shm-use-bigpages = 0
# /sbin/sysctl -a | grep sem
kernel.sem = 250 32000 100 128
# /sbin/sysctl -a | grep file-max
fs.file-max = 65536
# /sbin/sysctl -a | grep ip_local_port_range
net.ipv4.ip_local_port_range = 1024 65000
# /sbin/sysctl -a | grep rmem_default
net.core.rmem_default = 4194304
# /sbin/sysctl -a | grep rmem_max
net.core.rmem_max = 4194304
# /sbin/sysctl -a | grep wmem_default
net.core.wmem_default = 262144
# /sbin/sysctl -a | grep wmem_max
net.core.wmem_max = 262144
Setting shell limits for the oracle user
Oracle recommends setting limits on the number of processes and open files each Linux account may use. To make these changes, cut and paste the following commands as root:
cat >> /etc/security/limits.conf <oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
Oracle Database 11g Release 1 can be downloaded from OTN. Oracle offers a development and testing license free of charge. However, no support is provided and the license does not permit production use. A full description of the license agreement is available on OTN.
The easiest way to make the Oracle Database 11g Release 1 distribution media available on your server is to download them directly to the server.
Use the graphical login to log in as oracle.
Create a directory to contain the Oracle Database 11g Release 1 distribution:
mkdir 11gR1_db
To download Oracle Database 11g Release 1 from OTN, point your browser to the Oracle Database Download Page. Read the OTN License agreement. If you agree with the restrictions and the license agreement, click on Accept License Agreement.
Click on the Linux x86 link (32-bit) or Linux x86-64 link (64-bit) and save the file in the directory you created for this purpose (11gR1_db)—if you have not already logged in to OTN, you may be prompted to do so at this point.
Unzip and extract the file.
cd 11gR1_db
For 32-bit unzip linux_11gR1_database.zip
For 64-bit
unzip linux.x64_11gR1_database.zip
Install the Software and Create a Database
Log in using the oracle account.
Change directory to the directory containing the Oracle Database 11g Release 1 software.
Ex:
$ cd $HOME/11gR1_db/database
Start the Oracle Universal Installer.
$ ./runInstaller
Select Installation Method
Select Basic Installation
Oracle Base Location: /u01/app/oracle
Oracle Home Location: /u01/app/oracle/product/11.1.0/db_1
Installation Type: Enterprise Edition (3.3GB)
UNIX DBA Group: dba
Make sure Create Starter Database is checked
Global Database Name: demo1
Enter the Database Password and Confirm Password
Click on Next
Specify Inventory Directory and Credentials
Inventory Directory: /u01/app/oraInventory
Operating System group name: oinstall
Click on Next
Product-specific Prerequisite Checks
If you've been following the steps in this guide, all the checks should pass without difficulty. You may receive a warning related to swap file size if the default partition layout was used during OEL5 installation. This may be safely ignored . If one or more checks fail, correct the problem before proceeding.
Click on Next
Oracle Configuration Manager Registration
Leave this disabled for the demo and click on Next
Summary
A summary of the products being installed is presented.
Click on Install.
Install
Installation progress is displayed
Configuration Assistants
The Oracle Net, Oracle Database, and iSQL*Plus configuration assistants will run automatically
Take note of the information presented in the Database Configuration Assistant pop-up window and click on OK.
Execute Configuration Scripts
At the end of the installation, a pop up window will appear indicating scripts that need to be run as root. Login as root and run the indicated scripts.
Click on OK when finished.
End of Installation
Make note of the URLs presented in the summary, and click on Exit when ready.
Congratulations! Your new Oracle Database 11g Release 1 database is up and ready for use.
Part IV: Configuring Storage
The database we created in Part III used a single filesystem for disk storage. However, there are several other ways to configure storage for an Oracle database.
This section explores other methods of configuring disk storage for a database. In particular, it describes creating an additional filesystem and using Automatic Storage Management (ASM).
Partition the Disks
In order to use either file systems or ASM, you must have unused disk partitions available. This section describes how to create the partitions that will be used for new file systems and for ASM.
WARNING: Improperly partitioning a disk is one of the surest and fastest ways to wipe out everything on your hard disk. If you are unsure how to proceed, stop and get help, or you will risk losing data.
This example uses /dev/sda (an empty disk with no existing partitions) to create a single partition for the entire disk.
Ex:
# fdisk /dev/sda
The number of cylinders for this disk is set to 30401.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-30401, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-30401, default 30401):
Using default value 30401
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Now verify the new partition:
Ex:
# fdisk -l /dev/sda
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 30401 244196001 83 Linux
Repeat the above steps for each disk to be partitioned. The following section on Filesystems uses a single disk partition, /dev/sda1. The ASM example uses two disks: /dev/sda1 and /dev/sdb1.
Filesystems
Filesystems are the most widely used means of storing data file, redo logs, and control files for Oracle databases. Filesystems are easy to implement and require no third-party software to administer.
In most cases, filesystems are created during the initial installation of Linux. However, there are times when a new filesystem must be created after the initial installation, such as when a new disk drive is being installed.
This section describes building a new filesystem and using it in an Oracle database. Unless otherwise noted, all commands must be run as root.
Create the Filesystem
Use ext3 to create this new filesystem. Other filesystems work just as well, but ext3 offers the fastest recovery time in the event of a system crash.
Ex:
# mke2fs -j /dev/sda1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
30539776 inodes, 61049000 blocks
3052450 blocks (5.00%) reserved for the super user
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Create the Mount Point
A filesystem must have a mount point, which is simply an empty directory where the new filesystem "attaches" to the system's directory tree. Mount points should be given names consistent with the Oracle Flexible Architecture (OFA) standard. For more information on OFA standards, see Appendix D of the Oracle Database Installation Guide 11g Release 1 (11.1) for Linux.
Because the /u01 directory was created in Part I, this example uses /u02.
Ex:
# mkdir /u02
Add the New Filesystem to /etc/fstab
So that the new filesystem will be mounted automatically when the system boots, you need to add a line to the /etc/fstab file that describes the new filesystem and where to mount it. Add a line similar to the one below to /etc/fstab, using a text editor.
/dev/sda1 /u02 ext3 defaults 1 2
Mount the New Filesystem
Mounting the filesystem makes it available for use. Until the filesystem is mounted, files cannot be stored in it. Use the following commands to mount the filesystem and verify that it is available.
mount /u02
df -h /u02
Ex:
# mount /u02
# df -h /u02
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 230G 188M 218G 1% /u02
Create Oracle Directories and Set Permissions
Now create a directory to store your Oracle database files. The directory name used in the example follows the OFA standard naming convention for a database with ORACLE_SID=demo1.
The new filesystem is ready for use. Next you create a new tablespace in the filesystem to store your database objects. Connect to the database as the SYSTEM user, and execute the CREATE TABLESPACE statement, specifying the data file in the new filesystem.
Ex:
$ sqlplus
SQL*Plus: Release 11.1.0.6.0 - Production on Sun Nov 4 15:19:00 2007
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Enter user-name: system
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create tablespace data1
2 datafile '/u01/app/oracle/oradata/demo1/data1_01.dbf' size 100m
3 extent management local
4 segment space management auto;
Tablespace created.
Now you can use the new tablespace to store database objects such as tables and indexes.
Ex:
SQL> create table demotab (id number(5) not null primary key,
2 name varchar2(50) not null,
3 amount number(9,2))
4 tablespace data1;
Table created.
Automatic Storage Management (ASM)
ASM is a disk storage option that provides the services of a filesystem, logical volume manager, and software RAID in a platform-independent manner. ASM can stripe and mirror your disks, allow disks to be added or removed while the database is under load, and automatically balance I/O to remove "hot spots." It also supports direct and asynchronous I/O and implements the Oracle Data Manager API (simplified I/O system call interface) introduced in Oracle9i.
ASM is not a general-purpose filesystem and can be used only for Oracle database related files. Files in ASM can be created and named automatically by the database (by use of the Oracle Managed Files feature) or manually by the DBA. ASM files are not accessible using operating system commands such as ls, cp, and dd. To manage ASM files, use Oracle Enterprise Manager or other Oracle provided methods.
ASM is implemented as a separate Oracle instance that must be running if other databases are to be able to access it. Memory requirements for ASM are light: only 64 MB for most systems.
Installing ASM
ASM can use a variety of storage types including raw partitions, RAID LUNs, and NFS files. For Linux systems, Oracle provides a custom device driver known as ASMLib, which is recommended for most ASM installations on Linux. ASMLib is available for free download from OTN. This section walks through the process of configuring a simple ASM instance using ASMLib 2.0 and building a database that uses ASM for disk storage.
Determine Which Version of ASMLib You Need
ASMLib 2.0 is delivered as a set of three RPM packages.
oracleasmlib-2.0 - the ASM libraries
oracleasm-support-2.0 - utilities needed to administer ASMLib
oracleasm - a kernel module for the ASM library that is specific to each kernel
Each Linux distribution has its own set of ASMLib 2.0 packages (OEL 5 uses the same RPMs as Red Hat Enterprise Linux 5 AS). Within each distribution, each kernel version has a corresponding oracleasm package. The following paragraphs describe how to determine which set of packages you need.
First, determine which kernel you are using by logging in as root and running the following command:
uname -rm
Ex:
# uname -rm
2.6.18-8.el5 i686
The example shows that this is a 2.6.18 kernel, patch level 8, for Enterprise Linux 5 on 32-bit x86 compatible hardware (i686).
Use this information to find the correct ASMLib packages on OTN:
Download the oracleasmlib and oracleasm-support packages for your version of Linux. The files are grouped by architecture (AMD64 / Intel em64t for x86_64, IA64 for Itanium, and IA32 for x86). At the top of each section is a Library and Tools heading. Download both of the files under this heading - these are the support utilities and ASM libraries (oracleasm-support and oracleasmlib, respectively).
Next, download the oracleasm package corresponding to your kernel. In the example above, the oracleasm-2.6.18-8.el5-2.0.4-1.el5.i686.rpm package was used. Note that there are two or three drivers listed under most of the kernel versions. For example:
Choose only one of these. In this example, there are drivers for Xen (virtual machine architecture), PAE (for 32-bit systems with more than 4GB RAM), and the "standard" 32-bit kernel.
Next, install the packages by executing the following command as root:
Before using ASMLib, you must run a configuration script to prepare the driver. Run the following command as root, and answer the prompts as shown in the example below.
# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver. The following questions will determine whether the driver is
loaded on boot and what permissions it will have. The current values
will be shown in brackets ('[]'). Hitting without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]
Next you tell the ASM driver which disks you want it to use. Oracle recommends that each disk contain a single partition for the entire disk. See Partitioning the Disks at the beginning of this section for an example of creating disk partitions.
Mark disks for use by ASMLib by running the following command as root:
Ex:
# /etc/init.d/oracleasm createdisk VOL1 /dev/sda1
Marking disk "/dev/sdb1" as an ASM disk:[OK]
# /etc/init.d/oracleasm createdisk VOL2 /dev/sdb1
Marking disk "/dev/sdb1" as an ASM disk:[OK]
Verify that ASMLib has marked the disks:
# /etc/init.d/oracleasm listdisks
VOL1
VOL2
Create the ASM Instance
ASM runs as a separate Oracle instance which can be created and configured using the Oracle Universal Installer. Now that ASMLib is installed and the disks are marked for use, you can create an ASM instance.
Log in as oracle and start runInstaller:
$ ./runInstaller
Select Installation Method
Select Advanced Installation
Click on Next
Specify Inventory Directory and Credentials
Inventory Directory: /u01/app/oraInventory
Operating System group name: oinstall
Click on Next
Select Installation Type
Select Enterprise Edition
Click on Next
Install Location
Oracle Base: /u01/app/oracle
Name: OraDB11gASM
Path: /u01/app/oracle/product/11.1.0/asm
Note:Oracle recommends using a different ORACLE_HOME for ASM than the ORACLE_HOME used for the database for ease of administration.
Click on Next
Product-specific Prerequisite Checks
If you've been following the steps in this guide, all the checks should pass without difficulty. If one or more checks fail, correct the problem before proceeding.
Redundancy
- High mirrors data twice.
- Normal mirrors data once. This is the default.
- External does not mirror data within ASM. This is typically used if an external RAID array is providing redundancy.
Add Disks
The disks you configured for use with ASMLib are listed as Candidate Disks. Select each disk you wish to include in the disk group.
Click on Next
Privileged Operating System Groups
Database Administrator (OSDBA) Group: dba
Database Operator (OSOPER) Group: dba
ASM administrator (OSASM) Group: dba
Click on Next
Oracle Configuration Manager Registration
Leave this disabled for the demo
Click on Next
Summary
A summary of the products being installed is presented.
Click on Install.
Install
Installation progress is displayed
Execute Configuration Scripts
At the end of the installation, a pop up window will appear indicating scripts that need to be run as root. Login as root and run the indicated scripts.
Click on OK when finished.
Configuration Assistants
The Oracle Net, Oracle Database, and iSQL*Plus configuration assistants will run automatically
End of Installation
Cick on Exit
Congratulations! Your new Oracle ASM Instance is up and ready for use.
Create the Database
Once the ASM instance has been created, create a database that uses ASM for storage:
Log in as oracle and start runInstaller:
$ ./runInstaller
Select Installation Method
Select Advanced Installation
Click on Next
Select Installation Type
Select Enterprise Edition
Click on Next
Install Location
Oracle Base: /u01/app/oracle
Name: OraDb11g_home1
Path: /u01/app/oracle/product/11.1.0/db_1
Note:Oracle recommends using a different ORACLE_HOME for the database than the ORACLE_HOME used for ASM.
Click on Next
Product-specific Prerequisite Checks
If you've been following the steps in this guide, all the checks should pass without difficulty. If one or more checks fail, correct the problem before proceeding.
Click on Next
Select Configuration Option
Select Create a Database
Click on Next
Select Database Configuration
Select General Purpose
Click on Next
Specify Database Configuration Options
Enter the Global Database Name and SID
Click on Next
Specify Database Config Options
Accept the defaults or change as desired
Click on Next
Select Database Management Option
Select Use Database Control for Database Management
Click on Next
Specify Database Storage Option
Select Automatic Storage Management (ASM)
Click on Next
Specify Backup and Recovery Options
Select Do not enable Automated backups
Click on Next
Select ASM Disk Group
Select the DATA disk group created in the previous section
Click on Next
Specify Database Schema Passwords
Select Use the same password for all the accounts
Enter the password and confirm
Click on Next
Privileged Operating System Groups
Database Administrator (OSDBA) Group: dba
Database Operator (OSOPER) Group: dba
ASM administrator (OSASM) Group: dba
Click on Next
Oracle Configuration Manager Registration
Leave this disabled for the demo
Click on Next
Summary
A summary of the products being installed is presented.
Click on Install.
Configuration Assistants
The Oracle configuration assistants will run automatically
When the configuration is complete, a pop-up window will appear with information about the database. Make note of the URL and click on OK when ready.
Execute Configuration Scripts
At the end of the installation, a pop up window will appear indicating scripts that need to be run as root. Login as root and run the indicated scripts.
Click on OK when finished.
End of Installation
Click on Exit
Congratulations! Your new Oracle Database is up and ready for use.
Conclusion
Now that your database is up and running, you can begin exploring the many new features offered in Oracle Database 11g Release 1. A great place to start is with Oracle Enterprise Manager. If you're unsure where to begin, the Oracle Database Concepts 11g Release 1 and the 2-Day DBA guide will help familiarize you with your new database. OTN also has a number of guides designed to help you get the most out of Oracle Database 11g Release 1.
Appendix
Accessing the Database with SQL*Plus
Log into Linux as oracle. Set the environment.
Set the Oracle environment variables:
$ . oraenv
ORACLE_SID = [demo1] ? demo1
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is /u01/app/oracle
Run SQL*Plus:
$ sqlplus
SQL*Plus: Release 11.1.0.6.0 - Production on Sun Nov 4 23:56:47 2007
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Enter user-name: / as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
Using Oracle Enterprise Manager 11g Database Control
In a Web browser, connect to the URL provided during the installation.
Ex:
https://ds1.orademo.org:1158/em (You may have to use the IP address instead of the host name if your database server isn’t in your DNS.)
User Name: SYSTEM
Password: Connect As: Normal
Click on
Welcome to Oracle Enterprise Manager 11g Database Control.
Starting and Stopping Oracle Enterprise Manager Database Control:
$ emctl start dbconsole
$ emctl stop dbconsole
Starting and Stopping the Listener:
The listener accepts connection requests from clients and creates connections to the database once the credentials have been authenticated. Before you can use OEM, the listener must be up.
$ lsnrctl start
$ lsnrctl stop
Starting and Stopping the Database:
The easiest way to start and stop the database is from the OEM Console. To do that from the command line, use SQL*Plus while logged in as oracle, as follows:
Startup:
$ sqlplus
SQL*Plus: Release 11.1.0.6.0 - Production on Mon Nov 5 00:00:31 2007
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Enter user-name: / as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> startup
ORACLE instance started.
Total System Global Area 849530880 bytes
Fixed Size 1303216 bytes
Variable Size 377490768 bytes
Database Buffers 465567744 bytes
Redo Buffers 5169152 bytes
Database mounted.
Database opened.
SQL> exit
Shutdown:
$ sqlplus
SQL*Plus: Release 11.1.0.6.0 - Production on Mon Nov 5 00:00:31 2007
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Enter user-name: / as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
John Smiley [jrsmiley@gmail.com] is a senior database engineer at a major online retailer. He is an Oracle Certified Master DBA with 20 years of experience with Oracle databases running on all major platforms. He specializes in engineering highly available, high performance Oracle database systems.