zoukankan      html  css  js  c++  java
  • oracle11g_x64_rhel_preinstall

    #############################################
    #!/bin/bash
    #############################################

    #To check whether the depended packages ware installed
    echo "-----------------------------------------------"
    echo -e "To check \e[31;7msoftware's dependency\e[0m"
    echo "-----------------------------------------------"
    echo ""

    PACKAGE="binutils
    compat-libstdc++
    elfutils-libelf
    elfutils-libelf-devel
    elfutils-libelf-devel-static
    gcc
    gcc-c++
    glibc
    glibc-common
    glibc-devel
    glibc-headers
    kernel-headers
    ksh
    libaio
    libaio-devel
    libgcc
    libgomp
    libstdc++
    libstdc++-devel
    make
    sysstat"

    for i in $PACKAGE
    do
        if [ "$i" = "glibc-devel" ];then
            yum -y install $i >/dev/null 2>&1
        fi

        STAT=$(rpm -qa |grep -w $i)
        if [ "$STAT" != "" ];then
            echo -e "$i is \e[32;5minstalled\e[0m"
            echo ""
        else
            echo -e "$i is \e[31;5mnot\e[0m \e[32;5minstalled\e[0m"
            echo -e "\e[31;5minstalling\e[0m \e[32;5m$i\e[0m"
            yum -y install $i
            echo -e "$i is \e[32;5minstalled\e[0m"
        fi
    done

    echo "***********************************************"

    sleep 1
    clear



    echo ""
    echo "-----------------------------------------------"
    echo -e "To \e[31;7mcheck again\e[0m"
    echo "-----------------------------------------------"
    echo ""
    #To check again
    for i in $PACKAGE
    do
        STAT=$(rpm -q $i)
        if [ "$STAT" != "" ];then
            echo -e "\e[35;1m$i\e[0m is \e[32;4minstalled\e[0m"
        fi
    done
    echo ""
    echo "***********************************************"

    sleep 3
    clear
    #To install unixODBC
    echo "-----------------------------------------------"
    echo -e "To check \e[35;7munixODBC\e[0m"
    echo "-----------------------------------------------"
    echo ""
    ODBC="unixODBC unixODBC-devel"
    for i in $ODBC
    do
    if [ "$(rpm -qa|grep -w $i)" = "" ];then
        yum -y install unixODBC unixODBC-devel
        echo ""
        echo "Installed $i"
    else
        echo -e "\e[35;1m$i\e[0m is \e[32;4minstalled\e[0m"
    fi
    done
    echo "***********************************************"
    sleep 1

    #To prepare groups
    echo ""
    echo ""
    echo ""
    echo "-----------------------------------------------"
    echo -e "To check \e[31;7mgroups\e[0m '\e[32;7moinstall, dba, oper, asmadmin, asmdba, asmoper\e[0m'"
    echo "-----------------------------------------------"
    echo ""
    if [ "$(grep -w oinstall /etc/group)" = "" ];then
        /usr/sbin/groupadd oinstall
        echo -e "add group--->\e[31;1moinstall\e[0m"
    else
        echo -e "\e[31;1moinstall\e[0m is exist"
    fi

    if [ "$(grep -w dba /etc/group)" = "" ];then
        /usr/sbin/groupadd -g 502 dba
        echo -e "add group--->\e[31;1mdba\e[0m"
    else
        echo -e "\e[31;1mdba\e[0m is exist"
    fi

    if [ "$(grep -w oper /etc/group)" = "" ];then
        /usr/sbin/groupadd -g 503 oper
        echo -e "add group--->\e[31;1moper\e[0m"
    else
        echo -e "\e[31;1moper\e[0m is exist"
    fi

    if [ "$(grep -w asmadmin /etc/group)" = "" ];then
        /usr/sbin/groupadd -g 504 asmadmin
        echo -e "add group--->\e[31;1masmadmin\e[0m"
    else
        echo -e "\e[31;1masmadmin\e[0m is exist"
    fi

    if [ "$(grep -w asmoper /etc/group)" = "" ];then
        /usr/sbin/groupadd -g 505 asmoper
        echo -e "add group--->\e[31;1masmoper\e[0m"
    else
        echo -e "\e[31;1masmoper\e[0m is exist"
    fi

    if [ "$(grep -w asmdba /etc/group)" = "" ];then
        /usr/sbin/groupadd -g 506 asmdba
        echo -e "add group--->\e[31;1masmdba\e[0m"
    else
        echo -e "\e[31;1masmdba\e[0m is exist"
    fi

    echo "***********************************************"

    #To add users
    echo ""
    echo ""
    echo ""
    echo "-----------------------------------------------"
    echo -e "To check \e[31;7musers\e[0m '\e[32;7moracle, grid\e[0m'"
    echo "-----------------------------------------------"
    echo ""
    if [ "$(grep -w oracle /etc/passwd)" = "" ];then
        /usr/sbin/useradd -u 502 -g oinstall -G dba,asmdba,oper oracle
        echo oracle|passwd --stdin oracle
        
        echo -e "add user--->\e[31;1moracle\e[0m"
    else
        echo -e "\e[31;1moracle\e[0m is exist"
    fi

    if [ "$(grep -w grid /etc/passwd)" = "" ];then
        /usr/sbin/useradd -u 503 -g oinstall -G asmadmin,asmdba,asmoper,dba grid
        echo oracle|passwd --stdin grid
        
        echo -e "add user--->\e[31;1mgrid\e[0m"
    else
        echo -e "\e[31;1mgrid\e[0m is exist"
    fi

    echo "***********************************************"

    #To check resource limits
    echo ""
    echo ""
    echo ""
    echo "-----------------------------------------------"
    echo -e "To check \e[31;7mlimits\e[0m"
    echo "-----------------------------------------------"
    echo ""
    if [ "$(grep -w oracle /etc/security/limits.conf)" = "" ];then
        echo "
        #For oracle
        oracle            soft    nproc   2047
        oracle            hard    nproc   16384
        oracle            soft    nofile  1024
        oracle            hard    nofile  65536
        oracle            soft    stack   10240

        grid              soft    nproc   2047
        grid              hard    nproc   16384
        grid              soft    nofile  1024
        grid              hard    nofile  65536
        grid              soft    stack   10240">>/etc/security/limits.conf
    else    
        echo -e "A \e[32;1mlimit\e[0m is \e[31;1mexist\e[0m"
    fi
    echo "***********************************************"

    #To check kernel parameters
    echo ""
    echo ""
    echo ""
    echo "-----------------------------------------------"
    echo -e "To check \e[31;7mkernel parameters\e[0m"
    echo "-----------------------------------------------"
    echo ""
    if [ "$(grep net.core.wmem_max /etc/sysctl.conf)" = "" ];then
    echo "
    fs.aio-max-nr = 1048576
    fs.file-max = 6815744
    kernel.shmall = 2097152
    kernel.shmmax = 4294967295
    kernel.shmmni = 4096
    kernel.sem = 250 32000 100 128
    net.ipv4.ip_local_port_range = 9000 65500
    net.core.rmem_default = 262144
    net.core.rmem_max = 4194304
    net.core.wmem_default = 262144
    net.core.wmem_max = 1048576">>/etc/sysctl.conf
    /sbin/sysctl -p
    else
        echo  -e "The \e[32;1mkernel parameters\e[0m has been \e[31;1mdebuged\e[0m"
    fi
    echo "***********************************************"

    #To create related directorys
    echo ""
    echo ""
    echo ""
    echo "-----------------------------------------------"
    echo -e "To check oracle & grid \e[31;7mdirectories\e[0m"
    echo "-----------------------------------------------"
    echo ""
    ORACLE_DIR=/u01/app/oracle
    if [ ! -e "$ORACLE_DIR" ];then
        mkdir -p $ORACLE_DIR
        chown -R oracle:oinstall $ORACLE_DIR
        chmod -R 775 $ORACLE_DIR
        echo -e "Created \e[31;1m$ORACLE_DIR\e[0m"
    elif [ -e "$ORACLE_DIR" ] && [ -f "$ORACLE_DIR" ];then
        rm -rf $ORACLE_DIR
        mkdir -p $ORACLE_DIR
        chown -R oracle:oinstall $ORACLE_DIR
        chmod -R 775 $ORACLE_DIR
        echo -e "Created \e[31;1m$ORACLE_DIR\e[0m"
    else
        echo -e "\e[31;1m$ORACLE_DIR\e[0m is exist"
    fi

    GRID_DIR=/u01/app/grid
    if [ ! -e "$GRID_DIR" ];then
        mkdir -p $GRID_DIR
        chown -R grid:oinstall $GRID_DIR
        chmod -R 775 $GRID_DIR
        echo -e "Created \e[31;1m$GRID_DIR\e[0m"
    elif [ -e "$GRID_DIR" ] && [ -f "$GRID_DIR" ];then
        rm -rf $GRID_DIR
        mkdir -p $GRID_DIR
        chown -R grid:oinstall $GRID_DIR
        chmod -R 775 $GRID_DIR
        echo -e "Created \e[31;1m$GRID_DIR\e[0m"
    else
        echo -e "\e[31;1m$GRID_DIR\e[0m is exist"
    fi
    echo "***********************************************"

    #Configuring the oracle User's Environment
    echo ""
    echo ""
    echo ""
    echo "-----------------------------------------------"
    echo -e "To configuring the oracle User's \e[31;7mEnvironment\e[0m"
    echo "-----------------------------------------------"
    echo ""
    if [ "$(grep ORACLE /home/oracle/.bash_profile)" = "" ];then
        export ORACLE_BASE=$ORACLE_DIR
        echo "
    #Oracle env
    export ORACLE_BASE=$ORACLE_DIR
    export ORACLE_SID=orcl
    export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/db_1
    export LD_LIBRARY_PATH=\$ORACLE_HOME/lib
    export PATH=\$ORACLE_HOME/bin:\$PATH
    export EDITOR=vi">>/home/oracle/.bash_profile
        echo -e "\e[31;1mOracle\e[0m configure done"
        echo ""
    else
        echo -e "\e[31;1mOracle\e[0m has being configured, \e[32;1mdo nothing\e[0m"
        echo ""
    fi

    if [ "$(grep ORACLE /home/grid/.bash_profile)" = "" ];then
        export ORACLE_BASE=$GRID_DIR
        echo "
    #Oracle env
    export ORACLE_BASE=$GRID_DIR
    export ORACLE_SID=+ASM
    export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/db_1
    export LD_LIBRARY_PATH=\$ORACLE_HOME/lib
    export PATH=\$ORACLE_HOME/bin:\$PATH
    export EDITOR=vi">>/home/grid/.bash_profile
        echo -e "\e[31;1mgrid\e[0m configure done"
        echo ""
    else
        echo -e "\e[31;1mgrid\e[0m has being configured, \e[32;1mdo nothing\e[0m"
        echo ""
    fi
    echo "***********************************************"

  • 相关阅读:
    Qt 学习之路 :文本文件读写
    Qt 学习之路:文本文件读写
    Qt 学习之路:二进制文件读写
    Qt 学习之路 :文件
    安全通信 QSslSocket
    Qt 学习之路:绘制设备
    Qt 学习之路:坐标系统
    Qt 学习之路 :坐标系统
    dmesg 程序崩溃调试2
    dmesg 程序崩溃调试
  • 原文地址:https://www.cnblogs.com/lixuebin/p/10814631.html
Copyright © 2011-2022 走看看