woensdag 29 februari 2012

Setup the Oracle account and the directory structure.

Create the Oracle inventory group:
When you install Oracle software on the system for the first time, Oracle Universal Installer creates the oraInst.loc file. This file identifies the name of the Oracle Inventory group (typically, oinstall) and the path of the Oracle Inventory directory.
  • Determine if the oraInst.loc file exists:  more /etc/oraInst.loc
    If the oraInst.loc file exists, then the output from this command is similar to the following: inventory_loc=/u01/app/oraInventory
    inst_group=oinstall
  • Determine if the Oracle Inventory group exists: grep oinstall /etc/group
  • If the oraInst.loc file does not exist, then create the Oracle Inventory group:
    /usr/sbin/groupadd oinstall
 
Create the OSDBA group:
/usr/sbin/groupadd -g 502 dba 

Create the OSOPER group (optional):
/usr/sbin/groupadd -g 503 oper

Create the OSASM, OSDBA and OSOPER groups for ASM:If you intend to use ASM, then also create the following groups:

/usr/sbin/groupadd -g 504 asmadmin
/usr/sbin/groupadd -g 506 asmdba
/usr/sbin/groupadd -g 505 asmoper
 
Create the Oracle software owner user: 

 
/usr/sbin/useradd -u 502 -g oinstall -G dba,asmdba,[oper] oracle 
 
Set the password of the oracle user:
passwd oracle 

Modifying an Existing Oracle Software Owner User

If the oracle user exists, but its primary group is not oinstall, or it is not a member of the appropriate OSDBA or OSOPER groups, then modify it as follows:

/usr/sbin/usermod -g oinstall -G dba,asmdba[,oper] oracle

Checking Resource Limits for the Oracle Software Installation Users:

Resource Shell Limit Resource Soft Limit Hard Limit
Open file descriptors nofile at least 1024 at least 65536
Number of processes available to a single user nproc at least 2047 at least 16384
Size of the stack segment of the process stack at least 10240 KB at least 10240 KB, and at most 32768 KB
  1. Log in as the Oracle software iowner user (typically: oracle)
  2. Check the soft and hard limits for the file descriptor setting.
    $ ulimit -Sn
    1024
    $ ulimit -Hn
    65536
    
  3. Check the soft and hard limits for the number of processes available to a user.
    $ ulimit -Su
    2047
    $ ulimit -Hu
    16384
    
    
  4. Check the soft limit for the stack setting.
    $ ulimit -Ss
    10240
    $ ulimit -Hs
    32768
    
    If necessary, update the resource limits in the /etc/security/limits.conf configuration file for the installation owner. 
    For example, add the following lines to the /etc/security/limits.conf file:
    oracle soft nproc 2047
    oracle hard nproc 16384
    oracle soft nofile 1024
    oracle hard nofile 65536
    oracle soft stack 10240 
When the limits.conf file is changed, these changes take effect immediately.
But logged on users will not see the change yet => log off all connections as user oracle.

ORACLE_BASE:
The Oracle base directory is a top-level directory for Oracle software installations.
The Optimal Flexible Architecture (OFA) guidelines recommend that you use a path similar to the following for the Oracle base directory:
/mount_point/app/software_owner

E.g: /u01/app/oracle

If different operating system users install Oracle software on the same system, then each user must create a separate Oracle base directory.

Example of a second ORACLE_BASE that exists on the same system: /u01/app/orauser

Indentifying an existing ORACLE_BASE directory:
After you locate the Oracle home directory (see next paragraph), run a similar command to confirm the location of Oracle base:
cat /u01/app/oraInventory/ContentsXML/inventory.xml

Before deciding to use an existing Oracle base directory for this installation, ensure that it meets the following conditions:
  • It is not on the same file system as the operating system.
  • It has sufficient free disk space, as follows:
    Requirement Free Disk Space
    The Oracle base directory contains only software files. Up to 4 GB
    The Oracle base directory contains both software and database files (not recommended for production databases). Up to 6 GB
 
Create the ORACLE_BASE directory, and set the correct permissions: 
 
# mkdir -p /u01/app/oracle
# chown -R oracle:oinstall /u01/app/oracle
# chmod -R 775 /u01/app/oracle

ORACLE_HOME:

The directory that you specify must be a subdirectory of the Oracle base directory. Oracle recommends that you specify a path similar to the following for the Oracle home directory
$ORACLE_BASE/product/11.2.0/dbhome_1

Oracle Universal Installer creates the directory path that you specify under the Oracle base directory.
It also sets the correct owner, group, and permissions on it. You do not have to create this directory (better not, you can run into issues if you set the wrong permissions).

Identifying an existing Oracle home directory


