linux自动化安装oracle,linux安装oracle 11g环境搭配自动安装脚本

#!/usr/bin/env bash

#set -x

#define oracle install dir

oracle_dir=""

if [ -z $oracle_dir ];then

echo "your need define oracle install PATH,please open this setting oracle_dir variables"

exit 0

fi

[ -d $oracle_dir/app ] || mkdir -p /$oracle_dir/app

[ -d $oracle_dir/tmp ] || mkdir -p /$oracle_dir/tmp

echo "Create dir $oracle_dir/app $oracle_dir/tmp"

#Echo text color

function cecho ()

{

export red='\E[31m\c'

export green='\E[32m\c'

export white='\E[37m\c'

message=$1

color=${2:-$white}

echo -e "$color"

echo -e "$message"

tput sgr0

echo -e "$white"

return

}

#Check rpm package installed

rpm -q ksh compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc gcc-c++ libaio-devel libaio libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel | grep "not installed"

if [ $? -eq 0 ];then

exit 0

fi

#Add system variables in the /etc/sysctl.conf

cat /etc/sysctl.conf | grep "^kernel.shmall" > /dev/null

if [ $? -eq 0 ];then

sed -i    's/^kernel.shmall = .*/kernel.shmall = 2097152/' /etc/sysctl.conf

else

echo "kernel.shmall = 2097152" >> /etc/sysctl.conf

fi

cat /etc/sysctl.conf | grep "^kernel.shmmax" > /dev/null

if [ $? -eq 0 ];then

sed -i    's/^kernel.shmmax = .*/kernel.shmmax = 2147483648/' /etc/sysctl.conf

else

echo "kernel.shmmax = 2147483648" >> /etc/sysctl.conf

fi

cat /etc/sysctl.conf | grep "^kernel.shmmni" > /dev/null

if [ $? -eq 0 ];then

sed -i    's/^kernel.shmmni = .*/kernel.shmmni = 4096/' /etc/sysctl.conf

else

echo "kernel.shmmni = 4096" >> /etc/sysctl.conf

fi

cat /etc/sysctl.conf | grep "^kernel.sem" > /dev/null

if [ $? -eq 0 ];then

sed -i    's/^kernel.sem = .*/kernel.sem = 250 32000 100 128/' /etc/sysctl.conf

else

echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf

fi

cat /etc/sysctl.conf | grep "^fs.file-max" > /dev/null

if [ $? -eq 0 ];then

sed -i    's/^fs.file-max = .*/fs.file-max = 65536/' /etc/sysctl.conf

else

echo "fs.file-max = 65536" >> /etc/sysctl.conf

fi

cat /etc/sysctl.conf | grep "^net.ipv4.ip_local_port_range" > /dev/null

if [ $? -eq 0 ];then

sed -i    's/^net.ipv4.ip_local_port_range = .*/net.ipv4.ip_local_port_range = 1024 65000/' /etc/sysctl.conf

else

echo "net.ipv4.ip_local_port_range = 1024 65000" >> /etc/sysctl.conf

fi

cat /etc/sysctl.conf | grep "^net.core.rmem_default" > /dev/null

if [ $? -eq 0 ];then

sed -i    's/^net.core.rmem_default = .*/net.core.rmem_default = 4194304/' /etc/sysctl.conf

else

echo "net.core.rmem_default = 4194304" >> /etc/sysctl.conf

fi

cat /etc/sysctl.conf | grep "^net.core.rmem_max" > /dev/null

if [ $? -eq 0 ];then

sed -i    's/^net.core.rmem_max = .*/net.core.rmem_max = 4194304/' /etc/sysctl.conf

else

echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf

fi

cat /etc/sysctl.conf | grep "^net.core.wmem_default" > /dev/null

if [ $? -eq 0 ];then

sed -i    's/^net.core.wmem_default = .*/net.core.wmem_default = 262144/' /etc/sysctl.conf

else

echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf

fi

cat /etc/sysctl.conf | grep "^net.core.wmem_max" > /dev/null

if [ $? -eq 0 ];then

sed -i    's/^net.core.wmem_max = .*/net.core.wmem_max = 262144/' /etc/sysctl.conf

else

echo "net.core.wmem_max = 262144" >> /etc/sysctl.conf

fi

/sbin/sysctl -p    > /dev/null

if [ $? -ne 0 ];then

cecho "\c"

cecho "Edir sysctl.conf failure" $red

cecho "\c"

exit 0

else

cecho "\c"

cecho "Edir sysctl.conf sucessfull" $green

cecho "\c"

fi

#Create user and group

cat /etc/group | grep oinstall > /dev/null

if [ $? -ne 0 ];then

groupadd oinstall

cecho "\c"

cecho "add group oinstall" $green

cecho "\c"

fi

cat /etc/group | grep dba > /dev/null

if [ $? -ne 0 ];then

groupadd dba

cecho "\c"

cecho "add group dba" $green

