Sunday 2 October 2011

Oracle 11g

Installing and Configuring Oracle Database 11g
on the Linux Platform
In this document we will install the 11.2.0.1 release of Oracle Database 11g. This is the base distribution of Oracle Database 11g release 2. We run our Oracle installations on servers equipped with Intel processors running Red Hat Enterprise Linux ES release 5 (Tikanga), update 4 (x86_64). Oracle Database 11g is supported on other processor architectures and Linux distributions as well.
There are four phases to getting Oracle up and running on our server:
1.      Prepare the server
2.      Install the Oracle software and latest patch set
3.      Create a database
4.      Complete the server configuration
Prepare the Server:
These steps configure the database server so that it will be ready to accept the Oracle software and database. In this section, we will make sure our server meets Oracle’s minimum requirements, create a Linux user and group to “own” the software, and create some directories that will be used by the Oracle software and database. All of the steps in this section are run as the root user.
1.      Make sure that our hardware platform (processor architecture) is certified by Oracle Corporation for use with Oracle Database 11g release 2, and that we have acquired the correct distribution of Oracle software for our hardware platform. As of May 2010, the supported hardware platforms for Oracle on Linux are as follows:
Supported Hardware Platforms for Oracle Database 11g release 2
x86 (Intel and AMD processor chips that adhere to the x86 32-bit architecture)
x86-64 (AMD64/EM64T and Intel processor chips that adhere to the x86-64 architecture)
2.      The following commands can be used to identify the processor architecture on our database server:
# uname -m
# grep "model name" /proc/cpuinfo
3.      Make sure that our Linux distribution is certified by Oracle Corporation for use with Oracle Database 11g release 2. Note that certifications vary by hardware platform. As of May 2010, the supported Linux distributions are as follows:
Supported Linux Distributions for Oracle Database 11g release 2
Oracle Enterprise Linux 5 update 2, kernel 2.6.18-92 or higher
Oracle Enterprise Linux 4 update 7
Red Hat Enterprise Linux AS/ES 5 update 2 or later
Red Hat Enterprise Linux AS/ES 4 update 7 or later
SUSE Linux Enterprise Server 11.0, kernel 2.6.27.19-5 or higher
SUSE Linux Enterprise Server 10.0 with SP2 or later, kernel 2.6.16.21-0.8 or higher
Asianux 3.0
Asianux 2.0 (update 7 required for x86)
4.      Be sure to check Oracle Support’s Metalink for the latest certification information, because it is quite possible that Oracle Database 11g release 2 has been certified with additional Linux distributions or hardware platforms since this paper was written.
5.      On systems running Red Hat distributions of Linux, we can use the following command to determine exactly which version and update of Red Hat we are using:
# cat /etc/redhat-release
6.      Make sure that all of the required operating system packages have been installed on the database server. Which packages and versions are required will vary depending on our Linux distribution and hardware platform. The package version specified is typically a minimum, meaning that newer versions of the package are usually acceptable.
Required Packages for RHEL 5
Oracle EL5 and Asianux 3.0
(x86 Hardware Platform)
Required Packages for RHEL 5
Oracle EL 5 and Asianux 3.0
(x86-64 Hardware Platform)
binutils-2.17.50.0.6
binutils-2.17.50.0.6
compat-libstdc++-33-3.2.3
compat-libstdc++-33-3.2.3 (both 32 and 64 bit required)
elfutils-libelf-0.125
elfutils-libelf-0.125
elfutils-libelf-devel-0.125
elfutils-libelf-devel-0.125
elfutils-libelf-devel-static-0.125
gcc-4.1.2
gcc-4.1.2
gcc-c++-4.1.2
gcc-c++-4.1.2
glibc-2.5-24 (both 32 and 64 bit required)
glibc-2.5-24
glibc-common-2.5
glibc-common-2.5
glibc-devel-2.5 (both 32 and 64 bit required)
glibc-devel-2.5
glibc-headers-2.5
glibc-headers-2.5
ksh-20060214
kernel-headers-2.6.18
libaio-0.3.106 (both 32 and 64 bit required)
ksh-20060214
libaio-devel-0.3.106 (both 32 and 64 bit required)
libaio-0.3.106
libgcc-4.1.2 (both 32 and 64 bit required)
libaio-devel-0.3.106
libstdc++-4.1.2 (both 32 and 64 bit required)
libgcc-4.1.2
libstdc++-devel 4.1.2
libgomp-4.1.2
make-3.81
libstdc++-4.1.2
sysstat-7.0.2
libstdc++-devel 4.1.2
unixODBC-2.2.11 (both 32 and 64 bit required)
make-3.81
unixODBC-devel-2.2.11 (both 32 and 64 bit required)
sysstat-7.0.2