Enter the following command to display the contents of the oratab file:
# more /etc/oratab

If the oratab file exists, then it contains lines of code similar to the following:
*:/u03/app/oracle/product/11.2.0/dbhome_1:N
*:/opt/orauser/infra_904:N
*:/oracle/9.2.0:N

Oracle inventory directory:
Oracle recommends that you do not put the oraInventory directory under the Oracle base directory for a new installation (which is teh default if you set the ORACLE_BASE environment variable...).

/u01/app/orainventory


All Oracle software installations rely on the Oracle Inventory directory. Ensure that you back it up regularly.


Database file structure:
Database file directory:
# mkdir /mount_point/oradata
# chown oracle:oinstall /mount_point/oradata
# chmod 775 /mount_point/oradata




Recovery file directory (fast recovery area):
# mkdir /mount_point/fast_recovery_area
# chown oracle:oinstall /mount_point/fast_recovery_area
# chmod 775 /mount_point/fast_recovery_area

The fast recovery area (this was called the flash recovery area in 10g) should be on different physical disks than the datafiles (for recovery purposes).

Redo logs:
The members of the redo log groups should be spread over 2 different oradata directories, which are on 2 different physical disks.

Control files:
The 3 control files should be spread over at least 2 different disks (if possible over 3).

Creating a Udev Permissions File for Oracle Database:

With the 2. 6 kernel or later for Red Hat Enterprise Linux, Oracle Linux, and SUSE Linux Enterprise Server, you must create a permissions file to maintain permissions on Oracle database files.

If you do not create this permissions file, then permissions on disk devices revert to their default values, root:disk, and Oracle Database fails to start. Use the following steps to set the permissions file number:
  • On Red Hat Enterprise Linux 4 and Oracle Linux 4, you must create a permissions file number that is lower than 50.
  • On Asianux Server 3, Red Hat Enterprise Linux 5, Oracle Linux 5, SUSE Linux Enterprise Server 10, or SUSE Linux Enterprise Server 11, you must create a permissions file number that is higher than 50.
Create or modify the rules file in /etc/udev/rules.d to change the permissions of the data files from the default root ownership.

Ensure that the file you create is appropriate for your distribution. For example, name this file 99-oracle.rules on Asianux, Red Hat Enterprise Linux, Oracle Linux, and SUSE Linux Enterprise Server systems.

 Example 2-1 Example of a Rules File with User oracle
/etc/udev/rules.d/99-oracle.rules
#
# ASM disks
KERNEL=="sdb[6-9]", OWNER="oracle", GROUP="dba", MODE="0660"
KERNEL=="sdb10", OWNER="oracle", GROUP="dba", MODE="0660"
 
Example 2-2 Example of a Rules File with User grid
/etc/udev/rules.d/99-oracle.rules
#
# ASM disks
KERNEL=="sdb[6-9]", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sdb10", OWNER="grid", GROUP="asmadmin", MODE="0660" 
 
Configuring the Oracle user's environment. 

Contents of /home/oracle/.profile: 
umask 022
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH 
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib32:$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export LIBPATH=$ORACLE_HOME/lib32:$ORACLE_HOME/lib:$LIBPATH
...
 
(I will copy over a .profile file of a working environment soon)
 
Before you run Oracle Universal Installer, make sure to unset the ORACLE_HOME:
unset $ORACLE_HOME
 
Set the DISPLAY variable: 
export DISPLAY=local_host:0.0 
 
Verify that X applications display properly. The following command should display a clock:
xclock
 

Create the database: overview

  1. First we need to set up the oracle account and the directory structure.
    This is a common step for all 3 methods of creating a database.
  2. Next we’ll install the database software:
  3. Create a database:
  4. Drop the database:
    • With dbca
    • With the “DROP DATABASE” statement
I prefer to not immediately create a database together with the software installation.
It’s better to first install the software, install the latest patch set, and then create the database.
If the database was created together with the base install, you would need to patch the database as well…

Remark:
Starting with the release of the 11.2.0.2 patch set for Oracle Database 11g Release 2, Oracle Database patch sets are full installations of the Oracle Database software.
So you can immediately install the correct version, and don't need to apply the patch set afterwards.

New Tool to Configure Custom Installation Options

Oracle Universal Installer no longer provides the custom installation option of individual components. Use the chopt tool, a command-line utility that is located in the ORACLE_HOME/bin directory, to configure the database options.

See Also: "Enabling and Disabling Database Options"

Deinstallation Tool

Use the new deinstallation tool (deinstall) available as an Oracle Technology Network download (before installation) and in the Oracle home directory (after installation) to remove Oracle Database software.

See Chapter 7, "Removing Oracle Database Software"

dinsdag 28 februari 2012

Setup of the environment


