文章目录
- 1 感谢
- 2 安装过程
- 2.1 前言
- 2.2 安装前准备
- 2.3 系统设置
- 2.4 安装依赖
- 2.5 正式开始安装
- 2.6 图形安装设置
- 2.6.1 VNC 相关设置
- 2.6.1.1 安装步骤
- 2.6.1.1.1 提示不支持
- 2.6.1.1.2 提供订阅的信息
- 2.6.1.1.3 选择 【create and configure a database 】
- 2.6.1.1.4 选择 【Server class】
- 2.6.1.1.5 选择 【single instance database intallation】
- 2.6.1.1.6 选择 【Advanced install】
- 2.6.1.1.7 选择 【Enterprise Edition】
- 2.6.1.1.8 安装路径
- 2.6.1.1.9 选择 Inventory Direcotry
- 2.6.1.1.10 选择用途
- 2.6.1.1.11 指定数据库标示
- 2.6.1.1.12 配置选项
- 2.6.1.1.13 配置数据库存储
- 2.6.1.1.14 配置em,直接下一步
- 2.6.1.1.15 配置Recovery Options
- 2.6.1.1.16 配置用户和组
- 2.6.1.1.17 点击 【install】
- 2.6.1.1 安装步骤
- 2.6.1 VNC 相关设置
- 2.7 控制台安装或静默安装
- 2.8 安装后的设置
- 2.9 Oracle 12C 新特性的一些教程
- 3 安装过程中碰到的问题
- 4 修订记录
感谢
本次安装过程中,参考了很多教程,走过很多弯路,因此在这里记录下来,为大家做一个参考。安装过程中,我详细参考了 Mackvord’s Blog 在此感谢原作者的辛苦付出。另外也参考了网上其他作者的内容,但没有一一记录网页地址,在此感谢广大前辈的付出。
试用范围
本教程应试用Debian 系(包括8 9,以及Ubuntu的相关版本),安装过程应同样适合 CentOS,以及官方推荐的Oracle Linux。
安装过程
前言
Oracle 12c 官方的教程只有对Oracle Linux 的相关说明,但是没有对Ubuntu 和Debian的相关说明。而且其安装教程也主要针对Oracle Linux, 这里补充对Debian的相关教程,以使其支持面更加大。
安装前准备
首先你需要下载所需要的Oracle 12c版本,可以访问 Oracle 官网 进行下载,本教程以 Oracle Database 12c Release 2
进行说明,下载完成之后,可以校验文件是否损坏或被篡改,具体如下:
#filename 为下载的文件名
cksum filename
将结果,对比Oracle官方的提供的校验码,如果一致,说明可以继续下一步了。
PS: 如何下载:
直接在网页中进行下载,然后复制其下载链接,通常会带有一个AuthParam=xxx
的参数,将整个链接复制,并且停止浏览器中下载,那么你接下来可以在服务器上使用 wget 进行下载。
另外,Oracle专家们可能还需要访问 Oracle文档中心 详细了解一下安装过程,以下将我安装过程中的碰到的问题进行记录一下:
内存建议
项目 | 建议设置 | 备注 |
---|---|---|
内存 | 最少1G,建议2G以上 | |
/tmp | 空间剩余至少1G | |
swap (1G-2G内存) | 1.5倍内存大小 | |
swap (2G-16G内存) | 等于内存大小 | |
swap (16G以上) | 16G |
系统设置
创建用户
## 增加组和用户
groupadd oinstall #组用于安装数据库
groupadd dba #组用于管理数据库
useradd -g oinstall -G dba -m -c "Oracle Database" -s `which bash` oracle
## -d:参数是指定用户主目录
## -m:自动建立用户的登入目录
## -c:用户描述
## -g:指定用户所属的组
## -G:指定用户所属的附加组
## -s:指定用户登入后所使用的shell
passwd oracle
参数设置
编辑文件 /etc/sysctl.conf
,添加如下内容,或者你也可以根据实际情况进行编辑
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 8329226240
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
执行命令sysctl -p
生效
编辑文件 /etc/security/limits.conf
,增加如下内容:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
安装依赖
Oracle12C的主要依赖如下,使用apt进行安装即可,注意:为避免后续重启服务器,建议第一件事就是将服务器进行补丁更新
apt update
apt upgrade -y
#Oracle 安装需要的依赖
apt install libaio-dev sysstat unixodbc-dev \
libelf-dev unzip g++ zlib1g-dev \
ksh libstdc++5 binutils
#其他方便系统维护的依赖
apt install ufw supervisor screen vim
安装gcc 4.8
通过网友的经验发现,在安装oracle 12c过程中使用debian 9 默认的gcc (版本为6.x)会导致编译出错[Error in invoking target 'links proc gen_pcscfg procob' of makefile...
],因此通过临时降级gcc 版本进行安装,之后再还原即可,操作如下:
# debian 9 默认已经没有gcc 4.8了,需要通过debian8进行安装,
echo "deb http://mirrors.aliyun.com/debian/ jessie main contrib non-free" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/debian/ jessie main contrib non-free" >> /etc/apt/sources.list
apt update
apt install gcc-4.8 g++-4.8 g++-4.8-multilib
cd /usr/bin
mv gcc gcc.script ## 备份一下
mv g++ g++.script ## 备份一下
ln -s gcc-4.8 gcc
ln -s g++-4.8 g++
创建文件软连接
由于本身Oracle Linux的不同,为了能够在Debian中正确安装,需要提前建立目录的映射管系,具体如下:
mkdir /usr/lib64
ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/basename /bin/basename
ln -s /usr/bin/rpm /bin/rpm
ln -s /etc /etc/rc.d
ln -s /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a /usr/lib64/
ln -s /usr/lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib64/
ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib64/
正式开始安装
创建安装目录
以下目录规划,可以根据实际情况进行的,因为本次安装是以此为演示,具体安装可以根据实际情况进行配置
mkdir -p /data/oracle
mkdir -p /data/oracle/oraInventory
mkdir -p /data/oracle/oradata
chown -R oracle:dba /data/oracle
检查hostname
在安装过程中发现,如果hostname无法访问的话,会导致安装程序启动报错COULD NOT RETRIEVE LOCAL NODENAME
, 具体要求如下:
## 检查当前的hostname设置
root@storage:~# hostname
storage
root@storage:~# ping storage
PING storage (10.10.0.144) 56(84) bytes of data.
64 bytes from storage (10.10.0.144): icmp_seq=1 ttl=64 time=0.015 ms
64 bytes from storage (10.10.0.144): icmp_seq=2 ttl=64 time=0.027 ms
## 如果 ping 提示,不存在的话,在 /etc/hosts 增加一个映射关系就可以
例如:
127.0.0.1 storage # ip地址可以使用ifconfig得到的IP
准备文件
将前面下载的oracle12c文件,移动到 /data/oracle下,并使用unzip解压(具体不做解释了,如果unzip没有可以安装),解压目录一般为 database,
图形安装设置
VNC 相关设置
由于Oracle安装过程需要图形界面进行选择 、安装之类的。但是又不想安装一个桌面环境,我们可以通过安装VNC Server的方式进行
apt install tightvncserver x11-xserver-utils
vncserver # 执行该命令时,需要输入访问密码,请记住该密码
export DISPLAY=localhost:1 # 这里临时设置,指示使用的display地址,后面的:1 在完成 vncserver 之后可以看到,
xhost + # 开启任意地址访问的权限,这里也可以指定特定IP。
切换到 /data/oracle/database目录下:
首先执行 screen -S oracle
避免因为网络中断,导致安装到一半而出现中断的情况。
按照下面到命令顺序进行执行:
su oracle ## 使用Oracle用户进行安装
## 为避免图形安装界面乱买
export LANG=en_us
export NLS_LANG=AMERICAN_AMERICA.UTF8
export LC_ALL=C
## 指定刚刚启动到vncserver进行安装
export DISPLAY=localhost:1
## 如果你想提前指定安装的位置,可以设置如下的变量
export ORACLE_BASE=/data/oracle/app
export ORACLE_HOME=/data/oracle/app/product/12.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=orcl
## 指定库的路径,可以省略
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu:/usr/lib64
接下来,直接执行 oracle 解压目录下的 ./runInstaller
即可开启安装,主要输出日志如下:
oracle@storage:/data/oracle/installer/database$ ./runInstaller
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 500 MB. Actual 7385 MB Passed
Checking swap space: must be greater than 150 MB. Actual 18149 MB Passed
Checking monitor: must be configured to display at least 256 colors. Actual 16777216 Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-04-14_03-08-34PM. Please wait ...
安装步骤
接下来,使用VNC Viewer(如果不想安装VNC的话,可以使用Chrome的VNC View插件程序)访问: IP:1, 请注意IP为实际的地址,如果无法访问,可能需要你检查防火墙。另外 :1
表示 刚刚 执行 vncserver 命令的结果
提示不支持
打开VNC Viewer之后,首先会看到提示,主要内容表示,不支持该系统,问你是否继续。此处点击:Yes
提供订阅的信息
主要输入 邮件和订阅支持,因为并没有该服务器,此处: 邮件留空, 不勾选 ,点击【next】,此时也会弹出警告提示,直接选择【yes】
选择 【create and configure a database 】
选择 【Server class】
选择 【single instance database intallation】
选择 【Advanced install】
选择 【Enterprise Edition】
安装路径
这一步可以根据实际情况进行设置,默认的值,是上面的环境变量设置的位置,我们点击下班
选择 Inventory Direcotry
路径为:/data/oracle/oraInventory
组名为: dba
选择用途
配置为: 一般用途/事务处理
继续点击 【Next】
指定数据库标示
这里默认即可,可以根据实际情况自行定制。
配置选项
看 【Character Sets】,选择编码,可以根据实际情况进行选择,这里选择了【AL32UTF8 – Unicode UTF-8】
看【Sample shemas】,选择了【Install】 为了方便学习,专家也可以不安装
之后点击【next】
配置数据库存储
默认选择文件存储,并指定文件存储的位置,你可以根据实际情况进行配置,这里我们指定了存储位置在 /data/oracle/oradata
,点击下一步
配置em,直接下一步
配置Recovery Options
此处根据实际情况配置,如果需要的话,可以启用,这里直接跳过
配置用户密码
这里将所有的用户密码都设置为一个,选择 第二个单选框,并配置密码
配置用户和组
这里,我们配置为 dba,这里主要的依据是,数据库安装目录的权限要一致,记得吗?前面我们已经将所有的权限设置为 oracle.dba
了, 点击下一步,
点击 【install】
此处将是漫长的等待时间。大致到了79%的进度时,会弹出一个对话框,大致的意思时,某些脚本需要以root用户执行,主要需要执行的脚本如下:
/data/oracle/oraInventory/orainstRoot.sh
/data/oracle/app/product/12.2.0/root.sh
其中路径可能跟你的不一样,具体都是看自己的配置,这些影响不大,执行之后,回到vnc viewer 直接,点击【OK】
控制台安装或静默安装
上面章节介绍了使用VNC Viewer 配合VNC Server进行安装的相关教程,但是对于有些环境来说,VNCServer搭建或者配置已经过于复杂。幸亏Oracle官方支持静默安装,安装方式主要有两种,一种通过命令行参数,一种通过response文件,其实归根到底,这两种是一样的,下面分别介绍这两种额外的安装方式。
我们假设你已经安装了【图形安装】之前的所有设置,并且预定义了以下的安装目标
#安装文件
/data/oracle/installer/database
#数据库数据目录
/data/oracle/oradata
#数据库Inventory目录
/data/oracle/oraInventory
#数据库安装目录
/data/oracle/app
# 数据库实例安装路径
/data/oracle/app/product/12.2.0/dbhome_1
通过数据库响应文件(Oracle Universal Installer(OUI))进行安装
在oracle安装文件夹目录下,其实已经内置了相关的reposose文件了,我们可以直接应用,并将其安装自己的需求进行配置,随后就可以安装了。相应文件文件主要分为三个部分
数据库安装
拷贝出新的相应文件,并按照需要进行编辑cp /data/oracle/installer/database/response/db_install.rsp /data/oracle/
,这里直接拷贝到oracle的目录,下面对其中关键的内容进行编辑:
# vim /data/oracle/db_install.resp
# 关键修改内容如下:
ORACLE_HOSTNAME=oracle12c # 注意这里要跟你的hostname一致,如果不存在,请手动添加 host
oracle.install.option=INSTALL_DB_SWONLY # 只安装数据库软件,之后我们会手动创库
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/oracle/oraInventory
ORACLE_HOME=/data/oracle/app/product/12.2.0/dbhome_1
ORACLE_BASE=/data/oracle/app
oracle.install.db.InstallEdition=EE # 安装Enterprise Edition
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=dba
oracle.install.db.OSBACKUPDBA_GROUP=dba
oracle.install.db.OSDGDBA_GROUP=dba
oracle.install.db.OSKMDBA_GROUP=dba
oracle.install.db.OSRACDBA_GROUP=dba
DECLINE_SECURITY_UPDATES=true
oracle.install.db.config.starterdb.characterSet=AL32UTF8 # 字符编码设置
oracle.install.db.config.starterdb.memoryLimit=16384 # 内存使用设置,这里你需要根据实际情况,oracle一般是 40%的整个内存
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.password.ALL=oracle # 设置所有用户的密码都为oracle
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/data/oracle/oradata # 设置文件存储位置
oracle.install.db.config.starterdb.enableRecovery=true # 是否开启恢复分区,根据情况设置
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/data/oracle/app/ecovery_area
另外附上完整的Response文件,文件所在目录为,解压后的 response
目录下
####################################################################
## Copyright(c) Oracle Corporation 1998,2017. All rights reserved.##
## ##
## Specify values for the variables listed below to customize ##
## your installation. ##
## ##
## Each variable is associated with a comment. The comment ##
## can help to populate the variables with the appropriate ##
## values. ##
## ##
## IMPORTANT NOTE: This file contains plain text passwords and ##
## should be secured to have read permission only by oracle user ##
## or db administrator who owns this installation. ##
## ##
####################################################################
#-------------------------------------------------------------------------------
# Do not change the following system generated value.
#-------------------------------------------------------------------------------
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.2.0
#-------------------------------------------------------------------------------
# Specify the installation option.
# It can be one of the following:
# - INSTALL_DB_SWONLY
# - INSTALL_DB_AND_CONFIG
# - UPGRADE_DB
#-------------------------------------------------------------------------------
oracle.install.option=
#-------------------------------------------------------------------------------
# Specify the Unix group to be set for the inventory directory.
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=
#-------------------------------------------------------------------------------
# Specify the location which holds the inventory files.
# This is an optional parameter if installing on
# Windows based Operating System.
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=
#-------------------------------------------------------------------------------
# Specify the complete path of the Oracle Home.
#-------------------------------------------------------------------------------
ORACLE_HOME=
#-------------------------------------------------------------------------------
# Specify the complete path of the Oracle Base.
#-------------------------------------------------------------------------------
ORACLE_BASE=
#-------------------------------------------------------------------------------
# Specify the installation edition of the component.
#
# The value should contain only one of these choices.
# - EE : Enterprise Edition
# - SE2 : Standard Edition 2
#-------------------------------------------------------------------------------
oracle.install.db.InstallEdition=
###############################################################################
# #
# PRIVILEGED OPERATING SYSTEM GROUPS #
# ------------------------------------------ #
# Provide values for the OS groups to which SYSDBA and SYSOPER privileges #
# needs to be granted. If the install is being performed as a member of the #
# group "dba", then that will be used unless specified otherwise below. #
# #
# The value to be specified for OSDBA and OSOPER group is only for UNIX based #
# Operating System. #
# #
###############################################################################
#------------------------------------------------------------------------------
# The OSDBA_GROUP is the OS group which is to be granted SYSDBA privileges.
#-------------------------------------------------------------------------------
oracle.install.db.OSDBA_GROUP=
#------------------------------------------------------------------------------
# The OSOPER_GROUP is the OS group which is to be granted SYSOPER privileges.
# The value to be specified for OSOPER group is optional.
#------------------------------------------------------------------------------
oracle.install.db.OSOPER_GROUP=
#------------------------------------------------------------------------------
# The OSBACKUPDBA_GROUP is the OS group which is to be granted SYSBACKUP privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSBACKUPDBA_GROUP=
#------------------------------------------------------------------------------
# The OSDGDBA_GROUP is the OS group which is to be granted SYSDG privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSDGDBA_GROUP=
#------------------------------------------------------------------------------
# The OSKMDBA_GROUP is the OS group which is to be granted SYSKM privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSKMDBA_GROUP=
#------------------------------------------------------------------------------
# The OSRACDBA_GROUP is the OS group which is to be granted SYSRAC privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSRACDBA_GROUP=
###############################################################################
# #
# Grid Options #
# #
###############################################################################
#------------------------------------------------------------------------------
# Specify the type of Real Application Cluster Database
#
# - ADMIN_MANAGED: Admin-Managed
# - POLICY_MANAGED: Policy-Managed
#
# If left unspecified, default will be ADMIN_MANAGED
#------------------------------------------------------------------------------
oracle.install.db.rac.configurationType=
#------------------------------------------------------------------------------
# Value is required only if RAC database type is ADMIN_MANAGED
#
# Specify the cluster node names selected during the installation.
# Leaving it blank will result in install on local server only (Single Instance)
#
# Example : oracle.install.db.CLUSTER_NODES=node1,node2
#------------------------------------------------------------------------------
oracle.install.db.CLUSTER_NODES=
#------------------------------------------------------------------------------
# This variable is used to enable or disable RAC One Node install.
#
# - true : Value of RAC One Node service name is used.
# - false : Value of RAC One Node service name is not used.
#
# If left blank, it will be assumed to be false.
#------------------------------------------------------------------------------
oracle.install.db.isRACOneInstall=
#------------------------------------------------------------------------------
# Value is required only if oracle.install.db.isRACOneInstall is true.
#
# Specify the name for RAC One Node Service
#------------------------------------------------------------------------------
oracle.install.db.racOneServiceName=
#------------------------------------------------------------------------------
# Value is required only if RAC database type is POLICY_MANAGED
#
# Specify a name for the new Server pool that will be configured
# Example : oracle.install.db.rac.serverpoolName=pool1
#------------------------------------------------------------------------------
oracle.install.db.rac.serverpoolName=
#------------------------------------------------------------------------------
# Value is required only if RAC database type is POLICY_MANAGED
#
# Specify a number as cardinality for the new Server pool that will be configured
# Example : oracle.install.db.rac.serverpoolCardinality=2
#------------------------------------------------------------------------------
oracle.install.db.rac.serverpoolCardinality=
###############################################################################
# #
# Database Configuration Options #
# #
###############################################################################
#-------------------------------------------------------------------------------
# Specify the type of database to create.
# It can be one of the following:
# - GENERAL_PURPOSE
# - DATA_WAREHOUSE
# GENERAL_PURPOSE: A starter database designed for general purpose use or transaction-heavy applications.
# DATA_WAREHOUSE : A starter database optimized for data warehousing applications.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.type=
#-------------------------------------------------------------------------------
# Specify the Starter Database Global Database Name.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.globalDBName=
#-------------------------------------------------------------------------------
# Specify the Starter Database SID.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.SID=
#-------------------------------------------------------------------------------
# Specify whether the database should be configured as a Container database.
# The value can be either "true" or "false". If left blank it will be assumed
# to be "false".
#-------------------------------------------------------------------------------
oracle.install.db.ConfigureAsContainerDB=
#-------------------------------------------------------------------------------
# Specify the Pluggable Database name for the pluggable database in Container Database.
#-------------------------------------------------------------------------------
oracle.install.db.config.PDBName=
#-------------------------------------------------------------------------------
# Specify the Starter Database character set.
#
# One of the following
# AL32UTF8, WE8ISO8859P15, WE8MSWIN1252, EE8ISO8859P2,
# EE8MSWIN1250, NE8ISO8859P10, NEE8ISO8859P4, BLT8MSWIN1257,
# BLT8ISO8859P13, CL8ISO8859P5, CL8MSWIN1251, AR8ISO8859P6,
# AR8MSWIN1256, EL8ISO8859P7, EL8MSWIN1253, IW8ISO8859P8,
# IW8MSWIN1255, JA16EUC, JA16EUCTILDE, JA16SJIS, JA16SJISTILDE,
# KO16MSWIN949, ZHS16GBK, TH8TISASCII, ZHT32EUC, ZHT16MSWIN950,
# ZHT16HKSCS, WE8ISO8859P9, TR8MSWIN1254, VN8MSWIN1258
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.characterSet=
#------------------------------------------------------------------------------
# This variable should be set to true if Automatic Memory Management
# in Database is desired.
# If Automatic Memory Management is not desired, and memory allocation
# is to be done manually, then set it to false.
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.memoryOption=
#-------------------------------------------------------------------------------
# Specify the total memory allocation for the database. Value(in MB) should be
# at least 256 MB, and should not exceed the total physical memory available
# on the system.
# Example: oracle.install.db.config.starterdb.memoryLimit=512
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.memoryLimit=
#-------------------------------------------------------------------------------
# This variable controls whether to load Example Schemas onto
# the starter database or not.
# The value can be either "true" or "false". If left blank it will be assumed
# to be "false".
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.installExampleSchemas=
###############################################################################
# #
# Passwords can be supplied for the following four schemas in the #
# starter database: #
# SYS #
# SYSTEM #
# DBSNMP (used by Enterprise Manager) #
# #
# Same password can be used for all accounts (not recommended) #
# or different passwords for each account can be provided (recommended) #
# #
###############################################################################
#------------------------------------------------------------------------------
# This variable holds the password that is to be used for all schemas in the
# starter database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.ALL=
#-------------------------------------------------------------------------------
# Specify the SYS password for the starter database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYS=
#-------------------------------------------------------------------------------
# Specify the SYSTEM password for the starter database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYSTEM=
#-------------------------------------------------------------------------------
# Specify the DBSNMP password for the starter database.
# Applicable only when oracle.install.db.config.starterdb.managementOption=CLOUD_CONTROL
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.DBSNMP=
#-------------------------------------------------------------------------------
# Specify the PDBADMIN password required for creation of Pluggable Database in the Container Database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.PDBADMIN=
#-------------------------------------------------------------------------------
# Specify the management option to use for managing the database.
# Options are:
# 1. CLOUD_CONTROL - If you want to manage your database with Enterprise Manager Cloud Control along with Database Express.
# 2. DEFAULT -If you want to manage your database using the default Database Express option.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.managementOption=
#-------------------------------------------------------------------------------
# Specify the OMS host to connect to Cloud Control.
# Applicable only when oracle.install.db.config.starterdb.managementOption=CLOUD_CONTROL
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.omsHost=
#-------------------------------------------------------------------------------
# Specify the OMS port to connect to Cloud Control.
# Applicable only when oracle.install.db.config.starterdb.managementOption=CLOUD_CONTROL
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.omsPort=
#-------------------------------------------------------------------------------
# Specify the EM Admin user name to use to connect to Cloud Control.
# Applicable only when oracle.install.db.config.starterdb.managementOption=CLOUD_CONTROL
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.emAdminUser=
#-------------------------------------------------------------------------------
# Specify the EM Admin password to use to connect to Cloud Control.
# Applicable only when oracle.install.db.config.starterdb.managementOption=CLOUD_CONTROL
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.emAdminPassword=
###############################################################################
# #
# SPECIFY RECOVERY OPTIONS #
# ------------------------------------ #
# Recovery options for the database can be mentioned using the entries below #
# #
###############################################################################
#------------------------------------------------------------------------------
# This variable is to be set to false if database recovery is not required. Else
# this can be set to true.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.enableRecovery=
#-------------------------------------------------------------------------------
# Specify the type of storage to use for the database.
# It can be one of the following:
# - FILE_SYSTEM_STORAGE
# - ASM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.storageType=
#-------------------------------------------------------------------------------
# Specify the database file location which is a directory for datafiles, control
# files, redo logs.
#
# Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
#-------------------------------------------------------------------------------
# Specify the recovery location.
#
# Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
#-------------------------------------------------------------------------------
# Specify the existing ASM disk groups to be used for storage.
#
# Applicable only when oracle.install.db.config.starterdb.storageType=ASM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.asm.diskGroup=
#-------------------------------------------------------------------------------
# Specify the password for ASMSNMP user of the ASM instance.
#
# Applicable only when oracle.install.db.config.starterdb.storage=ASM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.asm.ASMSNMPPassword=
#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username.
#
# Example : [email protected]
#------------------------------------------------------------------------------
MYORACLESUPPORT_USERNAME=
#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username password.
#
# Example : MYORACLESUPPORT_PASSWORD=password
#------------------------------------------------------------------------------
MYORACLESUPPORT_PASSWORD=
#------------------------------------------------------------------------------
# Specify whether to enable the user to set the password for
# My Oracle Support credentials. The value can be either true or false.
# If left blank it will be assumed to be false.
#
# Example : SECURITY_UPDATES_VIA_MYORACLESUPPORT=true
#------------------------------------------------------------------------------
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
#------------------------------------------------------------------------------
# Specify whether user doesn't want to configure Security Updates.
# The value for this variable should be true if you don't want to configure
# Security Updates, false otherwise.
#
# The value can be either true or false. If left blank it will be assumed
# to be true.
#
# Example : DECLINE_SECURITY_UPDATES=false
#------------------------------------------------------------------------------
DECLINE_SECURITY_UPDATES=
#------------------------------------------------------------------------------
# Specify the Proxy server name. Length should be greater than zero.
#
# Example : PROXY_HOST=proxy.domain.com
#------------------------------------------------------------------------------
PROXY_HOST=
#------------------------------------------------------------------------------
# Specify the proxy port number. Should be Numeric and at least 2 chars.
#
# Example : PROXY_PORT=25
#------------------------------------------------------------------------------
PROXY_PORT=
#------------------------------------------------------------------------------
# Specify the proxy user name. Leave PROXY_USER and PROXY_PWD
# blank if your proxy server requires no authentication.
#
# Example : PROXY_USER=username
#------------------------------------------------------------------------------
PROXY_USER=
#------------------------------------------------------------------------------
# Specify the proxy password. Leave PROXY_USER and PROXY_PWD
# blank if your proxy server requires no authentication.
#
# Example : PROXY_PWD=password
#------------------------------------------------------------------------------
PROXY_PWD=
#------------------------------------------------------------------------------
# Specify the Oracle Support Hub URL.
#
# Example : COLLECTOR_SUPPORTHUB_URL=https://orasupporthub.company.com:8080/
#------------------------------------------------------------------------------
COLLECTOR_SUPPORTHUB_URL=
开始安装
启动OUI安装器,指定响应文件,开始静默安装。主要命令如下:
screen -S oracle # 这里使用screen 避免安装到一半网络中断等异常情况导致安装中断
/data/oracle/installer/database/runInstaller -ignoreSysPrereqs -waitforcompletion -silent -responseFile /data/oracle/db_install.rsp
- -responseFile 指定文件的绝对路径,避免出错
- -ignoreSysPrereqs 跳过检查,前面我们已经准备好,不需要检查
- -waitforcompletion 等待安装完成,否则启动后跳到后台无法跟踪安装情况
执行root用户文件
安装到最后,会提示说:
The installation of Oracle Database 12c was successful.
Please check ‘/data/oracle/oraInventory/logs/silentInstall2018-04-11_11-47-25AM.log’ for more details.
As a root user, execute the following script(s):
1. /data/oracle/oraInventory/orainstRoot.sh
2. /data/oracle/product/12.2.0/dbhome_1/root.sh
简单来说,就是安装完成,需要用root用户执行两个文件,我们直接切换会root用户就好
初始化数据
上面只是安装好了软件,并没有初始化完成,下面我们开始初始化数据库,首先我们设置一下环境变量,主要配置好一些基础参数,并将oracle的命令导入PATH中,
export ORACLE_BASE=/data/oracle/app
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=orcl
使用 dbca
初始化数据库,其中将其中的所有数据库密码设置为oracle:
dbca -silent \
-createDatabase \
-templateName General_Purpose.dbc \
-gdbName oracle12c \
-sid orcl \
-createAsContainerDatabase true \
-numberOfPdbs 1 \
-pdbName orclpdb \
-pdbadminUsername pdba \
-pdbadminPassword oracle \
-SysPassword oracle \
-SystemPassword oracle \
-emConfiguration NONE \
-recoveryAreaDestination $ORACLE_BASE/recovery_area \
-characterSet "AL32UTF8" \
-nationalCharacterSet "UTF8" \
-enableArchive true \
-redoLogFileSize 100
另外dbca同样可以通过 rsp 文件进行安装,原始的文件再数据库解压目录下:repsonse/dbcp.rsp 通过修改参数同样可以实现上述安装的效果。
配置监听器
同样再 response的目录下 ,还有一个 netca.rsp的文件,这个文件里主要用来配置网络参数的,以下是其原始内容:
######################################################################
## Copyright(c) 1998, 2016 Oracle Corporation. All rights reserved. ##
## ##
## Specify values for the variables listed below to customize your ##
## installation. ##
## ##
## Each variable is associated with a comment. The comment ##
## identifies the variable type. ##
## ##
## Please specify the values in the following format: ##
## ##
## Type Example ##
## String "Sample Value" ##
## Boolean True or False ##
## Number 1000 ##
## StringList {"String value 1","String Value 2"} ##
## ##
######################################################################
## ##
## This sample response file causes the Oracle Net Configuration ##
## Assistant (NetCA) to complete an Oracle Net configuration during ##
## a custom install of the Oracle12c server which is similar to ##
## what would be created by the NetCA during typical Oracle12c ##
## install. It also documents all of the NetCA response file ##
## variables so you can create your own response file to configure ##
## Oracle Net during an install the way you wish. ##
## ##
######################################################################
[GENERAL]
RESPONSEFILE_VERSION="12.2"
CREATE_TYPE="CUSTOM"
#-------------------------------------------------------------------------------
# Name : SHOW_GUI
# Datatype : Boolean
# Description: This variable controls appearance/suppression of the NetCA GUI,
# Pre-req : N/A
# Default : TRUE
# Note:
# This must be set to false in order to run NetCA in silent mode.
# This is a substitute of "/silent" flag in the NetCA command line.
# The command line flag has precedence over the one in this response file.
# This feature is present since 10.1.0.3.
#-------------------------------------------------------------------------------
#SHOW_GUI=false
#-------------------------------------------------------------------------------
# Name : LOG_FILE
# Datatype : String
# Description: If present, NetCA will log output to this file in addition to the
# standard out.
# Pre-req : N/A
# Default : NONE
# Note:
# This is a substitute of "/log" in the NetCA command line.
# The command line argument has precedence over the one in this response file.
# This feature is present since 10.1.0.3.
#-------------------------------------------------------------------------------
#LOG_FILE=""/oracle12cHome/network/tools/log/netca.log""
[oracle.net.ca]
#INSTALLED_COMPONENTS;StringList;list of installed components
# The possible values for installed components are:
# "net8","server","client","aso", "cman", "javavm"
INSTALLED_COMPONENTS={"server","net8","javavm"}
#INSTALL_TYPE;String;type of install
# The possible values for install type are:
# "typical","minimal" or "custom"
INSTALL_TYPE=""typical""
#LISTENER_NUMBER;Number;Number of Listeners
# A typical install sets one listener
LISTENER_NUMBER=1
#LISTENER_NAMES;StringList;list of listener names
# The values for listener are:
# "LISTENER","LISTENER1","LISTENER2","LISTENER3", ...
# A typical install sets only "LISTENER"
LISTENER_NAMES={"LISTENER"}
#LISTENER_PROTOCOLS;StringList;list of listener addresses (protocols and parameters separated by semicolons)
# The possible values for listener protocols are:
# "TCP;1521","TCPS;2484","NMP;ORAPIPE","IPC;IPCKEY","VI;1521"
# For multiple listeners, separate them with commas ex "TCP;1521","TCPS;2484"
# For multiple protocols in single listener, separate them with "&" ex "TCP;1521&TCPS;2484"
# A typical install sets only "TCP;1521"
LISTENER_PROTOCOLS={"TCP;1521"}
#LISTENER_START;String;name of the listener to start, in double quotes
LISTENER_START=""LISTENER""
#NAMING_METHODS;StringList;list of naming methods
# The possible values for naming methods are:
# LDAP, TNSNAMES, ONAMES, HOSTNAME, NOVELL, NIS, DCE
# A typical install sets only: "TNSNAMES","ONAMES","HOSTNAMES"
# or "LDAP","TNSNAMES","ONAMES","HOSTNAMES" for LDAP
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
#NOVELL_NAMECONTEXT;String;Novell Directory Service name context, in double quotes
# A typical install does not use this variable.
#NOVELL_NAMECONTEXT = ""NAMCONTEXT""
#SUN_METAMAP;String; SUN meta map, in double quotes
# A typical install does not use this variable.
#SUN_METAMAP = ""MAP""
#DCE_CELLNAME;String;DCE cell name, in double quotes
# A typical install does not use this variable.
#DCE_CELLNAME = ""CELL""
#NSN_NUMBER;Number;Number of NetService Names
# A typical install sets one net service name
NSN_NUMBER=1
#NSN_NAMES;StringList;list of Net Service names
# A typical install sets net service name to "EXTPROC_CONNECTION_DATA"
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
#NSN_SERVICE;StringList;Oracle12c database's service name
# A typical install sets Oracle12c database's service name to "PLSExtProc"
NSN_SERVICE={"PLSExtProc"}
#NSN_PROTOCOLS;StringList;list of coma separated strings of Net Service Name protocol parameters
# The possible values for net service name protocol parameters are:
# "TCP;HOSTNAME;1521","TCPS;HOSTNAME;2484","NMP;COMPUTERNAME;ORAPIPE","VI;HOSTNAME;1521","IPC;IPCKEY"
# A typical install sets parameters to "IPC;EXTPROC"
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
#SERVICEUSERPASSWORD;String;Windows service user password
# If the oracle home is installed as secure user, supply the password
#SERVICEUSERPASSWORD=""svcpassword""
我们根据需要,对其进行裁剪,同样也修改需要的地方。
首先我们将其复制到新的目录下: cp /data/oracle/installer/database/resposne/netcat.rsp /data/oracle/
修改的内容主要如下:
[GENERAL]
RESPONSEFILE_VERSION="12.1"
CREATE_TYPE="CUSTOM" # Note, 设置为定制的,否则默认的是LISTENER, 1521
[oracle.net.ca]
INSTALLED_COMPONENTS={"server","net8","javavm"}
INSTALL_TYPE=""custom""
LISTENER_NUMBER=1
LISTENER_NAMES={"LISTENER"} # 根据情况自行配置
LISTENER_PROTOCOLS={"TCP;1521"} #根据情况自行配置
LISTENER_START=""LISTENER"" # 需要同上面的保持一致
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
NSN_SERVICE={"PLSExtProc"}
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
最后再oracle的安装目录下,完整路径为 $ORACLE_HOME/bin/netca -silent -responseFile /data/oracle/netca.rsp
安装后的设置
还原gcc的版本
切换到/usr/bin/目录下,执行以下命令:
mv g++.script g++
mv gcc.script gcc
修改自动启动
打开文件 /etc/oratab
编辑其中的实例,将你需要的启动的实例改成 Y
参考格式如下:
#$ORACLE_SID:$ORACLE_HOME:<N|Y>: N 不启动,需要手动去启动,Y自动随机启动
orcl:/data/oracle/app/product/12.2.0:Y
增加环境变量
在用户的~/.bashrc 增加下面:
export ORACLE_BASE=/data/oracle/app
export ORACLE_HOME=/data/oracle/app/product/12.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=orcl
PS: 你也可以根据需要在 /ect/profile
中增加
systemctl 启动脚本
你可以利用systemctl 完成对 oracle 的自动启动和关闭管理,参考的脚本如下,注意,你需要将其中的$ORACLE_HOME 替换成你实际安装的路径,编辑 vim /etc/systemd/system/oracle.service
,添加如下的内容:
[Unit]
Description=Oracle Database 12c Start service
[Service]
Type=forking
User=oracle
ExecStart=$ORACLE_HOME/bin/dbstart $ORACLE_HOME #ORACLE_HOME 需要使用真是的路径
ExecStop=$ORACLE_HOME/bin/dbshut $ORACLE_HOME #ORACLE_HOME 需要使用真是的路径
LimitMEMLOCK=infinity
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
Oracle 12C 新特性的一些教程
术语
Multitenant Environment:多租户环境
CDB(Container Database):数据库容器
PD(Pluggable Database):可插拔数据库
常用命令1-pdb操作
# 查看当前的连接
show con_name
select con_id,dbid,NAME,OPEN_MODE from v$pdbs;
# 修改pdb状态
alter pluggable database pdb2 open;
alter pluggable database pdb2 close;
# 当在root环境下,可以使用all 打开 关闭所有的 pdb
alter pluggable database all close;
# 切换当前的pdb
alter session set container=pdb;
# 切换到ROOT
alter session set container=CDB$ROOT;
# 保存状态,默认状态时,pdb重启后会是 mounted,并不会启动
ALTER PLUGGABLE DATABASE [all]|[PDB_NAME] SAVE STATE;
# 创建新的pdb
CREATE pluggable DATABASE newdb admin USER newdbmgr identified BY xxxxxx roles=(connect)
file_name_convert= ('/data/oracle/oradata/orcl/pdbseed', '/data/oracle/oradata/newdb');
常用命令2-表空间、用户创建和授权
-- 创建临时空间
create temporary tablespace newdbtemp
tempfile '/data/oracle/oradata/newdb/newdb_temp.dbf'
size 200m
autoextend on
next 32m MAXSIZE unlimited
extent management local;
-- 创建数据空间
create tablespace newdbdata
logging
datafile '/data/oracle/oradata/newdb/newdb_data.dbf'
size 10240m
autoextend on
next 100m MAXSIZE unlimited
extent management local;
-- 创建用户
create user newdb identified by "XXXXXXXX"
default tablespace newdbdata
temporary tablespace newdbtemp;
-- 用户授权
grant create user,drop user,alter user,create any view,connect,resource,dba,create session,create any sequence to newdb;
安装过程中碰到的问题
使用天翼云、阿里云无法外网连接的问题
在编写教程的过程中,我在使用天翼云(阿里云)进行试验教程,但是发现通过外网ip并不能直接访问,原因是由于现在的云服务均是通过NAT进行网络转发,真正的主机IP是一个内网IP,我使用其他的同网段的内网主机,使用sqlplus 能够正常访问,单独通过公网IP无法进行访问。经过一番参照,主要参考: Oracle 官方论坛 的一个帖子解决问题,主要是配置 dispachers 进行,原始教程是通过EM进行配置,但实际上,直接可以通过命令行进行,主要过程如下:
su oracle
sqlplus / as sysdba
show parameter dispatchers;
select value from v$parameter where name = 'dispatchers';
# 把上面的看到的dispacher添加,并加上自己需要对外提供的服务
alter system set "dispatchers"='(PROTOCOL=TCP)','(ADDRESS=(PROTOCOL=TCP)(CONNECTIONS=500)(HOST=newdb)(PORT=1522))(DISPATCHERS=5)(SERVICE=newdb)' scope=both
# 上面设置了两个,并使用 逗号进行分割,语法
# connections 参数标识每一个dispacher支持多少个连接
# host 这里应该改成你需要的IP或者域名
# port 这里我不知道是否能与主服务一样,因此我改成了新端口
# DISPATCHERS 开启的数量
# service dispacher 对应的服务名
# scope 这里使用both 标识内存和spfile一起生效,也就是重启野生型
修订记录
- 2019年4月10日初稿
- 2019年4月14日第一次发布
- 2019年4月16日补充常用操作命令
- 2019年4月19日补充静默安装