shell脚本安装oracle

这是一个用于在CentOs 6.6系统上自动安装Oracle 11.2.0.4数据库的Shell脚本。脚本首先检查主机名和IP配置,然后进行必要的YUM安装,创建dba用户组和oracle用户,更新系统配置,创建Oracle主目录和数据目录,最后调整参数文件并解压安装文件。
摘要由CSDN通过智能技术生成
#!/bin/bash
#install oracle
# version1.0 OS:CentOs 6.6 DB: 11.2.0.4

# /etc/hosts
hostname=`sed -n '/zw/p' /etc/sysconfig/network| sed -s "s/=/ /g"|gawk '{print $2}'`
ip=`ifconfig | sed -n '/192.168/p'| gawk '{print $1 $2}'|gawk -F: '{print $2}'`
lianjie=${ip}${hostname}
hosts=`sed -n '/192.168/p' /etc/hosts| sed -s 's/ //g'`

if [ "$lianjie" = "$hosts" ]
then
echo "hostname aready exixts!!"
else
echo $ip $hostname >> /etc/hosts
fi

# yum
yum install -y  binutils-* libXp* compat-libstdc++-33-* elfutils-libelf-* elfutils-libelf-devel-* gcc-* gcc-c++-* glibc-* glibc-common-* glibc-devel-* glibc-headers-* ksh-* libaio-* libgcc-* libstdc++-*  make-* sysstat-* unixODBC-*  unixODBC-devel-*s


# create dba group 
testgroup=dba
testuser=oracle

if grep $testgroup /etc/group
   then
      echo "you are $testgroup!!"
          if grep $testuser /etc/passwd
           then
           echo "you are $testuser!!"
           userdel -r oracle
         else
           groupdel dba
          fi
else
     groupadd -g 501 dba
     echo "group dba is created !"
fi


# create oracle user 

if grep $testuser /etc/passwd
   then
      echo "you are $testuser!!"
      userdel -r $testuser
	  useradd -u 500 -g dba oracle
else
     useradd -u 500 -g dba oracle
     echo "user oracle is created !"
fi


# update  /etc/sysctl.conf
 
shmall=`sed -n '/kernel.shmall/p' /etc/sysctl.conf| gawk -F = '{print $1}'`
aio=`sed -n '/fs.aio-max-nr/p' /etc/sysctl.conf| gawk -F = '{print $1}'`
file=`sed -n '/fs.file-max/p' /etc/sysctl.conf| gawk -F = '{print $1}'`
shmmax=`sed -n '/kernel.shmmax/p' /etc/sysctl.conf| gawk -F = '{print $1}'`
shmmni=`sed -n '/kernel.shmmni/p' /etc/sysctl.conf| gawk -F = '{print $1}'`
sem=`sed -n '/kernel.sem/p' /etc/sysctl.conf| gawk -F = '{print $1}'`
ipv4=`sed -n '/net.ipv4.ip_local_port_range/p' /etc/sysctl.conf| gawk -F = '{print $1}'`
rmem_default=`sed -n '/net.core.rmem_default/p' /etc/sysctl.conf| gawk -F = '{print $1}'`
rmem_max=`sed -n '/net.core.rmem_max/p' /etc/sysctl.conf| gawk -F = '{print $1}'`
wmem_default=`sed -n '/net.core.wmem_default/p' /etc/sysctl.conf| gawk -F = '{print $1}'`
wmem_max=`sed -n '/net.core.wmem_max/p' /etc/sysctl.conf| gawk -F = '{print $1}'`


if [ "$shmall" = "" ]
  then
  echo "updating......"
  echo "kernel.shmall = 4294967296" >>/etc/sysctl.conf
  else
  echo "$shmall can't update!"
fi

if [ "$aio" = "" ]
  then
  echo "updating......"
  echo "fs.aio-max-nr = 1048576" >>/etc/sysctl.conf
  else
  echo "$aio can't update!"
fi

if [ "$file" = "" ]
  then
  echo "updating......"
 echo &
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值