分享

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

 书房1974 2019-12-02

准备工作

  • 安装环境介绍

软件:Vmware pro 15、Oracle 11gR2


oracle 11g R2

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

VMWARE PRO 15

系统:CentOS 7.6 64位

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

CentOS 7.6

我是在虚拟机上安装的Linux,虚拟机配置如下

内存2G、1个2核CPU、硬盘空间40G

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

虚拟机配置

  • 下载Oracle安装文件官网下载地址: https://www.oracle.com/database/technologies/oracle-database-software-downloads.html

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

oracle 11g R2官网下载页面

下载完毕,会得到如下两个压缩文件:

  1. linux.x64_11gR2_database_1of2.zip
  2. linux.x64_11gR2_database_2of2.zip

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

  • 检查系统版本
[root@localhost ~]# uname -mx86_64[root@localhost ~]# cat /etc/redhat-releaseCentOS Linux release 7.6.1810 (Core) [root@localhost ~]#

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

Linux系统版本

  • 修改主机名
[root@localhost home]# sed -i 's/HOSTNAME=localhost.localdomain/HOSTNAME=oracledb/' /etc/sysconfig/network[root@localhost home]# hostname oracledb
  • 添加主机名与IP对应记录
[root@localhost home]# vim /etc/hosts

在末尾处添加:本机IP地址 oracledb

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

修改主机名

  • 关闭Selinux
[root@localhost home]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config [root@localhost home]# setenforce 0
  • 创建用户和组(root用户:创建Oracle安装组oinstall,数据库管理员组dba,及oracle用户)
[root@localhost home]# groupadd -g 200 oinstall[root@localhost home]# groupadd -g 201 dba[root@localhost home]# useradd -u 440 -g oinstall -G dba oracle #主组oinstall,其它组:dba[root@localhost home]# passwd oracle #设置密码更改用户 oracle 的密码 。新的 密码:无效的密码: 密码未通过字典检查 - 它基于(颠倒的)字典单词 #Linux密码验证机制,请忽略重新输入新的 密码:passwd:所有的身份验证令牌已经成功更新。[root@localhost home]#

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

新建用户组及用户

  • 修改内核参数(root用户:修改 /etc/sysctl.conf 文件,加上如下参数)
[root@localhost home]# vim /etc/sysctl.conf #末尾添加如下net.ipv4.ip_local_port_range= 9000 65500fs.file-max = 6815744kernel.shmall = 10523004kernel.shmmax = 6465333657kernel.shmmni = 4096kernel.sem = 250 32000 100128net.core.rmem_default=262144net.core.wmem_default=262144net.core.rmem_max=4194304net.core.wmem_max=1048576fs.aio-max-nr = 1048576

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

修改Linux内核

[root@localhost home]# sysctl -p #使配置生效net.ipv4.ip_local_port_range = 9000 65500fs.file-max = 6815744kernel.shmall = 10523004kernel.shmmax = 6465333657kernel.shmmni = 4096kernel.sem = 250 32000 100128net.core.rmem_default = 262144net.core.wmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_max = 1048576fs.aio-max-nr = 1048576[root@localhost home]#
  • 修改系统资源限制(root用户:修改 /etc/security/limits.conf 文件,加上下面的参数)
[root@localhost home]# vim /etc/security/limits.conf #末尾添加如下oracle soft nproc 2047oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

资源限制修改

  • 修改用户验证选项(root用户下:修改/etc/pam.d/login文件加上如下参数)
$ vim /etc/pam.d/loginsession required pam_namespace.so #下面添加一条pam_limits.sosession required pam_limits.so

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

  • 修改用户配置文件(root用户下:修改/etc/profile文件加入如下参数)
[root@localhost home]# vim /etc/profile #(如果做了第9步的limits.conf设置,这个设置就不需要了)if [ $USER ='oracle' ]; then if [ $SHELL = '/bin/ksh' ];then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fifi
  • 创建安装目录及设置权限
[root@localhost home]# mkdir -p /opt/app/oracle/ [root@localhost home]# chmod 755 /opt/app/oracle/ [root@localhost home]# chown oracle.oinstall -R /opt/app/oracle/

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

  • 设置Oracle环境变量
[root@localhost app]# su - oracle[oracle@oracledb ~]$ vim ~/.bash_profile #添加一下内如 export ORACLE_BASE=/opt/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin export ORACLE_SID=orcl export ORACLE_PID=ora11g export NLS_LANG=AMERICAN_AMERICA.AL32UTF8export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

修改环境变量

完成后执行:

[oracle@oracledb ~]$ source ~/.bash_profile #立即生效[oracle@oracledb ~]$ env | grep ORA #查看环境变量是否完成ORACLE_SID=orclORACLE_BASE=/opt/app/oracleORACLE_PID=ora11gORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1[oracle@oracledb ~]$

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

