美文网首页我爱编程
Linux上静默安装Oracle

Linux上静默安装Oracle

作者: 丑小雕 | 来源:发表于2017-03-13 13:36 被阅读0次

    1.安装必须的包

    以下依赖包可在系统盘(或U盘启动盘)的 Packages 文件夹中查找。

    rpm -ivh mpfr-2.4.1-6.el6.x86_64.rpm
    rpm -ivh ppl-0.10.2-11.el6.x86_64.rpm
    rpm -ivh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm
    rpm -ivh cpp-4.4.7-4.el6.x86_64.rpm
    rpm -ivh gcc-4.4.7-4.el6.x86_64.rpm
    rpm -ivh make-3.81-20.el6.x86_64.rpm
    rpm -ivh binutils-2.20.51.0.2-5.36.el6.x86_64.rpm
    rpm -ivh zlib-devel-1.2.3-29.el6.x86_64.rpm
    rpm -ivh binutils-devel-2.20.51.0.2-5.36.el6.x86_64.rpm
    rpm -ivh libstdc++-devel-4.4.7-4.el6.x86_64.rpm 
    rpm -ivh gcc-c++-4.4.7-4.el6.x86_64.rpm
    rpm -ivh compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm
    rpm -ivh elfutils-libelf-0.152-1.el6.x86_64.rpm
    rpm -ivh elfutils-libelf-devel-0.152-1.el6.x86_64.rpm
    rpm -ivh ksh-20120801-10.el6.x86_64.rpm
    rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm
    rpm -ivh libaio-devel-0.3.107-10.el6.x86_64.rpm
    rpm -ivh numactl-devel-2.0.7-8.el6.x86_64.rpm
    rpm -ivh sysstat-9.0.4-22.el6.x86_64.rpm
    rpm -ivh unixODBC-2.2.14-14.el6.x86_64.rpm
    rpm -ivh unixODBC-devel-2.2.14-14.el6.x86_64.rpm
    rpm -ivh pcre-devel-7.8-6.el6.x86_64.rpm
    
    //glibc-2.12-1.132.el6.x86_64.rpm
    //glibc-devel-2.12-1.132.el6.x86_64.rpm
    //glibc-headers-2.12-1.132.el6.x86_64.rpm
    //glibc-utils-2.12-1.132.el6.x86_64.rpm
    
        //nss-softokn-3.14.3-9.el6.i686.rpm
        //nss-softokn-3.14.3-9.el6.x86_64.rpm
        //nss-softokn-freebl-devel-3.14.3-9.el6.x86_64.rpm
    rpm -ivh glibc-2.12-1.132.el6.i686.rpm nss-softokn-freebl-3.14.3-9.el6.i686.rpm
    rpm -ivh glibc-devel-2.12-1.132.el6.i686.rpm
    
    rpm -ivh libaio-0.3.107-10.el6.i686.rpm
    rpm -ivh libaio-devel-0.3.107-10.el6.i686.rpm
    

    2.缺省包的安装

    以下安装包需自行下载后安装

     pdksh-5.2.14-30.x86_64.rpm
    

    注意:

    如果出现如下错误
        warning: pdksh-5.2.14-30.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 73307de6: NOKEY
        error: Failed dependencies:
                pdksh conflicts with ksh-20120801-28.el6_7.3.x86_64
    解决办法:
        rpm -e ksh-20120801-10.el6.x86_64
        rpm -ivh pdksh-5.2.14-30.x86_64.rpm
    

    ///////////////////////////以下为root用户操作/////////////////

    3.创建用户和组

    创建用户,输入命令:

    # groupadd oinstall 
    # groupadd dba 
    

    创建Oracle用户和密码,输入命令:

    # useradd -g oinstall -G dba oracle 
    # passwd oracle
    

    (将用户添加到已有组:gpasswd -a 用户名 组名)
    (groups oracle: 查看 oracle 用户所在的组,以及组内成员)

    4.修改hosts文件

    输入命令:

    vi /etc/hosts  
    

    在 127.0.0.1 行后面 添加你的主机名称(hostname)
    在 ::1 行后面 添加你的主机名称(hostname)
    例:

        vim /etc/hosts
    
        127.0.0.1   localhost fdkj
        ::1         localhost fdkj
    
        有人还加上最后一行的ip设置(我没加)
    
        /etc/sysconfig/network中的hostname要与/etc/hosts中的一致
        vim /etc/sysconfig/network
        NETWORKING=yes
        HOSTNAME=
        GATEWAY=192.168.137.1
        NTPSERVERARGS=iburst
    

    5.设置内核参数

    编辑/etc/sysctl.conf文件

    vim /etc/sysctl.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 = 1048586
    

    改变当前系统内核参数值(让/etc/sysctl.conf立即生效)

    # sysctl -p
    

    6.设置PAM资源限制

    修改/etc/security/limits.conf文件

    vim /etc/security/limits.conf
    

    在打开的文件底部添加下面内容

    oracle soft nproc 2047
    oracle hard nproc 16384
    oracle soft nofile 1024
    oracle hard nofile 65536
    oracle soft stack 10240
    

    //////////////////////////以下为oracle用户操作//////////////////

    7.创建oracle11g安装目录

    //#mkdir /home/oracle/product/
    //#mkdir /home/oracle/product/11.2.0/
    //#mkdir /home/oracle/product/11.2.0/dbhome_1/
    
    # mkdir -p /home/oracle/oracle_11g/app/
    
    #mkdir /home/oracle/oracle_11g/app/oracle/product/
    #mkdir /home/oracle/oracle_11g/app/oracle/product/11.2.0/
    #mkdir /home/oracle/oracle_11g/app/oracle/product/11.2.0/dbhome_1/
    
    # chown -R oracle:oinstall /home/oracle/oracle_11g/app/
    # chmod -R 775 /home/oracle/oracle_11g/app/
    
    # mkdir -p /home/oracle/oracle_11g/oraInventory/
    # chown -R oracle:oinstall /home/oracle/oracle_11g/oraInventory/
    # chmod -R 775 /home/oracle/oracle_11g/oraInventory/
    

    //////////////////////////以下为oracle用户操作//////////////////

    8.编辑 /etc/profile

    编辑 /home/oracle/.bash_profile

    vim /home/oracle/.bash_profile
    

    在打开的文件中添加下面内容

    umask 022
    export ORACLE_BASE=/home/oracle/oracle_11g/app
    export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
    export ORACLE_SID=orcl
    export PATH=$PATH:HOME/bin:$ORACLE_HOME/bin
    export ORACLE_HOME_LISTENER
    export ORACLE_UNQNAME=$ORACLE_SID
    

    执行source命令立即生效:

    [oracle@localhost ~]$ source /home/oracle/.bash_profile
    

    编辑 /etc/pam.d/login

    vim /etc/pam.d/login
    

    在打开的文件中添加下面内容(root用户)

    session required /lib64/security/pam_limits.so
    session required pam_limits.so
    

    编辑 /etc/profile(root用户)

    vim /etc/profile
    

    在打开的文件中添加下面内容

    if [ $USER = "oracle" ]; then
       if [ $SHELL = "/bin/ksh" ]; then
          ulimit -p 16384
          ulimit -n 65536
       else
          ulimit -u 16384 -n 65536
       fi
    fi
    

    执行source命令立即生效:

    [root@localhost oracle]# source /etc/profile
    

    9.更改目录属主为Oracle用户所有

      chown -R oracle:oinstall /home/oracle/oracle_11g/app
    

    10.安装

    # cd /home/oracle/oracle_11g/app
    # unzip linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip 
    # chown -R oracle:oinstall /home/oracle/oracle_11g/app/database 
    

    11.备份应答文件

    [oracle@localhost response]$ pwd
    /home/oracle/oracle_11g/app/database/response
    [oracle@localhost response]$ mkdir rspbak
    [oracle@localhost response]$ ls
    dbca.rsp  db_install.rsp  netca.rsp  rspbak
    [oracle@localhost response]$ cp *.rsp ./rspbak/
    

    12.删除应答文件中的注释行(以#开头)

    vi编辑替换或者直接使用sed命令快速替换

    $ sed -i 's/^#.*$//g' *.rsp
    

    13.刪除沒有內容的空行(^$)

    vi编辑替换或者直接使用sed命令快速替换

    $ sed -i '/^$/d' *.rsp
    

    14.配置db_install.rsp

    http://www.cnblogs.com/ylqmf/archive/2012/04/16/2451211.html
    http://www.linuxidc.com/Linux/2016-03/128778.htm
    http://blog.csdn.net/xiaoqiaoi5685/article/details/51831439
    https://zhidao.baidu.com/question/2076706893515870868.html
    http://blog.csdn.net/yinzhipeng123/article/details/53141950

    以下为 db_install.rsp 的配置:

    INVENTORY_LOCATION=/home/oracle/oracle_11g/oraInventory
    SELECTED_LANGUAGES=en,zh_CN
    ORACLE_HOME=/home/oracle/oracle_11g/app/oracle/product/11.2.0/dbhome_1
    ORACLE_BASE=/home/oracle/oracle_11g/app
    oracle.install.db.InstallEdition=EE
    oracle.install.db.isCustomInstall=true
    oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
    oracle.install.db.DBA_GROUP=dba
    oracle.install.db.OPER_GROUP=oinstall
    oracle.install.db.CLUSTER_NODES=
    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=AL32UTF8
    oracle.install.db.config.starterdb.memoryOption=true
    oracle.install.db.config.starterdb.memoryLimit=512
    oracle.install.db.config.starterdb.installExampleSchemas=false
    oracle.install.db.config.starterdb.enableSecuritySettings=true
    oracle.install.db.config.starterdb.password.ALL=123456
    oracle.install.db.config.starterdb.password.SYS=
    oracle.install.db.config.starterdb.password.SYSTEM=
    oracle.install.db.config.starterdb.password.SYSMAN=
    oracle.install.db.config.starterdb.password.DBSNMP=
    oracle.install.db.config.starterdb.control=DB_CONTROL
    oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
    oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
    oracle.install.db.config.starterdb.dbcontrol.emailAddress=
    oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
    oracle.install.db.config.starterdb.automatedBackup.enable=false
    oracle.install.db.config.starterdb.automatedBackup.osuid=
    oracle.install.db.config.starterdb.automatedBackup.ospwd=
    oracle.install.db.config.starterdb.storageType=
    oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
    oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
    oracle.install.db.config.asm.diskGroup=
    oracle.install.db.config.asm.ASMSNMPPassword=
    MYORACLESUPPORT_USERNAME=
    MYORACLESUPPORT_PASSWORD=
    SECURITY_UPDATES_VIA_MYORACLESUPPORT=
    DECLINE_SECURITY_UPDATES=true
    PROXY_HOST=
    PROXY_PORT=
    PROXY_USER=
    PROXY_PWD=
    

    15.

    [oracle@localhost database]$ pwd
    /home/oracle/oracle_11g/app/database
    
    [oracle@localhost database]$ ./runInstaller -silent -force -noconfig -responseFile /home/oracle/oracle_11g/app/database/response/db_install.rsp 
    

    备注:[WARNING] 是需要安装一些i386/i686 的包。查看log安装即可

    控制台直到出现以下提示则表示安装完成:

    
    #-------------------------------------------------------------------
    ...
    
    /u01/app/oracle/oraInventory/orainstRoot.sh
    
    /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
    
    To execute the configuration scripts:
    
             1. Open a terminal window 
    
             2. Log in as "root" 
    
             3. Run the scripts 
    
             4. Return to this window and hit "Enter" key to continue 
    
    
    Successfully Setup Software.
    #-------------------------------------------------------------------
    

    16.运行orainstRoot.sh和root.sh

    (1)若本机第一次安装oracle软件, 则执行orainstRoot.sh来建立oraInst.loc文件和修改权限:
    [oracle@localhost oraInventory]$ pwd
    /home/oracle/oracle_11g/oraInventory
    [oracle@localhost oraInventory]$ ./orainstRoot.sh 
    

    必须以 root 身份执行此脚本

    [oracle@localhost oraInventory]$ su root
    密码:
    [root@localhost oraInventory]# ./orainstRoot.sh 
    更改权限/home/oracle/oracle_11g/oraInventory.
    添加组的读取和写入权限。
    删除全局的读取, 写入和执行权限。
    
    更改组名/home/oracle/oracle_11g/oraInventory 到 oinstall.
    脚本的执行已完成。
    
    (2)执行$ORACLE_HOME下的root.sh来建立oratab,dbhome,oraenv,coraenv文件, 如果提示则一直回车:
    [root@localhost dbhome_1]# pwd
    /home/oracle/oracle_11g/app/oracle/product/11.2.0/dbhome_1
    [root@localhost dbhome_1]# ./root.sh 
    Check /home/oracle/oracle_11g/app/oracle/product/11.2.0/dbhome_1/install/root_localhost.localdomain_2017-01-25_16-46-49.log for the output of root script
    

    17.添加oracle环境变量

    [oracle@localhost ~]$ vim /.bash_profile
    
    export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
    export TNS_ADMIN=$ORACLE_HOME/network/admin
    export PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin
    export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/lib
    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
    export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/JRE
    export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/JRE/lib
    export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
    export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
    export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
    export LIBPATH=${CLASSPATH}:$ORACLE_HOME/lib:$ORACLE_HOME/ctx/lib
    export ORACLE_OWNER=oracle
    export SPFILE_PATH=$ORACLE_HOME/dbs
    export ORA_NLS10=$ORACLE_HOME/nls/data
    

    立即生效:

    [oracle@localhost ~]$ source ~/.bash_profile
    

    Sqlplus测试

    $ sqlplus /nolog
    

    18.静默配置监听

    [oracle@localhost ~]$ $ORACLE_HOME/bin/netca /silent /responseFile /home/oracle/oracle_11g/app/database/response/netca.rsp
    

    19.静默安装数据库

    http://blog.csdn.net/yinzhipeng123/article/details/53144589

    (1)修改响应文件模板
    [oracle@localhost response]$ pwd
    /home/oracle/oracle_11g/app/database/response
    [oracle@localhost response]$ vim dbca.rsp
    
      [GENERAL]
      RESPONSEFILE_VERSION = "11.2.0"
      OPERATION_TYPE = "createDatabase"
      [CREATEDATABASE]
      GDBNAME = "orcl"
      SID = "orcl"
      TEMPLATENAME = "General_Purpose.dbc"
      CHARACTERSET="AL32UTF8"
      NATIONALCHARACTERSET="UTF8"
      SYSPASSWORD="123456"
      SYSTEMPASSWORD="123456"
    
    (2)
      [oracle@localhost response]$ $ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/oracle_11g/app/database/response/dbca.rsp
    

    20.测试

    (1)建库后监听检查
    $ lsnrctl status
    
    ...
    
    Services Summary...
    
    Service "ORCL.LK" has 1 instance(s).
    
      Instance "ORCL", status READY, has 1 handler(s) for this service...
    
    Service "ORCLXDB.LK" has 1 instance(s).
    
      Instance "ORCL", status READY, has 1 handler(s) for this service...
    
    The command completed successfully
    

    实例应该被动态注册到监听程序了. 如果未被动态注册到监听程序, 则可以手工注册:

    $ sqlplus / as sysdba
    
    SQL*Plus: Release 11.2.0.1.0 Production on Wed Sep 16 11:11:46 2009
    
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    
    Connected to:
    
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    
    With the Partitioning, Oracle Label Security, OLAP, Data Mining,
    
    Oracle Database Vault and Real Application Testing options
    
    SQL> alter system register;
    
    (2) 改为归档模式并重启
    $ sqlplus / as sysdba
    
    SQL> shutdown immediate;
    
    SQL> startup mount;
    
    SQL> alter database archivelog;
    
    SQL> alter database flashback on; (如果要启用数据库闪回功能则执行)
    
    SQL> alter database open;
    
    SQL> execute utl_recomp.recomp_serial(); (重新编译所有可能失效对象)
    
    SQL> alter system archive log current; (手工归档测试)
    

    到此建库完毕!

    21.创建实例用户

    在oracle用户下操作(样例):

    在sqlplus / as sysdba下执行以下命令
    (1)create user ucrcdb identified by ucrcdb; (创建用户名和密码都是ucrcdb)
    (2)(给用户ucrcdb授权)
        grant create any sequence to ucrcdb;
        grant connect,resource to ucrcdb;
        grant CREATE DATABASE LINK to ucrcdb;
        grant CREATE PUBLIC DATABASE LINK to ucrcdb;
        grant CREATE SESSION to ucrcdb;
    
        最后 sqlplus ucrcdb/ucrcdb@ucrc 登录成功
    
    

    参考:

    http://www.cnblogs.com/ylqmf/archive/2012/04/16/2451211.html
    http://www.2cto.com/database/201307/229218.html
    http://blog.csdn.net/tongzidane/article/details/43852705
    http://blog.csdn.net/xiaoqiaoi5685/article/details/51831439
    http://www.linuxidc.com/Linux/2016-03/128778.htm

    相关文章

      网友评论

        本文标题:Linux上静默安装Oracle

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