#!/bin/bash
#Test in RHEL 5.5 for 10g
C= ' Cat/etc/shadow | grep Oracle | Wc-l '
if [$c! = 0]
Then
W=0
While [$w-eq 0]
Do
echo "--find user Oracle has been existed!--"
echo "--do want to delete user Oracle?" [Yes/no]: "
Read yn
Case $yn in
"Yes")
gpasswd-d Oracle DBA
Userdel-r Oracle
Rm-fr/home/oracle
echo "--user Oracle has been deleted.--"
/usr/sbin/groupadd Oinstall
/usr/sbin/groupadd DBA
/USR/SBIN/USERADD-G oinstall-g dba Oracle
echo "--please set user Oracle ' s password--"
passwd Oracle
echo "--password is OK!--"
W=1
;;
"No")
echo "-I'll not delete user Oracle!--"
W=1
;;
*)
echo "--please input yes or no!--"
W=0
;;
Esac
Done
Else
/usr/sbin/groupadd Oinstall
/usr/sbin/groupadd DBA
/USR/SBIN/USERADD-G oinstall-g dba Oracle
echo "--please set user Oracle ' s password."
passwd Oracle
echo "--password is OK!--"
Fi
Mkdir-p/u01/app/oracle
Chown-r oracle:oinstall/u01
Chmod-r 775/u01
Sed-i '/kernel.shmmax/d '/etc/sysctl.conf
sed-i '/kernel.shmall/d '/etc/sysctl.conf
sed-i '/kernel.shmmni/ d '/etc/sysctl.conf
sed-i '/kernel.sem/d '/etc/sysctl.conf
sed-i '/fs.file-max/d '/etc/sysctl.conf
sed-i '/ net.ipv4.ip_local_port_range/d '/etc/sysctl.conf
sed-i '/net.core.rmem_default/d '/etc/sysctl.conf
sed-i '/ Net.core.rmem_max/d '/etc/sysctl.conf
sed-i '/net.core.wmem_default/d '/etc/sysctl.conf
sed-i '/ Net.core.wmem_max/d '/etc/sysctl.conf
Sed-i "/#fordelbegin/,/#fordelend/d"/etc/sysctl.conf
Cat >>/etc/sysctl.conf << "EOF"
#fordelbegin #################################
#use for Oracle
Kernel.shmmax = 2147483648
Kernel.shmall = 2097152
Kernel.shmmni = 4096
Kernel.sem = 250 32000 100 128
Fs.file-max = 65536
Net.ipv4.ip_local_port_range = 1024 65000
Net.core.rmem_default = 1048576
Net.core.rmem_max = 1048576
Net.core.wmem_default = 262144
Net.core.wmem_max = 262144
#fordelend
Eof
/sbin/sysctl-p
echo "--/ect/sysctl.conf is OK!--"
Sed-i "/#fordelbegin/,/#fordelend/d"/etc/security/limits.conf
Cat >>/etc/security/limits.conf << "EOF"
#fordelbegin #################################
#use for Oracle
Oracle Soft Nproc 2047
Oracle Hard Nproc 16384
Oracle Soft Nofile 1024
Oracle Hard Nofile 65536
#fordelend
Eof
echo "--/etc/security/limits.conf is OK!--"
Sed-i "/#fordelbegin/,/#fordelend/d"/etc/pam.d/login
Cat >>/etc/pam.d/login << "EOF"
#fordelbegin #################################
#use for Oracle
#session required/lib64/security/pam_limits.so #for 64
Session Required/lib/security/pam_limits.so #for 32
Session Required Pam_limits.so
#fordelend
Eof
echo "--/etc/pam.d/login is OK!--"
Sed-i "/#fordelbegin/,/#fordelend/d"/etc/profile
Cat >>/etc/profile << "EOF"
#fordelbegin # # # # # # # #############################
#use for Oracle
If [$USER = "Oracle"]; then & NBSP;&NBSP
If [$SHELL = "/bin/ksh"]; then
ulimit-p 16384
ulimit-n 65536
else
ulimit-u 16384-n 65536
fi
Fi
#fordelend
EOF
echo "--/etc/profile is OK!--"
Sed-i "/#fordelbegin/,/#fordelend/d"/home/oracle/.bash_profile
Cat >>/home/oracle/.bash_profile << "EOF"
#fordelbegin #################################
#use for Oracle
Umask 022
Oracle_base=/u01/app/oracle
Oracle_home= $ORACLE _base/product/10.2.0/db_1
Oracle_sid=db01
Path= $ORACLE _home/bin: $PATH
Ld_library_path= $ORACLE _home/lib:/lib:/usr/lib
Nls_lang=american_america. Zhs16gbk
Export oracle_base oracle_home oracle_sid PATH ld_libary_path Nls_lang
#fordelend
Eof
echo "--please set you Oracle_sid:"
Read Orasid
Sed-i "s/db01/$orasid/g"/home/oracle/.bash_profile
Source/home/oracle/.bash_profile
echo "--/home/oracle/.bash_profile is OK!--"
echo "--config is OK!--"
echo "--dont forget to VI your/etc/hosts.--"
Oracle 10g Installation Environment configuration script