unixODBC-2.2.11

unixODBC-devel-2.2.11

7.      Notes: elfutils-libelf-devel has a mutual dependency with elfutils-libelf-devel-static so they must both be installed with a single rpm command e.g. (for x86-64)
# rpm -ivh elfutils-libelf-devel-static-0.137-3.el5.x86_64.rpm \ elfutils-libelf-devel-0.137-3.el5.x86_64.rpm
8.      Also some of these packages also have pre-reqs e.g. glibc-headers requires glibc-kernheaders, gcc (x86_64) requires libgomp, glibc-headers (x86_84) required kernel-headers (x86_64), etc.
9.      We can use the following command to verify that a package has been installed:
# rpm -q
10.   The following command will verify all of the packages required on Red Hat Enterprise Linux 5 (x86_86) systems:
# rpm –q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel
# rpm –q gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers ksh
# rpm –q libaio libaio-devel libgcc libstdc++- libstdc++-devel make
# rpm –q sysstat unixODBC unixODBC-devel
11.   Note that in the cases where both the 32 bit and 64 bit architecture of an RPM are required we should see the same package twice in the output. We can confirm that both have been installed with a command similar to the following:
# rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n" | grep libaio
12.   We will need to perform the Oracle installation from an X window environment. We cannot use a character mode environment such as an SSH or telnet session. There is a facility for performing non-interactive installations (“silent” installs), but we won’t be covering that technique here. Our X environment can be the console on the database server, but it does not need to be. We can also use a Windows X emulator like Cygwin. If the database server is in a remote location, we can use SSH to securely forward X traffic from the database server back to our desktop. We can also use VNC to install remotely. We have run installations from a Windows desktop using both Cygwin and VNC and have had no problems with either. Over slow networks, VNC seems to be faster than X.
13.   Make sure that the hardware is sufficient. We’ll need at least 1024 Mb RAM, a swap space at least the size of physical memory (or 1.5 times the amount of physical memory if we have 2 Gb or less of RAM), and a bare minimum of 6.5 Gb of disk space. This will let we perform a “typical” Enterprise or Standard Edition software installation from CD or DVD and create a starter database. The following commands will allow we to check physical memory and swap space:
# grep MemTotal /proc/meminfo
# grep SwapTotal /proc/meminfo
14.   The Oracle installer will need access to a directory with at least 1 Gb of free space for writing temporary files during installation. Usually /tmp serves this purpose. If /tmp on our database server has less than 1 Gb of free space, then we will need to locate another directory with sufficient free space for use during the installation. We can point at this other directory by setting the TMP and TMPDIR environment variables in the oracle user's environment.
15. Make sure that the Linux kernel on the database server has parameters set sufficiently high for Oracle. The Oracle architecture makes extensive use of shared memory segments for sharing data among multiple processes and semaphores for handling locking. Many operating systems, including Linux, do not by default offer sufficient shared memory or semaphores for optimal Oracle performance. Thankfully, we can change kernel parameters in Linux simply by editing the “/etc/sysctl.conf” file and rebooting the server.
The following table shows the purpose of each of these kernel parameters and a recommended setting to get us started:
Kernel
Parameter
Setting To Get
We Started
Purpose
aio-max-nr
1048576
The total number of concurrent outstanding I/O requests
shmmni
4096
Maximum number of shared memory segments
shmall
2097152
Maximum total shared memory (4 Kb pages)
shmmax
4294967295
Maximum size of a single shared memory segment. Set to either (4GB -1) or 1/2 the size of physical memory (in bytes) whichever is lower
semmsl
250
Maximum number of semaphores per set
semmns
32000
Maximum number of semaphores
semopm
100
Maximum operations per semop call
semmni
128
Maximum number of semaphore sets
file-max
6815744
Maximum number of open files
ip_local_port_range
9000 - 65500
Range of ports to use for client connections
rmem_default
262144
Default TCP/IP receive window
rmem_max
4194304
Maximum TCP/IP receive window
wmem_default
262144
Maximum TCP/IP send window
wmem_max
1048576
Maximum TCP/IP send window
These settings will be appropriate for most systems. If we decide to configure a very large buffer cache or library cache for our database down the road, or if we choose to run a large number of databases on one server, then we may need to increase the shmall setting and possibly the shmmax setting as well. In addition, if we configure our database to allow a large number of concurrent sessions without using Oracle's shared server architecture, then we may need to increase the semmsl and semmns settings as well.
Note that these recommended settings assume we have no other applications running on the database server that use shared memory segments or semaphores. We can view current shared memory and semaphore usage on our system with the following command:
# ipcs
In general, if our Linux kernel already has any of these parameters set larger than recommended here, we should not reduce the settings.
We added the following lines to the end of our /etc/sysctl.conf file:
# vi /etc/sysctl.conf
      # Kernel parameter settings for Oracle
           fs.aio-max-nr = 1048576
           fs.file-max = 6815744
           kernel.shmall = 2097152
           kernel.shmmax = 4294967295
           kernel.shmmni = 4096
           kernel.sem = 250 32000 100 128
           net.ipv4.ip_local_port_range = 9000 65500
           net.core.rmem_default = 262144
           net.core.rmem_max = 4194304
           net.core.wmem_default = 262144
           net.core.wmem_max = 1048586