In this post, I will set up the same environment as the exam environment on VMWare Workstation:
Oracle Linux Release 5.2 (64-bit)
Oracle Database 11g version 11.2.0 (64-bit)
Oracle Enterprise Management Grid Control 10g version 10.2.0.5 (64-bit)

First, create a new vm machine:

Open VMware WorkStation, and click on “Create a New Virtual Machine”:











Click on Customize Hardware:


Change memory to 1,5 GB, and networking to Host-Only:


Afterwards, I started the new VM, but I received the following error:


Apparently, VT was disabled in my bios.
I had to restart and change my Virtual Technology setting to Enabled in the BIOS. Afterwards I was able to start the VM.

Install Enterprise Linux 5.2

Start the VM, and press Enter in the following screen:


Press Skip in the following screen:


Press Next:


Press Next:

Select the keyboard, and click Next.


Click Yes:

Click Next:



Click Edit and enter an IP Address and a host name:







Right click on the VM, and choose Removable Devices -> CD/DVD (IDE) -> Settings.
In the popup, change the cd to the second iso.

Then click on Connect (Removable Devices -> CD/DVD (IDE) ->Connect).
Afterwards, click on OK to proceed with the second CD.



Repeat the same step to select and proceed with the third and fourth disk.
At the end of the installation, make sure to change the CD settings (no ISO selected), and click on Reboot afterwards.

Right click on the VM, and choose Removable Devices -> CD/DVD (IDE) -> Settings.
Untick “Connect at power on” and “Connected”.


 
Click on Reboot.

 
After the reboot, the installer will ask you to provide some more details:





 
Create a new user called “oracle”:



Press Finish. Afterwards the OS will reboot:



Install VMWare Tools.

Choose VM > Install VMware Tools. A new folder is displayed containing a tar file.
Untar this file by right clicking it an choosing “Extract to “.
I extracted the tar to the Desktop.

Open a terminal window, and su root.
cd /home/oracle/Desktop/vmware-tools-distrib
./vmware-install.pl

Follow all the defaults and choose an appropriate resolution at the end.

Check Preinstallation requirements:


Check the following requirements:

Install required extra packages.

See the Preinstallation Requirements for Oracle Database on Tahiti.oracle.com:
Linux x86-64 - Oracle Database Package Requirements

The following packages (or later versions) must be installed:
rpm -q binutils-2.17.50.0.6
rpm -q compat-libstdc++-33-3.2.3
rpm -q elfutils-libelf-0.125
rpm -q elfutils-libelf-devel-0.125 -- NOT INSTALLED YET (CD2)
rpm -q gcc-4.1.2                   -- NOT INSTALLED YET (CD 2)
rpm -q gcc-c++-4.1.2               -- NOT INSTALLED YET (CD2)
rpm -q glibc-2.5-24
rpm -q glibc-2.5-24 (32 bit)
rpm -q glibc-common-2.5
rpm -q glibc-devel-2.5             -- NOT INSTALLED YET (CD2)
rpm -q glibc-headers-2.5           -- NOT INSTALLED YET (CD2)
rpm -q ksh-20060214
rpm -q libaio-0.3.106
rpm -q libaio-devel-0.3.106        -- NOT INSTALLED YET (CD 1)
rpm -q libgcc-4.1.2
rpm -q libstdc++-4.1.2
rpm -q libstdc++-devel 4.1.2       -- NOT INSTALLED YET (CD 2)
rpm -q make-3.81
rpm -q sysstat-7.0.2               -- NOT INSTALLED YET

To determine if the required packages are installed, enter commands similar to the following:
# rpm -q package_name

Install the required packages using the rpm command:
rpm -ivh <package_name>.rpm

You’ll have to search on the Oracle Enterprise Linux 5.2 disks which one contains the missing package, and install it.
On each disk, go to the directory which contains the packages
Open the disk: VM -> Removable Devices->Settings->CD/DVD:

[root@ORAVM1 Server]# df –h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
23G 2.6G 19G 12% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 760M 0 760M 0% /dev/shm
/dev/hdc 600M 600M 0 100% /media/Enterprise Linux cd 3 20080528

[root@ORAVM1 Server]# cd /media/Enterp*
 
[root@ORAVM1 Enterprise Linux cd 3 20080528]# ls
Cluster ClusterStorage EULA GPL RPM-GPG-KEY Server TRANS.TBL VT

[root@ORAVM1 Enterprise Linux cd 3 20080528]# cd Server

Check for all packages if they are on this disk. And if they are, install them.

Example:
[root@ORAVM1 Server]# ls libaio*
libaio-devel-0.3.106-3.2.i386.rpm libaio-devel-0.3.106-3.2.x86_64.rpm

