gbless 发表于 2018-9-13 09:16:38

oracle安装脚本

#!/bin/bash  
#encoding:utf-8
  
#auto install oralce
  
oracle_env(){
  
yum -y install binutils compat-libstdc++-33 compat-libstdc++-33.i686 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc.i686 glibc-common glibc-devel glibc-devel.i686 glibc-headers ksh libaio libaio.i686 libaio-devel libaio-devel.i686 libgcc libgcc.i686 libstdc++ libstdc++.i686 libstdc++-devel make sysstat
  
}
  
oracle_user(){
  
read -t 5-p "请输入安装oracle的用户名,默认的用户名是oracle:" user
  
echo
  
read -t 5 -s -p "请输入为了oracle用户设置的密码,默认的密码是oracle:" password
  
iftest -z $user
  
then
  echo "开始创建ORACLE用户"
  /usr/sbin/groupadd oinstall
  /usr/sbin/groupadd dba
  /usr/sbin/useradd -g oinstall -G dba oracle
  echo "oracle" |passwd --stdin oracle
  
else
  echo "检测此用户是否被创建----------------------"
  if cat /etc/passwd | awk -F: '{print $1}'| grep$user >/dev/null 2>&1
  then
  echo "用户已经存在--------------"
  else
  echo "用户不存在,检测用户组是否存在后创建!"
  user_exist=0
  fi
  if cat /etc/group | awk -F: '{print $1}' | grep dba >/dev/null 2>&1
  then
  echo "dba用户组已存在--------------"
  else
  echo "dba用户组不存在!"
  dba_exist=0
  fi
  if cat /etc/group | awk -F: '{print $1}'| grep oinstall > /dev/null 2>&1
  then
  echo "oinstall用户组已存在----------"
  else
  echo "oinstall 用户组不存在!"
  oinstall_exist=0
  fi
  if [[ "$user_exist" -eq "0" ]] && [[ "$dba_exist" -eq "0" ]] && [[ "$oinstall_exist" -eq "0" ]]
  then
  /usr/sbin/groupadd dba
  /usr/sbin/groupadd oinstall
  /usr/sbin/useradd -g oinstall -G dba $user
  elif [[ "$user_exist" -ne "0" ]] && [[ "$dba_exist" -eq "0" ]] && [[ "$oinstall_exist" -eq "0" ]]
  then
  /usr/sbin/groupadd dba
  /usr/sbin/groupadd oinstall
  /usr/sbin/usermod -G dba,oinstall $user
  elif [[ "$user_exist" -ne "0" ]] && [[ "$dba_exist" -eq "0" ]] && [[ "$oinstall_exist" -eq "0" ]]
  then
  /usr/sbin/groupadd dba
  /usr/sbin/groupadd oinstall
  /usr/sbin/usermod -G dba,oinstall $user
  elif [[ "$user_exist" -eq "0" ]] && [[ "$dba_exist" -ne "0" ]] && [[ "$oinstall_exist" -ne "0" ]]
  then
  /usr/sbin/useradd -g oinstall -G dba $user
  elif [[ "$user_exist" -ne "0" ]] && [[ "$dba_exist" -ne "0" ]] && [[ "$oinstall_exist" -ne "0" ]]
  then
  /usr/sbin/usermod -G oinstall,dba $user
  fi
  
fi
  
}
  
add_sysctl(){
  
echo "添加内核参数!"
  
cat >> /etc/sysctl.conf > /etc/security/limits.conf > /etc/oraInst.loc
页: [1]
查看完整版本: oracle安装脚本