Depending upon our Linux version we can dynamically update the system values via the command
# /sbin/sysctl -p
or simply reboot the server for these parameters to take effect.
If we are using SUSE Linux, then we must run the following command before rebooting the server to ensure that the /etc/sysctl.conf file will be read during reboot:
# /sbin/chkconfig boot.sysctl on
15.   Create a Linux group that will be used by the Oracle software owner. We can call it anything we like, but the standard is “oinstall”. This group is often called the “Oracle Inventory” group. If we will be installing Oracle on multiple servers on our network, we might want to keep the groupid the same on all servers. We can create our oinstall group with a command like:
# /usr/sbin/groupadd -g 501 oinstall
16.   Create a Linux group that will be used by Oracle database administrators. We can call it anything we like, but the standard is “dba”. Anybody who logs onto the database server with a Linux login that belongs to this group will be able to log onto all databases that run from this Oracle software installation with DBA privileges. If we will be installing Oracle on multiple servers on our network, we might want to keep the groupid the same on all servers. We can create our dba group with a command like:
# /usr/sbin/groupadd -g 502 dba
17.   Create a Linux user that will be the Oracle software owner. We can call it anything we like, but the standard is “oracle”. If we will be installing Oracle on multiple servers on our network, we might want to keep the userid the same on all servers. Note that this user’s home directory will not be the ORACLE_HOME or where the actual Oracle software is installed; this user’s home directory should be in the same place as other users’ home directories.
The Oracle software owner should have the oinstall group as the primary group and the dba group as a secondary group. We can create our oracle user with commands like:
# useradd -c 'Oracle software owner' -d /home/oracle -g oinstall -G dba -m -u 501 -s /bin/bash oracle
# passwd oracle
18.   It is necessary to increase limits that the shell imposes on the oracle user for maximum number of open file descriptors and processes. Follow these steps to increase the limits: 
a.      Add the following lines in the “/etc/security/limits.conf” file:
oracle             soft      nproc    2047
oracle             hard    nproc    16384
oracle             soft      nofile    1024
oracle             hard    nofile    65536
b.      Add the following lines to the “/etc/pam.d/login” file, if they are not already present:
session    required     /lib/security/pam_limits.so
session    required     pam_limits.so
c.      Add the following lines in the “/etc/profile” file if the oracle user uses the Bash, Korn or Bourne shell:
               if [ $USER = "oracle" ]; then
              if [ $SHELL = "/bin/ksh" ]; then
                    ulimit -p 16384
                    ulimit -n 65536
              else
                    ulimit -u 16384 -n 65536
              fi
              umask 022
      fi
