美文网首页oracle
oracle 11g 静默安装(CentOS6.5 )

oracle 11g 静默安装(CentOS6.5 )

作者: 十二找十三 | 来源:发表于2019-10-05 21:08 被阅读0次
    1. 搭建基础环境 使用root 用户 执行下面脚本就行 (下面整个是个脚本)同数据库两个压缩包放在同一目录下
    #!/bin/sh
    # 基础环境
    yum -y install binutils compat-libstdc++-33 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 numactl-devel sysstat unixODBC unixODBC-devel
    
    groupadd oinstall
    groupadd dba
    useradd -g oinstall -G dba oracle
    echo "oracle" | passwd --stdin oracle
    
    
    # 创建目录并解压
    mkdir -p /env/oracle/product/11.2.0/db
    mkdir -p /env/oracle/oradata
    mkdir -p /env/oracle/inventory
    mkdir -p /env/oracle/fast_recovery_area
    unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip 
    mv database /env/oracle
    chown -R oracle.oinstall /env/oracle
    chmod -R 755 /env/oracle
    
    
    # 修改内核参数文件
    echo "# add env" >> /etc/sysctl.conf
    echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
    echo "fs.file-max = 6815744" >> /etc/sysctl.conf
    echo "kernel.shmall = 2097152" >> /etc/sysctl.conf
    echo "kernel.shmmax = 2048000000" >> /etc/sysctl.conf
    echo "kernel.shmmni = 4096" >> /etc/sysctl.conf
    echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
    echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf
    echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf
    echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf
    echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf
    echo "net.core.wmem_max = 1048576" >> /etc/sysctl.conf
    
    sysctl -p
    
    # 修改用户的限制文件
    echo "oracle    soft    nproc    2047" >> /etc/security/limits.conf
    echo "oracle    hard    nproc    16384" >> /etc/security/limits.conf
    echo "oracle    soft    nofile    1024" >> /etc/security/limits.conf
    echo "oracle    hard    nofile    65536" >> /etc/security/limits.conf
    echo "oracle    soft    stack    10240" >> /etc/security/limits.conf
    
    # 修改/etc/pam.d/login文件:
    echo "session required  /lib64/security/pam_limits.so" >> /etc/pam.d/login
    echo "session required  pam_limits.so" >> /etc/pam.d/login
    
    # 修改/etc/pam.d/login文件:
    echo "127.0.0.1  oracle.ccbckj" >> /etc/hosts
    sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=oracle.ccbckj/' /etc/sysconfig/network
    
    1. 把防火墙关掉 vi /etc/selinux/config SELINUX=disabled
      reboot 一下服务器
      service iptables stop
    2. ssh登录服务器之后 切换oracle用户 su - oracle
    #!/bin/sh
    
    # 配置环境变量
    echo 'ORACLE_BASE=/env/oracle' >> ~/.bash_profile
    echo 'ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db' >> ~/.bash_profile
    echo 'ORACLE_SID=ccbckj' >> ~/.bash_profile
    echo 'PATH=$PATH:$ORACLE_HOME/bin' >> ~/.bash_profile
    echo 'export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH' >> ~/.bash_profile
    
    source ~/.bash_profile
    
    # 配置oracle配置文件
    sed -i 's#^oracle.install.option=#oracle.install.option=INSTALL_DB_SWONLY#g' /env/oracle/database/response/db_install.rsp
    sed -i 's#^ORACLE_HOSTNAME=#ORACLE_HOSTNAME=oracle.ccbckj#g' /env/oracle/database/response/db_install.rsp
    sed -i 's#^UNIX_GROUP_NAME=#UNIX_GROUP_NAME=oinstall#g' /env/oracle/database/response/db_install.rsp
    sed -i 's#^INVENTORY_LOCATION=#INVENTORY_LOCATION=/env/oracle/inventory#g' /env/oracle/database/response/db_install.rsp
    sed -i 's#^SELECTED_LANGUAGES=#SELECTED_LANGUAGES=en,zh_CN#g' /env/oracle/database/response/db_install.rsp
    sed -i 's#^ORACLE_HOME=#ORACLE_HOME=/env/oracle/product/11.2.0/db#g' /env/oracle/database/response/db_install.rsp
    sed -i 's#^ORACLE_BASE=#ORACLE_BASE=/env/oracle#g' /env/oracle/database/response/db_install.rsp
    sed -i 's#^oracle.install.db.InstallEdition=#oracle.install.db.InstallEdition=EE#g' /env/oracle/database/response/db_install.rsp
    sed -i 's#^oracle.install.db.DBA_GROUP=#oracle.install.db.DBA_GROUP=dba#g' /env/oracle/database/response/db_install.rsp
    sed -i 's#^oracle.install.db.OPER_GROUP=#oracle.install.db.OPER_GROUP=dba#g' /env/oracle/database/response/db_install.rsp
    sed -i 's#^DECLINE_SECURITY_UPDATES=#DECLINE_SECURITY_UPDATES=true#g' /env/oracle/database/response/db_install.rsp
    
    安装命令   期间可以查看日志  最后需要根据提示用root用户执行两个脚本
    /env/oracle/database/runInstaller -silent -ignoreSysPrereqs -ignorePrereq -responseFile /env/oracle/database/response/db_install.rsp
    
    数据库监听
    netca /silent /responseFile /env/oracle/database/response/netca.rsp
    
    创建数据库
    
    vi /env/oracle/database/response/dbca.rsp
    # 修改下列参数
    GDBNAME= "oracle.ccbckj"
    SID =" ccbckj"
    SYSPASSWORD= "oracle"
    SYSTEMPASSWORD= "oracle"
    SYSMANPASSWORD= "oracle"
    DBSNMPPASSWORD= "oracle"
    DATAFILEDESTINATION=/env/oracle/oradata
    RECOVERYAREADESTINATION=/env/oracle/fast_recovery_area
    CHARACTERSET= "AL32UTF8"
    TOTALMEMORY= "3096"
    # 其中TOTALMEMORY ="3096" 为3096MB,物理内存。
    
    
    dbca -silent -responseFile /env/oracle/database/response/dbca.rsp
    # 复制数据库文件
    # 1% 已完成
    # 3% 已完成
    # 11% 已完成
    # 18% 已完成
    # 37% 已完成
    # 正在创建并启动 Oracle 实例
    # 40% 已完成
    # 45% 已完成
    # 50% 已完成
    # 55% 已完成
    # 56% 已完成
    # 57% 已完成
    # 60% 已完成
    # 62% 已完成
    # 正在进行数据库创建
    # 66% 已完成
    # 70% 已完成
    # 73% 已完成
    # 85% 已完成
    # 96% 已完成
    # 100% 已完成
    # 有关详细信息, 请参阅日志文件 "/env/oracle/cfgtoollogs/dbca/oracle/oracle.log"。
    

    4.总结

    # 检验端口
    # 可以用nc命令检测端口  
    nc -zvn 127.0.0.1 1521
    
    
    最后可以  sqlplus / as sysdba
    create user ccbckjdemo identified by ccbckjdemo;
    grant dba to ccbckjdemo;
    grant connect,resource to ccbckjdemo;
    
    oracle开机自启动
    1.vi /etc/oratab   N  ==> Y
    2.vi /etc/rc.d/rc.local
    su oracle -lc "/home/oracle/product/11.2.0/db/bin/lsnrctl start"
    su oracle -lc /home/oracle/product/11.2.0/db/bin/dbstart
    
    oracle 字符集可以参考这个
    [https://www.cnblogs.com/leolzi/p/9796316.html]
    
    
    错误总结
    sqlplus 没有问题   可以  source .bash_profile
    
    

    相关文章

      网友评论

        本文标题:oracle 11g 静默安装(CentOS6.5 )

        本文链接:https://www.haomeiwen.com/subject/xeeypctx.html