暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

【Oracle学习02】CentOS6静默安装Oracle12c

陶老师运维笔记 2019-11-27
2276

【Oracle学习02】CentOS6静默安装Oracle12c

   Oracle Database,又名Oracle RDBMS,或简称Oracle。是甲骨文公司的一款关系型数据库管理系统。

Oracle官方文档:https://www.oracle.com/index.htmlhttps://docs.oracle.com/en/database/oracle/oracle-database/index.htmlhttps://docs.oracle.com/en/database/oracle/oracle-database/12.2/install-and-upgrade.html

Oracle12c安装要求:硬件: Disk >8G, 内存>2G,若安装 Oracle Grid>8G。

操作系统: Linux 7.2: 3.10.0-327.el7.s390x or later, Linux 6.6: 2.6.32-504.el6.s390x or later

软件包依赖: https://docs.oracle.com/en/database/oracle/oracle-database/12.2/cwlin/supported-red-hat-enterprise-linux-6-distributions-for-x86-64.html#GUID-3B53A308-3EC2-4173-98A0-0FFD68994E90

1. 安装环境

1.1 系统环境

OSHostnameIP硬件
CentOS6.6Oracle-01192.122.132.37空闲磁盘>8G,内存>2G,SWap分区>2G。

1.2 软件下载

下载Oracle12.2.0.1.0版本,选择Linux x86-64安装包。(下载需要Oracle账号)。https://www.oracle.com/technetwork/cn/database/enterprise-edition/downloads/index.html

下载地址: https://www.oracle.com/database/technologies/oracle12c-linux-12201-downloads.html

检查下载文件:

  1. $cksum oracle_linuxx64_12201_database.zip

  2. 4170261901 3453696911 oracle_linuxx64_12201_database.zip

上面的输出信息中校验码为 4170261901 , 文件大小为3453696911,和官方图示相同。

2. 安装介绍

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/tutorials.htmlhttps://docs.oracle.com/en/database/oracle/oracle-database/12.2/install-and-upgrade.html

2.1 安装方法

oracle 安装使用OUI(Oracle Universal Installer )。

OUI介绍 :https://docs.oracle.com/cd/E2685401/em.121/e37799/ch1introduction.htm#OUICG107https://oracle-base.com/articles/misc/oui-silent-installationshttps://www.2cto.com/database/201110/107339.html

深入理解OUI三种模式(Modes of Installation):

  • Interactive Mode

  • Suppressed-Interactive Mode

  • Silent Mode

1) OUI图形化安装

Oracle Universal Installer (OUI)图形化安装。Interactive Mode。

2)静默安装

静默安装 Silent Mode 。在无图形界面或命令行批量部署时可静默(Silent Mode)安装 oracle ,用命令行创建db,配置netca等,快速完成oracle部署。

  1. $ORACLE_HOME/runInstaller -h

  2. ./runInstaller [-silent] [-noconfig] -responseFile responsefilename

3)克隆安装

若是有配置相同的机器需要安装,这时可以进行clone安装。

2.2 安装目录

OFA 中有几个关键目录需要知道。介绍:https://blog.csdn.net/m0_37814112/article/details/77373863如下:

  • oracle  inventory  目录:保存本机上所安装的Oracle 软件的目录清单,本机上安装的所有Oracle软件都需要并且共享使用这个目录。

  • oracle  Base 目录 (ORACLE_BASE): Oracle Base 目录是Oracle软件安装的最顶层目录。这个目录下可以安装多个版本的Oracle软件,OFA标准里的Oracle Base目录是这样的:通常可能这样:/u01/app/oracle

  • Oracle  Home 目录 (ORACLEHOME): oracle的产品目录,类似 u01/app/oracle/product/11.2.0/db1

  • Oracle  Network 目录 (TNSADMIN) Automatic  Diagnostic  Repository  (ADRHOME) 自动诊断库

  • GRID 目录:Grid 的ORACLEBASE 和ORACLEHOME有所不同,GRID的ORACLEHOME不能是ORACLEBASE的子目录,否则安装会报错。

  • ORACLEBASE、ORACLEHOME环境变量 grid、Oracle 两个用户各自的设置是不同的:

  1. #grid、Oracle 两个用户各自的设置是不同的:

  2. $env |grep ORA -i

  3. GRID用户的环境变量设置:

  4. export ORACLE_BASE=/u01/app/grid

  5. export ORACLE_HOME=/u01/app/12.2.0.1/grid

  6. path=$ORACLE_HOME/bin:$PATH:$HOME/bin


  7. oracle 用户的环境变量设置:

  8. export ORACLE_BASE=/u01/app/oracle

  9. export ORACLE_HOME=$ORACLE_BASE/product/12.2.0.1/dbhome_1

  10. path=$ORACLE_HOME/bin:$PATH:$HOME/bin

