当前位置 主页 > 服务器问题 > Linux/apache问题 >

    centos7.7安装oracle11g脚本(推荐)

    栏目:Linux/apache问题 时间:2020-01-05 21:58

    最近需要安装oracle,然后网上查了一下教程,在centos7.7上安装成功,运行正常。这里记录一下。

    环境:

    硬件4核/8G RAM/100G 存储

    centos7.7(64bit)

    oracle11g(官网下载的)

    步骤(转载):

    第一个脚本preinstalloracle.sh,以root用户运行。执行完后需要重启电脑,需要注意看一下hostname是否修改好了

     #!/bin/bash
    #以root用户运行
    #注意修改第三行的ip为自己的ip地址
    echo "172.16.1.110 orcl orcl" >> /etc/hosts
    cat >> /etc/sysconfig/network <<EOF
    network=yes
    hostname=orcl
    EOF

    第二个脚本secinstalloracle.sh,以root用户运行

     #!/bin/bash
    #以root用户运行
    #内核参数设置kernel.shmall=2097152其中16G物理内存建议设为4194304类推8G应为2097152
    #kernel.shmmax=4294967296一般设置为物理内存的一半,8G:4294967296也可以全部用完8*1024*1024*1024
    yum install -y binutils 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 ksh numactl-devel zip unzip
    cat >> /etc/sysctl.conf <<EOF
    fs.file-max = 6815744
    fs.aio-max-nr = 1048576
    kernel.shmall = 2097152    
    kernel.shmmax = 4294967296  
    kernel.shmmni = 4096
    kernel.sem = 250 32000 100 128
    net.ipv4.ip_local_port_range = 9000 65500
    net.core.rmem_default = 4194304
    net.core.rmem_max = 4194304
    net.core.wmem_default = 262144
    net.core.wmem_max = 1048576
    EOF
    sysctl -p #使配置文件生效
    cat >> /etc/security/limits.conf <<EOF
    oracle      soft  nproc      2047
    oracle      hard  nproc      16384
    oracle      soft  nofile     1024
    oracle      hard  nofile     65536
    EOF
    cat >> /etc/pam.d/login <<EOF
    session  required   /lib/security/pam_limits.so
    session  required   pam_limits.so
    EOF
    cat >> /etc/profile <<EOF
    if [ $USER = "oracle" ]; then
      if [ $SHELL = "/bin/ksh" ]; then
       ulimit -p 16384
       ulimit -n 65536
      else
       ulimit -u 16384 -n 65536
      fi
    fi
    EOF
    groupadd oinstall
    groupadd dba
    useradd -g oinstall -G dba oracle 
    mkdir -p /u01/app/oracle/product/11.2.0/db_1
    mkdir -p /u01/app/oracle/oradata
    mkdir -p /u01/app/oraInventory
    mkdir -p /u01/app/oracle/fast_recovery_area
    chown -R oracle:oinstall /u01/app/oracle
    chown -R oracle:oinstall /u01/app/oraInventory
    chmod -R 755 /u01/app/oracle
    chmod -R 755 /u01/app/oraInventory
    systemctl disable firewalld
    systemctl stop firewalld
    setenforce 0
    sed -i 's/=enforcing/=disabled/g' /etc/selinux/config
    mv p13390677_112040_Linux-x86-64_1of7.zip /home/oracle  
    mv p13390677_112040_Linux-x86-64_2of7.zip /home/oracle
    cp thiinstalloracle.sh /home/oracle/
    cp fouinstalloracle.sh /home/oracle/

    第三个脚本thiinstalloracle.sh,以oracle用户运行,su - oracle

     #!/bin/bash
    #以oracle用户运行,su - oracle
    cat >> .bash_profile <<EOF
    ORACLE_BASE=/u01/app/oracle
    ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/db_1
    ORACLE_SID=orcl 
    export NLS_LANG=AMERICAN_AMERICA.UTF8
    PATH=\$PATH:\$ORACLE_HOME/bin
    export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
    umask 022
    EOF
    source .bash_profile
    unzip p13390677_112040_Linux-x86-64_1of7.zip 
    unzip p13390677_112040_Linux-x86-64_2of7.zip
    chown -R oracle:oinstall database
    cd database/response
    cp db_install.rsp db_install.rsp.bak
    sed -i "s/^oracle.install.option=/oracle.install.option=INSTALL_DB_SWONLY/g" db_install.rsp
    sed -i "s/^ORACLE_HOSTNAME=/ORACLE_HOSTNAME= orcl/g" db_install.rsp
    sed -i "s/^UNIX_GROUP_NAME=/UNIX_GROUP_NAME=oinstall/g" db_install.rsp
    sed -i "s/^INVENTORY_LOCATION=/INVENTORY_LOCATION=\/u01\/app\/oraInventory/g" db_install.rsp
    sed -i "s/^SELECTED_LANGUAGES=en/SELECTED_LANGUAGES=en,zh_CN/g" db_install.rsp
    sed -i "s/^ORACLE_HOME=/ORACLE_HOME=\/u01\/app\/oracle\/product\/11.2.0\/db_1/g" db_install.rsp
    sed -i "s/^ORACLE_BASE=/ORACLE_BASE=\/u01\/app\/oracle/g" db_install.rsp
    sed -i "s/^oracle.install.db.InstallEdition=/oracle.install.db.InstallEdition=EE/g" db_install.rsp
    sed -i "s/^oracle.install.db.DBA_GROUP=/oracle.install.db.DBA_GROUP=dba/g" db_install.rsp
    sed -i "s/^oracle.install.db.OPER_GROUP=/oracle.install.db.OPER_GROUP=dba/g" db_install.rsp
    sed -i "s/^DECLINE_SECURITY_UPDATES=/DECLINE_SECURITY_UPDATES=true/g" db_install.rsp
    cd ..