CentOS 7.2 Oracle 12C R2安装部署

  • 一、环境检查
  • 1、操作系统检查
  • 2、内存检查
  • 3、SWAP检查
  • 4、共享内存检查
  • 5、磁盘空间检查
  • 二、YUM配置及RPM依赖包安装
  • 1、 本地YUM源搭建
  • 2、 RPM依赖包安装
  • 三、创建组、用户、目录
  • 1、创建组、用户
  • 2、创建目录
  • 四、系统参数配置
  • 1、关闭防火墙
  • 2、配置/etc/hosts文件
  • 3、关闭SELINUX
  • 4、配置内核参数
  • 5、配置/etc/security/limits.conf
  • 6、配置/etc/pam.d/login
  • 7、配置/etc/profile
  • 8、配置ORACLE用户的环境变量
  • 五、ORACLE 12C R2安装部署
  • 1、上传安装介质
  • 2、解压安装介质
  • 3、软件安装
  • 4、创建监听
  • 5、创建数据库
  • 6、启停命令
  • 7、启动顺序



本文描述了在CENTOS 7.2操作系统环境上使用图形化安装部署ORACLE 12C R2 12.2.0.1.0版本单实例数据库。


注:本文中,#开头命令表示在root用户下执行,$开头命令表示在oracle用户下执行。

一、环境检查

1、操作系统检查

ORACLE 12C R2的部署安装对系统及内核版本有一定的要求,对于Red Hat Enterprise Linux 6.4: 2.6.32-358.el6.x86_64 或更高的版本。

官网系统版本要求:
The following Linux x86-64 kernels are supported:
Oracle Linux 7 with the Unbreakable Enterprise Kernel 3: 3.8.13-35.3.1.el7uek.x86_64 or later
Oracle Linux 7.2 with the Unbreakable Enterprise Kernel 4: 4.1.12-32.2.3.el7uek.x86_64 or later
Oracle Linux 7 with the Red Hat Compatible kernel: 3.10.0-123.el7.x86_64 or later
Red Hat Enterprise Linux 7: 3.10.0-123.el7.x86_64 or later
Oracle Linux 6.4 with the Unbreakable Enterprise Kernel 2: 2.6.39-400.211.1.el6uek.x86_64or later
Oracle Linux 6.6 with the Unbreakable Enterprise Kernel 3: 3.8.13-44.1.1.el6uek.x86_64 or later
Oracle Linux 6.8 with the Unbreakable Enterprise Kernel 4: 4.1.12-37.6.2.el6uek.x86_64 or later
Oracle Linux 6.4 with the Red Hat Compatible kernel: 2.6.32-358.el6.x86_64 or later
Red Hat Enterprise Linux 6.4: 2.6.32-358.el6.x86_64 or later
SUSE Linux Enterprise Server 12 SP1: 3.12.49-11.1 or later
Review the system requirements section for a list of minimum package requirements.

[root@ORACLE12 ~]#  cat /etc/redhat-release

centos7 安装extundelete 安装centos7.2_bc

[root@ORACLE12 ~]# uname -r

centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_02

2、内存检查

ORACLE公司给出ORACLE 12C R2的单实例的最小安装内存是1G,推荐最小内存是2G,集群最小内存8G。

官网推荐RAM:
Minimum RAM :At least 1 GB RAM for Oracle Database installations. 2 GB RAM recommended
At least 8 GB RAM for Oracle Grid Infrastructure installations

检查内存语句:

[root@ORACLE12C ~]# grep MemTotal /proc/meminfo

centos7 安装extundelete 安装centos7.2_Enterprise_03

3、SWAP检查

合理的设置SWAP空间能够有效的提高Oracle性能,ORACLE公司给出的SWAP的设置与RAM有这如下关系如下:
RAM 1GB~2GB,SWAP 大小为1.5RAM
RAM 2GB~16GB,SWAP 大小为与RAM大小一致
RAM 大于16GB,SWAP 大小为16GB

官网推荐SWAP设置:
Between 1 GB and 2 GB: 1.5 times the size of the RAM
Between 2 GB and 16 GB: Equal to the size of the RAM
More than 16 GB: 16 GB
Note: If you enable HugePages for your Linux servers, then you should deduct the memory allocated to HugePages from the available RAM before calculating swap space.

通过下面命令查看SWAP大小,如果不满足需进行调整。

[root@ORACLE12C ~]# grep SwapTotal /proc/meminfo

