Instalacion Oracle en Linux RH
Instalacion Oracle en Linux RH
Instalacion Oracle en Linux RH
html
ggggggggg
Oracle Database 11.2.0.3 Install and Setup on RedHat
Linux 6 x86_64
In this post we will install a new server with the latest Oracle Database 11gR2 software (as of
this writing, it is version 11.2.0.3). In this example, the new machine is
called opus.company.com and the new database instance is calledmeta.
Pre-Installation Tasks
Software Download
Start by connecting to My Oracle Support and search for patchset 10404530. There are seven
files in this patch. According to the patch README, the files are :
Installation Type Zip File Oracle Database (includes Oracle Database and Oracle RAC)
Note: you must download both zip files to install Oracle Database.
p10404530_112030_platform_1of7.zip
p10404530_112030_platform_2of7.zip
Oracle Grid Infrastructure (includes Oracle ASM, Oracle Clusterware, and Oracle Restart)
p10404530_112030_platform_3of7.zip
Oracle Gateways
p10404530_112030_platform_5of7.zip
Oracle Examples
p10404530_112030_platform_6of7.zip
Deinstall
p10404530_112030_platform_7of7.zip
We only need the first two files to install the database. Since that's our goal, then download the
first two files and place them into a staging NFS directory. If you don't have one, then go ahead
and create one on your NFS server as this is quite handy! (Check Doc ID 1117597.1 for the
NFS options).
Note that even if the files come from a patchset, they're actually a full software install. So we
don't need to have version 11.2.0.1 or 11.2.0.2 installed before we install version 11.2.0.3.
mkdir /nfs/install/oracle/11.2/x86_64
mv ~/Downloads/p10404530_112030_Linux-x8664_*.zip /nfs/install/oracle/11.2/x86_64
Create the checksum files. The exact values are listed in the patch digest page.
echo "80A78DF21976A6586FA746B1B05747230B588E34"
> /nfs/install/oracle/11.2/x86_64/p10404530_112030_Linux-x8664_1of7.zip.sha1
echo "A39BED06195681E31FBB0F6D7D393673BA938660"
> /nfs/install/oracle/11.2/x86_64/p10404530_112030_Linux-x8664_2of7.zip.sha1
Verify the SHA1 checksum of both files and compare the results with the ones listed above. The
results are not case sensitive.
openssl dgst -sha1
/nfs/install/oracle/11.2/x86_64/p10404530_112030_Linux-x86-64_1of7.zip
openssl dgst
-sha1 /nfs/install/oracle/11.2/x86_64/p10404530_112030_Linux-x8664_2of7.zip
Extract both zip files. This will create a database directory.
cd /nfs/install/oracle/11.2/x86_64
unzip p10404530_112030_Linux-x86-64_1of7.zip
unzip p10404530_112030_Linux-x86-64_2of7.zip
Server Setup
Install a Minimal RedHat Enterprise Linux 6 x86_64 machine. I like to create seperate mount
points for /u01, /u02and /u03 as specified by the Oracle Flexible Architecture guide. In this
blog, we build an RMAN server. It doesn't need quite a lot of disk space, so I'm only using local
disk drives. For production databases, the /u02 and /u03mount points are LUNs on a SAN, so
I use ASM. But this will be the topic of another blog post :)
/etc/fstab
Once your server is up and running, connect to it and edit the /etc/fstab to build a bigger
shared memory. Bigger is better here. But it depends on the amount of memory the machine
has. See the Oracle Database Administrator's Reference 11g Release 2 (11.2) for Linux and
UNIX-Based Operating Systems Chapter C - Administering Oracle Database on Linux guide
for more info.
WARNING : don't just copy this fstab line! Just copy the line which starts with shmfs and
paste it into your own/etc/fstab file. And adjust the size according to the amount of memory
in your system. This is just an example.
sudo vi /etc/fstab
tmpfs
/dev/shm
tmpfs
size=4g
0 0
Kernel Configuration
We must change quite a few parameters in the RedHat Linux kernel to keep Oracle happy.
sudo vi /etc/sysctl.conf
Don't forget that we must reboot to enable those changes. Well, that's not exactly true, as we
can force the config with the help of sysctl(8) command. But rebooting now will ensure that
our /etc/sysctl.conf file does not contain any errors. Imagine you reboot after the software
is installed and it doesn't work. Try tracing the problem down to this file is quite a timeconsuming (and frustrating) task.
sudo shutdown -r now
Security Limits
Configure shell limits for the oracle user. Here I set both the grid and the oracle user's
limits. In this blog we're not using the grid user. But I like to have all my systems as identical as
possible.
sudo vi /etc/security/limits.conf
Package Installation
We must make sure this new Oracle machine has several RPM installed. For instance,
the xorg-x11-xauth rpm is installed because we need the xauth(1) command for the
X11 forwarding to work. We also install the xorg-x11-utils package in order to have access
to the xdpyinfo(1) command which is used by the Orace Universal Installer (OUI) when it
starts. We don't absolutely need this, as you can always ignore the system prerequisites when
you start the OUI with the -ignorePrereq flag.
sudo yum -y install xorg-x11-xauth gcc gcc-c++ libaio libaiodevel compat-libstdc++-33 glibc-devel glibc-headers libstdc+
+ sysstat binutils make expat compat-libcap1 ksh compat-glibc compatglibc-headers glibc-devel.i686
Don't be surprised by the number of other packages that will be installed to satisfy
dependencies.
groupadd
groupadd
groupadd
groupadd
groupadd
groupadd
-g
-g
-g
-g
-g
-g
5000
5001
5002
5003
5004
5005
oinstall
dba
sysoper
asmadmin
asmdba
asmoper
Then we create the oracle and grid users. Again, we don't really need the grid user in this
post, but let's create it anyway. Who knows, maybe one day we will migrate to ASM?
sudo useradd -u 5001 -g oinstall -G dba,asmadmin,asmdba,asmoper -d
/usr/home/grid -s /bin/bash -c
"Oracle Grid Infrastructure Owner" -m grid
sudo useradd -u 5000 -g oinstall -G dba,sysoper,asmdba -d
/usr/home/oracle -s /bin/bash -c "Oracle
Database Owner" -m oracle
Edit /etc/profile to handle these new users.
sudo vi /etc/profile
We will need our new Oracle machine to accept SSH connections from our oracle and grid
users. We also need it to forward X11. To do this, edit sshd's configuration.
WARNING : make sure you understand this file, because you can lock yourself out from the
server if you don't!
sudo vi /etc/ssh/sshd_config
Restart the daemon so that he understands the changes.
sudo /etc/init.d/sshd restart
Now from your workstation, if you haven't done so already, create a pair of SSH keys and then
send the public one to your new Oracle server.
ssh-keygen -t rsa
scp ~/.ssh/id_rsa.pub opus.company.com:/tmp
Connect to the machine and place your public SSH key into the oracle user's authorized_keys.
ssh opus.company.com
sudo su - oracle
mkdir ~/.ssh
cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
exit
rm /tmp/id_rsa.pub
exit
Back on your own workstation, allow the new server X11 access to the local machine and then
connect to the new machine with the X11 forwarding enabled.
xhost +opus.company.com
ssh -Y -X oracle@opus.company.com
Create Directories
Let's connect to the new machine and create some directories. First the Oracle Inventory.
ssh opus.company.com
sudo mkdir -p /u01/app/oraInventory
sudo chown root:oinstall /u01/app/oraInventory
sudo chmod -R 2775 /u01/app/oraInventory
Then create the Oracle base.
sudo mkdir -p /u01/app/oracle
sudo chown -R oracle:oinstall /u01/app/oracle
sudo chmod -R 775 /u01/app/oracle
Software Installation
Connect to the new machine with X11 enabled.
ssh -YX oracle@opus.company.com
Doc ID 1454982.1 - Installing 11.2.0.3 64-bit (x86-64) on RHEL6 Reports That Packages
"elfutils-libelf-devel-0.97" and "pdksh-5.2.14" are missing (PRVF-7532)
Because of a bug with the 11.2.0.3 OUI (see Doc ID 1454982.1), we must edit a file before we
can start the OUI.
cd /nfs/install/oracle/11.2/x86_64/database/stage/cvu/cv/admin
cp cvu_config cvu_config.backup
vi cvu_config
Post-Installation Tasks
.bash_profile
Let's configure the oracle user's environment. I always like to keep a copy of the environment
that has nothing Oracle related configured. It's usefull when we need to run OUI again.
cp ~/.bash_profile ~/.bash_profile.oui
vi ~/.bash_profile
.aliases
Let's create some finger-friendly aliases.
vi ~/.aliases
Check to make sure the environment is ok?
source ~/.bash_profile
env | sort
alias
login.sql
This file is read when we start an sqlplus session. I like to change things a bit.
mkdir -p /nfs/home/oracle/scripts/
vi /nfs/home/oracle/scripts/login.sql
Database Creation
We're now ready to create a new empty database. In this example, the database will be called
meta .
for DIR in adump dpdump hdump pfile scripts; do
sudo mkdir -p /u01/app/oracle/admin/meta/$DIR
done
sudo mkdir -p /u01/oradata /u02/oradata /u03/oradata
sudo chown -R oracle:oinstall /u0*/oradata
sudo chown -R oracle:oinstall /u01/app/oracle/admin
I like to use the Oracle Database Configuration Assistant (DBCA) to setup the SQL scripts. This
is because each version of Oracle has a modified DBCA which uses the latest configurations.
Instead of using a database creation script I used for Oracle 10gR1 on a new 11gR2, I prefer to
generate new scripts via the latest DBCA. I then save those scripts and run them manually.
Running them manually gives me the opportunity to learn how it's done. I can also run those
scripts manually on another machine without using DBCA again in case this machine doesn't
have X11 forwarding enabled. So start DBCA and save the scripts.
sudo su - oracle
$ORACLE_HOME/bin/dbca
This will generate a bunch of files. You can download them from my dropbox account.
Execute the scripts to create the new database.
sudo su - oracle
sh /u01/app/oracle/admin/meta/scripts/meta.sh
Configure SQL*Net
Switch to the oracle user and configure SQL*Net.
sudo su - oracle
vi $ORACLE_HOME/network/admin/tnsnames.ora
Configure a basic listener setup. The point here is just to start the listener. Don't forget that we
already have alistener.ora template located in
the $ORACLE_HOME/network/admin/samples directory.
vi $ORACLE_HOME/network/admin/listener.ora
Start the listener.
lsnrctl start
Next SQL*Net file to configure is the sqlnet.ora file.
vi $ORACLE_HOME/network/admin/sqlnet.ora
And the tnsnames.ora file.
vi $ORACLE_HOME/network/admin/tnsnames.ora
I've already wrote on this topic in a previous blog post, but it was for RedHat 5 and we're on
RedHat 6 here. So let's go over this again. We will change all of our databases audit trail to
SYSLOG audit trails as it's the Oracle recommended best practices. The idea here is that logs
sent to syslog will be placed inside a file to which neither the oracle user nor any of it's groups
have write access. So in theory, the DBA and the Linux systems administrator are not the same
person. Which means that if the DBA does something fishy, he won't be able to edit the audit
trail to cover his or her actions.
Configuring Syslog Auditing
kick in. We run the show parameter audit query again after the restart to make sure our audit
parameters are now online.
SQL> shutdown immediate;
SQL> startup;
SQL> show parameter audit;
NAME
TYPE
VALUE
---------------------- -------- -------------------------------audit_file_dest
string
/u01/app/oracle/admin/meta/adump
audit_sys_operations
boolean TRUE
audit_syslog_level
string LOCAL0.INFO
audit_trail
string OS
Double check the audit trail now?
SQL> exit
tail /var/log/oracle/audit.log
You should get a permission denied here because you tried to access the audit trail as
the oracle user. Try again as root via sudo.
exit
sudo tail /var/log/oracle/audit.log
Good!
One last thing before we're finished with the audit parameters. As Doc ID 308066.1 clearly
explains, we will always get audit logs in our $ORACLE_BASE/admin/
$ORACLE_SID/adump directory. So let's make sure it doesn't grow out of proportion by clearing
the old audit logs. We do this in the oracle user's crontab.
sudo su - oracle
crontab -e
Finally, I like to use Jefferey M. Hunter's scripts. He's an Oracle ACE which has created
management scripts for Oracle. They're interesting, so we install them. Grab a copy of the
scripts and extract them to a central Oracle NFS directory.
mkdir -p /nfs/home/oracle/scripts/jeffrey.hunter
cd /nfs/home/oracle/scripts/jeffrey.hunter
wget
http://www.idevelopment.info/data/Oracle/DBA_scripts/dba_scripts_archi
ve_Oracle.zip
unzip
/nfs/home/oracle/scripts/jeffrey.hunter/dba_scripts_archive_Oracle.zip
Then, create the ORACLE_PATH directory and extract the scripts into it.
mkdir -p $ORACLE_BASE/common/sql
cp /nfs/home/oracle/scripts/jeffrey.hunter/dba_scripts/sql/*
$ORACLE_BASE/common/sql
Doc ID 369619.1 - OCM (Oracle Configuration Manager) and My Oracle Support : FAQ
and Troubleshooting
OCM comes built-in with 11gR2, so we will configure it right now. OCM requires Java JRE to be
installed. So go to theOracle Java website and download the latest Java SE package and install
it (follow the instructions on the Oracle website).
Once you have Java JRE installed, configure OCM. You will need your Oracle Support Contract
number and the email you use to connect to My Oracle Support. In this example, the contract
number and the email is bogus, as this is just an example...
$ORACLE_HOME/ccr/bin/setupCCR 973649 david.robillard@company.com
This will deploy OCM and print out some info about what it's doing and what are the next steps
you need to execute. One of those steps is to configure the daily collection interval. The idea
here is to use different collection times for the various machines on your network so that they
don't connect to My Oracle Support at the exact same time.
$ORACLE_HOME/ccr/bin/emCCR set collection_interval="FREQ=DAILY;
BYHOUR=6; BYMINUTE=20"
We can now check the crontab to see what was installed by the emCCR command?
crontab -l
0,15,30,45 * * * *
/u01/app/oracle/product/11.2.0.3/dbhome_1/ccr/bin/emCCR -cron -silent
start
For each of the database instances running on the machine, execute the post-installation script.
$ORACLE_HOME/ccr/admin/scripts/installCCRSQL.sh collectconfig -s meta
Test then start a collection.
$ORACLE_HOME/ccr/bin/emCCR test
$ORACLE_HOME/ccr/bin/emCCR collect
Now login to My Oracle Support and check the Systems tab, you should now see your instance
listed there.
Startup Scripts
Let's create startup scripts for the listener and the database. We will include those new scripts in
the RedHat startup procedure. So, as your own user, create the Oracle listener startup script.
sudo vi /etc/init.d/oracle.listener
sudo chkconfig oracle.listener on
And then the Oracle RDBMS startup script.
sudo vi /etc/init.d/oracle.db
sudo chkconfig oracle.db on
Double check to see if the new scripts are part of the RedHat system's startup configuration?
chkconfig --list | grep oracle
Be sure to test both scripts!
Reboot your server to see if the database and the listener are up without any intervention on
your part.
sudo shutdown -r now
===========================
File Size(MB) Tablespace
---- -------- -------------------1
612
SYSTEM
/u02/oradata/meta/system01.dbf
2
666
SYSAUX
/u02/oradata/meta/sysaux01.dbf
3
393
UNDOTBS1
/u02/oradata/meta/undotbs01.dbf
4
5
USERS
/u02/oradata/meta/users01.dbf
5
14
RMAN
/u02/oradata/meta/rman01.dbf