3. 安装的先决条件

3.1 软件包准备

依赖软件: https://docs.oracle.com/en/database/oracle/oracle-database/12.2/cwlin/supported-red-hat-enterprise-linux-6-distributions-for-x86-64.html#GUID-3B53A308-3EC2-4173-98A0-0FFD68994E90

  1. yum install -y bc

  2. yum install -y compat-libcap1*

  3. yum install -y compat-libcap*

  4. yum install -y binutils

  5. yum install -y compat-libstdc++-33

  6. yum install -y elfutils-libelf

  7. yum install -y elfutils-libelf-devel

  8. yum install -y gcc

  9. yum install -y gcc-c++

  10. yum install -y glibc-2.5

  11. yum install -y glibc-common

  12. yum install -y glibc-devel

  13. yum install -y glibc-headers

  14. yum install -y ksh libaio

  15. yum install -y libaio-devel

  16. yum install -y libgcc

  17. yum install -y libstdc++

  18. yum install -y libstdc++-devel

  19. yum install -y make

  20. yum install -y sysstat

  21. yum install -y unixODBC

  22. yum install -y unixODBC-devel

  23. yum install -y binutils*

  24. yum install -y compat-libstdc*

  25. yum install -y elfutils-libelf*

  26. yum install -y gcc*

  27. yum install -y glibc*

  28. yum install -y ksh*

  29. yum install -y libaio*

  30. yum install -y libgcc*

  31. yum install -y libstdc*

  32. yum install -y make*

  33. yum install -y sysstat*

  34. yum install -y libXp*

  35. yum install -y glibc-kernheaders

  36. yum install -y net-tools-*

或写在一起。检查软件包安装情况:

  1. $rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n" \

  2. bc compat-libcap1* compat-libcap* binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc-2.5 glibc-common glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel binutils* compat-libstdc* elfutils-libelf* glibc* ksh* libaio* libgcc* libstdc* sysstat* libXp* glibc-kernheaders net-tools-* \

  3. | grep not | grep -v grep | awk '{print "yum install -y " $2 }'


  4. #结果,缺少的软件包就会列出来,如下。

  5. ...

  6. yum install -y glibc-2.5

  7. yum install -y gcc*

3.2 修改OS参数

3.2.1 修改内核参数

修改/etc/sysctl.conf 在末尾加上如下代码。

  1. $vim /etc/sysctl.conf

  2. kernel.shmmax = 277495689510912

  3. kernel.shmmni = 4096

  4. kernel.sem = 250 32000 100 128

  5. net.core.rmem_default = 262144

  6. net.core.rmem_max = 4194304

  7. net.core.wmem_default = 262144

  8. net.core.wmem_max = 1048586

  9. fs.file-max = 6815744

  10. kernel.shmall = 4294967296

  11. net.ipv4.tcp_max_tw_buckets = 6000

  12. net.ipv4.ip_local_port_range = 9000 65500

  13. net.ipv4.tcp_tw_recycle = 0

  14. net.ipv4.tcp_tw_reuse = 1

  15. net.core.somaxconn = 262144

  16. net.core.netdev_max_backlog = 262144

  17. net.ipv4.tcp_max_orphans = 262144

  18. net.ipv4.tcp_max_syn_backlog = 262144

  19. net.ipv4.tcp_synack_retries = 2

  20. net.ipv4.tcp_syn_retries = 1

  21. net.ipv4.tcp_fin_timeout = 1

  22. net.ipv4.tcp_keepalive_time = 30

  23. net.ipv4.tcp_keepalive_probes = 6

  24. net.ipv4.tcp_keepalive_intvl = 5

  25. net.ipv4.tcp_timestamps = 0

  26. fs.aio-max-nr = 1048576

  27. net.ipv4.conf.all.rp_filter = 2

  28. net.ipv4.conf.default.rp_filter = 2


  29. #检查配置

  30. $/etc/sysctl.conf |grep -v '#' |grep -v '^$'

修改后使之生效执行如下代码。

  1. $sysctl -p

3.2.2 修改文件 limits.conf

  1. $vi /etc/security/limits.conf


  2. oracle soft nofile 1024

  3. oracle hard nofile 65536

  4. oracle soft nproc 16384

  5. oracle hard nproc 16384

  6. oracle soft stack 10240

  7. oracle hard stack 32768

  8. oracle hard memlock 134217728

  9. oracle soft memlock 134217728