d.      If the oracle user uses the C shell, then add the following lines in the “/etc/csh.login” file.
           if ( $USER == "oracle" ) then
              limit maxproc 16384
              limit descriptors 65536
              umask 022
      endif
19.   Create mount points for the Oracle software and the Oracle database. Each mount point should correspond to a separate physical device or set of devices. We’ll need at least one mount point. Typically we use one mount point for the Oracle software and one or more mount points for each database. One common convention is to call the mount points /u01, /u02, and so on. Because mount points are typically owned by root and the Oracle installer will run as the oracle user and not as root, we should create some subdirectories now to avoid permission problems later. Create an “app/oracle” subdirectory below the software mount point, and “oradata” subdirectories below the mount points to be used for database files. (We can put software and a database on the same mount point if we wish.) Make these subdirectories owned by the oracle user and oinstall group, and give them 775 permissions, except for the datafile directory, give these 750 permissions.
# mkdir -p /u01/app /u01/app/oracle /u01/oradata
# chown oracle:oinstall /u01/app /u01/app/oracle /u01/oradata
# chmod 775 /u01/app /u01/app/oracle
# chmod 750 /u01/oradata
20.   If we downloaded the Oracle software Oracle Technology Network, then use unzip to unpack the distribution. If we have the software on CD or DVD, then mount the Oracle Database 11g release 2 media now.

21.   As an optional step, it is suggested that we validate our configuration using the pre-install tests of Oracle's Remote Diagnostic Agent (rda.sh), we can find details of doing this in Metalink note 250262.1. The procedure is to download the latest version of rda.sh and run its pre-install checklist via the command
# cd
# ./rda.sh -T hcve
Then choose the appropriate option 'Oracle Database 11g R2 (11.2.0) Preinstall (Linux AMD64)' option.

Install the Oracle Software and Latest Patch Set:
These steps install the Oracle software and latest patch set on our server. The Oracle Universal Installer will suggest creating a database at the same time that it installs the Oracle software. Although we do not have any latest patchsets to install, we will hold off on the database creation until a later step since that is the preferred sequence of events once a 11g release 2 patch set is eventually released.
In this section, we will prepare the oracle user’s environment, run the Oracle Universal Installer and tidy up a few minor loose ends. All of the steps in this section, except where noted, are run as the oracle user.
1.      Edit the oracle user’s login file on the database server so that the environment will be configured automatically on login. If we are using Bash shell, then edit “/etc/profile”.
# vi /etc/profile
export ORACLE_BASE=/u01/app/oracle
unset ORACLE_HOME
unset TNS_ADMIN
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
2.      Log out and log back in as the oracle user from an X window so that the environment is set correctly.
# su – oracle
3.      Make sure our DISPLAY variable is set. If we are forwarding X window traffic over an SSH connection, using VNC, or working from the server’s console directly, the DISPLAY variable should already be set for we. If our DISPLAY variable has not been set already, then we will need to set it manually to the IP address of our X server plus the X server and screen numbers. We can set our DISPLAY variable with a command like:
$ export DISPLAY=myworkstation:0.0
               or,
$ export DISPLAY=:0.0

4.      If we had to set our DISPLAY variable manually in the previous step, then ensure that the X server on our workstation will allow our database server to open windows on our display. The easiest way to do this is to issue an xhost command from a session on our workstation. (Don’t get confused and issue the command in a window that is logged onto our database server.) We can issue a command like:
$ xhost +mydatabaseserver
               or,
$ xhost +

5.      Ensure that the mount point we plan to use for the Oracle software has sufficient free space. For a basic Enterprise Edition and patch set installation, allow 1.6 GB for the software mount point as a bare minimum.

