专业只做数据库实训和认证的品牌机构

微信公众号新浪微博
免费咨询电话:400-0909-964
当前位置: 网站首页 > DBA实战 > DBA课程 > CentOS 7静默安装Oracle 12C数据库

CentOS 7静默安装Oracle 12C数据库

文章来源: 更新时间:2020/3/19 16:16:32

在线老师点击咨询:

最新学讯:近期OCP认证正在报名中,因考试人员较多请尽快报名获取最近考试时间,报名费用请联系在线老师,甲骨文官方认证,报名从速!

我要咨询

环境

System : CentOS 7.x

mydb://> uname -a

Linux mydb 3.10.0-693.17.1.el7.x86_64 #1 SMP Thu Jan 25 20:13:58 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

SELINUX: 关闭

FIREWALL:关闭

systemctl stop firewalld.service --关闭防火墙

systemctl disable firewalld.service -- 禁止防火墙开机启动

systemctl status firewalld.service -- 查看防火墙状态

操作步骤

A、环境准备

B、用户组创建

C、修改系统内核参数

D、修改用户配置

E、数据库应用安装

F、数据库初始化


A、环境准备

1、选择Oracle安装包,直接去官网选择自己需要的版本

2、使用root用户登录,进行系统基础环境准备。

执行以下命令:

yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686

执行检查命令:

rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel


B、用户组创建

1、创建 oinstall 和 DBA

mydb:/root/> groupadd oinstall

mydb:/root/> groupadd DBA

2、创建 Oracle 用户,设置密码

mydb:/root/> useradd -g oinstall -G DBA Oracle

mydb:/root/> passwd Oracle

Changing password for user Oracle.

New password:

BAD PASSWORD: it is based on a dictionary word

BAD PASSWORD: is too simple

Retype new password:

BAD PASSWORD: The password is shorter than 8 characters

Retype new password:

passwd: all authentication tokens updated successfully.

3、查看用户 id Oracle

mydb:/root/> id Oracle

uid=1004(Oracle) gid=1004(oinstall) groups=1004(oinstall),1005(DBA)


C、修改系统内核参数

1、修改系统配置: vi /etc/sysctl.conf ,增加如下内容:

fs.aio-max-nr = 1048576

fs.file-max = 6815744

# shmall 是全部允许使用的共享内存大小,shmmax 是单个段允许使用的大小。

kernel.shmmax = 6465333657

kernel.shmall = 10523004

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 = 1048576

2、使配置生效: sysctl -p


D、修改用户配置

1、修改用户限制。

打开文件: vi /etc/security/limits.conf

在文件末尾添加如下6行内容:

Oracle soft nproc 2047

Oracle hard nproc 16384

Oracle soft nofile 1024

Oracle hard nofile 65536

Oracle soft stack 10240

Oracle hard stack 10240

2、修改用户登录库文件引用

打开系统文件: vi /etc/pam.d/login

在文件末尾添加如下2行内容:

session required /lib64/security/pam_limits.so

session required pam_limits.so

3、修改用户登录环境变量

打开系统文件: 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

退出编辑状态,使修改的文件生效:source /etc/profile

4、创建安装目录,配置安装目录权限。

mkdir -p /usr/app/

chown -R Oracle:oinstall /usr/app/

chmod -R 775 /usr/app/

5、配置 Oracle 用户环境变量

切换用户: su – Oracle

编辑环境变量: vi .bash_profile

新增配置如下:

export ORACLE_BASE=/usr/app/oracle

export ORACLE_SID=orcl

export PS1=`uname -n`':$PWD/> '

生效配置文件: source .bash_profile


E、数据库应用安装

1、使用 Oracle 用户,创建数据库安装配置文件夹 etc 。

mydb://> su - Oracle

mydb:/home/oracle/> mkdir etc

2、上传安装文件到 Oracle 用户目录下,并解压文件。

执行命令:

mydb:/home/oracle/> unzip linuxamd64_12102_database_1of2.zip

mydb:/home/oracle/> unzip linuxamd64_12102_database_2of2.zip

解压完成会在用户目录下出现一个 database 文件夹

3、复制 Oracle配置文件到 etc 目录下,并修改配置文件权限