cecho "\c"

fi

cat /etc/passwd | grep oracle > /dev/null

if [ $? -ne 0 ];then

useradd -g oinstall -G dba oracle > /dev/null 2>&1

cecho "\c"

cecho "add user oracle" $green

cecho "\c"

fi

passwd oracle

chown -R oracle:oinstall $oracle_dir/app/

chown -R oracle:oinstall $oracle_dir

chmod -R 775 $oracle_dir/app/

chmod a+wr $oracle_dir/tmp

#Add variables in the /etc/security/limits.conf

cat /etc/security/limits.conf | grep "oracle soft nproc 2047" > /dev/null 2>&1

if [ $? -ne 0 ];then

echo "oracle soft nproc 2047" >> /etc/security/limits.conf

fi

cat /etc/security/limits.conf | grep "oracle hard nproc 16384" > /dev/null 2>&1

if [ $? -ne 0 ];then

echo "oracle hard nproc 16384" >> /etc/security/limits.conf

fi

cat /etc/security/limits.conf | grep "oracle soft nofile 1024" > /dev/null 2>&1

if [ $? -ne 0 ];then

echo "oracle soft nofile 1024" >> /etc/security/limits.conf

fi

cat /etc/security/limits.conf | grep "oracle hard nofile 65536" > /dev/null 2>&1

if [ $? -ne 0 ];then

echo "oracle hard nofile 65536" >> /etc/security/limits.conf

fi

cat /etc/security/limits.conf | grep    "nofile" > /dev/null

if [ $? -eq 0 ];then

cecho "\c"

cecho "Add variables in the /etc/security/limits.conf " $green

cecho "\c"

fi

#Add variables in the /etc/profile

cat /etc/profile | grep oracle >    /dev/null

if [ $? -ne 0 ];then

echo " if [ \$USER = "oracle" ];then " >> /etc/profile

echo "    if [ \$SHELL = "/bin/ksh" ];then" >> /etc/profile

echo "         ulimit -p 16384" >> /etc/profile

echo "            ulimit -p 65536" >> /etc/profile

echo "     else" >> /etc/profile

echo "    ulimit -u 16384 -n 65536" >> /etc/profile

echo "fi" >> /etc/profile

echo "fi" >> /etc/profile

fi

cecho "\c"

cecho "Add variables in the /etc/profile " $green

cecho "\c"

#Add env variables in the /home/oracle/.bash_profile

sed -i '2i\umask 022' /home/oracle/.bash_profile

sed -i "3i\TMP=$oracle_dir/tmp" /home/oracle/.bash_profile

sed -i "4i\TMPDIR=$oracle_dir/tmp" /home/oracle/.bash_profile

sed -i '5i\export TMP TMPDIR' /home/oracle/.bash_profile

echo "export ORACLE_BASE=$oracle_dir/app/oracle" >> /home/oracle/.bash_profile

echo "export ORACLE_HOME=\$ORACLE_BASE/product/11.1.0/db_1" >> /home/oracle/.bash_profile

echo "export ORA_CRS_HOME=\$ORACLE_BASE/crs" >> /home/oracle/.bash_profile

echo "export ORACLE_PATH=\$ORALCE_BASE/common/oracle/sql:.:\$ORACLE_HOME/rdbms/admin" >> /home/oracle/.bash_profile

echo "export ORACLE_SID=orcl" >> /home/oracle/.bash_profile #输入你的实例名echo "export PATH=\$ORACLE_HOME/bin:\$ORA_CRS_HOME/bin:\${PATH}:\$HOME/bin" >> /home/oracle/.bash_profileecho "export PATH=\${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin" >> /home/oracle/.bash_profileecho "export PATH=\${PATH}:\$ORACLE-BASE/common/oracle/bin" >> /home/oracle/.bash_profileecho "export ORACLE_TERM=xterm" >> /home/oracle/.bash_profileecho "export TNS_ADMIN=\$ORACLE_HOME/network/admin" >> /home/oracle/.bash_profileecho "export ORA_NLS10=\$ORACLE_HOME/nls/data" >> /home/oracle/.bash_profileecho "export LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib:\$ORACLE_HOME/oracm/lib:/\$ORACLE_HOME/lib" >> /home/oracle/.bash_profileecho "export  LIBPATH=\$LIBPATH:\$ORA_CRS_HOME/lib:/\$ORACLE_HOME/lib" >> /home/oracle/.bash_profileecho "export CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/rdbms/jlib:\$ORACLE_HOME/jlib:\$ORACLE_HOME/network/jlib:\$ORACLE_HOME/JRE" >> /home/oracle/.bash_profileecho "export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK" >> /home/oracle/.bash_profileecho "export LANG=AMERICAN_AMERICA.ZHS16GBK" >> /home/oracle/.bash_profileecho "export DISPLAY=:0.0" >> /home/oracle/.bash_profile 下面有附件下载,不要解压缩,把rar 格式改为sh格式就行。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值