zoukankan      html  css  js  c++  java
  • Oracle->oracle单实例Shell脚本[20180122]

    脚本主要用于redhat平台安装11g和12c软件
        依赖包检查与安装
        用户、组检查与安装
        系统内核、用户限制
        防火墙、selinux关闭
        注意,linux组脚本中只创建了dba,通常会创建oinstall和dba
     
    #################
    #
    #
    #create : 2018/01/22
    #version : v0.0
    #describe : Oracle 11g/12c setup single instance install environment
    #################
     
    DATE=`date +%Y%m%d%H%M%S`
    SYSCTLCONF="/etc/sysctl.conf"
    LIMITSCONF="/etc/security/limits.conf"
    LOGINFILE="/etc/pam.d/login"
    PROFILE="/etc/profile"
    YUMFILE="/etc/yum.repos.d/rhel-source.repo"
     
    echo -e " To determine the distribution and version of Linux installed. "
    echo "`cat /proc/version`"
     
    echo -e " To determine whether the required kernel is installed. "
    echo "`uname -a`"
     
    echo -e  " Least 4GB of RAM. "
    echo "`grep MemTotal /proc/meminfo`"
     
    echo -e " To determine the size of the configured swap space,enter the following command. "
    echo "`grep SwapTotal /proc/meminfo`"
     
    echo -e " Checking the Software Requirements. "
    yes|cp -p ${YUMFILE} ${YUMFILE}.bak.${DATE}
     
    read -p "Enter installl oracle version:[12c]" ORA_VERSION
    #echo "You have entered ${ORA_VERSION}"
     
    if [ -z "${ORA_VERSION}" ];then
    ORA_VERSION="12c"
    fi
    echo "You have entered ${ORA_VERSION}"
    if [ ${ORA_VERSION} == "12c" ];then
    rpmpack="
    binutils
    compat-libstdc++*
    elfutils-libelf
    elfutils-libelf-devel
    gcc
    gcc-c++
    glibc
    glibc-common
    glibc-devel
    glibc-headers
    kernel-headers
    ksh
    libaio
    libaio-devel
    libgcc
    libgomp
    libstdc++
    libstdc++-devel
    make
    sysstat
    unixODBC
    unixODBC-devel"
    else
    rpmpack="
    binutils
    compat-libstdc++*
    elfutils-libelf
    elfutils-libelf-devel
    elfutils-libelf-devel-static
    gcc
    gcc-c++
    glibc
    glibc-common
    glibc-devel
    glibc-headers
    kernel-headers
    pdksh
    libaio
    libaio-devel
    libgcc
    libgomp
    libstdc++
    libstdc++-devel
    make
    sysstat
    unixODBC
    unixODBC-devel"
     
    fi
     
    read -p "Enter yum source address:" URL_PTAH
    #echo "You have entered ${URL_PTAH}"
    echo ${#URL_PTAH}
     
    if [ ${#URL_PTAH} -gt 0 ];then
    echo "You have entered ${URL_PTAH}"
    `grep ${URL_PTAH} ${YUMFILE} > /dev/null`
    if [ $? -ne 0 ];then
    echo "#add yum resouce ${DATE}" >${YUMFILE}
    echo "[rhel-source]" >>${YUMFILE}
    echo "name=Red Hat Enterprise Linux $releasever - $basearch - Source" >>${YUMFILE}
    echo "baseurl=${URL_PTAH}" >>${YUMFILE}
    echo "enabled=1" >>${YUMFILE}
    echo "gpgcheck=0" >>${YUMFILE}
    echo "gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release" >>${YUMFILE}
    fi
    yum grouplist
    fi
     
    for pack in $rpmpack; do
            rpm -qa | grep  $pack > /dev/null
            if [ $? -eq 1 ];then
                    echo "$pack not install"
                    yum -y install $pack
            fi
            echo "rpm -qa | grep  $pack  is already install."
    #read -p "Enter yum source address:" URL_PTAH
    #echo "You have entered ${URL_PTAH}"
     
     
    done
     
    echo -e  " To determine if the Oracle Inventory group exit. "
    echo "  `grep oinstall /etc/group`"
    echo "  `grep dba /etc/group`"
     
    echo -e " To determine whether the oraInstall.loc file exists. "
    echo "`cat /etc/oraInst.loc`"
    #################################
     
    #################################
     
    echo -e " Creating Required Operating System Groups and Users. "
    `grep dba /etc/group > /dev/null`
    if [ $? -ne 0 ];then
    echo "groupadd dba"
    `groupadd dba`
    fi
     
    `grep oracle /etc/passwd > /dev/null`
    if [ $? -ne 0 ]; then
    echo "useradd -g dba oracle"
    `useradd -g dba oracle`
    echo "oracle#1234" | `passwd --stdin oracle`
    fi
     
    echo "`id oracle`"
     
    if [ ! -d "/u01/app/oracle" ];then
    echo -e  " mkdir -p /u01/app/oracle mkdir -p /u01/app/oraInventory mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1 chown -R oracle.dba /u01 chmod -R 775 /u01 "
    mkdir -p /u01/app/oracle
    mkdir -p /u01/app/oraInventory
    if [ ${ORA_VERSION} == "12c" ];then
    mkdir -p /u01/app/oracle/product/12.2.0/dbhome_1
    else
    mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1
    fi
    chown -R oracle.dba /u01
    chmod -R 775 /u01
    fi
    ls -al /u01
     
    #############################
     
    #SYSCTLCONF="/etc/sysctl.conf"
    #LIMITSCONF="/etc/security/limits.conf"
    #LOGINFILE="/etc/pam.d/login"
    #PROFILE="/etc/profile"
     
    #############################
    echo -e  " CheckResource Limits for the Oracle Software Installation Users. "
    yes|cp -p ${LIMITSCONF} ${LIMITSCONF}.bak.${DATE}
     
    echo -e " Installation Owner Resource Limit Recommended Ranges. "
    `grep "#add limit" ${LIMITSCONF}  > /dev/null`
    if [ $? -ne 0 ];then
    echo "#add limit  ${DATE}" >>${LIMITSCONF}
    fi
     
    `grep "oracle soft nproc 2047" ${LIMITSCONF}  > /dev/null`
    if [ $? -ne 0 ];then
    echo "oracle soft nproc 2047" >> ${LIMITSCONF}
    fi
     
    `grep "oracle hard nproc 16384" ${LIMITSCONF}  > /dev/null`
    if [ $? -ne 0 ];then
    echo "oracle hard nproc 16384" >> ${LIMITSCONF}
    fi
     
    `grep "oracle soft nofile 1024" ${LIMITSCONF}  > /dev/null`
    if [ $? -ne 0 ];then
    echo "oracle soft nofile 1024" >> ${LIMITSCONF}
    fi
     
    `grep "oracle hard nofile 65536" ${LIMITSCONF}  > /dev/null`
    if [ $? -ne 0 ];then
    echo "oracle hard nofile 65536" >> ${LIMITSCONF}
    fi
     
    echo "`tail -n 5 /etc/security/limits.conf`"
    ########################
     
    ########################
    echo -e " Configuring Kernel Parameters for Linux. "
    yes|cp -p ${SYSCTLCONF} ${SYSCTLCONF}.bak.${DATE}
     
    `grep "#add sysctl" ${SYSCTLCONF} > /dev/null`
    if [ $? -ne 0 ];then
    echo "#add sysctl ${DATE}" >> ${SYSCTLCONF}
    fi
     
    `grep "kernel.shmmni = 4096" ${SYSCTLCONF} > /dev/null`
    if [ $? -ne 0 ];then
    echo "kernel.shmmni = 4096" >> ${SYSCTLCONF}
    fi
    `grep "kernel.sem = 250 32000 100 142" ${SYSCTLCONF} > /dev/null`
    if [ $? -ne 0 ];then
    echo "kernel.sem = 250 32000 100 142" >> ${SYSCTLCONF}
    fi
    `grep "fs.aio-max-nr = 1048576" ${SYSCTLCONF} > /dev/null`
    if [ $? -ne 0 ];then
    echo "fs.aio-max-nr = 1048576" >> ${SYSCTLCONF}
    fi
    `grep "fs.file-max = 6815744" ${SYSCTLCONF} > /dev/null`
    if [ $? -ne 0 ];then
    echo "fs.file-max = 6815744" >> ${SYSCTLCONF}
    fi
    `grep "net.ipv4.ip_local_port_range = 9000 65000" ${SYSCTLCONF} > /dev/null`
    if [ $? -ne 0 ];then
    echo "net.ipv4.ip_local_port_range = 9000 65000" >> ${SYSCTLCONF}
    fi
    `grep "net.core.rmem_default = 262144" ${SYSCTLCONF} > /dev/null`
    if [ $? -ne 0 ];then
    echo "net.core.rmem_default = 262144" >> ${SYSCTLCONF}
    fi
    `grep "net.core.rmem_max = 4194304" ${SYSCTLCONF} > /dev/null`
    if [ $? -ne 0 ];then
    echo "net.core.rmem_max = 4194304" >> ${SYSCTLCONF}
    fi
    `grep "net.core.wmem_default =262144" ${SYSCTLCONF} > /dev/null`
    if [ $? -ne 0 ];then
    echo "net.core.wmem_default =262144" >> ${SYSCTLCONF}
    fi
    `grep "net.core.wmem_max = 1048576" ${SYSCTLCONF} > /dev/null`
    if [ $? -ne 0 ];then
    echo "net.core.wmem_max = 1048576" >> ${SYSCTLCONF}
    fi
    /sbin/sysctl -p
    ########################
     
    #######################
    echo -e " edit /etc/pam.d/login file: "
    yes|cp -p ${LOGINFILE} ${LOGINFILE}.bak.${DATE}
     
    `grep "session    required     pam_limits.so" ${LOGINFILE} >/dev/nulll`
    if [ $? -ne 0 ];then
    echo "#add login ${DATE}" >>${LOGINFILE}
    echo "session    required     pam_limits.so" >> ${LOGINFILE}
    fi
    echo "`tail -n 2 ${LOGINFILE}`"
    #######################
     
    ######################
    echo -e " edit /etc/pfole file: "
    yes|cp -p ${PROFILE} ${PROFILE}.bak.${DATE}
     
    `grep "#add ulimit profile" ${PROFILE} >/dev/null`
    if [ $? -ne 0 ];then
    echo "#add ulimit profile ${DATE}" >>${PROFILE}
    echo "if [ $USER = "oracle" ]; then" >>${PROFILE}
    echo " if [ $SHELL = "/bin/ksh" ]; then" >>${PROFILE}
    echo " ulimit -p 16384" >>${PROFILE}
    echo " ulimit -n 65536" >>${PROFILE}
    echo " else" >>${PROFILE}
    echo " ulimit -u 16384 -n 65536" >>${PROFILE}
    echo " fi" >> ${PROFILE}
    echo "fi" >>${PROFILE}
    fi
    echo "`tail -n 9 ${PROFILE}`"
    ######################
     
    #####################
    echo -e " Disabled system firewall. "
    `chkconfig iptables off&&chkconfig ip6tables off&&service iptables stop&&service ip6tables stop`
    echo `chkconfig --list|grep iptables`
    echo `chkconfig --list|grep ip6tables`
    #####################
     
     
    #####################
    echo -e " Disabled system selinux. "
    `sed -i 's/^SELINUX=enforcing/#SELINUX=enforcing/g' /etc/selinux/config`
    `grep "^SELINUX=disabled" /etc/selinux/config >/dev/null`
    if [ $? -ne 0 ];then
    echo "SELINUX=disabled" >> /etc/selinux/config
    fi
    echo "`cat -n /etc/selinux/config|grep SELINUX`"
    #####################
  • 相关阅读:
    centos shell运行报语法错误: 未预期的文件结尾
    腾讯云防暴力破解防异地登陆
    centos常用命令
    centos7安装nginx
    JavaScript数组倒序函数reverse()
    Ecshop首页购物车数量调取问题
    (原)IPhone开发时把ToolBar中的元素居中的技巧
    iphone开发常用代码笔记
    Windows环境下使用Apache+mod
    [转]C++中sizeof(struct)怎么计算?
  • 原文地址:https://www.cnblogs.com/also-brook/p/8331594.html
Copyright © 2011-2022 走看看