设置环境变量生效

安装及配置

  • 安装依赖包所需依赖列表:
  1. binutils-2.23.52.0.1-12.el7.x86_64
  2. compat-libcap1-1.10-3.el7.x86_64
  3. compat-libstdc++-33-3.2.3-71.el7.i686
  4. compat-libstdc++-33-3.2.3-71.el7.x86_64
  5. gcc-4.8.2-3.el7.x86_64
  6. gcc-c++-4.8.2-3.el7.x86_64
  7. glibc-2.17-36.el7.i686
  8. glibc-2.17-36.el7.x86_64
  9. glibc-devel-2.17-36.el7.i686
  10. glibc-devel-2.17-36.el7.x86_64
  11. ksh
  12. libaio-0.3.109-9.el7.i686
  13. libaio-0.3.109-9.el7.x86_64
  14. libaio-devel-0.3.109-9.el7.i686
  15. libaio-devel-0.3.109-9.el7.x86_64
  16. libgcc-4.8.2-3.el7.i686
  17. libgcc-4.8.2-3.el7.x86_64
  18. libstdc++-4.8.2-3.el7.i686
  19. libstdc++-4.8.2-3.el7.x86_64
  20. libstdc++-devel-4.8.2-3.el7.i686
  21. libstdc++-devel-4.8.2-3.el7.x86_64
  22. libXi-1.7.2-1.el7.i686
  23. libXi-1.7.2-1.el7.x86_64
  24. libXtst-1.2.2-1.el7.i686
  25. libXtst-1.2.2-1.el7.x86_64
  26. make-3.82-19.el7.x86_64
  27. sysstat-10.1.5-1.el7.x86_64
  28. unixODBC-2.3.1-6.el7.x86_64 or later
  29. unixODBC-2.3.1-6.el7.i686 or later
  30. unixODBC-devel-2.3.1-6.el7.x86_64 or later
  31. unixODBC-devel-2.3.1-6.el7.i686 or later
  • 使用yum -y install 进行安装(记得切换用户为root)
[root@oracledb oracle]# yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

依赖安装

  • 检查是否全部已经安装,没安装的单独进行安装
[root@oracledb oracle]# rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

检查依赖

安装Oracle


安装unzip:(如已安装请忽略)

[root@oracledb home]# yum -y install unzip

将下载的Oracle压缩包放入/opt目录下,在/opt目录下进行解压

[root@oracledb home]# ls *.zip | xargs -n1 unzip -o

或者

$ unzip linux.x64_11gR2_database_1of2.zip$ unzip linux.x64_11gR2_database_2of2.zip

解压后得到database,进入database下面的response文件夹,里面有3个文件

[root@oracledb response]# cd /opt/database/response/[root@oracledb response]# lltotal 76-rw-rw-r--. 1 root root 44969 Feb 13 2009 dbca.rsp #创建数据库应答-rw-rw-r--. 1 root root 22557 Aug 15 2009 db_install.rsp #安装应答-rwxrwxr-x. 1 root root 5740 Feb 26 2009 netca.rsp #建立监听、本地服务名等网络设置的应答[root@oracledb response]#

将db_install.rsp备份一份,在其基础上修改内容

修改静默安装的配置文件

[root@oracledb response]# vim db_install.rsp #按照下方的参数进行修改oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0oracle.install.option=INSTALL_DB_SWONLYORACLE_HOSTNAME=oracledbUNIX_GROUP_NAME=oinstallINVENTORY_LOCATION=/opt/app/oracle/oraInventorySELECTED_LANGUAGES=en,zh_CNORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1ORACLE_BASE=/opt/app/oracleoracle.install.db.InstallEdition=EEoracle.install.db.isCustomInstall=falseoracle.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.0oracle.install.db.DBA_GROUP=dbaoracle.install.db.OPER_GROUP=oinstalloracle.install.db.CLUSTER_NODES=oracle.install.db.config.starterdb.type=GENERAL_PURPOSEoracle.install.db.config.starterdb.globalDBName=ora11goracle.install.db.config.starterdb.SID=ora11goracle.install.db.config.starterdb.characterSet=AL32UTF8oracle.install.db.config.starterdb.memoryOption=trueoracle.install.db.config.starterdb.memoryLimit=1500oracle.install.db.config.starterdb.installExampleSchemas=falseoracle.install.db.config.starterdb.enableSecuritySettings=trueoracle.install.db.config.starterdb.password.ALL=oracleoracle.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_CONTROLoracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=falseoracle.install.db.config.starterdb.dbcontrol.emailAddress=oracle.install.db.config.starterdb.dbcontrol.SMTPServer=oracle.install.db.config.starterdb.automatedBackup.enable=falseoracle.install.db.config.starterdb.automatedBackup.osuid=oracle.install.db.config.starterdb.automatedBackup.ospwd=oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGEoracle.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 //一定要设为 truePROXY_HOST=PROXY_PORT=PROXY_USER=PROXY_PWD=

