在Oracle Linux 7U5上安装Oracle Database 12.2.0.1

环境准备

硬件准备

在VirtualBox上安装一台OL7u5的虚机,8G内存,一个vCPU,一块网卡(NAT,以便从公网下载包)。我是从现成的模板导入的。

# cat /etc/oracle-release 
Oracle Linux Server release 7.5
# free -m
              total        used        free      shared  buff/cache   available
Mem:           7724        1003        3537          11        3183        6536
Swap:          3967           0        3967
# cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 142
model name	: Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz
stepping	: 9
cpu MHz		: 2729.703
cache size	: 3072 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 22
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq monitor ssse3 cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase avx2 invpcid rdseed clflushopt
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass
bogomips	: 5424.00
clflush size	: 64
cache_alignment	: 64
address sizes	: 39 bits physical, 48 bits virtual
power management:

# ip link show
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3:  mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:e3:07:bf brd ff:ff:ff:ff:ff:ff
3: virbr0:  mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default 
    link/ether 52:54:00:f5:57:be brd ff:ff:ff:ff:ff:ff
4: virbr0-nic:  mtu 1500 qdisc pfifo_fast master virbr0 state DOWN mode DEFAULT group default qlen 500
    link/ether 52:54:00:f5:57:be brd ff:ff:ff:ff:ff:ff

# ip address show enp0s3
2: enp0s3:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:e3:07:bf brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute dynamic enp0s3
       valid_lft 84804sec preferred_lft 84804sec
    inet6 fe80::a00:27ff:fee3:7bf/64 scope link 
       valid_lft forever preferred_lft forever

安装前剩余空间大于20G:

# df -h /
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/ol-root   36G  9.3G   26G  27% /

软件准备

从OTN或E-Delivery下载。
版本为12.2.0.1,分为两个zip文件,分别用于数据库安装和Grid Infrastructure安装。
将安装介质所在目录共享到虚机,然后解压,解压后大约3.6G:

# cd /mnt
# ll
total 6297252
-rwxrwxrwx. 1 root root 3453696911 Feb 14  2017 linuxx64_12201_database.zip
-rwxrwxrwx. 1 root root 2994687209 Feb 14  2017 linuxx64_12201_grid_home.zip
# unzip linuxx64_12201_database.zip 
# ls
database  linuxx64_12201_database.zip  linuxx64_12201_grid_home.zip
# du -sh database
3.6G	database

在解压的文件中,oraparams.ini定义了一些安装的先决条件:

# find . -name oraparam.ini
./install/oraparam.ini
# cat ./install/oraparam.ini
[Oracle]
DISTRIBUTION=TRUE
SOURCE=../stage/products.xml
LICENSE_LOCATION=
BOOTSTRAP_COMPS="oracle.swd.oui:12.2.0.1.4,oracle.swd.oui.core:12.2.0.1.4,oracle.swd.oui.core.min:12.2.0.1.4,oracle.jdk:1.8.0.91.0" 
JRE_SCRATCH_LOC=jdk/jre
JRE_MEMORY_OPTIONS=" -Xms150m -Xmx2048m -XX:-OmitStackTraceInFastThrow -XX:CompileCommand=quiet -XX:CompileCommand=exclude,javax/swing/text/GlyphView,getBreakSpot "
DEFAULT_HOME_LOCATION=product/12.2.0/dbhome
。。。

主机与网络设置

设置主机名为ol7-122

# echo "ol7-122.localdomain" > /etc/hostname
# hostname $(cat /etc/hostname)
# hostname
ol7-122.localdomain

禁用防火墙:

# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2018-09-26 07:32:12 EDT; 55min ago
     Docs: man:firewalld(1)
 Main PID: 791 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─791 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Sep 26 07:32:03 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Sep 26 07:32:12 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

禁用selinux:

# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      29
# 编辑/etc/selinux/config文件,将SELINUX的值改为permissive
# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 

selinux修改后需要重启,重启后确认各项改变生效:

# systemctl reboot
# 等待启动完成
# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          permissive
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      29

# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

# hostname
ol7-122.localdomain

安装先决条件包

此包会自动建立oracle用户,及调整内核参数。在执行前,请确保没有oracle用户,如果有,则删除:

# userdel -r oracle
# id oracle
id: oracle: no such user

# yum install oracle-database-server-12cR2-preinstall -y
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package oracle-database-server-12cR2-preinstall.x86_64 0:1.0-3.el7 will be installed
--> Processing Dependency: compat-libcap1 for package: oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64
--> Processing Dependency: ksh for package: oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64
--> Processing Dependency: libaio-devel for package: oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64
--> Processing Dependency: compat-libstdc++-33 for package: oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64
--> Processing Dependency: libstdc++-devel for package: oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64
--> Running transaction check
---> Package compat-libcap1.x86_64 0:1.10-7.el7 will be installed
---> Package compat-libstdc++-33.x86_64 0:3.2.3-72.el7 will be installed
---> Package ksh.x86_64 0:20120801-137.0.1.el7 will be installed
---> Package libaio-devel.x86_64 0:0.3.109-13.el7 will be installed
---> Package libstdc++-devel.x86_64 0:4.8.5-28.0.1.el7_5.1 will be installed
--> Processing Dependency: libstdc++(x86-64) = 4.8.5-28.0.1.el7_5.1 for package: libstdc++-devel-4.8.5-28.0.1.el7_5.1.x86_64
--> Running transaction check
---> Package libstdc++.x86_64 0:4.8.5-28.0.1.el7 will be updated
---> Package libstdc++.x86_64 0:4.8.5-28.0.1.el7_5.1 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================================================================================
 Package                                                                Arch                                  Version                                              Repository                                 Size