3.2.3 修改 etc/pam.d/login

增加如下两条

  1. vim /etc/pam.d/login

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

  3. session required pam_limits.so

3.2.4 关闭SELINUX

  1. $vi /etc/selinux/config

  2. # 将`SELINUX`修改为disabled

  3. SELINUX=disabled

  4. SELINUXTYPE=targeted

  5. #临时关闭

  6. $setenforce 0

3.2.5 禁用防火墙

为了避免不必要的问题,可以关闭防火墙。

  1. iptables -L

  2. cat /etc/sysconfig/iptables

  3. iptables-save > /etc/sysconfig/iptables

  4. #永久关闭防火墙

  5. service iptables stop

  6. chkconfig iptables off

  7. service ip6tables stop

  8. chkconfig ip6tables off

  9. ##centos7

  10. systemctl stop firewalld

  11. systemctl disable firewalld

4. 创建用户及组

4.1 创建用户及安装目录

创建用户:

  1. #添加用户组:(组id最好在500以后的值, 500前为系统用户。)

  2. $groupadd -g 54321 oinstall

  3. $groupadd -g 54322 dba

  4. $groupadd -g 54323 oper

  5. #groupadd oracle

  6. $useradd -g oinstall -G dba,oper oracle

  7. #

  8. $id oracle

  9. uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper)

  10. #usermod -a -G GroupName UserName

创建oracle安装目录:官方是类似/u01/app/oracle目录,但是作者是data1磁盘最大,安装在data1盘中。如下:

  1. #mkdir -p u01/app/oracle

  2. #环境是data1盘最大,没有安装在/

  3. mkdir -p /data1/u01/app/oracle

  4. mkdir -p /data1/u01/app/oraInventory

  5. ln -s /data1/u01 /u01

  6. chown -R oracle.oinstall /data1/u01

  7. chmod -R 775 /data1/u01/app/oracle

  8. chown -R oracle.oinstall /u01

修改oracle用户的密码:

  1. $passwd oracle #oracleoracle

说明:不必非要叫oinstall,和dba,只不过一般文档上就这么叫:oinstall组用于安装数据库 , dba组用于管理数据库。-g表示这个用户的主组 , -G标识这个用户的其它组。一个用户可以属于多个用户组,但是一个用户只能指定一个组作为其主组。

5. Oracle环境变量

su - oracle 切换到oracle账户,修改 .bash_profile 文件,$env |grep ORA -i查看。

  1. su - oracle

  2. vim /home/oracle/.bash_profile

  3. #oracle

  4. export EDITOR=vi

  5. export TMP=/tmp

  6. export TMPDIR=$TMP

  7. export ORACLE_SID=orcl

  8. export ORACLE_BASE=/data1/u01/app/oracle

  9. export ORACLE_HOME=$ORACLE_BASE/product/12.2.0.1/db_1

  10. export INVENTORY_LOCATION=/data1/u01/app/oraInventory

  11. export TNS_ADMIN=$ORACLE_HOME/network/admin

  12. export LD_LIBRARY_PATH=$ORACLE_HOME/lib

  13. export NLS_LANG=AMERICAN_AMERICA.AL32UTF8

  14. export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'

  15. export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:$PATH:$HOME/bin

  16. umask 022

  17. #export PS1=$LOGNAME@`hostname`:'$PWD>'

  18. export SQLPATH=$ORACLE_HOME/sqlplus/admin:/home/oracle/admin/sql

  19. alias ohome="cd $ORACLE_HOME"

  20. alias sql='sqlplus "/"'

  21. alias sqln="sqlplus nolog"

  22. #生效

  23. $source .bash_profile

  24. $env |grep ORA -i

  25. #测试umask

  26. $umask -S

6. Oracle静默安装

6.1 上传软件

将下载的linuxx6412201database.zip上传到Linux系统/home/oracle目录下解压,解压后目录为database。

  1. cd /home/oracle

  2. wget 'xxx/oracle_linuxx64_12201_database.zip'

  3. unzip oracle_linuxx64_12201_database.zip

6.2 修改静默响应文件

6.2.1 配置说明

静默响应文件位于database/response/dbinstall.rsp 。数据库安装响应文件dbinstall.rsp修改的地方,参见Oracle Universal Installer (OUI) Silent Installations中12cR2进行设置。

静默安装的参数含义:

