CentOS下静默安装Oracle11g

1.下载Oracle 11g的安装包

    官网下载:http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html

        # wget http://v.yingsun.net/cobra/download/linux.x64_11gR2_database_1of2.zip

        # wget http://v.yingsun.net/cobra/download/linux.x64_11gR2_database_2of2.zip


2.安装必须的RPM包

    # yum install -y 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


3.创建用户组

# groupadd oinstall && groupadd dba

4.创建用户、配置密码

# useradd -g oinstall -G dba oracle

# passwd oracle

5.修改hosts文件

 # vim /etc/hosts

    在127.0.0.1以及::1这两行后面添加主机名

6.设置内核参数

# 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

    保存退出;

# sysctl -p

7.设置PAM资源限制

 # vim /etc/security/limits.conf

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

        oracle soft nproc 10240

        oracle hard nproc 65535

        oracle soft nofile 10240

        oracle hard nofile 65536

        oracle soft stack 10240



8.创建安装目录

# su - oracle

$ mkdir -p /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/

9.修改环境变量

$ 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

    注意:ORACLE_SID=orcl 这里是用户自己定义的数据库名称,后面配置需要用到,设置后就不能再改。

$ source /home/oracle/.bash_profile

$ sudo vim /etc/pam.d/login

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

        session required /lib64/security/pam_limits.so

        session required pam_limits.so

10.解压Oracle安装文件

$ 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.备份应答文件

$ cd /home/oracle/oracle_11g/app/database/response

$ mkdir rsp_bak

$ cp *.rsp ./rsp_bak/

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

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

13.配置db_install.rsp

$ echo > db_install.rsp

        oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0

        #默认即可

        oracle.install.option=INSTALL_DB_SWONLY

        #安装类型

        ORACLE_HOSTNAME=oracle

        #主机名称(hostname查询,这里要注意,主机名要在 /etc/hosts 文件中配置好ip对应关系,否则安装会报错)

        UNIX_GROUP_NAME=oinstall

        #安装组

        INVENTORY_LOCATION=/home/oracle/oracle_11g/oraInventory

        #INVENTORY目录位置,需填写成自己创建的目录位置

        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

        #BASE目录地址

        oracle.install.db.InstallEdition=EE

        #指定oracle版本

        oracle.install.db.isCustomInstall=false

        #是否自定义安装,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

        #dba用户组

        oracle.install.db.OPER_GROUP=oinstall

        #oper用户组

        oracle.install.db.CLUSTER_NODES=

        oracle.install.db.config.starterdb.type=GENERAL_PURPOSE

        #数据库类型

        oracle.install.db.config.starterdb.globalDBName=orcl  

        #globalDBName(这里要和第8步配置的sid一致)

        oracle.install.db.config.starterdb.SID=orcl

        #SID(这里要和第8步配置的sid一致)

        oracle.install.db.config.starterdb.characterSet=AL32UTF8

        #使用的编码格式

        oracle.install.db.config.starterdb.memoryOption=true

        oracle.install.db.config.starterdb.memoryLimit=1024

        #自动管理的内存大小(M)

        oracle.install.db.config.starterdb.installExampleSchemas=false

        oracle.install.db.config.starterdb.enableSecuritySettings=true

        oracle.install.db.config.starterdb.password.ALL=sskm2017

        #设定所有数据库用户使用同一个密码

        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

        #设置安全更新(貌似是有bug,这个一定要选true,否则会无限提醒邮件地址有问题,终止安装。PS:不管地址对不对)

        PROXY_HOST=

        PROXY_PORT=

        PROXY_USER=

        PROXY_PWD=

$ cd /home/oracle/oracle_11g/app/database

$ ./runInstaller -silent -force -noconfig -responseFile /home/oracle/oracle_11g/app/database/response/db_install.rsp


14.运行orainstRoot.sh和root.sh

1)执行orainstRoot.sh来建立oraInst.loc文件和修改权限

$ su - root 

# cd /home/oracle/oracle_11g/oraInventory

# ./orainstRoot.sh

CentOS下静默安装Oracle11g_第1张图片
执行结果

    脚本执行后主要进行的操作:更改权限/home/oracle/oracle_11g/oraInventory.添加组的读取和写入权限。删除全局的读取, 写入和执行权限。更改组名/home/oracle/oracle_11g/oraInventory 到 oinstall.

(2)执行$ORACLE_HOME下的root.sh

    执行$ORACLE_HOME下的root.sh来建立oratab,dbhome,oraenv,coraenv文件, 如果提示则一直回车。

# cd /home/oracle/oracle_11g/app/oracle/product/11.2.0/dbhome_1

# ./root.sh 

Check /home/oracle/oracle_11g/app/oracle/product/11.2.0/dbhome_1/install/root_m22p135_2017-08-07_16-39-28.log for the output of root script

15.添加Oracle环境变量

# vim /home/oracle/.bash_profile

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/binexport 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/libexport 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

$ source /home/oracle/.bash_profile

16.配置静默监听

$ $ORACLE_HOME/bin/netca /silent /responseFile /home/oracle/oracle_11g/app/database/response/netca.rsp

Parsing command line arguments:

Parameter "silent" = true

Parameter "responsefile" = /home/oracle/oracle_11g/app/database/response/netca.rsp

Done parsing command line arguments.

Oracle Net Services Configuration:

Profile configuration complete.

Oracle Net Listener Startup:

Running Listener Control: /home/oracle/oracle_11g/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start LISTENER

Listener Control complete.

Listener started successfully.

Listener configuration complete.

Oracle Net Services configuration successful. The exit code is 0

17.静默安装数据库

$ echo> /home/oracle/oracle_11g/app/database/response/dbca.rsp

$ vim /home/oracle/oracle_11g/app/database/response/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"

18.测试数据库

(1)、启动数据库

$ sqlplus / as sysdba

SQL*Plus:Release11.2.0.1.0ProductiononMonAug7 17:09:502017Copyright(c) 1982, 2009,Oracle.Allrightsreserved.Connectedto:OracleDatabase11gEnterpriseEditionRelease11.2.0.1.0-64bitProductionWiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions

SQL> start

SP2-1506:START, @or@@ command hasnoarguments

注:可以使用show parameter;或者select table_name from dba_tables命令看看是否运行正常

(2)、监听检查

$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 07-AUG-2017 17:12:00

Copyright (c) 1991, 2009, Oracle.  All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))STATUS of the LISTENER------------------------Alias                    LISTENERVersion                  TNSLSNR for Linux: Version 11.2.0.1.0 - ProductionStartDate07-AUG-201717:01:30Uptime0days0hr.10min.29secTraceLeveloffSecurityON:LocalOSAuthenticationSNMPOFFListener ParameterFile/home/oracle/oracle_11g/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.oraListenerLogFile/home/oracle/oracle_11g/app/diag/tnslsnr/m22p135/listener/alert/log.xmlListening Endpoints Summary...  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=m22p135)(PORT=1521)))Services Summary...Service"orcl"has1instance(s).Instance"orcl",statusREADY, has1handler(s)forthis service...Service"orclXDB"has1instance(s).Instance"orcl",statusREADY, has1handler(s)forthis service...The command completed successfully

启动监听:lsnrctl start 

查看监听:lsnrctl status 

停止监听:lsnrctl stop

实例应该被动态注册到监听程序了. 到此oracle安装建库完毕!

你可能感兴趣的:(CentOS下静默安装Oracle11g)