===================================================================================================================================================================================================================
Installing:
 oracle-database-server-12cR2-preinstall                                x86_64                                1.0-3.el7                                            ol7_latest                                 19 k
Installing for dependencies:
 compat-libcap1                                                         x86_64                                1.10-7.el7                                           ol7_latest                                 17 k
 compat-libstdc++-33                                                    x86_64                                3.2.3-72.el7                                         ol7_latest                                190 k
 ksh                                                                    x86_64                                20120801-137.0.1.el7                                 ol7_latest                                881 k
 libaio-devel                                                           x86_64                                0.3.109-13.el7                                       ol7_latest                                 12 k
 libstdc++-devel                                                        x86_64                                4.8.5-28.0.1.el7_5.1                                 ol7_latest                                1.5 M
Updating for dependencies:
 libstdc++                                                              x86_64                                4.8.5-28.0.1.el7_5.1                                 ol7_latest                                303 k

Transaction Summary
===================================================================================================================================================================================================================
Install  1 Package  (+5 Dependent packages)
Upgrade             ( 1 Dependent package)

Total size: 2.9 M
Total download size: 2.6 M
Downloading packages:
(1/6): compat-libcap1-1.10-7.el7.x86_64.rpm                                                                                                                                                 |  17 kB  00:00:00     
(2/6): compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm                                                                                                                                          | 190 kB  00:00:00     
(3/6): libaio-devel-0.3.109-13.el7.x86_64.rpm                                                                                                                                               |  12 kB  00:00:00     
(4/6): ksh-20120801-137.0.1.el7.x86_64.rpm                                                                                                                                                  | 881 kB  00:00:00     
(5/6): oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64.rpm                                                                                                                         |  19 kB  00:00:00     
(6/6): libstdc++-devel-4.8.5-28.0.1.el7_5.1.x86_64.rpm                                                                                                                                      | 1.5 MB  00:00:00     
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                              2.3 MB/s | 2.6 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Updating   : libstdc++-4.8.5-28.0.1.el7_5.1.x86_64                                                                                                                                                           1/8 
  Installing : libstdc++-devel-4.8.5-28.0.1.el7_5.1.x86_64                                                                                                                                                     2/8 
  Installing : ksh-20120801-137.0.1.el7.x86_64                                                                                                                                                                 3/8 
  Installing : libaio-devel-0.3.109-13.el7.x86_64                                                                                                                                                              4/8 
  Installing : compat-libcap1-1.10-7.el7.x86_64                                                                                                                                                                5/8 
  Installing : compat-libstdc++-33-3.2.3-72.el7.x86_64                                                                                                                                                         6/8 
  Installing : oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64                                                                                                                                        7/8 
  Cleanup    : libstdc++-4.8.5-28.0.1.el7.x86_64                                                                                                                                                               8/8 
  Verifying  : libstdc++-4.8.5-28.0.1.el7_5.1.x86_64                                                                                                                                                           1/8 
  Verifying  : libstdc++-devel-4.8.5-28.0.1.el7_5.1.x86_64                                                                                                                                                     2/8 
  Verifying  : compat-libstdc++-33-3.2.3-72.el7.x86_64                                                                                                                                                         3/8 
  Verifying  : compat-libcap1-1.10-7.el7.x86_64                                                                                                                                                                4/8 
  Verifying  : libaio-devel-0.3.109-13.el7.x86_64                                                                                                                                                              5/8 
  Verifying  : oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64                                                                                                                                        6/8 
  Verifying  : ksh-20120801-137.0.1.el7.x86_64                                                                                                                                                                 7/8 
  Verifying  : libstdc++-4.8.5-28.0.1.el7.x86_64                                                                                                                                                               8/8 

Installed:
  oracle-database-server-12cR2-preinstall.x86_64 0:1.0-3.el7                                                                                                                                                       

Dependency Installed:
  compat-libcap1.x86_64 0:1.10-7.el7    compat-libstdc++-33.x86_64 0:3.2.3-72.el7    ksh.x86_64 0:20120801-137.0.1.el7    libaio-devel.x86_64 0:0.3.109-13.el7    libstdc++-devel.x86_64 0:4.8.5-28.0.1.el7_5.1   

Dependency Updated:
  libstdc++.x86_64 0:4.8.5-28.0.1.el7_5.1                                                                                                                                                                          

Complete!

先决条件包安装完毕后,oracle用户及相关组已建立:

# id oracle
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)

