Friday, December 17, 2010

Quick reference: pre-installation steps of Oracle database 10g and 11g (non RAC) on RHEL 5


1. Users, groups and directories
# groupadd oinstall
# groupadd dba
# groupadd oper
# useradd -g oinstall -G dba,oper oracle
# passwd oracle
# mkdir -p /u01/app/oracle
# chown oracle:oinstall /u01/app
# chown oracle:oinstall /u01/app/oracle

2. Packages (This needs an yum repository to be configured ready. If you do not have it, refer steps here to create)
# yum install compat-libstdc++* elfutils* gcc-c++ libaio-devel libXp sysstat unixODBC-devel

3. Kernel parameters
/etc/sysctl.conf:

fs.aio-max-nr = 1048576
fs.file-max   = 6815744

kernel.shmall = 2097152
kernel.shmmax = 536870912
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

To make these effect immediately
# sysctl -p

4. Shell limits
/etc/pam.d/login:
session    required     pam_limits.so

/etc/security/limits.conf:
oracle  soft    nproc    2047
oracle  hard    nproc   16384
oracle  soft    nofile   1024
oracle  hard    nofile  65536

/etc/profile:
if [ $USER = "oracle" ]; then
  ulimit -u 16384 -n 65536
fi


Yet another blog post to create database manually (Oracle version 10.2)


1. Environment variables
$ export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
$ export PATH=$ORACLE_HOME/bin:$PATH
$ export ORACLE_SID=testdb

2. Required directories
$ mkdir -p /dbdir/testdb/{control,data,redo,arch}
$ mkdir -p /dbdir/testdb/admin/{a,b,c,u}dump

3. Entries in pfile $ORACLE_HOME/dbs/inittestdb.ora
db_name                    = testdb

control_files              = (/dbdir/testdb/control/control.dbf)

log_archive_dest_1         = "LOCATION=/dbdir/testdb/arch"
log_archive_dest_state_1   = enable

sga_target                 = 500M
pga_aggregate_target       = 100M

undo_management            = AUTO
undo_tablespace            = undotbs

audit_file_dest            = /dbdir/testdb/admin/adump
background_dump_dest       = /dbdir/testdb/admin/bdump
core_dump_dest             = /dbdir/testdb/admin/cdump
user_dump_dest             = /dbdir/testdb/admin/udump

4. Creating database
$ sqlplus / as sysdba

SQL> create spfile from pfile;

SQL> startup nomount;

SQL> CREATE DATABASE testdb
   USER SYS IDENTIFIED BY secret1
   USER SYSTEM IDENTIFIED BY secret2
   DATAFILE '/dbdir/testdb/data/system1.dbf' SIZE 200M
      EXTENT MANAGEMENT LOCAL
   SYSAUX DATAFILE '/dbdir/testdb/data/sysaux1.dbf' SIZE 50M
   DEFAULT TABLESPACE worktbs
      DATAFILE '/dbdir/testdb/data/work1.dbf' SIZE 50M
   DEFAULT TEMPORARY TABLESPACE temptbs
      TEMPFILE '/dbdir/testdb/data/temptbs1.dbf' SIZE 50M
   UNDO TABLESPACE undotbs
      DATAFILE '/dbdir/testdb/data/undotbs1.dbf' SIZE 50M
   LOGFILE GROUP 1 ('/dbdir/testdb/redo/redo1.log') SIZE 50M,
           GROUP 2 ('/dbdir/testdb/redo/redo2.log') SIZE 50M
   ARCHIVELOG
   CHARACTER SET AL32UTF8
   NATIONAL CHARACTER SET AL16UTF16
;

5. Post database creation steps
$ sqlplus / as sysdba
SQL> @?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql
SQL> connect system/secret2
SQL> @?/sqlplus/admin/pupbld.sql
SQL> exit

$ echo "$ORACLE_SID:$ORACLE_HOME:N" >> /etc/oratab


Saturday, December 4, 2010

YUM repository creation for RHEL 5 (a step by step method)

All the below steps have to be performed as "root" user

1. Choose a directory where you would like to stage all the RPMs. This directory occupies around 3GB disk space. In this example, I am using directory /dump/rpm_repo (but you can choose directory of your choice). Create directory using the command,
 # mkdir -p /dump/rpm_repo
2. Mount Linux installation DVD to a directory (for example /media/dvd)
 # mkdir /media/dvd
 # mount /dev/dvd /media/dvd

Verification:
The command
 # ls /media/dvd
should show files in DVD

3. Copy RPM files in DVD to staging directory you have created in step 1.
 # cp -rv /media/dvd/Server/* /dump/rpm_repo

4. Now change directory to staging directory /dump/rpm_repo, to create RPM repository data.
 # cd /dump/rpm_repo

5. Install createrepo package to have createrepo command in the system that we use in next step.
 # rpm -ivh createrepo*
If you get message "package already installed", you can ignore it.

Verification:
The command
 # rpm -q createrepo
should show version of package installed instead of the message "package not installed".

6. Create RPM repository using the command (observe . at the end of the command, which means create repository with packages in current directory)
 # createrepo -g repodata/comps-rhel5-server-core.xml .
This command may take some time to finish based on your system speed.

Now repository is ready, and we have to share it. We can use NFS, FTP or HTTP for this. In this example, we share it through FTP.

7. Install FTP server package using the command
 # rpm -ivh /dump/rpm_repo/vsftpd*

Verification:
The command
 # rpm -q vsftpd
should show version of package installed instead of the message "package not installed".

8. Create a mount point of staging directory in /var/ftp, so FTP server can share this directory.
 a) Create /var/ftp/rhel_repo
     # mkdir /var/ftp/rhel_repo
 b) Edit /etc/fstab and add this entry at the end for the mount point (Caution: Doing wrong things while editing this file, may make your OS not bootable!).
     /dump/rhel_repo  /var/ftp/rhel_repo    auto   bind  0 0
 c) Now, mount /var/ftp/rhel_repo using the command
     # mount /var/ftp/rhel_repo

Verification:
The commands
 # ls /var/ftp/rhel_repo
should show files that you have in /dump/rhel_repo

Note: You can skip this complicated step (8) if you choose your directory in step (1) as /var/ftp/rhel_repo instead of /dump/rhel_repo. But you have to make sure that /var directory should have enough disk space to store 3GB of packages (which is less likely in a typical work environment).

9. Start FTP service and make it to be auto started after reboot.
 # service vsftpd start
 # chkconfig vsftpd on

Verification:
a) Find the IP address of the system using the command
 # ifconfig

b) Now verify FTP server configuration using the command
 # lftp <IP Address>:/rhel_repo -e "ls;exit"
For example,
 # lftp 192.168.1.15:/rhel_repo -e "ls;exit"

This should show all the files you have in /dump/rhel_repo

Now your YUM repository FTP server is ready to use. Configure YUM repository information like below on the system where you want to install the packages.

1. Create a new file /etc/yum.repos.d/myrhel.repo with following contents
[myrhel]
baseurl=ftp://<IP address of YUM repository server>/rhel_repo
gpgcheck=0

For example,

[myrhel]
baseurl=ftp://192.168.1.15/rhel_repo
gpgcheck=0


You can replace your choice of name instead of "myrhel" above.

2. Now you can install any package that is available in repository with command
For example you can try installing a package named "sysstat" using the command,
# yum install sysstat