mydb:/home/oracle/> cp ./database/response/* ./etc/

mydb:/home/oracle/> chmod 700 ./etc/*.rsp

4、修改静默安装配置文件 db_install.rsp

vi ./etc/db_install.rsp

# 修改文件配置

#-------------------------------------------------------------------------------

# Specify the installation option.

# It can be one of the following:

# - INSTALL_DB_SWONLY

# - INSTALL_DB_AND_CONFIG

# - UPGRADE_DB

#-------------------------------------------------------------------------------

Oracle.install.option=INSTALL_DB_SWONLY

#-------------------------------------------------------------------------------

# Specify the Unix group to be set for the inventory directory.

#-------------------------------------------------------------------------------

UNIX_GROUP_NAME=oinstall

#-------------------------------------------------------------------------------

# Specify the location which holds the inventory files.

# This is an optional parameter if installing on

# Windows based Operating System.

#-------------------------------------------------------------------------------

INVENTORY_LOCATION=/usr/app/oracle/oraInventory

# Specify value as the following to select all the languages.

# Example : SELECTED_LANGUAGES=all_langs

#-------------------------------------------------------------------------------

SELECTED_LANGUAGES=en,zh_CN

#-------------------------------------------------------------------------------

# Specify the complete path of the Oracle Home.

#-------------------------------------------------------------------------------

ORACLE_HOME=/usr/app/oracle/product/12/db_1

#-------------------------------------------------------------------------------

# Specify the complete path of the Oracle Base.

#-------------------------------------------------------------------------------

ORACLE_BASE=/usr/app/oracle

#-------------------------------------------------------------------------------

# Specify the installation edition of the component.

#

# The value should contain only one of these choices.

# - EE : Enterprise Edition

#-------------------------------------------------------------------------------

Oracle.install.db.InstallEdition=EE

#------------------------------------------------------------------------------

# The DBA_GROUP is the OS group which is to be granted OSDBA privileges.

#-------------------------------------------------------------------------------

Oracle.install.db.DBA_GROUP=DBA

#------------------------------------------------------------------------------

# The OPER_GROUP is the OS group which is to be granted OSOPER privileges.

# The value to be specified for OSOPER group is optional.

#------------------------------------------------------------------------------

Oracle.install.db.OPER_GROUP=oinstall

#------------------------------------------------------------------------------

# The BACKUPDBA_GROUP is the OS group which is to be granted OSBACKUPDBA privileges.

#------------------------------------------------------------------------------

Oracle.install.db.BACKUPDBA_GROUP=oinstall

#------------------------------------------------------------------------------

# The DGDBA_GROUP is the OS group which is to be granted OSDGDBA privileges.

#------------------------------------------------------------------------------

Oracle.install.db.DGDBA_GROUP=oinstall

#------------------------------------------------------------------------------

# The KMDBA_GROUP is the OS group which is to be granted OSKMDBA privileges.

#------------------------------------------------------------------------------

Oracle.install.db.KMDBA_GROUP=oinstall

#-------------------------------------------------------------------------------

# 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=GENERAL_PURPOSE

#-------------------------------------------------------------------------------

# Specify the Starter Database Global Database Name.

#-------------------------------------------------------------------------------

Oracle.install.db.config.starterdb.globalDBName=orcl

#-------------------------------------------------------------------------------

# Specify the Starter Database SID.

#-------------------------------------------------------------------------------

Oracle.install.db.config.starterdb.SID=orcl

#-------------------------------------------------------------------------------

# 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=AL32UTF8

#------------------------------------------------------------------------------

# 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=true

#------------------------------------------------------------------------------

# This variable holds the password that is to be used for all schemas in the

# starter database.

#-------------------------------------------------------------------------------

Oracle.install.db.config.starterdb.password.ALL=Oracle

#------------------------------------------------------------------------------

# 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=true

#------------------------------------------------------------------------------

# 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 false.

#

# Example : DECLINE_SECURITY_UPDATES=false

#------------------------------------------------------------------------------

DECLINE_SECURITY_UPDATES=true

5、开始安装,执行 db_install.rsp

mydb:/home/oracle/> ./database/runInstaller -silent -responseFile /home/oracle/etc/db_install.rsp

Starting Oracle Universal Installer...

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

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

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-08-01_03-16-16PM. Please wait ...

You can find the log of this install session at:

/usr/app/oracle/oraInventory/logs/installActions2019-08-01_03-20-39PM.log

The installation of Oracle Database 12c was successful.

Please check '/usr/app/oracle/oraInventory/logs/silentInstall2019-08-01_03-20-39PM.log' for more details.

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

1. /usr/app/oracle/oraInventory/orainstRoot.sh

2. /usr/app/oracle/product/12/db_1/root.sh

Successfully Setup Software.

等待结果,这样安装就成功完成了。

6、切换 root 用户,修改数据库配置

mydb://> /usr/app/oracle/oraInventory/orainstRoot.sh

Changing permissions of /usr/app/oracle/oraInventory.

Adding read,write permissions for group.

Removing read,write,execute permissions for world.

Changing groupname of /usr/app/oracle/oraInventory to oinstall.

The execution of the script is complete.

mydb://> /usr/app/oracle/product/12/db_1/root.sh

Check /usr/app/oracle/product/12/db_1/install/root_mydb_2020-01-01_19-00-31.log for the output of root script


F、数据库初始化

1、使用 Oracle 用户登录,修改用户环境变量

export ORACLE_BASE=/usr/app/oracle

export ORACLE_SID=orcl

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

export ORACLE_HOME=/usr/app/oracle/product/12/db_1

export PATH=$PATH:$ORACLE_HOME/bin

export LANG="zh_CN.UTF-8"

export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"

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

使环境变量生效,执行命令:source .bash_profile

2、配置监听程序

mydb:/home/oracle/> netca /silent /responsefile /home/oracle/etc/netca.rsp

3、启动监听

mydb:/home/oracle/> lsnrctl start

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 01-8月 -2019 15:47:15

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

4、静默建库文件修改,打开 dbca.rsp 文件。

vi ./etc/dbca.rsp

#-----------------------------------------------------------------------------

# Name : SID

# Datatype : String

# Description : System identifier (SID) of the database

# Valid values : Check Oracle12c Administrator's Guide

# Default value : specified in GDBNAME

# Mandatory : No

#-----------------------------------------------------------------------------

SID = "orcl"

#-----------------------------------------------------------------------------

# Name : CHARACTERSET

# Datatype : String

# Description : Character set of the database

# Valid values : Check Oracle12c National Language Support Guide

# Default value : "US7ASCII"

# Mandatory : NO

#-----------------------------------------------------------------------------

CHARACTERSET = "AL32UTF8"

#-----------------------------------------------------------------------------

# Name : LISTENERS

# Datatype : String

# Description : Specifies list of listeners to register the database with.

# By default the database is configured for all the listeners specified in the

# $ORACLE_HOME/network/admin/listener.ora

# Valid values : The list should be comma separated like "listener1,listener2".

# Mandatory : NO

#-----------------------------------------------------------------------------

LISTENERS = "LISTENERS"

5、执行静默建库

mydb:/home/oracle/> dbca -silent -createDatabase -responseFile /home/oracle/etc/dbca.rsp

输入 SYS 用户口令:

输入 SYSTEM 用户口令:

复制数据库文件

1% 已完成

3% 已完成

11% 已完成

18% 已完成

26% 已完成

37% 已完成

正在创建并启动 Oracle 实例

40% 已完成

45% 已完成

50% 已完成

55% 已完成

56% 已完成

60% 已完成

62% 已完成

正在进行数据库创建

66% 已完成

70% 已完成

73% 已完成

85% 已完成

96% 已完成

100% 已完成

有关详细信息, 请参阅日志文件 "/usr/app/oracle/cfgtoollogs/dbca/orcl/orcl.log"。

建库完成了。

6、创建数据库应用用户并授权。

mydb:/home/oracle/> sqlplus / as sysDBA

SQL*Plus: Release 12.1.0.2.0 Production on 星期四 8月 1 16:45:33 2019

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

连接到:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> create user user1 identified by passwd1;

用户已创建。

SQL> grant connect,resource,DBA to user1;

授权成功。

本文地址:http://www.cuug.com.cn/dba/kecheng/24085539422.html 转载请注明!


在线预约 抢先报名 获取课程排期

Oracle培训机构

金牌讲师<>

冉乃纲-老师CUUG金牌讲师
冉老师 CUUG金牌讲师 Oracle及RedHat高级讲师、Unix/Linux 资深专家...[详细了解老师]

免费咨询上课流程 客服在线中

陈卫星-老师CUUG金牌讲师
陈老师 CUUG金牌讲师 精通Oracle管理、备份恢复、性能优化 11年Ora...[详细了解老师]

免费咨询上课流程 客服在线中

选学校如何选择适合自己的学校

CUUG -CHINA UNIX USER GROUP,是国际UNIX组织UNIFORUM的中国代表,是国内悠久的专业UNIX培训机构,被誉为中国UNIX 的摇篮。多年来,以提高教学质量为本,强调素质教育,积极引进、消化国外的新技术,有效的结合中国....[详情]

一站式服务(从入学到就业一帮到底)

入学

学习

就业

实操

食宿
地址:北京市海淀区北清路164号28-38号院
课程咨询:010-59426307 010-59426319 400-0909-964
企业服务:137 1818 8639(陈经理)
部分信息来源于网络,如有错误请联系指正!
版权所有@北京神脑资讯技术有限公司 (CUUG,中国UNIX用户协会) Copyright 2016 ALL Rights Reserved 京ICP备11008061号-1