https://oracle-base.com/articles/misc/12cR2.rsphttps://oracle-base.com/articles/misc/oui-silent-installationshttps://docs.oracle.com/cd/E2685401/em.121/e37799/ch3response_file.htm#OUICG184

  1. oracle 软件静默安装的参数含义如下:

  2. -silent 表示以静默方式安装,不会有任何提示

  3. -force 表示允许安装到一个非空目录

  4. -noconfig 表示不运行配置助手netca

  5. -responseFile 表示使用哪个响应文件,必需使用绝对路径

  6. oracle.install.responseFileVersion 响应文件模板的版本,该参数不要更改

  7. oracle.install.option 安装模式选项,本例只安装oracle软件,该参数不要更改

  8. DECLINE_SECURITY_UPDATES 是否需要在线安全更新,设置为false,该参数不要更改

  9. UNIX_GROUP_NAME oracle 用户用于安装软件的组名

  10. INVENTORY_LOCATION oracle 产品清单目录

  11. SELECTED_LANGUAGES oracle 运行语言环境,一般包括引文和简繁体中文

  12. ORACLE_HOME oracle安装目录

  13. ORACLE_BASE oracle基础目录

  14. oracle.install.db.InstallEdition 安装版本类型,一般是企业版

  15. oracle.install.db.isCustomInstall 是否定制安装,默认Partitioning,OLAP,RAT都选上。根据自己的需要选择组件。

  16. oracle.install.db.customComponents 定制安装组件列表:除了以上默认的,可加上Label SecurityDatabase Vault

  17. oracle.install.db.DBA_GROUP oracle 用户用于授予osdba权限的组名

  18. oracle.install.db.OPER_GROUP oracle 用户用于授予osoper权限的组名

6.2.2 修改响应文件

可以使用软件带的db_install.rsp修改,但为了简单直接使用https://oracle-base.com/articles/misc/12cR2.rsp 进行修改。12cR2.rsp文件:

  1. #解压软件后的db_install.rsp

  2. $cat response/db_install.rsp |grep -v '#' |grep -v '^$' |grep -v '=$'

  3. oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.2.0


  4. #把https://oracle-base.com/articles/misc/12cR2.rsp 下载放在~/12cR2.rsp

  5. $cat ~/12cR2.rsp |grep -v '#' |grep -v '^$'

  6. oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.2.0

  7. oracle.install.option=INSTALL_DB_SWONLY

  8. UNIX_GROUP_NAME=oinstall

  9. INVENTORY_LOCATION=/u01/app/oraInventory

  10. ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/db_1

  11. ORACLE_BASE=/u01/app/oracle

  12. oracle.install.db.InstallEdition=EE

  13. oracle.install.db.OSDBA_GROUP=dba

  14. oracle.install.db.OSOPER_GROUP=dba

  15. oracle.install.db.OSBACKUPDBA_GROUP=dba

  16. oracle.install.db.OSDGDBA_GROUP=dba

  17. oracle.install.db.OSKMDBA_GROUP=dba

  18. SECURITY_UPDATES_VIA_MYORACLESUPPORT=false

  19. DECLINE_SECURITY_UPDATES=true

修改:修改Response File,把INVENTORYLOCATION,ORACLEHOME,ORACLE_BASE目录修改下就可。读者依自已实际路径情况修改!

  1. cp 12cR2.rsp ~/12cR2_u01.rsp

  2. vim ~/12cR2_u01.rsp

  3. #增加data1

  4. INVENTORY_LOCATION=/data1/u01/app/oraInventory

  5. ORACLE_HOME=/data1/u01/app/oracle/product/12.2.0.1/db_1

  6. ORACLE_BASE=/data1/u01/app/oracle