[root@ORAVM1 Server]# rpm -q libaio-devel
package libaio-devel is not installed

[root@ORAVM1 Server]# rpm -ivh libaio-devel-0.3.106-3.2.i386.rpm
warning: libaio-devel-0.3.106-3.2.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing... ########################################### [100%]
1:libaio-devel ########################################### [100%]

[root@ORAVM1 Server]# rpm -ivh libaio-devel-0.3.106-3.2.x86_64.rpm
warning: libaio-devel-0.3.106-3.2.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing... ########################################### [100%]
1:libaio-devel ########################################### [100%]

Remark:
Pre-requisite packages elfutils-libelf-devel-0.125-3.el5.x86.rpm and elfutils-libelf-devel-static-0.125-3.el5.i386.rpm are dependent on each other and hence have to be installed together:

[root@ORAVM1 Server]# rpm -ivh elfutils-libelf-devel-0.125-3.el5.x86.rpm
warning: elfutils-libelf-devel-0.125-3.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159-
error: Failed dependencies:
elfutils-libelf-devel-static = 0.125-3.el5 is needed by elfutils-libelf-devel-0.125-3.el5.x86

[root@ORAVM1 Server]# rpm -ivh elfutils-libelf-devel-static-0.125-3.el5.x86_64.rpm
warning: elfutils-libelf-devel-static-0.125-3.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
error: Failed dependencies:
elfutils-libelf-devel = 0.125-3.el5 is needed by elfutils-libelf-devel-static-0.125-3.el5.x86_64

The following also had dependencies, and had to be installed together as well:
rpm -ivh gcc-c++-4.1.2-42.el5.x86_64.rpm gcc-4.1.2-42.el5.x86_64.rpm glibc-headers-2.5-24.x86_64.rpm glibc-devel-2.5-24.i386.rpm

I also had to install the following packages:
libgomp = 4.1.2-42.el5 is needed by gcc-4.1.2-42.el5.x86_64 (disk 2)
libgomp.so.1()(64bit) is needed by gcc-4.1.2-42.el5.x86_64 (disk 2)
kernel-headers >= 2.2.1 is needed by glibc-headers-2.5-24.x86_64 (disk 1)
Now I found out that there is a much simpler way to install the required packages:
Use the up2date command to install the packages. It will resolve the dependencies for you automatically.

up2date oracle-validated

will find all packages needed for an Oracle install, and adjust system settings also.

Or download and install the following rpm: http://oss.oracle.com/el5/oracle-validated/

This will save a lot of time hunting through the cd’s for the required packages and resolving dependencies…


Modify kernel limits:

Since version 11g, you can use the generated fixup scripts: "Installation Fixup Scripts".

(I’ll discuss this in the next post, where I’ll create a database).

For completeness, I’ll also discuss how to manually check and change these settings.
Configuring Kernel Parameters for Linux

semmsl
>=250, semmns>=32000 semopm>=100 semmni>=128

[root@ORAVM1 Server]# /sbin/sysctl -a | grep sem
kernel.sem = 250 32000 32 128
  • semopm is only 32, and should be 100
[root@ORAVM1 Server]# /sbin/sysctl -a | grep shm
vm.hugetlb_shm_group = 0
kernel.shmmni = 4096
kernel.shmall = 4294967296
(>=2097152)
kernel.shmmax = 68719476736 (too high: 68 GB, should be more than half of the physical memory => in my case the physical memory is 1,5 GB, so I’ll set it to 800 MB)

[root@ORAVM1 Server]# /sbin/sysctl -a | grep file-max
fs.file-max = 153379
(should be >= 6815744)

[root@ORAVM1 Server]# /sbin/sysctl -a | grep ip_local_port_range
net.ipv4.ip_local_port_range = 32768 61000
(should be 9000 65500)

[root@ORAVM1 Server]# /sbin/sysctl -a | grep rmem_default
net.core.rmem_default = 126976
(should be >=262144)

[root@ORAVM1 Server]# /sbin/sysctl -a | grep rmem_max
net.core.rmem_max = 131071
(should be >=4194304)

[root@ORAVM1 Server]# /sbin/sysctl -a | grep wmem_default
net.core.wmem_default = 126976
(should be >=262144)

[root@ORAVM1 Server]# /sbin/sysctl -a | grep wmem_max
net.core.wmem_max = 131071
(should be >=1048576)

[root@ORAVM1 Server]# /sbin/sysctl -a | grep aio-max-nr
fs.aio-max-nr = 65536
(max: 1048576 => ok)

To change the kernel parameters, create or edit the /etc/sysctl.conf file, and afterwards enter the following command to change the current values of the kernel parameters (=> no reboot necessary):

# /sbin/sysctl -p