6.      Double check that we are logged in as oracle and not root, and that the environment variables have been set by the login script we prepared earlier. Then change to our home directory and start the Oracle Universal Installer with a command like one of the following:
$ /database/runInstaller
               or,
$ /runInstaller
We’ll walk through the installer prompts one at a time: 
a.      The Configure Security Updates window appears. If we wish to receive security updates via email then enter our email address and our Oracle support password. If not, deselect the checkbox. Click Next. If we deselected the checkbox hit 'Yes' when the popup warning that we have not provided an email address appears.
b.      The Select Installation Option window appears. Choose option 'Install database software only'. Click Next.
c.      The Node Selection window appears. Choose Single instance database installation and then click Next.
d.      When the Select Product Languages window appears move the desired languages into the right hand panel. Click Next.
e.      The Select Database Edition window appears. We will perform a “typical” install to get a basic set of Oracle software installed. We can rerun the installer again later and choose Custom to install additional products individually. For now, choose Standard Edition or Enterprise Edition. The Enterprise Edition of Oracle Database 11g has some very sophisticated features missing from Standard Edition, and the opportunity to purchase additional options that might be valuable to a large enterprise. However, the Enterprise Edition is much more expensive than Standard Edition. It is very important that we choose the edition that matches our license, as this will be difficult to fix later. The Select Options button displays 6 extra cost options that can only be licensed against the Enterprise Edition. Again our specific license agreement needs to be consulted here, it is recommended that we deselect the extra cost options that we have not purchased. Click Next.
f.       The Specify Installation Location window appears. Oracle provides a suggested Oracle Base Path for the Oracle home (software installation) that is about to be created. We can name this Oracle home anything we like. Beginning in Oracle Database 11g the standard for Oracle home location has changed to /<mount-point>/app/oracle/product/11.2.0/dbhome_<N>. In 10g the dbhome string was shortened to db. The naming convention, such as dbhome_1, dbhome_2 allows us to install multiple copies of the same Oracle version on one server in a standardized way. Note that we will refer back to this path frequently, calling it the Oracle home or simply $ORACLE_HOME. If we are planning to go with the path suggestion provided by Oracle, make sure there isn’t an extra occurrence of the “oracle” component in the path.When we are satisfied with the path of Oracle Base and the name and path for our Oracle home, click Next.
g.      If we do not have at least 4,397MB of free disk space available in our $ORACLE_HOME we will get an error. Make sure we have enough free space available, otherwise we will not be able to proceed with the install.
h.     If the Create Inventory window appears, set the inventory directory to the parent of the $ORACLE_BASE directory, remember we set the value of the $ORACLE_BASE environment variable in the login script. In the oraInventory Group Name field, select the oinstall group. Click Next. We won't see this window if we have previously installed Oracle software on this database server. Historically it was common to have the inventory directory located as $ORACLE_BASE/oraInventory but in 11g Oracle are recommending against this configuration.
i.       The Privileged Operating System Groups screen appears. Set the OSDBA Group to 'dba' and the OSOPER Group to 'oinstall'. Click Next.
j.       The Prerequisite Checks will run, if they all pass then the installer will continue onto the Summary window. Obviously if we have failed any prerequisite checks we should resolve them before proceeding. Assuming we made it to the Summary window Click Finish.
k.      During the installation and Execute Configuration Scripts window will appear. The installation will be paused at this point, waiting for us to run scripts as root. (The first time we install Oracle software on the database server there will be two scripts to run as root, while additional installations only require one script to be run as root.) We should open another window, log in to the database server as root, and review the scripts to be run thoroughly, run the scripts, and click OK in the Execute Configuration Scripts window.
l.       Once the root scripts have ran the installer will display the Finish window, click Close to end the installation.

