Centos7安装oracle 12c R1——静默安装

时间:2021-12-25 20:02:20

系统环境:硬件——1cpu,2G内存,虚拟机;软件——CentOS7.5,oracle 12c R1
安装前请阅读另一篇文章:Centos7安装oracle 12c R1——先决条件检查

安装步骤

  1. 配置硬件和软件环境
  2. 修改内核参数
  3. 创建oracle用户和oinstall,dba组
  4. 创建必要的目录
  5. 配置oracle的环境变量
  6. 安装数据库软件

1. 配置硬件和软件环境

硬件环境
[root@orahost ~]# grep MemTotal /proc/meminfo
MemTotal:        1883484 kB
[root@orahost ~]# grep SwapTotal /proc/meminfo
SwapTotal:       2097148 kB
[root@orahost ~]# df -h /tmp/
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   39G  4.6G   34G  12% /
[root@orahost ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   39G  4.6G   34G  12% /
devtmpfs                 905M     0  905M   0% /dev
tmpfs                    920M     0  920M   0% /dev/shm
tmpfs                    920M  9.0M  911M   1% /run
tmpfs                    920M     0  920M   0% /sys/fs/cgroup
/dev/sda1               1014M  268M  747M  27% /boot
/dev/mapper/centos-home   19G  2.6G   17G  14% /home
Documents                734G  258G  477G  36% /media/sf_Documents
tmpfs                    184M  4.0K  184M   1% /run/user/42
tmpfs                    184M   36K  184M   1% /run/user/1000
tmpfs                    184M     0  184M   0% /run/user/0
[root@orahost ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           1.8G        755M         72M        8.2M        1.0G        840M
Swap:          2.0G        7.8M        2.0G
[root@orahost ~]# uname -m
x86_64
[root@orahost ~]# uname -r
3.10.0-693.21.1.el7.x86_64

# 检查jdk为openjdk,卸载并安装jdk1.8
[root@orahost ~]# rpm -qa | grep java
tzdata-java-2018e-3.el7.noarch
java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64
java-1.7.0-openjdk-1.7.0.181-2.6.14.8.el7_5.x86_64
java-1.8.0-openjdk-headless-1.8.0.171-8.b10.el7_5.x86_64
javapackages-tools-3.4.1-11.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.181-2.6.14.8.el7_5.x86_64

[root@orahost ~]# yum remove java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64 java-1.7.0-openjdk-1.7.0.181-2.6.14.8.el7_5.x86_64 java-1.8.0-openjdk-headless-1.8.0.171-8.b10.el7_5.x86_64 java-1.7.0-openjdk-headless-1.7.0.181-2.6.14.8.el7_5.x86_64
[root@orahost ~]# rpm -qa | grep java
tzdata-java-2018e-3.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
# openjdk已卸载
# 安装jdk1.8
[root@orahost ~]# wget http://xxxxxx下载jdk的rpm包
[...]
[root@orahost ~]# ls
jdk-8u172-linux-x64.rpm
[root@orahost ~]# yum localinstall jdk-8u172-linux-x64.rpm
[...]
[root@orahost ~]# java -version
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
# jdk1.8安装完成
# 检查依赖包并安装依赖包
[root@orahost ~]# rpm -q \
binutils.x86_64 \
compat-libcap1.x86_64 \
compat-libstdc++-33.i686 \
compat-libstdc++-33.x86_64 \
gcc.x86_64 \
gcc-c++.x86_64 \
glibc.i686 \
glibc.x86_64 \
glibc-devel.i686 \
glibc-devel.x86_64 \
ksh \
libaio.i686 \
libaio.x86_64 \
libaio-devel.i686 \
libaio-devel.x86_64 \
libgcc.i686 \
libgcc.x86_64 \
libstdc++.i686 \
libstdc++.x86_64 \
libstdc++-devel.i686 \
libstdc++-devel.x86_64 \
libXi.i686 \
libXi.x86_64 \
libXtst.i686 \
libXtst.x86_64 \
make.x86_64 \
sysstat.x86_64
# 输出结果
binutils-2.27-27.base.el7.x86_64
compat-libcap1-1.10-7.el7.x86_64
compat-libstdc++-33-3.2.3-72.el7.i686
compat-libstdc++-33-3.2.3-72.el7.x86_64
gcc-4.8.5-28.el7_5.1.x86_64
gcc-c++-4.8.5-28.el7_5.1.x86_64
glibc-2.17-222.el7.i686
glibc-2.17-222.el7.x86_64
glibc-devel-2.17-222.el7.i686
glibc-devel-2.17-222.el7.x86_64
ksh-20120801-137.el7.x86_64
libaio-0.3.109-13.el7.i686
libaio-0.3.109-13.el7.x86_64
libaio-devel-0.3.109-13.el7.i686
libaio-devel-0.3.109-13.el7.x86_64
libgcc-4.8.5-28.el7_5.1.i686
libgcc-4.8.5-28.el7_5.1.x86_64
libstdc++-4.8.5-28.el7_5.1.i686
libstdc++-4.8.5-28.el7_5.1.x86_64
libstdc++-devel-4.8.5-28.el7_5.1.i686
libstdc++-devel-4.8.5-28.el7_5.1.x86_64
libXi-1.7.9-1.el7.i686
libXi-1.7.9-1.el7.x86_64
libXtst-1.2.3-1.el7.i686
libXtst-1.2.3-1.el7.x86_64
make-3.82-23.el7.x86_64
sysstat-10.1.5-13.el7.x86_64
[依赖包全部都安装了!!!]

2. 修改内核参数

[root@orahost ~]# vi /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

[root@orahost ~]# sysctl -p
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

3.创建oracle用户和oinstall,dba组

[root@orahost ~]# groupadd oinstall
[root@orahost ~]# groupadd dba
[root@orahost ~]# groupadd oper
[root@orahost ~]# cat /etc/group
root:x:0:
leo:x:1000:
vboxsf:x:984:leo
[...]
oinstall:x:1001:
dba:x:1002:
oper:x:1003:
[root@orahost ~]# useradd -g oinstall -G dba,oper oracle
[root@orahost ~]# passwd oracle #给oracle用户设置密码
Changing password for user oracle.
New password:
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@orahost ~]# cat /etc/group
root:x:0:
leo:x:1000:
vboxsf:x:984:leo
[...]
oinstall:x:1001:
dba:x:1002:oracle
oper:x:1003:oracle

4.创建必要的目录

[root@orahost ~]# mkdir -p /u01/app/
[root@orahost ~]# chown -R oracle:oinstall /u01/app/
[root@orahost ~]# chmod -R 775 /u01/app/

5. 配置oracle的环境变量

# oracle用户登录
[oracle@orahost ~]$ vi .bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.1.0/dbhome_1
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ADR_HOME=$ORACLE_BASE/diag/rdbms/...
export ORACLE_SID=orcl
export LD_LIBRARY_PATH=/usr/lib:$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH:$TNS_ADMIN
[oracle@orahost ~]$ source .bash_profile

6. 安装数据库软件

# 配置db_install.rsp
[oracle@orahost ~]$ vi db.rsp
    oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.1.0
    oracle.install.option=INSTALL_DB_SWONLY
    ORACLE_HOSTNAME=orahost
    UNIX_GROUP_NAME=oinstall
    INVENTORY_LOCATION=/u01/app/oraInventory
    SELECTED_LANGUAGES=en,zh_CN
    ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
    ORACLE_BASE=/u01/app/oracle
    oracle.install.db.InstallEdition=EE
    oracle.install.db.DBA_GROUP=dba
    oracle.install.db.OPER_GROUP=oper
    oracle.install.db.BACKUPDBA_GROUP=dba
    oracle.install.db.DGDBA_GROUP=dba
    oracle.install.db.KMDBA_GROUP=dba

[oracle@orahost database]$ ./runInstaller -silent -responseFile /home/oracle/db.rsp 
正在启动 Oracle Universal Installer...

检查临时空间: 必须大于 500 MB。   实际为 33437 MB    通过
检查交换空间: 必须大于 150 MB。   实际为 1535 MB    通过
准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2018-06-07_09-39-07PM. 请稍候...
[oracle@orahost database]$ 可以在以下位置找到本次安装会话的日志:
 /u01/app/oraInventory/logs/installActions2018-06-07_09-39-07PM.log
Oracle Database 12c 的 安装 已成功。
请查看 '/u01/app/oraInventory/logs/silentInstall2018-06-07_09-39-07PM.log' 以获取详细资料。

以 root 用户的身份执行以下脚本:
    1. /u01/app/oraInventory/orainstRoot.sh
    2. /u01/app/oracle/product/12.1.0/dbhome_1/root.sh
Successfully Setup Software.

[root@orahost oracle]# /u01/app/oraInventory/orainstRoot.sh 
更改权限/u01/app/oraInventory.
添加组的读取和写入权限。
删除全局的读取, 写入和执行权限。

更改组名/u01/app/oraInventory 到 oinstall.
脚本的执行已完成。
[root@orahost oracle]# /u01/app/oracle/product/12.1.0/dbhome_1/root.sh 
Check /u01/app/oracle/product/12.1.0/dbhome_1/install/root_orahost_2018-06-07_21-50-59.log for the output of root script

[oracle@orahost database]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Thu Jun 7 21:52:24 2018

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> show user;
USER is "SYS"

至此,oracle数据库软件安装成功