最终响应文件配置:最终12cR2_u01.rsp文件如下。

  1. $cat 12cR2_u01.rsp |grep -v '#' |grep -v '^$'

  2. oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.2.0

  3. oracle.install.option=INSTALL_DB_SWONLY

  4. UNIX_GROUP_NAME=oinstall

  5. INVENTORY_LOCATION=/data1/u01/app/oraInventory

  6. ORACLE_HOME=/data1/u01/app/oracle/product/12.2.0.1/db_1

  7. ORACLE_BASE=/data1/u01/app/oracle

  8. oracle.install.db.InstallEdition=EE

  9. oracle.install.db.OSDBA_GROUP=dba

  10. oracle.install.db.OSOPER_GROUP=dba

  11. oracle.install.db.OSBACKUPDBA_GROUP=dba

  12. oracle.install.db.OSDGDBA_GROUP=dba

  13. oracle.install.db.OSKMDBA_GROUP=dba

  14. oracle.install.db.OSRACDBA_GROUP=

  15. oracle.install.db.rac.configurationType=

  16. oracle.install.db.CLUSTER_NODES=

  17. oracle.install.db.isRACOneInstall=

  18. oracle.install.db.racOneServiceName=

  19. oracle.install.db.rac.serverpoolName=

  20. oracle.install.db.rac.serverpoolCardinality=

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

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

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

  24. oracle.install.db.ConfigureAsContainerDB=

  25. oracle.install.db.config.PDBName=

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

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

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

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

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

  31. oracle.install.db.config.starterdb.password.SYS=

  32. oracle.install.db.config.starterdb.password.SYSTEM=

  33. oracle.install.db.config.starterdb.password.DBSNMP=

  34. oracle.install.db.config.starterdb.password.PDBADMIN=

  35. oracle.install.db.config.starterdb.managementOption=

  36. oracle.install.db.config.starterdb.omsHost=

  37. oracle.install.db.config.starterdb.omsPort=

  38. oracle.install.db.config.starterdb.emAdminUser=

  39. oracle.install.db.config.starterdb.emAdminPassword=

  40. oracle.install.db.config.starterdb.enableRecovery=

  41. oracle.install.db.config.starterdb.storageType=

  42. oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=

  43. oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=

  44. oracle.install.db.config.asm.diskGroup=

  45. oracle.install.db.config.asm.ASMSNMPPassword=

  46. MYORACLESUPPORT_USERNAME=

  47. MYORACLESUPPORT_PASSWORD=

  48. SECURITY_UPDATES_VIA_MYORACLESUPPORT=false

  49. DECLINE_SECURITY_UPDATES=true

  50. PROXY_HOST=

  51. PROXY_PORT=

  52. PROXY_USER=

  53. PROXY_PWD=

  54. COLLECTOR_SUPPORTHUB_URL=

6.3 执行静默安装

6.3.1检查响应文件

检查12cR2u01.rsp及.bashprofile 文件中路径设置是否一致。

  1. $cat /home/oracle/.bash_profile

  2. $cat 12cR2_u01.rsp |grep -v '#' |grep -v '^$' |grep -v '=$'

6.3.2执行安装

示例: https://oracle-base.com/articles/misc/oui-silent-installations

  1. #[https://oracle-base.com/articles/misc/oui-silent-installations](https://oracle-base.com/articles/misc/oui-silent-installations)

  2. #The OS group name parameters were renamed in 12cR2 to include a prefix of "OS" and the OSRACDBA parameter is now mandatory, as shown below.

  3. # 12cR2.

  4. $./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforcompletion -showProgress -silent \

  5. -responseFile /tmp/database/response/db_install.rsp \

  6. oracle.install.option=INSTALL_DB_SWONLY \

  7. ORACLE_HOSTNAME=${ORACLE_HOSTNAME} \

  8. UNIX_GROUP_NAME=oinstall \

  9. INVENTORY_LOCATION=${ORA_INVENTORY} \

  10. SELECTED_LANGUAGES=en,en_GB \

  11. ORACLE_HOME=${ORACLE_HOME} \

  12. ORACLE_BASE=${ORACLE_BASE} \

  13. oracle.install.db.InstallEdition=EE \

  14. oracle.install.db.OSDBA_GROUP=dba \

  15. oracle.install.db.OSBACKUPDBA_GROUP=dba \

  16. oracle.install.db.OSDGDBA_GROUP=dba \

  17. oracle.install.db.OSKMDBA_GROUP=dba \

  18. oracle.install.db.OSRACDBA_GROUP=dba \

  19. SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \

  20. DECLINE_SECURITY_UPDATES=true

