Oracle11gR2 命令行安装

  • Oracle版本:11.2.0.1.0
  • 服务器环境: CentOS7

到官网上下载两个安装包,大概2个多 G

-rw-r--r--. 1 root   root     1239269270 Mar  8 17:52 linux.x64_11gR2_database_1of2.zip
-rw-r--r--. 1 root   root     1111416131 Mar  8 17:52 linux.x64_11gR2_database_2of2.zip

解压后得到一个 database 的文件夹,目录结构如下:

total 24
drwxr-xr-x. 12 oracle oinstall 4096 Aug 17  2009 doc
drwxr-xr-x.  5 oracle oinstall 4096 Mar  8 18:01 install
drwxrwxr-x.  2 oracle oinstall  102 Mar  9 02:26 response
drwxr-xr-x.  2 oracle oinstall   33 Aug 15  2009 rpm
-rwxr-xr-x.  1 oracle oinstall 3226 Aug 15  2009 runInstaller
drwxrwxr-x.  2 oracle oinstall   28 Aug 15  2009 sshsetup
drwxr-xr-x. 14 oracle oinstall 4096 Aug 15  2009 stage
drwxrwx---.  3 oracle oinstall   17 Mar  8 18:01 trueoracle.install.option
-rw-r--r--.  1 oracle oinstall 5402 Aug 18  2009 welcome.html

命令行安装步骤

  1. 准备应答文件,在/response 下的3个文件:

    dbca.rsp
    db_install.rsp
    netca.rsp
  2. 安装数据库

     vi ~oracle/soft/database/response/db_install.rsp

    这是安装后的结果:

     grep -Ev "^$|^#" ~oracle/soft/database/response/db_install.rsp
    
    oracle.install.responseFileVersion=/oracle/install/ rspfmt_dbinstall_response_schema_v11_2_0
    oracle.install.option=INSTALL_DB_SWONLY
    ORACLE_HOSTNAME=bjl.mewifi.mobi
    UNIX_GROUP_NAME=oinstall
    INVENTORY_LOCATION=/home/oracle/app/oracle/oraInventory
    SELECTED_LANGUAGES=en
    ORACLE_HOME=/home/oracle/app/oracle/product/11gr2/dbhome_1
    ORACLE_BASE=/home/oracle/app/oracle
    oracle.install.db.InstallEdition=EE
    oracle.install.db.isCustomInstall=false
    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=oper
    oracle.install.db.CLUSTER_NODES=
    oracle.install.db.config.starterdb.type=
    oracle.install.db.config.starterdb.globalDBName= orcl//全局名称
    oracle.install.db.config.starterdb.SID= oracl // sid
    oracle.install.db.config.starterdb.characterSet=AL32UTF8
    oracle.install.db.config.starterdb.memoryOption=true
    oracle.install.db.config.starterdb.memoryLimit=10240
    oracle.install.db.config.starterdb.installExampleSchemas=false
    oracle.install.db.config.starterdb.enableSecuritySettings=true
    oracle.install.db.config.starterdb.password.ALL=**password**// 默认密码
    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=FILE_SYSTEM_STORAGE
    oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/home/oracle/app/ oracle/oradata
    oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/home/oracle/ app/oracle/fast_recovery_area
    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=

    执行database 下的命令:

    ./runInstaller -silent -responseFile /home/oracle/soft/database/response/db_install.rsp -ignoreSysPrereqs

    如果报错,具体日志在/home/oracle/app/oracle/oraInventory/logs/installAction*.log
    如果没有问题以 root 用户执行

    sh /home/oracle/app/oracle/product/11gr2/dbhome_1/root.sh
    
  3. 启动监听

    ~/app/oracle/product/11gr2/dbhome_1/bin/netca /silent /responsefile ~/app/oracle/product/11gr2/dbhome_1/inventory/response/netca.rsp
    

    这里会提示找不到监听程序,编辑 listener.ora 后再运行一次;
    编辑 listener.ora

    su - oracle
    cd ~/app/oracle/product/11gr2/dbhome_1/network/admin/
    
    ~/app/oracle/product/11gr2/dbhome_1/bin/netca /silent /responsefile ~/app/oracle/product/11gr2/dbhome_1/inventory/response/netca.rsp
    

    执行结果

    Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /home/oracle/app/oracle/product/11gr2/dbhome_1/inventory/response/netca.rsp
    Done parsing command line arguments.
    Oracle Net Services Configuration:
    Profile configuration complete.
    Listener "LISTENER" already exists.
    Oracle Net Services configuration successful. The exit code is 0    

    这里提示监听程序"LISTENER" 已存在,成功完成 Oracle NetServices 配置,退出代码是0

    lsnrctl start
    lsnrctl status
    
  4. 新建数据库
    编辑response/dbca.rsp

    需要修改的有:

    GDBNAME = "orcl.ns5.centos.com" //全局数据库的名字=SID+主机域名
    SID="orcl" // SID
    CHARACTERSET="AL32UTF8" //编码
    NATIONALCHARACTERSET="UTF8" //编码
    SYSPASSWORD = "Oracle"    //密码
    SYSTEMPASSWORD = "Oracle"  //密码

    执行命令:

    dbca -silent -responseFile ~/soft/database/response/dbca.rsp
    

    执行成功后就可以通 sqlplus / as sysdba 访问数据库了。
    注意:oracle 用户密码默认有效期是180天,可以改为永久

    ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
    

可能出现的问题

1.执行./runInstaller -silent 时报错


解决:
需要先安装 jdk

2.执行./runInstaller -silent 时报错: ip 地址不合法


/home/oracle/app/oraInventory/logs 下的.err 日志中:

解决:

vi /etc/hosts
127.0.0.1   server001  server001.com.cn localhost4 localhost4.localdomain4

3.多次执行./runInstaller -silent 时报错:oracleHome 已被安装

SEVERE: [FATAL] [INS-32025] The chosen installation conflicts with software already installed in the given Oracle home.
   CAUSE: The chosen installation conflicted with software already installed in the given Oracle home.
   ACTION: Install into a different Oracle home.

解决:

 1. cat /etc/oraInst.loc
 2.  cd <oraInventory path>/oraInventory/ContextXML
 3. vi inventory.xml
 4. Remove the line that contain the new ORACLE Home
 5. Exit and re-run the installer.

4.使用 sqlplus 启动时报错:

SQL> startup;
ORA-00845: MEMORY_TARGET not supported on this system

解决:
问题的原因是因为,SGA参数的大小超过了操作系统/dev/shm的大小。

linux大内存支持(Very Large Memory)中,使用了shmfs/tmpfs选项,ramfs也可以。/dev/shm目录挂载类型为tmpfs,此共享内存用于交换,尤其对于大文件优势明显。相对于ramfs,tmpfs的优势在于动态调整物理内存的占用,而ramfs不能调整。
/dev/shm与swap的区别:shm基于内存的文件系统,swap基于硬盘的文件系统。
而/dev/shm 大小默认是内存的一半。

所以只需要调整/dev/shm 的大小即可解决

vi /etc/fstab
tmpfs /dev/shm tmpfs defaults,size=16384M 0 0

重新加载

umount /dev/shm
mount /dev/shm

查看大小:

$ df -h /dev/shm
Filesystem      Size  Used Avail Use% Mounted on
tmpfs            16G  3.7G   13G  23% /dev/shm

登录测试:

sqlplus / as sysdba
2016-03-09 19:0086