centos7 安装extundelete 安装centos7.2_ORACLE 12C R2_04

4、共享内存检查

为了保证数据库运行稳定,要对操作系统进行共享内存的设置,设置大小一般是RAM内存的80%。

官网推荐设置共享内存:
Check Shared Memory File System Mount:
By default, your operating system includes an entry in /etc/fstab to mount /dev/shm. However, if your Cluster Verification Utility (CVU) or Oracle Universal Installer (OUI) checks fail, ensure that the /dev/shm mount area is of type tmpfs and is mounted with the following options:
rw and exec permissions set on it
Without noexec or nosuid set on it

用df -h /dev/shm命令查看,不满足进行调整。

[root@ORACLE12C ~]# df -h /dev/shm

centos7 安装extundelete 安装centos7.2_Enterprise_05

共享内存调整步骤:
a、卸载“/dev/shm”

[root@ORACLE12C ~]# umount /dev/shm

centos7 安装extundelete 安装centos7.2_bc_06

如果资源忙,用fuser -m -v /dev/shm/查看使用进程,然后kill在用进程

[root@ORACLE12C ~]# fuser -m -v /dev/shm/
[root@ORACLE12C ~]# kill -9 1876

centos7 安装extundelete 安装centos7.2_oracle_07

b、调整“/dev/shm”

[root@ORACLE12C ~]# mount -t tmpfs shmfs -o size=6g /dev/shm

centos7 安装extundelete 安装centos7.2_oracle_08

c、修改文件“/etc/fstab”

[root@ORACLE12C ~]# vi /etc/fstab

centos7 安装extundelete 安装centos7.2_oracle_09

5、磁盘空间检查

Oracle安装对磁盘空间有一定的要求,磁盘空间至少要达到Oracle的最低要求才能顺利的完成Oracle的安装,磁盘最少空间要求如下:
Oracle Grid Infrastructure 磁盘要求:8.6G
Enterprise Edition磁盘要求:7.5G
Standard Edition磁盘要求:7.5G
查看语句df -h

[root@ORACLE12C ~]# df –h

centos7 安装extundelete 安装centos7.2_ORACLE 12C R2_10

官网存储要求:
Minimum local disk storage space for Oracle software:
For Linux x86-64:
At least 8.6 GB for an Oracle Grid Infrastructure for a standalone server installation.
At least 7.5 GB for Oracle Database Enterprise Edition.
At least 7.5 GB for Oracle Database Standard Edition 2.

二、YUM配置及RPM依赖包安装

1、 本地YUM源搭建

参考

2、 RPM依赖包安装

ORACLE 12C R2在Red Hat Enterprise Linux 7上的RPM依赖包如下:
binutils-2.23.52.0.1-12.el7 (x86_64)
compat-libcap1-1.10-3.el7 (x86_64)
compat-libstdc+±33-3.2.3-71.el7 (i686)
compat-libstdc+±33-3.2.3-71.el7 (x86_64)
glibc-2.17-36.el7 (i686)
glibc-2.17-36.el7 (x86_64)
glibc-devel-2.17-36.el7 (i686)
glibc-devel-2.17-36.el7 (x86_64)
ksh
libaio-0.3.109-9.el7 (i686)
libaio-0.3.109-9.el7 (x86_64)
libaio-devel-0.3.109-9.el7 (i686)
libaio-devel-0.3.109-9.el7 (x86_64)
libgcc-4.8.2-3.el7 (i686)
libgcc-4.8.2-3.el7 (x86_64)
libstdc+±4.8.2-3.el7 (i686)
libstdc+±4.8.2-3.el7 (x86_64)
libstdc+±devel-4.8.2-3.el7 (i686)
libstdc+±devel-4.8.2-3.el7 (x86_64)
libxcb-1.9-5.el7 (i686)
libxcb-1.9-5.el7 (x86_64)
libX11-1.6.0-2.1.el7 (i686)
libX11-1.6.0-2.1.el7 (x86_64)
libXau-1.0.8-2.1.el7 (i686)
libXau-1.0.8-2.1.el7 (x86_64)
libXi-1.7.2-1.el7 (i686)
libXi-1.7.2-1.el7 (x86_64)
libXtst-1.2.2-1.el7 (i686)
libXtst-1.2.2-1.el7 (x86_64)
make-3.82-19.el7 (x86_64)
net-tools-2.0-0.17.20131004git.el7 (x86_64) (for Oracle RAC and Oracle Clusterware)
nfs-utils-1.3.0-0.21.el7.x86_64 (for Oracle ACFS)
smartmontools-6.2-4.el7 (x86_64)
sysstat-10.1.5-1.el7 (x86_64)

