oracl安装脚本

#!/bin/bash

ip=`ifconfig|grep 'inet addr:'|grep -v '127.0.0.1'|cut -d: -f2 |awk '{ print $1}'`

hostname=`echo $HOSTNAME`

echo "$ip $hostname ">>/etc/hosts

mem=`grep MemTotal /proc/meminfo|awk '{print $2}'`

shmmax=$(($mem/2*1024))

ora_dir=/database/

sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config

setenforce 0

#install packages

yum -y install unzip binutils*x86_64* glibc*x86_64* compat-libstdc++*x86_64* elfutils-libelf*x86_64*  gcc*x86_64* ksh-*x86_64* libaio*x86_64* libgcc*x86_64* libstdc++*x86_64* make*x86_64* numactl-devel*x86_64* sysstat-9*x86_64* compat-libstdc++*i686* compat-libcap* libXp* libaio*

unzip /linux.x64_11gR2_database_1of2.zip   //必须先把安装文件下载到相应目录,才能解压

unzip /linux.x64_11gR2_database_2of2.zip

groupadd oinstall

groupadd dba

useradd -g oinstall -G dba oracle

echo oracle123|passwd oracle --stdin

mkdir -p /u01/app

chown -R oracle.oinstall /u01

chown -R oracle.oinstall $ora_dir

#chmod +x $ora_dir/runInstaller

#chmod 777 $ora_dir/install/.oui

#chmod 777 $ora_dir/install/unzip

#Modify the kernel parameters

sed -i -e "s/kernel.shmall.*/kernel.shmall = 2097152/" -e "s/kernel.shmmax.*/kernel.shmmax = $shmmax/" /etc/sysctl.conf     

cat >>/etc/sysctl.conf<<EOF

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

fs.file-max = 6815744

net.ipv4.ip_local_port_range = 900 65000

net.core.rmem_default= 262144

net.core.rmem_max= 4194304

net.core.wmem_default= 262144

net.core.wmem_max= 1048576

EOF

sysctl -p

#Modify the configuration of system resources

cat >> /etc/security/limits.conf <<EOF

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536

EOF

cat >/home/oracle/.bash_profile<<EOF

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

# User specific environment and startup programs

TMP=/tmp;export TMP

TMPDIR=\$TMP;export TMPDIR

ORACLE_BASE=/u01/app/oracle;export ORACLE_BASE

ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/db_1;export ORACLE_HOME

ORACLE_SID=orcl;export ORACLE_SID

LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH

PATH=\$PATH:\$HOME/bin:\$ORACLE_HOME/bin;export PATH

EOF

source /home/oracle/.bash_profile

xhost +

su oracle -c "export LANG=en_US && $ora_dir/runInstaller -silent -ignorePrereq -responseFile /db.rsp"   //应答脚本db.rsp得先准备好

sleep 18m                           //安装时间,这个自己把握。18分钟后再执行下面的脚本

/u01/app/oraInventory/orainstRoot.sh

/u01/app/oracle/product/11.2.0/db_1/root.sh


你可能感兴趣的:(oracle,安装,脚本)