执行安装:把示例中的变量进行更换即可。命令行的设置优先级高于xx.rsp文件。所以也可以直接用12cR2.rsp文件!

  1. $./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforcompletion -showProgress -silent \

  2. -responseFile /home/oracle/12cR2.rsp \

  3. oracle.install.option=INSTALL_DB_SWONLY \

  4. ORACLE_HOSTNAME=Oracle-01 \

  5. UNIX_GROUP_NAME=oinstall \

  6. INVENTORY_LOCATION=/data1/u01/app/oraInventory \

  7. SELECTED_LANGUAGES=en,en_GB \

  8. ORACLE_HOME=/data1/u01/app/oracle/product/12.2.0.1/db_1 \

  9. ORACLE_BASE=/data1/u01/app/oracle \

  10. oracle.install.db.InstallEdition=EE \

  11. oracle.install.db.OSDBA_GROUP=dba \

  12. oracle.install.db.OSBACKUPDBA_GROUP=dba \

  13. oracle.install.db.OSDGDBA_GROUP=dba \

  14. oracle.install.db.OSKMDBA_GROUP=dba \

  15. oracle.install.db.OSRACDBA_GROUP=dba \

  16. SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \

  17. DECLINE_SECURITY_UPDATES=true


  18. #

  19. Checking Temp space: must be greater than 500 MB. Actual 5498 MB Passed

  20. Checking swap space: must be greater than 150 MB. Actual 8391 MB Passed

  21. Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-11-13_02-57-42PM.

  22. Please wait ...You can find the log of this install session at:

  23. /data1/u01/app/oraInventory/logs/installActions2019-11-13_02-57-42PM.log


  24. Prepare in progress.

  25. .................................................. 8% Done.


  26. Prepare successful.


  27. Copy files in progress.

  28. .................................................. 17% Done.

  29. .................................................. 22% Done.

  30. ...

  31. .................................................. 75% Done.

  32. .................................................. 80% Done.

  33. ....................

  34. Copy files successful.


  35. Link binaries in progress.

  36. ..........

  37. Link binaries successful.


  38. Setup files in progress.

  39. ..............................

  40. Setup files successful.


  41. Setup Inventory in progress.


  42. Setup Inventory successful.


  43. Finish Setup successful.

  44. The installation of Oracle Database 12c was successful.

  45. Please check '/data1/u01/app/oraInventory/logs/silentInstall2019-11-13_02-57-42PM.log' for more details.


  46. Setup Oracle Base in progress.


  47. Setup Oracle Base successful.

  48. .................................................. 95% Done.


  49. As a root user, execute the following script(s):

  50. 1. /data1/u01/app/oraInventory/orainstRoot.sh

  51. 2. /data1/u01/app/oracle/product/12.2.0.1/db_1/root.sh

执行脚本:

  1. $sh /data1/u01/app/oraInventory/orainstRoot.sh

  2. Changing permissions of /data1/u01/app/oraInventory.

  3. Adding read,write permissions for group.

  4. Removing read,write,execute permissions for world.

  5. Changing groupname of /data1/u01/app/oraInventory to oinstall.

  6. The execution of the script is complete.

  7. ##

  8. $sh /data1/u01/app/oracle/product/12.2.0.1/db_1/root.sh

  9. Check /data1/u01/app/oracle/product/12.2.0.1/db_1/install/root_Oracle-02_2019-11-13_17-21-28-301583782.log for the output of root script

  10. #

  11. $tail -f /data1/u01/app/oracle/product/12.2.0.1/db_1/install/root_Oracle-02_2019-11-13_17-21-28-301583782.log

  12. Copying oraenv to /usr/local/bin ...

  13. Copying coraenv to /usr/local/bin ...

  14. Creating /etc/oratab file...

  15. Entries will be added to the /etc/oratab file as needed by

  16. Database Configuration Assistant when a database is created

  17. Finished running generic part of root script.

  18. Now product-specific root actions will be performed.

  19. Oracle Trace File Analyzer (TFA) is available at : /data1/u01/app/oracle/product/12.2.0.1/db_1/suptools/tfa/release/tfa_home/bin/tfactl

6.3.3 测试结果

目录结构:

  1. $cd /data1/u01/app

  2. $tree -L 2

  3. .

  4. ├── oracle

  5.    ├── checkpoints

  6.    ├── diag

  7.    └── product

  8. └── oraInventory

  9. ├── ContentsXML

  10. ├── logs

  11. ├── oraInst.loc

  12. ├── orainstRoot.sh

  13. └── oui

sqlplus登录:执行命令su - oracle ; sqlplus as sysdba

  1. $su - oracle

  2. $sqlplus -v

  3. $sqlplus / as sysdba

  4. Connected to an idle instance.

  5. SQL>


  6. $ps aux |grep ora -i

  7. oracle 11627 0.0 0.0 115800 12904 pts/0 S+ 17:45 0:00 sqlplus as sysdba

  8. oracle 11630 0.0 0.0 432292 17820 ? Ss 17:45 0:00 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))

7.创建数据库

可以使用DBCA或OMF等方式建数据库。

7.1 DBCA 静默建库