安装数据库软件用户,此处为oracle,必须属于oinstall和dba组,其中oinstall必须是主组。

创建安装目录

此处的/u01/app/oracle其实就是ORACLE_BASE:

mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01
chmod -R 775 /u01

按照Optimal Flexible Architecture (OFA)建议的目录结构,ORACLE_HOME应为:
/u01/app/oracle/product/12.2.0/dbhome_1

安装数据库软件

安装使用OUI(Oracle Universal Installer)。OUI不允许用root运行,否则报错:

# ./runInstaller 
The user is root. Oracle Universal Installer cannot continue installation if the user is root.

使用oracle用户启动OUI:

# su - oracle
Last login: Wed Sep 26 09:10:32 EDT 2018 on pts/1
$ echo $DISPLAY

$ export DISPLAY=:0.0
$ cd /mnt/database
$ ./runInstaller 
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 500 MB.   Actual 27294 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 3967 MB    Passed
Checking monitor: must be configured to display at least 256 colors.    Actual 16777216    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-09-26_09-18-27AM. Please wait ...

进入图形界面:

  1. Configure Security Updates
    在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第1张图片
  2. Select Install Option
    在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第2张图片
  3. Select Database Installation Option
    在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第3张图片
  4. Select Database Edition
    在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第4张图片
  5. Specify Installation Location
    在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第5张图片
  6. Create Inventory
    在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第6张图片
  7. Privilege Operating System groups
    在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第7张图片
  8. Perform Prerequisite Checks
    在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第8张图片
  9. Summary
    在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第9张图片
  10. Execute Configuration Scripts
    在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第10张图片
    以root用户执行脚本:
# /u01/app/oraInventory/orainstRoot.sh 
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
# /u01/app/oracle/product/12.2.0/dbhome_1/root.sh
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/12.2.0/dbhome_1

Enter the full pathname of the local bin directory: [/usr/local/bin]: 
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...


Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Do you want to setup Oracle Trace File Analyzer (TFA) now ? yes|[no] : 
yes
Installing Oracle Trace File Analyzer (TFA).
Log File: /u01/app/oracle/product/12.2.0/dbhome_1/install/root_ol7-122.localdomain_2018-09-26_09-41-56-711793085.log
Finished installing Oracle Trace File Analyzer (TFA)

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第11张图片
21:31开始安装,整个过程不超过15分钟。
空间占用约为7.7G,和预估的差不多:

# df -h /
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/ol-root   36G   17G   20G  46% /

验证安装,从oraInsta.loc文件中可查询到Oracle Inventory目录:

# cat /etc/oraInst.loc
inventory_loc=/u01/app/oraInventory
inst_group=oinstall
# ls /u01/app/oraInventory
ContentsXML  logs  oraInst.loc  orainstRoot.sh  oui

由于数据库尚未创建,因此oratab文件暂无条目:

# cat /etc/oratab 
#



# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
#   $ORACLE_SID:$ORACLE_HOME::
#
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third field indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
# 

创建数据库

在~oracle/.bash_profile中设置环境变量:

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH

因为dbca在$ORACLE_HOME/bin目录中,必须将此目录放在PATH的最前面。
然后运行dbca:

$ dbca

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第12张图片

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第13张图片

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第14张图片

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第15张图片

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第16张图片
整个过程约20分钟。
此时在oratab中有条目了:

$ tail -1 /etc/oratab
orcl:/u01/app/oracle/product/12.2.0/dbhome_1:N

验证可以登录数据库:

$ export ORACLE_SID=orcl
$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed Sep 26 11:09:05 2018

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> 

查看空间,发现数据库占用空间在3-4G之间:

$ df -h /
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/ol-root   36G   20G   16G  57% /

使用dbca将数据库删除,然后使用高级模式重新创建数据库:
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第17张图片

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第18张图片

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第19张图片

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第20张图片

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第21张图片
以下开始高级方式的安装。
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第22张图片
选择Advanced configuration:
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第23张图片
Deployment Type:
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第24张图片
Database Identification:
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第25张图片
Storage Option:
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第26张图片
Fast Recovery Option:
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第27张图片
Network Configuration:
这一步需要注意,如果没有listener,可以立即创建一个,或使用netca创建。如果利用之前创建的listener,则listener必须处于启动状态。
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第28张图片
Data Vault Option:
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第29张图片
Configuration Option(共五部分):
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第30张图片

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第31张图片

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第32张图片

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第33张图片

在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第34张图片
Management Option(EM DB Express):
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第35张图片
User Credentials:
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第36张图片
Creation Option,可以选择仅生成脚本或存为模板:
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第37张图片
Summary:
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第38张图片
Finish:
在Oracle Linux 7U5上安装Oracle Database 12.2.0.1_第39张图片

参考文档

  1. Oracle Database 12c Release 2 (12.2) Installation On Oracle Linux 6 (OL6) and 7 (OL7)
  2. Deploying Oracle Database 12c Release 2 on Red Hat Enterprise Linux 7
  3. Installation Guide for Linux

你可能感兴趣的:(Oracle,数据库)