#! /bin/bash
echo "#########oracle9R204 的一个简单的安装脚本 ##############################"
#
# 为系统添加oracle的用户和用户组
#
groupadd dba
groupadd oinstall
useradd -c "Oracle software owner" -g oinstall -G dba oracle
passwd oracle
# 创建oracle 的安装目录
mkdir /oracle/oracle
mkdir /oracle/oracle/product
mkdir /oracle/oracle/product/9.2.0
chown -R oracle.oinstall /oracle/oracle
mkdir /var/opt/oracle
chown oracle.dba /var/opt/oracle
chmod 755 /var/opt/oracle
#更改gcc,g++版本
cd /usr/bin
mv gcc gcc323
mv g++ g++323
ln -s gcc296 gcc
ln -s g++296 g++
#设置Oracle配置文件
echo "oracle soft nofile 65536" >> /etc/security/limits.conf
echo "oracle hard nofile 65536" >> /etc/security/limits.conf
#最大的进程数量
echo "oracle soft nproc 16384" >> /etc/security/limits.conf
echo "oracle hard nproc 16384" >> /etc/security/limits.conf
#修改配置/etc/sysctl.conf
echo "#################################################### " >> /etc/sysctl.conf
echo "kernel.shmall = 2097152" >> /etc/sysctl.conf
# shmmax内核参数定义单个共享内存段的最大值,如果该参数设置小于Oracle SGA设置,
# 那么SGA就会被分配多个共享内存段。这在繁忙的系统中可能成为性能负担,带来系统问题。
# 如果没有修改shmmax参数,Oracle在启动过程中就可能会报出以下错误:
##############################################################################
# Starting ORACLE instance (normal)
# Thu Nov 17 09:27:29 2005
# WARNING: EINVAL creating segment of size 0x0000000033400000
# fix shm parameters in /etc/system or equivalent
##############################################################################
#这里我们设为 2G
echo "kernel.shmmax = 2147483648" >> /etc/sysctl.conf
#单个共享内存段的最小值
echo "kernel.shmmni=4096" >> /etc/sysctl.conf
# kernel.sem中的四个值分别 是指
# 1:SEMMSL(每个用户拥有信号量最大数量),
# 2:SEMMNS(系统信号量最大数量),
# 3:SEMOPM(每次semop系统调用操作数),
# 4:SEMMNI(系统信号量集最小数量)
echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
#系统允许同时打开的最大文件数为65536
echo "fs.file-max = 65536" >> /etc/sysctl.conf
# 本地主机在ipv4下可用端口范围
echo "net.ipv4.ip_local_port_range = 1024 65000" >> /etc/sysctl.conf
# 使/etc/sysctl.conf 文件生效
/sbin/sysctl -p
#
#通过编辑 /home/oracle/.bash_profile文件来设置用户环境变量
echo "############ everoment for oracle################" >> /home/oracle/.bash_profile
echo "export LD_ASSUME_KERNEL=2.4.1" >> /home/oracle/.bash_profile
echo "export THREADS_FLAG=native" >> /home/oracle/.bash_profile
echo "export ORACLE_BASE=/oracle/oracle" >> /home/oracle/.bash_profile
echo "export ORACLE_HOME=/oracle/oracle/product/9.2.0" >> /home/oracle/.bash_profile
echo "export ORACLE_SID=orcl" >> /home/oracle/.bash_profile
echo "export ORACLE_TERM=xterm" >> /home/oracle/.bash_profile
echo "export ORACLE_OWNER=oracle" >> /home/oracle/.bash_profile
echo "export NLS_LANG=AMERICAN;" >> /home/oracle/.bash_profile
echo 'export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data' >> /home/oracle/.bash_profile
echo 'LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib' >> /home/oracle/.bash_profile
echo 'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib' >> /home/oracle/.bash_profile
echo "export LD_LIBRARY_PATH" >> /home/oracle/.bash_profile
echo 'export PATH=$PATH:$ORACLE_HOME/bin' >> /home/oracle/.bash_profile
#打安装前所需的p3006854补丁
USER=`whoami`
if [ $USER != root ]; then
echo "Must be root to run this script, please login as root and re-try"
exit
fi
# see if libcwait.so is already being loaded
if [ -f "/etc/ld.so.preload" ] && [ -n "`grep libcwait /etc/ld.so.preload`" ]; then
echo "Patch has already been applied"
exit
else
echo "Applying patch..."
fi
cat << EOF |
#include <errno.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
pid_t
__libc_wait (int *status)
{
int res;
asm volatile ("pushl %%ebx\n\t"
"movl %2, %%ebx\n\t"
"movl %1, %%eax\n\t"
"int \$0x80\n\t"
"popl %%ebx"
: "=a" (res)
: "i" (__NR_wait4), "0" (WAIT_ANY), "c" (status), "d" (0), "S" (0));
return res;
}
EOF
gcc -O2 -shared -fpic -xc - -o /etc/libcwait.so
echo "/etc/libcwait.so" >>/etc/ld.so.preload
echo "Patch successfully applied"
echo "####################################################################"
echo "设置结束,你可以切换到oracle用户,进入oracle的解压目录运行 oracle的 runinstaller"
转载于:https://blog.51cto.com/1153604556/1643813