https://docs.oracle.com/database/121/ADMIN/create.htm#ADMIN11124数据库配置助手DBCA静默模式下创建数据库:

  1. $dbca -help

  2. $cat $ORACLE_HOME/dbs/init.ora #查看参数。

  3. #totalMemory设置为8G,

  4. $dbca -silent -createDatabase \

  5. -templateName $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc \

  6. -gdbname cdb1 -sid cdb1 -responseFile NO_VALUE \

  7. -characterSet AL32UTF8 \

  8. -sysPassword OraPasswd1 \

  9. -systemPassword OraPasswd1 \

  10. -createAsContainerDatabase true \

  11. -numberOfPDBs 1 \

  12. -pdbName pdb1 \

  13. -pdbAdminPassword OraPasswd1 \

  14. -databaseType MULTIPURPOSE \

  15. -automaticMemoryManagement false \

  16. -totalMemory 8192 \

  17. -storageType FS \

  18. -datafileDestination "/data1/u01/app/oracle/oradata/" \

  19. -useOMF true \

  20. -redoLogFileSize 50 \

  21. -emConfiguration NONE \

  22. -ignorePreReqs


  23. ##输出信息

  24. Copying database files

  25. 1% complete

  26. 13% complete

  27. 25% complete

  28. Creating and starting Oracle instance

  29. 26% complete

  30. Creating Pluggable Databases

  31. 55% complete

  32. 75% complete

  33. Executing Post Configuration Actions

  34. 100% complete

  35. Look at the log file "/data1/u01/app/oracle/cfgtoollogs/dbca/cdb1/cdb10.log" for further details.

  36. #查看

  37. $tail -f /data1/u01/app/oracle/cfgtoollogs/dbca/cdb1/cdb10.log

  38. /data1/u01/app/oracle/cfgtoollogs/dbca/cdb1.

  39. Database Information:

  40. Global Database Name:cdb1

  41. System Identifier(SID):cdb1

说明: 命令中的totalMemory不能小于2G,否则会失败。

结果:

  1. sqlplus / as sysdba

启动TNSLSNR:

  1. lsnrctl start

  2. LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 14-NOV-2019 14:46:46

  3. Copyright (c) 1991, 2016, Oracle. All rights reserved.

  4. Starting /data1/u01/app/oracle/product/12.2.0.1/db_1/bin/tnslsnr: please wait...

  5. TNSLSNR for Linux: Version 12.2.0.1.0 - Production

  6. Log messages written to /data1/u01/app/oracle/diag/tnslsnr/Oracle-02/listener/alert/log.xml

  7. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Oracle-02)(PORT=1521)))


  8. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

  9. STATUS of the LISTENER

  10. ------------------------

  11. Alias LISTENER

  12. Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production

  13. Start Date 14-NOV-2019 14:46:48

  14. Uptime 0 days 0 hr. 0 min. 1 sec

  15. Trace Level off

  16. Security ON: Local OS Authentication

  17. SNMP OFF

  18. Listener Log File /data1/u01/app/oracle/diag/tnslsnr/Oracle-02/listener/alert/log.xml

  19. Listening Endpoints Summary...

  20. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Oracle-02)(PORT=1521)))

  21. The listener supports no services

  22. The command completed successfully

lsnrctl status:

  1. lsnrctl status


  2. LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 14-NOV-2019 14:48:53

  3. Copyright (c) 1991, 2016, Oracle. All rights reserved.

  4. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

  5. STATUS of the LISTENER

  6. ------------------------

  7. Alias LISTENER

  8. Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production

  9. Start Date 14-NOV-2019 14:46:48

  10. Uptime 0 days 0 hr. 2 min. 6 sec

  11. Trace Level off

  12. Security ON: Local OS Authentication

  13. SNMP OFF

  14. Listener Log File /data1/u01/app/oracle/diag/tnslsnr/Oracle-02/listener/alert/log.xml

  15. Listening Endpoints Summary...

  16. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Oracle-02)(PORT=1521)))

  17. Services Summary...

  18. Service "973d59cd17000978e05326847a0a1556" has 1 instance(s).

  19. Instance "cdb1", status READY, has 1 handler(s) for this service...

  20. Service "cdb1" has 1 instance(s).

  21. Instance "cdb1", status READY, has 1 handler(s) for this service...

  22. Service "cdb1XDB" has 1 instance(s).

  23. Instance "cdb1", status READY, has 1 handler(s) for this service...

  24. Service "pdb1" has 1 instance(s).

  25. Instance "cdb1", status READY, has 1 handler(s) for this service...

  26. The command completed successfully

7.2 OMF建库

OMF全称“Oracle managed file”。(略)

7.3 web方式建库

(略)

8.问题处理

8.1 问题1 : Users With Same UID:.