通过上面搭建的YUM进行rpm依赖包安装,如下:

[root@ORACLE12C yum.repos.d]# yum install -y  binutils.x86_64

yum install -y binutils.x86_64
yum install -y compat-libcap1.x86_64
yum install -y compat-libstdc+±33.i686 compat-libstdc+±33.x86_64
yum install -y glibc.i686 glibc.x86_64
yum install -y glibc-devel.i686 glibc-devel.x86_64
yum install -y ksh
yum install -y libaio.i686 libaio.x86_64
yum install -y libaio-devel.i686 libaio-devel.x86_64
yum install -y libgcc.i686 libgcc.x86_64
yum install -y libstdc++.i686 libstdc++.x86_64
yum install -y libstdc+±devel.i686 libstdc+±devel.x86_64
yum install -y libxcb.i686 libxcb.x86_64
yum install -y libX11.i686 libX11.x86_64
yum install -y libXau.i686 libXau.x86_64
yum install -y libXi.i686 libXi.x86_64
yum install -y libXtst.i686 libXtst.x86_64
yum install -y make.x86_64
yum install -y net-tools.x86_64
yum install -y nfs-utils.x86_64
yum install -y smartmontools.x86_64
yum install -y sysstat.x86_64

三、创建组、用户、目录

1、创建组、用户

groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle
passwd oracle

说明:
groupadd oinstall --创建 oinstall组 安装数据库软件用
groupadd dba --创建 dba组 管理数据库软件用
groupadd oper --创建 oper组 操作数据库软件用–但是基本用不到。因为官方文档要求,所以我们最好还是给他建立上
useradd -g oinstall -G dba,oper oracle -g代表的是主组 -G代表的属组 oracle代表的是建立的用户名
这个命令的意思是 我建立一个oracle用户 让他的主组数据oinstall组 让他数组属于dba oper组

2、创建目录

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

说明
mkdir -p /u01/app/oracle --级联创建/u01/app/oracle目录
mkdir -p /u01/oraInventory --级联创建oraInventory目录 这个目录下放置的是安装oracle所需要的的环境
chown -R oracle.oinstall /u01 --该命令为把/u01这个目录的所属用户和所属组变为oracle用户和oracle用户所在的oinstall组
chown -R oracle:oinstall /u01/app/oracle --该命令为把/u01/app/oracle这个目录所属用户和所属组改成oracle用户和oinstall组
chmod -R 775 /u01/app/oracle --该命令为把/u01/app/oracle这个目录的权限改为所属用户可对可写可执行 所属用户所在组下的所有同组成员皆为可读可写可执行 其他用户对这个目录只有可读和可执行

四、系统参数配置

1、关闭防火墙

[root@ORACLE12C yum.repos.d]# systemctl status firewalld.service

systemctl status firewalld.service–检查防火墙状态

[root@ORACLE12C yum.repos.d]# systemctl stop firewalld.service

systemctl stop firewalld.service–暂时关闭防火墙,下次启动时防火墙仍随系统启动而启动

[root@ORACLE12C yum.repos.d]# systemctl disable firewalld.service

systemctl disable firewalld.service–彻底永久关闭防火墙

centos7 安装extundelete 安装centos7.2_Enterprise_11

2、配置/etc/hosts文件

查看主机名和IP地址

[root@ORACLE12C yum.repos.d]# hostname
[root@ORACLE12C yum.repos.d]# ifconfig

将查询到的主机名 IP地址添加到/etc/hosts文件

[root@ORACLE12C yum.repos.d]# vi /etc/hosts

centos7 安装extundelete 安装centos7.2_ORACLE 12C R2_12

3、关闭SELINUX

将内容SELINUX=enforcing更改为SELINUX=disabled

[root@ORACLE12C yum.repos.d]# vi /etc/selinux/config

centos7 安装extundelete 安装centos7.2_Enterprise_13

4、配置内核参数

将以下内容追加到/etc/sysctl.conf文件结尾。