7.      In $ORACLE_HOME/bin (the bin directory under our Oracle home) we will find a shell script called oraenv. This script can be called from .bash_profile or .profile to set up a user’s environment automatically whenever they log onto the database server. We will customize the oraenv script because there are a few variables that the script should set but doesn’t. Make a backup copy of the oraenv script and then edit it, adding the following lines to the very end:
# vi ~/.bash_profile
               # Begin customizations
           DBA=$ORACLE_BASE/admin
           # Substitute the locale and character set we plan to use for our
           # database in the line below. Nowadays the two main common choices are:
           #   NLS_LANG=american_america.WE8MSWIN1252 (11gR2 Unix default)
           #   NLS_LANG=american_america.AL32UTF8     (Unicode 5)
           NLS_LANG=american_america.WE8MSWIN1252
           export DBA NLS_LANG
           # End customizations

8.      In the same directory we’ll also find a shell script called coraenv that can be called from .cshrc. If we use C shell, we will want to back up and edit coraenv with similar changes to the oraenv script.

9.      The root.sh script copied oraenv and coraenv from $ORACLE_HOME/bin to the /usr/local/bin directory. We just updated these scripts in $ORACLE_HOME/bin. Copy the updated versions to the /usr/local/bin directory.

10.   Set the ORACLE_HOME environment variable to point to our Oracle home with a command like:
# vi /etc/profile
               export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
           export ORACLE_SID=dev11ee
           :wq


            Reconfigure Oracle 11g: If error occurs first de-configure it and then reconfigure it as,
# su – oracle
$ cd /u01/app/oracle/product/11.2.0/db_1/bin
$ ./emca –deconfig dbcontrol db –repos drop      (De-configure Oracle 11g)
               Now reconfigure it as,
$ ./emca –config dbcontrol db –repos create


            Starting Oracle Listener and Database:
# su – oracle
$ lsnrctl status                                 (Check database status)
$ lsnrctl start                                     (To start Oracle listener)
$ sqlplus / as sysdba
SQL> startup                                    (To start Oracle database)
SQL> alter database open
SQL> show user
SQL> startup mount
SQL> alter database mount;
SQL> exit

# netstat –tnlp | grep 1158            (To check running status of oracle on 1158 port)

$ emctl start dbconsole                 (Starting Oracle Enterprise Manager)

               If we start database first and we cannot start listener before it then fire this command.
$ alter system resister


        Install APEX on Oracle 11g:
           With 11g database installing APEX is much easier.In Oracle Database 11g, Oracle Application Express is installs when the database is installed. Only thing we have to do is to run script “apxconf” located under “$ORACLE_HOME/apex” directory. This script will configure PL/SQL gateway.

# cd $ORACLE_HOME/apex
# su – oracle
$ sqlplus / as sysdba
SQL> @apxconf
      PORT         8080
Enter values below for the XDB HTTP listener port and the password for the Application Express ADMIN user.
Default values are in brackets [ ].
Press Enter to accept the default value.
Enter a password for the ADMIN user              [] admin_123
Enter a port for the XDB HTTP listener [      8080]
…changing HTTP Port
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
Session altered.
…changing password for ADMIN
PL/SQL procedure successfully completed.
Commit complete.
SQL> alter user anonymous account unlock;
User altered.
SQL> exit


Manage Workspace and User in Oracle 11g APEX

To create Workspace (Group): Be sure the Oracle 11g Listener, Database and Enterprise Manager is started. Open any Web explorer  and type http://127.0.0.1:6565/apex/apex_admin, where “6565” is the Oracle apex port number which is assign during apex installation. It will ask the admin password, enter the the password which is also assign during apex installation. After that open Oracle Application Express.
Click on Manage Workspaces > Create Workspace > Enter any workspace name (developer) > Next > Enter Schema name (dev) and Schema Password (123456) > Next > Enter Adminstrator Password (123456), First name, Last name and E-mail of Administrator > Next > Create > Done.
A new workspaces is create.

Creating User Under Workspace: Click on Manage Workspace > Existing Wokspaces > Click on newlly created workspace (developer) > Manage User > Create > Enter User name, E-mail address, Default Schema, Workspace, First name, Last name and Password > Create.
A new user is created under a workspace.

No comments:

Post a Comment

Boot to UEFI Mode or legacy BIOS mode

Boot to UEFI Mode or legacy BIOS mode Choose UEFI or legacy BIOS modes while installing Windows. After Windows is installed, if you nee...