现象:Users With Same UID: 0: This test checks that multiple users do not exist with user id as "0".

  1. $./runInstaller -force -silent -noconfig -responseFile /home/oracle/oracle12g/database/db_install.rsp


  2. $tail -f xx.log

  3. INFO: Using default Validator configured in the Action class oracle.install.ivw.db.action.PrereqAction

  4. INFO: ------------------List of failed Tasks------------------

  5. INFO: *********************************************

  6. INFO: Swap Size: This is a prerequisite condition to test whether sufficient total swap space is available on the system.

  7. INFO: Severity:IGNORABLE

  8. INFO: OverallStatus:VERIFICATION_FAILED

  9. INFO: *********************************************

  10. INFO: Users With Same UID: 0: This test checks that multiple users do not exist with user id as "0".

  11. INFO: Severity:CRITICAL

  12. INFO: OverallStatus:VERIFICATION_FAILED

  13. INFO: -----------------End of failed Tasks List----------------

  14. INFO: Adding ExitStatus PREREQUISITES_NOT_MET to the exit status set

  15. SEVERE: [FATAL] [INS-13013] Target environment does not meet some mandatory requirements.

原因:有相同的UID 0。0:超级用户 UID,1-500为系统用户,>500为普通用户。解决:修改冲突的UID。发现果然有冲突如下,把冲突的leadmin uid,gid改为非0。

  1. cat /etc/passwd|grep 'x:0:0:'

  2. root:x:0:0:root:/root:/bin/bash

  3. leadmin:x:0:0:lele:/home/lele:/bin/bash

8.2 问题2 oraInventory/ is being used as a source by another session

https://blog.dbi-services.com/severeoui-10020the-target-area-u01apporacleorainventory-is-being-used-as-a-source-by-another-session/http://blog.itpub.net/17252115/viewspace-1378059/

现象:

  1. 出错信息:

  2. oraInventory/ is being used as a source by another session

原因:原因较多种各不同如下。作者遇到的是因为目录为/data1/u01/app并ln 到/u01。就以为可以直接写软链路径/u01/app/oraInventory做为INVENTORYLOCATION,结果出错如提示(正确该写INVENTORYLOCATION=/data1/u01/app/oraInventory)。

  • INVENTORY_LOCATION=/u01/app/oracle/oraInventory 写成/u01/app/oracle/oraInventory/ 多写'/'号。

  • Specific software is holding a lock on the OraInventory file.

  • Someone else is running an Oracle installation at the same time from the same Oracle_home

  • INVENTORY_LOCATION使用软链目录地址,不是绝对路径。

解决:依出错可能分别相应解决。

8.3 ORA-00821: Specified value of sga_target xx M is too small

现象:dbca -silent -createDatabase时提示sgatarget is too small。出错ORA-00821: Specified value of sgatarget 1152M is too small, needs to be at least 1936M

  1. $dbca -silent -createDatabase xxx

  2. -automaticMemoryManagement false \

  3. -totalMemory 1536 \

  4. ...

  5. Copying database files

  6. 1% complete

  7. 2% complete

  8. DBCA Operation failed.

  9. Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb1/cdb1.log" for further details.

原因:查看日志可以看到是内存分配太小的原因。

  1. #查看日志

  2. tail /u01/app/oracle/cfgtoollogs/dbca/cdb1/cdb1.log

  3. [ 2019-11-13 18:40:51.621 CST ] Copying database files

  4. DBCA_PROGRESS : 1%

  5. [ 2019-11-13 18:40:52.812 CST ] ORA-00821: Specified value of sga_target 1152M is too small, needs to be at least 1936M

解决:在dbca时直接指定较大的totalMemory,或者修改$ORACLEHOME/dbs/init.ora中memorytarget=1G配置。

  1. #ORACLE_HOME/dbs/init.ora

  2. cp $ORACLE_HOME/dbs/init.ora $ORACLE_HOME/dbs//init.ora.org

  3. vim $ORACLE_HOME/dbs/init.ora

参考:

  • https://docs.oracle.com/en/database/oracle/oracle-database/12.2/install-and-upgrade.html

  • https://oracle-base.com/articles/misc/oui-silent-installations

  • https://docs.oracle.com/cd/E2685401/em.121/e37799/ch1introduction.htm#OUICG107

  • https://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/odbquickstart/odbquick_start.html

  • Linux命令行安装Oracle12c https://blog.csdn.net/sl1992/article/details/80457935

  • 静默安装 oracle 11gr2 杨奇龙 http://blog.itpub.net/22664653/viewspace-1062585/

  • oracle dir 说明: https://blog.csdn.net/m0_37814112/article/details/77373863


最后修改时间:2019-12-17 12:28:26
文章转载自陶老师运维笔记,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论