[root@ORACLE12C yum.repos.d]# vi /etc/sysctl.conf
#oracle
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmmax = 6871947673
#表示最大共享内存大小,一般为物理内存的3/4
kernel.shmall = 1677721
#内存大小*1024*1024*1024/4*1024
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.ip_local_port_range = 9000 65500
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 1
#net.core.somaxconn = 262144
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 6
net.ipv4.tcp_keepalive_intvl = 5
net.ipv4.tcp_timestamps = 0
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2

参数说明:
fs.file-max //文件句柄数 一次可以打开文件的个数
fs.aio-max-nr //异步IO请求数目 推荐值是:1048576 其实它等于 10241024 也就是 1024K 个
kernel.shmall //公式:内存大小
102410241024/4*1024 //表示所有内存大小(单位:页=4K)
kernel.shmmax //表示最大共享内存大小,一般为物理内存的3/4 但是常用的就是将所有内存换算成字节后-1(单位:字节)
kernel.shmmni = 4096 //表示最小共享内存固定4096KB 一般是固定值
kernel.sem //4个参数依次是SEMMSL:每个用户拥有信号量最大数,SEMMNS:系统信号量最大数,SEMOPM:每次semopm系统调用操作数,SEMMNI:系统辛苦量集数最大数。这4个参数为固定内容大小
net.ipv4.ip_local_port_range = 9000 65500 //ip_local_port_range表示端口的范围,为指定的内容 一般是固定值
net.core.rmem_default //表示套接字接收缓冲区大小的缺省值
net.core.rmem_max //表示套接字接收缓冲区大小的最大值。
net.core.wmem_default //表示套接字发送缓冲区大小的缺省值。
net.core.wmem_max //表示套接字发送缓冲区大小的最大值。
参数编辑完成后执行下面的命令

sysctl -p 系统参数生效

5、配置/etc/security/limits.conf

将以下内容追加到/etc/security/limits.conf文件结尾。

[root@ORACLE12C yum.repos.d]# vi /etc/security/limits.conf
#oracle
oracle   soft   nofile    1024
oracle   hard   nofile    65536
oracle   soft   nproc    16384
oracle   hard   nproc    16384
oracle   soft   stack    10240
oracle   hard   stack    32768
oracle   hard   memlock    134217728
oracle   soft   memlock    134217728

6、配置/etc/pam.d/login

将以下内容追加到/etc/pam.d/login文件结尾。

[root@ORACLE12C yum.repos.d]# vi /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so

7、配置/etc/profile

将以下内容追加到/etc/profile文件结尾。

[root@ORACLE12C yum.repos.d]# vi /etc/profile
if [ $USER = "oracle" ]; then
   if [ $SHELL = "/bin/ksh" ]; then
      ulimit -p 16384
      ulimit -n 65536
   else
      ulimit -u 16384 -n 65536
   fi
fi

生产参数

[root@ORACLE12C yum.repos.d]# source /etc/profile

8、配置ORACLE用户的环境变量

将以下内容追加到/home/oracle/.bash_profile文件结尾。

[oracle@ORACLE12C ~]$ vi /home/oracle/.bash_profile
#oracle
export EDITOR=vi
export TMP=/tmp  
export TMPDIR=$TMP
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
export INVENTORY_LOCATION=/u01/oraInventory
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export NLS_LANG="Simplified Chinese_China.UTF8"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:$PATH:$HOME/bin
umask 022

生产参数

[oracle@ORACLE12C ~]$ source /home/oracle/.bash_profile

参数说明
export EDITOR=vi 默认的编辑器是vi
export TMP=/tmp ORACLE默认的临时目录是/tmp
export TMPDIR=centos7 安装extundelete 安装centos7.2_ORACLE 12C R2_14ORACLE_BASE/product/12.2.0/db_1 ORACLE数据库的HOME目录
export INVENTORY_LOCATION=/u01/oraInventory ORACLE安装时的inventory
export TNS_ADMIN=centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_15ORACLE_HOME/lib ORACLE的库文件目录
export NLS_LANG=" Simplified Chinese_China.UTF8" ORACLE的字符集 不过我们弃用 因为我们使用UTF8
export NLS_DATE_FORMAT=“YYYY-MM-DD HH24:MI:SS” ORACLE的日期格式 我们使用会话的方式修改 没有上面的NLS_LANG,那么这个参数不会生成
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:$PATH:$HOME/bin 生成相关参数
umask 022

生成参数

source .bash_profile或 . ~/.bash_profile

五、ORACLE 12C R2安装部署

1、上传安装介质

centos7 安装extundelete 安装centos7.2_oracle_16

