关闭

在CentOS7中安装Oracle 11g

标签: oraclecentos
81人阅读 评论(0) 收藏 举报

本教程适合进行汇文系统的准备

  1. 下载 Oracle 11g的安装文件备用(2个zip文件)
  2. 安装所必须的软件包
    binutils
    compat-libcap1
    compat-libstdc++-33.i686
    compat-libstdc++-33.x86_64
    gcc
    gcc-c++
    glibc.i686 
    glibc.x86_64 
    glibc-devel.i686 
    glibc-devel.x86_64 
    ksh
    libaio.i686 
    libaio.x86_64 
    libaio-devel.i686 
    libaio-devel.x86_64 
    libgcc.i686 
    libgcc.x86_64 
    libstdc++.i686 
    libstdc++.x86_64 
    libstdc++-devel.i686 
    libstdc++-devel.x86_64 
    libXi.i686 
    libXi.x86_64 
    libXtst.i686 
    libXtst.x86_64 
    pam
    make
    sysstat
    unixODBC
  3. 创建必须的组与用户
    # groupadd oinstall
    # groupadd dba
    # useradd -g oinstall -G dba oracle
  4. 修改系统配置文件,添加关于内核的参数
    # cat /usr/lib/sysctl.d/oradb.conf
    fs.aio-max-nr = 1048576
    fs.file-max = 6815744
    kernel.shmall = 2097152
    kernel.shmmax = 536870912
    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
    
    # cat /etc/security/limits.d/oradb.conf
    oracle soft nproc 2047
    oracle hard nproc 16384
    oracle soft nofile 1024
    oracle hard nofile 65536
    oracle soft stack  10240
  5. 创建必须的目录
    # mkdir -p /u01/app/
    # chown -R oracle:oinstall /u01/app/
    # chmod -R 775 /u01/app/
  6. 创建oracle响应文件用于静默安装
    将oracle安装文件解压到 /home/oracle/database 下
    $ cat /home/oracle/database/response/libsys.rsp
    oracle.install.option=INSTALL_DB_AND_CONFIG
    UNIX_GROUP_NAME=oinstall
    INVENTORY_LOCATION=/u01/app/oraInventory
    SELECTED_LANGUAGES=en,fr,es,de,it,zh_CN,zh_TW
    ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
    ORACLE_BASE=/u01/app/oracle
    oracle.install.db.InstallEdition=EE
    oracle.install.db.DBA_GROUP=dba
    oracle.install.db.OPER_GROUP=oinstall
    oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
    oracle.install.db.config.starterdb.globalDBName=orcl
    oracle.install.db.config.starterdb.SID=orcl
    oracle.install.db.config.starterdb.characterSet=ZHS16GBK
    oracle.install.db.config.starterdb.memoryLimit=512
    oracle.install.db.config.starterdb.password.ALL=XXXXxxxx
    oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
    oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/home/oracle/oradata
    SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
    DECLINE_SECURITY_UPDATES=true
  7. 静默安装oracle
    $ ./runInstaller -silent -responseFile /home/oracle/database/response/libsys.rsp
  8. 等待提示完成,运行指示的脚本
  9. 创建 systemd service 文件,并设置开机即启动

    $ cat /home/oracle/scripts/startup.sh
    ===== CUT HERE =====
    #!/bin/bash
    
    export TMP=/tmp
    export TMPDIR=$TMP
    export PATH=/usr/sbin:/usr/local/bin:$PATH
    
    export ORACLE_SID=orcl
    ORAENV_ASK=NO
    . oraenv
    ORAENV_ASK=YES
    
    # Start Listener
    lsnrctl start
    
    # Start Database
    sqlplus / as sysdba << EOF
    STARTUP;
    EXIT;
    EOF
    ===== CUT HERE =====
    
    $ cat /home/oracle/scripts/shutdown.sh
    ===== CUT HERE =====
    #!/bin/bash
    
    export TMP=/tmp
    export TMPDIR=$TMP
    export PATH=/usr/sbin:/usr/local/bin:$PATH
    
    export ORACLE_SID=orcl
    ORAENV_ASK=NO
    . oraenv
    ORAENV_ASK=YES
    
    # Stop Database
    sqlplus / as sysdba << EOF
    SHUTDOWN IMMEDIATE;
    EXIT;
    EOF
    
    # Stop Listener
    lsnrctl stop
    ===== CUT HERE =====
    
    
    # cat /usr/lib/systemd/system/dbora.service
    ===== CUT HERE =====
    [Unit]
    Description=The Oracle Database Service
    After=syslog.target network.target
    
    [Service]
    # systemd ignores PAM limits, so set any necessary limits in the service.
    # Not really a bug, but a feature.
    # https://bugzilla.redhat.com/show_bug.cgi?id=754285
    LimitMEMLOCK=infinity
    LimitNOFILE=65535
    
    #Type=simple
    # idle: similar to simple, the actual execution of the service binary is delayed
    #       until all jobs are finished, which avoids mixing the status output with shell output of services.
    RemainAfterExit=yes
    User=oracle
    Group=oinstall
    ExecStart=/home/oracle/scripts/startup.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1 &
    ExecStop=/home/oracle/scripts/shutdown.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1
    
    [Install]
    WantedBy=multi-user.target
    ===== CUT HERE =====
    
    # systemctl enable dbora
  10. 开放防火墙
    # firewall-cmd --zone=public --add-port=1521/tcp --permanent
  11. 修改账户的生命周期
    默认情况下,oracle用户密码的生命周期是180天,180天之后必须修改密码。将生命周期更改为无限制,可以避免以后产生的无法登录的问题
    # sqlplus / as sysdba
    SQL> ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:82次
    • 积分:10
    • 等级:
    • 排名:千里之外
    • 原创:0篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档