开始静默安装,使用oracle用户

[root@oracledb database]# su oracle[oracle@oracledb response]# cd /opt/database/ #进入/opt/database目录[oracle@oracledb database]# ./runInstaller -silent -force -responseFile /opt/database/response/db_install.rsp

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

安装过程

[WARING]可暂时忽略,此时安装程序仍在后台进行,如果出现[FATAL],则安装程序已经停止了。

安装需要一会儿,如果想看安装进度,可以再打开一个窗口,输出会话日志

tail -f 日志路径 #日志文件(下图中红色框中未日志文件绝对路径)

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

当出现Successfully Setup Software.证明已经安装成功,然后根据提示以root用户执行脚本

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

安装成功

[oracle@oracledb database]$ su rootPassword: [root@oracledb database]# sh /opt/app/oracle/oraInventory/orainstRoot.shChanging permissions of /opt/app/oracle/oraInventory.Adding read,write permissions for group.Removing read,write,execute permissions for world.Changing groupname of /opt/app/oracle/oraInventory to oinstall.The execution of the script is complete.[root@oracledb database]# sh /opt/app/oracle/product/11.2.0/db_1/root.shCheck /opt/app/oracle/product/11.2.0/db_1/install/root_oracledb_2019-10-08_02-50-55.log for the output of root script
  • 配置监听程序

监听命令(注意:一定要切换回oracle用户

启动监听:

[oracle@oracledb database]# lsnrctl start

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

启动监听

重启监听:

[root@oracledb database]# lsnrctl reload

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

重启监听

停止监听:

[oracle@oracledb database]# lsnrctl stop

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

停止监听

查看监听:

[root@oracledb database]# lsnrctl status

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

监听状态

  • 配置监听(使用oracle用户)
[oracle@oracledb database]# $ORACLE_HOME/bin/netca /silent /responseFile /opt/database/response/netca.rsp

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

监听配置

  • 查看监听(使用oracle用户)
[oracle@oracledb database]# lsnrctl status

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

监听状态

  • 静默dbca建库
[oracle@oracledb database]# vim /opt/database/response/dbca.rsp

修改如下内容:

GDBNAME = 'orcl' #第78行

SID='orcl' #第149行

CHARACTERSET='AL32UTF8' #第415行,去掉注释

NATIONALCHARACTERSET='UTF8' #第425行 去掉注释

保存退出

然后执行

[root@oracledb database]# su - oracleLast login: Tue Oct 8 02:40:43 EDT 2019 on pts/0[oracle@oracledb ~]# $ORACLE_HOME/bin/dbca -silent -responseFile /opt/database/response/dbca.rsp

然后输入两次密码后开始自动创建:

CentOS 7.6静默安装Oracle 11gR2(最新版安装详细教程)

创建数据库

  • 启动数据库
[oracle@oracledb ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Mon Feb 16 14:26:57 2015Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to an idle instance.SQL> startSP2-1506: START, @ or @@ command has no argumentsSQL> shutdownDatabase closed.Database dismounted.ORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 759943168 bytesFixed Size		 2217224 bytesVariable Size		 448793336 bytesDatabase Buffers	 301989888 bytesRedo Buffers		 6942720 bytesDatabase mounted.Database opened.SQL> exit; #退出数据库控制台
  • 开机自动启动监听、启动Oracle
[oracle@oracledb oracle]$ vim /etc/oratab

其中:

orcl:/opt/app/oracle/product/11.2.0/db_1:N

把第三段的N改为Y

改后如下:

orcl:/opt/app/oracle/product/11.2.0/db_1:Y 务必是大写的Y

保存后退出

[root@oracledb oracle]# su root #切换至root用户[root@oracledb oracle]# vim /etc/rc.local

#在文件末尾增加如下内容

su - oracle -c 'dbstart'

su - oracle -c 'lsnrctl start'

然后执行

[root@oracledb oracle]# chmod +x /etc/rc.local

其实开机自动以oracle用户执行上面两个命令啦

  • 开放1521端口(远程连接Oracle所需)

查看端口是否开放:

[root@oracledb oracle]# firewall-cmd --query-port=1521/tcpno

永久开放1521端口号:

[root@oracledb oracle]# firewall-cmd --permanent --zone=public --add-port=1521/tcpsuccess

重启防火墙:

[root@oracledb oracle]# systemctl restart firewalld.service

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多