2、解压安装介质

[root@ORACLE12C opt]# unzip linuxx64_12201_database.zip

centos7 安装extundelete 安装centos7.2_ORACLE 12C R2_17


centos7 安装extundelete 安装centos7.2_bc_18

3、软件安装

通过图形化界面安装ORACLE 12C R2数据库我们必须要能访问图形化界面,访问方式多种多样。如直接登录CentOS桌面、VNC、Xmanager、MobaXterm等。如果在现场,我们直接通过连接显示器访问CentOS桌面进行安装,如不是现场,推荐使用MobaXterm,比较方便。
通过MobaXterm安装只需执行export DISPLAY=172.16.10.100:0.0(这里的IP是自己本机的IP地址)即可将图形化界面投送至本机。
注:安装时用oracle用户进行操作

[oracle@ORACLE12C ~]$ export DISPLAY=172.16.10.100:0.0

centos7 安装extundelete 安装centos7.2_bc_19

进去解压后的目录,执行runInstaller进行安装(弹出的窗口全部选择“是(Y)”进入安装界面

[oracle@ORACLE12C ~]$ cd /opt/database/
[oracle@ORACLE12C database]$ ./runInstaller

centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_20


centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_21

centos7 安装extundelete 安装centos7.2_ORACLE 12C R2_22


centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_23

centos7 安装extundelete 安装centos7.2_bc_24

centos7 安装extundelete 安装centos7.2_Enterprise_25


centos7 安装extundelete 安装centos7.2_ORACLE 12C R2_26

centos7 安装extundelete 安装centos7.2_oracle_27

centos7 安装extundelete 安装centos7.2_ORACLE 12C R2_28

centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_29

centos7 安装extundelete 安装centos7.2_oracle_30

centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_31

centos7 安装extundelete 安装centos7.2_Enterprise_32

以root执行弹出窗口要执行的脚本:

[root@ORACLE12C ~]# /u01/oraInventory/orainstRoot.sh
[root@ORACLE12C ~]# /u01/app/oracle/product/12.2.0/db_1/root.sh

centos7 安装extundelete 安装centos7.2_Enterprise_33


centos7 安装extundelete 安装centos7.2_bc_34

4、创建监听

在oracle用户下执行netca命令创建监听。

[oracle@ORACLE12C database]$ netca

centos7 安装extundelete 安装centos7.2_oracle_35


centos7 安装extundelete 安装centos7.2_oracle_36

centos7 安装extundelete 安装centos7.2_oracle_37

centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_38


centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_39

centos7 安装extundelete 安装centos7.2_ORACLE 12C R2_40


centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_41

5、创建数据库

在oracle用户下执行dbca命令创建实例。

[oracle@ORACLE12C database]$ dbca

centos7 安装extundelete 安装centos7.2_bc_42

centos7 安装extundelete 安装centos7.2_oracle_43


centos7 安装extundelete 安装centos7.2_bc_44


centos7 安装extundelete 安装centos7.2_ORACLE 12C R2_45

centos7 安装extundelete 安装centos7.2_ORACLE 12C R2_46

centos7 安装extundelete 安装centos7.2_ORACLE 12C R2_47

centos7 安装extundelete 安装centos7.2_ORACLE 12C R2_48


centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_49

centos7 安装extundelete 安装centos7.2_oracle_50

centos7 安装extundelete 安装centos7.2_bc_51

centos7 安装extundelete 安装centos7.2_bc_52

centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_53

centos7 安装extundelete 安装centos7.2_Enterprise_54

centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_55

centos7 安装extundelete 安装centos7.2_CentOS7 ORACLE_56

centos7 安装extundelete 安装centos7.2_oracle_57

centos7 安装extundelete 安装centos7.2_Enterprise_58


centos7 安装extundelete 安装centos7.2_Enterprise_59


centos7 安装extundelete 安装centos7.2_Enterprise_60

6、启停命令

操作系统重启命令 shutdown -r now
操作系统关闭命令 shudtown -h now
数据库关闭命令 shutdown immediate
数据库启动命令 startup
监听启动命令 lsnrctl start
监听关闭命令 lsnrctl stop
监听查看命令 lsnrctl status

7、启动顺序

在日常工作中,关于数据库的启停:
先关闭上层应用服务---->关闭监听---->关闭数据库
启动数据库----->启动监听----->启动应用 进行相关的连接测试